2 * Copyright (C) 2007-2009 Luca Tettamanti <kronos.it@gmail.com>
4 * This file is released under the GPLv2
5 * See COPYING in the top level directory of the kernel tree.
8 #include <linux/kernel.h>
9 #include <linux/hwmon.h>
10 #include <linux/list.h>
11 #include <linux/module.h>
13 #include <acpi/acpi.h>
14 #include <acpi/acpixf.h>
15 #include <acpi/acpi_drivers.h>
16 #include <acpi/acpi_bus.h>
19 #define ATK_HID "ATK0110"
21 /* Minimum time between readings, enforced in order to avoid
26 #define BOARD_ID "MBIF"
27 #define METHOD_ENUMERATE "GGRP"
28 #define METHOD_READ "GITM"
29 #define METHOD_WRITE "SITM"
30 #define METHOD_OLD_READ_TMP "RTMP"
31 #define METHOD_OLD_READ_VLT "RVLT"
32 #define METHOD_OLD_READ_FAN "RFAN"
33 #define METHOD_OLD_ENUM_TMP "TSIF"
34 #define METHOD_OLD_ENUM_VLT "VSIF"
35 #define METHOD_OLD_ENUM_FAN "FSIF"
37 #define ATK_MUX_HWMON 0x00000006ULL
39 #define ATK_CLASS_MASK 0xff000000ULL
40 #define ATK_CLASS_FREQ_CTL 0x03000000ULL
41 #define ATK_CLASS_FAN_CTL 0x04000000ULL
42 #define ATK_CLASS_HWMON 0x06000000ULL
44 #define ATK_TYPE_MASK 0x00ff0000ULL
45 #define HWMON_TYPE_VOLT 0x00020000ULL
46 #define HWMON_TYPE_TEMP 0x00030000ULL
47 #define HWMON_TYPE_FAN 0x00040000ULL
49 #define HWMON_SENSOR_ID_MASK 0x0000ffffULL
51 enum atk_pack_member {
59 /* New package format */
60 #define _HWMON_NEW_PACK_SIZE 7
61 #define _HWMON_NEW_PACK_FLAGS 0
62 #define _HWMON_NEW_PACK_NAME 1
63 #define _HWMON_NEW_PACK_UNK1 2
64 #define _HWMON_NEW_PACK_UNK2 3
65 #define _HWMON_NEW_PACK_LIMIT1 4
66 #define _HWMON_NEW_PACK_LIMIT2 5
67 #define _HWMON_NEW_PACK_ENABLE 6
69 /* Old package format */
70 #define _HWMON_OLD_PACK_SIZE 5
71 #define _HWMON_OLD_PACK_FLAGS 0
72 #define _HWMON_OLD_PACK_NAME 1
73 #define _HWMON_OLD_PACK_LIMIT1 2
74 #define _HWMON_OLD_PACK_LIMIT2 3
75 #define _HWMON_OLD_PACK_ENABLE 4
79 struct device *hwmon_dev;
80 acpi_handle atk_handle;
81 struct acpi_device *acpi_dev;
86 acpi_handle rtmp_handle;
87 acpi_handle rvlt_handle;
88 acpi_handle rfan_handle;
90 acpi_handle enumerate_handle;
91 acpi_handle read_handle;
94 int temperature_count;
96 struct list_head sensor_list;
100 typedef ssize_t (*sysfs_show_func)(struct device *dev,
101 struct device_attribute *attr, char *buf);
103 static const struct acpi_device_id atk_ids[] = {
107 MODULE_DEVICE_TABLE(acpi, atk_ids);
109 #define ATTR_NAME_SIZE 16 /* Worst case is "tempN_input" */
111 struct atk_sensor_data {
112 struct list_head list;
113 struct atk_data *data;
114 struct device_attribute label_attr;
115 struct device_attribute input_attr;
116 struct device_attribute limit1_attr;
117 struct device_attribute limit2_attr;
118 char label_attr_name[ATTR_NAME_SIZE];
119 char input_attr_name[ATTR_NAME_SIZE];
120 char limit1_attr_name[ATTR_NAME_SIZE];
121 char limit2_attr_name[ATTR_NAME_SIZE];
127 unsigned long last_updated; /* in jiffies */
129 char const *acpi_name;
132 struct atk_acpi_buffer_u64 {
133 union acpi_object buf;
137 static int atk_add(struct acpi_device *device);
138 static int atk_remove(struct acpi_device *device, int type);
139 static void atk_print_sensor(struct atk_data *data, union acpi_object *obj);
140 static int atk_read_value(struct atk_sensor_data *sensor, u64 *value);
141 static void atk_free_sensors(struct atk_data *data);
143 static struct acpi_driver atk_driver = {
149 .remove = atk_remove,
153 #define input_to_atk_sensor(attr) \
154 container_of(attr, struct atk_sensor_data, input_attr)
156 #define label_to_atk_sensor(attr) \
157 container_of(attr, struct atk_sensor_data, label_attr)
159 #define limit1_to_atk_sensor(attr) \
160 container_of(attr, struct atk_sensor_data, limit1_attr)
162 #define limit2_to_atk_sensor(attr) \
163 container_of(attr, struct atk_sensor_data, limit2_attr)
165 static ssize_t atk_input_show(struct device *dev,
166 struct device_attribute *attr, char *buf)
168 struct atk_sensor_data *s = input_to_atk_sensor(attr);
172 err = atk_read_value(s, &value);
176 if (s->type == HWMON_TYPE_TEMP)
177 /* ACPI returns decidegree */
180 return sprintf(buf, "%llu\n", value);
183 static ssize_t atk_label_show(struct device *dev,
184 struct device_attribute *attr, char *buf)
186 struct atk_sensor_data *s = label_to_atk_sensor(attr);
188 return sprintf(buf, "%s\n", s->acpi_name);
191 static ssize_t atk_limit1_show(struct device *dev,
192 struct device_attribute *attr, char *buf)
194 struct atk_sensor_data *s = limit1_to_atk_sensor(attr);
195 u64 value = s->limit1;
197 if (s->type == HWMON_TYPE_TEMP)
200 return sprintf(buf, "%lld\n", value);
203 static ssize_t atk_limit2_show(struct device *dev,
204 struct device_attribute *attr, char *buf)
206 struct atk_sensor_data *s = limit2_to_atk_sensor(attr);
207 u64 value = s->limit2;
209 if (s->type == HWMON_TYPE_TEMP)
212 return sprintf(buf, "%lld\n", value);
215 static ssize_t atk_name_show(struct device *dev,
216 struct device_attribute *attr, char *buf)
218 return sprintf(buf, "atk0110\n");
220 static struct device_attribute atk_name_attr =
221 __ATTR(name, 0444, atk_name_show, NULL);
223 static void atk_init_attribute(struct device_attribute *attr, char *name,
224 sysfs_show_func show)
226 attr->attr.name = name;
227 attr->attr.mode = 0444;
233 static union acpi_object *atk_get_pack_member(struct atk_data *data,
234 union acpi_object *pack,
235 enum atk_pack_member m)
237 bool old_if = data->old_interface;
241 case HWMON_PACK_FLAGS:
242 offset = old_if ? _HWMON_OLD_PACK_FLAGS : _HWMON_NEW_PACK_FLAGS;
244 case HWMON_PACK_NAME:
245 offset = old_if ? _HWMON_OLD_PACK_NAME : _HWMON_NEW_PACK_NAME;
247 case HWMON_PACK_LIMIT1:
248 offset = old_if ? _HWMON_OLD_PACK_LIMIT1 :
249 _HWMON_NEW_PACK_LIMIT1;
251 case HWMON_PACK_LIMIT2:
252 offset = old_if ? _HWMON_OLD_PACK_LIMIT2 :
253 _HWMON_NEW_PACK_LIMIT2;
255 case HWMON_PACK_ENABLE:
256 offset = old_if ? _HWMON_OLD_PACK_ENABLE :
257 _HWMON_NEW_PACK_ENABLE;
263 return &pack->package.elements[offset];
267 /* New package format is:
269 * class - used for de-muxing the request to the correct GITn
270 * type (volt, temp, fan)
272 * sensor id - used for de-muxing the request _inside_ the GITn
280 * The old package has the same format but it's missing the two unknown fields.
282 static int validate_hwmon_pack(struct atk_data *data, union acpi_object *obj)
284 struct device *dev = &data->acpi_dev->dev;
285 union acpi_object *tmp;
286 bool old_if = data->old_interface;
287 int const expected_size = old_if ? _HWMON_OLD_PACK_SIZE :
288 _HWMON_NEW_PACK_SIZE;
290 if (obj->type != ACPI_TYPE_PACKAGE) {
291 dev_warn(dev, "Invalid type: %d\n", obj->type);
295 if (obj->package.count != expected_size) {
296 dev_warn(dev, "Invalid package size: %d, expected: %d\n",
297 obj->package.count, expected_size);
301 tmp = atk_get_pack_member(data, obj, HWMON_PACK_FLAGS);
302 if (tmp->type != ACPI_TYPE_INTEGER) {
303 dev_warn(dev, "Invalid type (flag): %d\n", tmp->type);
307 tmp = atk_get_pack_member(data, obj, HWMON_PACK_NAME);
308 if (tmp->type != ACPI_TYPE_STRING) {
309 dev_warn(dev, "Invalid type (name): %d\n", tmp->type);
313 /* Don't check... we don't know what they're useful for anyway */
315 tmp = &obj->package.elements[HWMON_PACK_UNK1];
316 if (tmp->type != ACPI_TYPE_INTEGER) {
317 dev_warn(dev, "Invalid type (unk1): %d\n", tmp->type);
321 tmp = &obj->package.elements[HWMON_PACK_UNK2];
322 if (tmp->type != ACPI_TYPE_INTEGER) {
323 dev_warn(dev, "Invalid type (unk2): %d\n", tmp->type);
328 tmp = atk_get_pack_member(data, obj, HWMON_PACK_LIMIT1);
329 if (tmp->type != ACPI_TYPE_INTEGER) {
330 dev_warn(dev, "Invalid type (limit1): %d\n", tmp->type);
334 tmp = atk_get_pack_member(data, obj, HWMON_PACK_LIMIT2);
335 if (tmp->type != ACPI_TYPE_INTEGER) {
336 dev_warn(dev, "Invalid type (limit2): %d\n", tmp->type);
340 tmp = atk_get_pack_member(data, obj, HWMON_PACK_ENABLE);
341 if (tmp->type != ACPI_TYPE_INTEGER) {
342 dev_warn(dev, "Invalid type (enable): %d\n", tmp->type);
346 atk_print_sensor(data, obj);
351 static char const *atk_sensor_type(union acpi_object *flags)
353 u64 type = flags->integer.value & ATK_TYPE_MASK;
357 case HWMON_TYPE_VOLT:
360 case HWMON_TYPE_TEMP:
361 what = "temperature";
374 static void atk_print_sensor(struct atk_data *data, union acpi_object *obj)
377 struct device *dev = &data->acpi_dev->dev;
378 union acpi_object *flags;
379 union acpi_object *name;
380 union acpi_object *limit1;
381 union acpi_object *limit2;
382 union acpi_object *enable;
385 flags = atk_get_pack_member(data, obj, HWMON_PACK_FLAGS);
386 name = atk_get_pack_member(data, obj, HWMON_PACK_NAME);
387 limit1 = atk_get_pack_member(data, obj, HWMON_PACK_LIMIT1);
388 limit2 = atk_get_pack_member(data, obj, HWMON_PACK_LIMIT2);
389 enable = atk_get_pack_member(data, obj, HWMON_PACK_ENABLE);
391 what = atk_sensor_type(flags);
393 dev_dbg(dev, "%s: %#llx %s [%llu-%llu] %s\n", what,
394 flags->integer.value,
395 name->string.pointer,
396 limit1->integer.value, limit2->integer.value,
397 enable->integer.value ? "enabled" : "disabled");
401 static int atk_read_value_old(struct atk_sensor_data *sensor, u64 *value)
403 struct atk_data *data = sensor->data;
404 struct device *dev = &data->acpi_dev->dev;
405 struct acpi_object_list params;
406 union acpi_object id;
410 switch (sensor->type) {
411 case HWMON_TYPE_VOLT:
412 method = data->rvlt_handle;
414 case HWMON_TYPE_TEMP:
415 method = data->rtmp_handle;
418 method = data->rfan_handle;
424 id.type = ACPI_TYPE_INTEGER;
425 id.integer.value = sensor->id;
428 params.pointer = &id;
430 status = acpi_evaluate_integer(method, NULL, ¶ms, value);
431 if (status != AE_OK) {
432 dev_warn(dev, "%s: ACPI exception: %s\n", __func__,
433 acpi_format_exception(status));
440 static int atk_read_value_new(struct atk_sensor_data *sensor, u64 *value)
442 struct atk_data *data = sensor->data;
443 struct device *dev = &data->acpi_dev->dev;
444 struct acpi_object_list params;
445 struct acpi_buffer ret;
446 union acpi_object id;
447 struct atk_acpi_buffer_u64 tmp;
450 id.type = ACPI_TYPE_INTEGER;
451 id.integer.value = sensor->id;
454 params.pointer = &id;
456 tmp.buf.type = ACPI_TYPE_BUFFER;
457 tmp.buf.buffer.pointer = (u8 *)&tmp.value;
458 tmp.buf.buffer.length = sizeof(u64);
459 ret.length = sizeof(tmp);
462 status = acpi_evaluate_object_typed(data->read_handle, NULL, ¶ms,
463 &ret, ACPI_TYPE_BUFFER);
464 if (status != AE_OK) {
465 dev_warn(dev, "%s: ACPI exception: %s\n", __func__,
466 acpi_format_exception(status));
470 /* Return buffer format:
471 * [0-3] "value" is valid flag
474 if (!(tmp.value & 0xffffffff)) {
475 /* The reading is not valid, possible causes:
477 * - enumeration was FUBAR (and we didn't notice)
479 dev_info(dev, "Failure: %#llx\n", tmp.value);
483 *value = (tmp.value & 0xffffffff00000000ULL) >> 32;
488 static int atk_read_value(struct atk_sensor_data *sensor, u64 *value)
492 if (!sensor->is_valid ||
493 time_after(jiffies, sensor->last_updated + CACHE_TIME)) {
494 if (sensor->data->old_interface)
495 err = atk_read_value_old(sensor, value);
497 err = atk_read_value_new(sensor, value);
499 sensor->is_valid = true;
500 sensor->last_updated = jiffies;
501 sensor->cached_value = *value;
503 *value = sensor->cached_value;
510 static int atk_add_sensor(struct atk_data *data, union acpi_object *obj)
512 struct device *dev = &data->acpi_dev->dev;
513 union acpi_object *flags;
514 union acpi_object *name;
515 union acpi_object *limit1;
516 union acpi_object *limit2;
517 union acpi_object *enable;
518 struct atk_sensor_data *sensor;
519 char const *base_name;
520 char const *limit1_name;
521 char const *limit2_name;
527 if (obj->type != ACPI_TYPE_PACKAGE) {
529 dev_warn(dev, "Unknown type for ACPI object: (%d)\n",
534 err = validate_hwmon_pack(data, obj);
538 /* Ok, we have a valid hwmon package */
539 type = atk_get_pack_member(data, obj, HWMON_PACK_FLAGS)->integer.value
543 case HWMON_TYPE_VOLT:
547 num = &data->voltage_count;
550 case HWMON_TYPE_TEMP:
553 limit2_name = "crit";
554 num = &data->temperature_count;
561 num = &data->fan_count;
565 dev_warn(dev, "Unknown sensor type: %#llx\n", type);
569 enable = atk_get_pack_member(data, obj, HWMON_PACK_ENABLE);
570 if (!enable->integer.value)
571 /* sensor is disabled */
574 flags = atk_get_pack_member(data, obj, HWMON_PACK_FLAGS);
575 name = atk_get_pack_member(data, obj, HWMON_PACK_NAME);
576 limit1 = atk_get_pack_member(data, obj, HWMON_PACK_LIMIT1);
577 limit2 = atk_get_pack_member(data, obj, HWMON_PACK_LIMIT2);
579 sensor = kzalloc(sizeof(*sensor), GFP_KERNEL);
583 sensor->acpi_name = kstrdup(name->string.pointer, GFP_KERNEL);
584 if (!sensor->acpi_name) {
589 INIT_LIST_HEAD(&sensor->list);
592 sensor->id = flags->integer.value;
593 sensor->limit1 = limit1->integer.value;
594 sensor->limit2 = limit2->integer.value;
596 snprintf(sensor->input_attr_name, ATTR_NAME_SIZE,
597 "%s%d_input", base_name, start + *num);
598 atk_init_attribute(&sensor->input_attr,
599 sensor->input_attr_name,
602 snprintf(sensor->label_attr_name, ATTR_NAME_SIZE,
603 "%s%d_label", base_name, start + *num);
604 atk_init_attribute(&sensor->label_attr,
605 sensor->label_attr_name,
608 snprintf(sensor->limit1_attr_name, ATTR_NAME_SIZE,
609 "%s%d_%s", base_name, start + *num, limit1_name);
610 atk_init_attribute(&sensor->limit1_attr,
611 sensor->limit1_attr_name,
614 snprintf(sensor->limit2_attr_name, ATTR_NAME_SIZE,
615 "%s%d_%s", base_name, start + *num, limit2_name);
616 atk_init_attribute(&sensor->limit2_attr,
617 sensor->limit2_attr_name,
620 list_add(&sensor->list, &data->sensor_list);
625 kfree(sensor->acpi_name);
630 static int atk_enumerate_old_hwmon(struct atk_data *data)
632 struct device *dev = &data->acpi_dev->dev;
633 struct acpi_buffer buf;
634 union acpi_object *pack;
640 buf.length = ACPI_ALLOCATE_BUFFER;
641 status = acpi_evaluate_object_typed(data->atk_handle,
642 METHOD_OLD_ENUM_VLT, NULL, &buf, ACPI_TYPE_PACKAGE);
643 if (status != AE_OK) {
644 dev_warn(dev, METHOD_OLD_ENUM_VLT ": ACPI exception: %s\n",
645 acpi_format_exception(status));
651 for (i = 1; i < pack->package.count; i++) {
652 union acpi_object *obj = &pack->package.elements[i];
654 ret = atk_add_sensor(data, obj);
658 ACPI_FREE(buf.pointer);
661 buf.length = ACPI_ALLOCATE_BUFFER;
662 status = acpi_evaluate_object_typed(data->atk_handle,
663 METHOD_OLD_ENUM_TMP, NULL, &buf, ACPI_TYPE_PACKAGE);
664 if (status != AE_OK) {
665 dev_warn(dev, METHOD_OLD_ENUM_TMP ": ACPI exception: %s\n",
666 acpi_format_exception(status));
673 for (i = 1; i < pack->package.count; i++) {
674 union acpi_object *obj = &pack->package.elements[i];
676 ret = atk_add_sensor(data, obj);
680 ACPI_FREE(buf.pointer);
683 buf.length = ACPI_ALLOCATE_BUFFER;
684 status = acpi_evaluate_object_typed(data->atk_handle,
685 METHOD_OLD_ENUM_FAN, NULL, &buf, ACPI_TYPE_PACKAGE);
686 if (status != AE_OK) {
687 dev_warn(dev, METHOD_OLD_ENUM_FAN ": ACPI exception: %s\n",
688 acpi_format_exception(status));
695 for (i = 1; i < pack->package.count; i++) {
696 union acpi_object *obj = &pack->package.elements[i];
698 ret = atk_add_sensor(data, obj);
702 ACPI_FREE(buf.pointer);
706 atk_free_sensors(data);
710 static int atk_enumerate_new_hwmon(struct atk_data *data)
712 struct device *dev = &data->acpi_dev->dev;
713 struct acpi_buffer buf;
715 struct acpi_object_list params;
716 union acpi_object id;
717 union acpi_object *pack;
721 dev_dbg(dev, "Enumerating hwmon sensors\n");
723 id.type = ACPI_TYPE_INTEGER;
724 id.integer.value = ATK_MUX_HWMON;
726 params.pointer = &id;
728 buf.length = ACPI_ALLOCATE_BUFFER;
729 ret = acpi_evaluate_object_typed(data->enumerate_handle, NULL, ¶ms,
730 &buf, ACPI_TYPE_PACKAGE);
732 dev_warn(dev, METHOD_ENUMERATE ": ACPI exception: %s\n",
733 acpi_format_exception(ret));
737 /* Result must be a package */
740 if (pack->package.count < 1) {
741 dev_dbg(dev, "%s: hwmon package is too small: %d\n", __func__,
742 pack->package.count);
747 for (i = 0; i < pack->package.count; i++) {
748 union acpi_object *obj = &pack->package.elements[i];
750 atk_add_sensor(data, obj);
753 err = data->voltage_count + data->temperature_count + data->fan_count;
756 ACPI_FREE(buf.pointer);
760 static int atk_create_files(struct atk_data *data)
762 struct atk_sensor_data *s;
765 list_for_each_entry(s, &data->sensor_list, list) {
766 err = device_create_file(data->hwmon_dev, &s->input_attr);
769 err = device_create_file(data->hwmon_dev, &s->label_attr);
772 err = device_create_file(data->hwmon_dev, &s->limit1_attr);
775 err = device_create_file(data->hwmon_dev, &s->limit2_attr);
780 err = device_create_file(data->hwmon_dev, &atk_name_attr);
785 static void atk_remove_files(struct atk_data *data)
787 struct atk_sensor_data *s;
789 list_for_each_entry(s, &data->sensor_list, list) {
790 device_remove_file(data->hwmon_dev, &s->input_attr);
791 device_remove_file(data->hwmon_dev, &s->label_attr);
792 device_remove_file(data->hwmon_dev, &s->limit1_attr);
793 device_remove_file(data->hwmon_dev, &s->limit2_attr);
795 device_remove_file(data->hwmon_dev, &atk_name_attr);
798 static void atk_free_sensors(struct atk_data *data)
800 struct list_head *head = &data->sensor_list;
801 struct atk_sensor_data *s, *tmp;
803 list_for_each_entry_safe(s, tmp, head, list) {
809 static int atk_register_hwmon(struct atk_data *data)
811 struct device *dev = &data->acpi_dev->dev;
814 dev_dbg(dev, "registering hwmon device\n");
815 data->hwmon_dev = hwmon_device_register(dev);
816 if (IS_ERR(data->hwmon_dev))
817 return PTR_ERR(data->hwmon_dev);
819 dev_dbg(dev, "populating sysfs directory\n");
820 err = atk_create_files(data);
826 /* Cleanup the registered files */
827 atk_remove_files(data);
828 hwmon_device_unregister(data->hwmon_dev);
832 static int atk_check_old_if(struct atk_data *data)
834 struct device *dev = &data->acpi_dev->dev;
838 /* RTMP: read temperature */
839 status = acpi_get_handle(data->atk_handle, METHOD_OLD_READ_TMP, &ret);
840 if (status != AE_OK) {
841 dev_dbg(dev, "method " METHOD_OLD_READ_TMP " not found: %s\n",
842 acpi_format_exception(status));
845 data->rtmp_handle = ret;
847 /* RVLT: read voltage */
848 status = acpi_get_handle(data->atk_handle, METHOD_OLD_READ_VLT, &ret);
849 if (status != AE_OK) {
850 dev_dbg(dev, "method " METHOD_OLD_READ_VLT " not found: %s\n",
851 acpi_format_exception(status));
854 data->rvlt_handle = ret;
856 /* RFAN: read fan status */
857 status = acpi_get_handle(data->atk_handle, METHOD_OLD_READ_FAN, &ret);
858 if (status != AE_OK) {
859 dev_dbg(dev, "method " METHOD_OLD_READ_FAN " not found: %s\n",
860 acpi_format_exception(status));
863 data->rfan_handle = ret;
868 static int atk_check_new_if(struct atk_data *data)
870 struct device *dev = &data->acpi_dev->dev;
875 status = acpi_get_handle(data->atk_handle, METHOD_ENUMERATE, &ret);
876 if (status != AE_OK) {
877 dev_dbg(dev, "method " METHOD_ENUMERATE " not found: %s\n",
878 acpi_format_exception(status));
881 data->enumerate_handle = ret;
883 /* De-multiplexer (read) */
884 status = acpi_get_handle(data->atk_handle, METHOD_READ, &ret);
885 if (status != AE_OK) {
886 dev_dbg(dev, "method " METHOD_READ " not found: %s\n",
887 acpi_format_exception(status));
890 data->read_handle = ret;
895 static int atk_add(struct acpi_device *device)
899 struct acpi_buffer buf;
900 union acpi_object *obj;
901 struct atk_data *data;
903 dev_dbg(&device->dev, "adding...\n");
905 data = kzalloc(sizeof(*data), GFP_KERNEL);
909 data->acpi_dev = device;
910 data->atk_handle = device->handle;
911 INIT_LIST_HEAD(&data->sensor_list);
913 buf.length = ACPI_ALLOCATE_BUFFER;
914 ret = acpi_evaluate_object_typed(data->atk_handle, BOARD_ID, NULL,
915 &buf, ACPI_TYPE_PACKAGE);
917 dev_dbg(&device->dev, "atk: method MBIF not found\n");
923 if (obj->package.count >= 2 &&
924 obj->package.elements[1].type == ACPI_TYPE_STRING) {
925 dev_dbg(&device->dev, "board ID = %s\n",
926 obj->package.elements[1].string.pointer);
928 ACPI_FREE(buf.pointer);
930 /* Check for hwmon methods: first check "old" style methods; note that
931 * both may be present: in this case we stick to the old interface;
932 * analysis of multiple DSDTs indicates that when both interfaces
933 * are present the new one (GGRP/GITM) is not functional.
935 err = atk_check_old_if(data);
937 dev_dbg(&device->dev, "Using old hwmon interface\n");
938 data->old_interface = true;
940 err = atk_check_new_if(data);
944 dev_dbg(&device->dev, "Using new hwmon interface\n");
945 data->old_interface = false;
948 if (data->old_interface)
949 err = atk_enumerate_old_hwmon(data);
951 err = atk_enumerate_new_hwmon(data);
955 dev_info(&device->dev,
956 "No usable sensor detected, bailing out\n");
961 err = atk_register_hwmon(data);
965 device->driver_data = data;
968 atk_free_sensors(data);
974 static int atk_remove(struct acpi_device *device, int type)
976 struct atk_data *data = device->driver_data;
977 dev_dbg(&device->dev, "removing...\n");
979 device->driver_data = NULL;
981 atk_remove_files(data);
982 atk_free_sensors(data);
983 hwmon_device_unregister(data->hwmon_dev);
990 static int __init atk0110_init(void)
994 ret = acpi_bus_register_driver(&atk_driver);
996 pr_info("atk: acpi_bus_register_driver failed: %d\n", ret);
1001 static void __exit atk0110_exit(void)
1003 acpi_bus_unregister_driver(&atk_driver);
1006 module_init(atk0110_init);
1007 module_exit(atk0110_exit);
1009 MODULE_LICENSE("GPL");