30 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
32 #include <linux/kernel.h>
33 #include <linux/module.h>
35 #include <linux/slab.h>
36 #include <linux/types.h>
37 #include <linux/pci.h>
53 #define MEMORY_GET_BANDWIDTH "GTHS"
54 #define MEMORY_SET_BANDWIDTH "STHS"
55 #define MEMORY_ARG_CUR_BANDWIDTH 1
56 #define MEMORY_ARG_MAX_BANDWIDTH 0
58 static void intel_menlow_unregister_sensor(
void);
66 unsigned long *max_state)
70 unsigned long long value;
76 arg_list.pointer = &
arg;
87 *max_state = value - 1;
94 struct acpi_device *device = cdev->
devdata;
102 arg_list.pointer = &
arg;
117 struct acpi_device *device = cdev->
devdata;
122 unsigned long long temp;
123 unsigned long max_state;
125 if (memory_get_max_bandwidth(cdev, &max_state))
128 if (state > max_state)
132 arg_list.pointer = &
arg;
140 pr_info(
"Bandwidth value was %ld: status is %d\n", state, status);
148 .get_max_state = memory_get_max_bandwidth,
149 .get_cur_state = memory_get_cur_bandwidth,
150 .set_cur_state = memory_set_cur_bandwidth,
156 static int intel_menlow_memory_add(
struct acpi_device *device)
175 &memory_cooling_ops);
177 result = PTR_ERR(cdev);
181 device->driver_data =
cdev;
183 &cdev->
device.kobj,
"thermal_cooling");
188 &device->dev.kobj,
"device");
203 static int intel_menlow_memory_remove(
struct acpi_device *device,
int type)
207 if (!device || !cdev)
222 static struct acpi_driver intel_menlow_memory_driver = {
223 .name =
"intel_menlow_thermal_control",
224 .ids = intel_menlow_memory_ids,
226 .add = intel_menlow_memory_add,
227 .remove = intel_menlow_memory_remove,
235 #define THERMAL_AUX0 0
236 #define THERMAL_AUX1 1
237 #define GET_AUX0 "GAX0"
238 #define GET_AUX1 "GAX1"
239 #define SET_AUX0 "SAX0"
240 #define SET_AUX1 "SAX1"
249 static LIST_HEAD(intel_menlow_attr_list);
259 unsigned long long *value)
263 if ((index != 0 && index != 1) || !value)
280 static int sensor_set_auxtrip(
acpi_handle handle,
int index,
int value)
289 unsigned long long temp;
291 if (index != 0 && index != 1)
298 if ((index && value < temp) || (!index && value > temp))
312 #define to_intel_menlow_attr(_attr) \
313 container_of(_attr, struct intel_menlow_attribute, attr)
319 unsigned long long value;
322 result = sensor_get_auxtrip(attr->
handle, 0, &value);
331 unsigned long long value;
334 result = sensor_get_auxtrip(attr->
handle, 1, &value);
339 static ssize_t aux0_store(
struct device *dev,
341 const char *buf,
size_t count)
348 if (!
sscanf(buf,
"%d", &value))
355 return result ? result :
count;
358 static ssize_t aux1_store(
struct device *dev,
360 const char *buf,
size_t count)
367 if (!
sscanf(buf,
"%d", &value))
374 return result ? result :
count;
378 #define BIOS_ENABLED "\\_TZ.GSTS"
379 static ssize_t bios_enabled_show(
struct device *dev,
383 unsigned long long bios_enabled;
389 return sprintf(buf,
"%s\n", bios_enabled ?
"enabled" :
"disabled");
392 static int intel_menlow_add_one_attribute(
char *
name,
umode_t mode,
void *show,
393 void *store,
struct device *dev,
406 attr->
attr.show = show;
407 attr->
attr.store = store;
445 result = intel_menlow_add_one_attribute(
"aux0", 0644,
446 aux0_show, aux0_store,
447 &thermal->
device, handle);
459 result = intel_menlow_add_one_attribute(
"aux1", 0644,
460 aux1_show, aux1_store,
461 &thermal->
device, handle);
463 intel_menlow_unregister_sensor();
472 result = intel_menlow_add_one_attribute(
"bios_enabled", 0444,
473 bios_enabled_show,
NULL,
474 &thermal->
device, handle);
476 intel_menlow_unregister_sensor();
486 intel_menlow_unregister_sensor();
490 static void intel_menlow_unregister_sensor(
void)
505 static int __init intel_menlow_module_init(
void)
509 unsigned long long enable;
536 static void __exit intel_menlow_module_exit(
void)
539 intel_menlow_unregister_sensor();