Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007-2009 Luca Tettamanti <kronos.it@gmail.com> |
| 3 | * |
| 4 | * This file is released under the GPLv2 |
| 5 | * See COPYING in the top level directory of the kernel tree. |
| 6 | */ |
| 7 | |
Luca Tettamanti | 7e5eab1 | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 8 | #include <linux/debugfs.h> |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 9 | #include <linux/kernel.h> |
| 10 | #include <linux/hwmon.h> |
| 11 | #include <linux/list.h> |
| 12 | #include <linux/module.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 13 | #include <linux/slab.h> |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 14 | |
| 15 | #include <acpi/acpi.h> |
| 16 | #include <acpi/acpixf.h> |
| 17 | #include <acpi/acpi_drivers.h> |
| 18 | #include <acpi/acpi_bus.h> |
| 19 | |
| 20 | |
| 21 | #define ATK_HID "ATK0110" |
| 22 | |
| 23 | /* Minimum time between readings, enforced in order to avoid |
| 24 | * hogging the CPU. |
| 25 | */ |
| 26 | #define CACHE_TIME HZ |
| 27 | |
| 28 | #define BOARD_ID "MBIF" |
| 29 | #define METHOD_ENUMERATE "GGRP" |
| 30 | #define METHOD_READ "GITM" |
| 31 | #define METHOD_WRITE "SITM" |
| 32 | #define METHOD_OLD_READ_TMP "RTMP" |
| 33 | #define METHOD_OLD_READ_VLT "RVLT" |
| 34 | #define METHOD_OLD_READ_FAN "RFAN" |
| 35 | #define METHOD_OLD_ENUM_TMP "TSIF" |
| 36 | #define METHOD_OLD_ENUM_VLT "VSIF" |
| 37 | #define METHOD_OLD_ENUM_FAN "FSIF" |
| 38 | |
| 39 | #define ATK_MUX_HWMON 0x00000006ULL |
Luca Tettamanti | 9e6eba6 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 40 | #define ATK_MUX_MGMT 0x00000011ULL |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 41 | |
| 42 | #define ATK_CLASS_MASK 0xff000000ULL |
| 43 | #define ATK_CLASS_FREQ_CTL 0x03000000ULL |
| 44 | #define ATK_CLASS_FAN_CTL 0x04000000ULL |
| 45 | #define ATK_CLASS_HWMON 0x06000000ULL |
Luca Tettamanti | 9e6eba6 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 46 | #define ATK_CLASS_MGMT 0x11000000ULL |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 47 | |
| 48 | #define ATK_TYPE_MASK 0x00ff0000ULL |
| 49 | #define HWMON_TYPE_VOLT 0x00020000ULL |
| 50 | #define HWMON_TYPE_TEMP 0x00030000ULL |
| 51 | #define HWMON_TYPE_FAN 0x00040000ULL |
| 52 | |
Luca Tettamanti | 9e6eba6 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 53 | #define ATK_ELEMENT_ID_MASK 0x0000ffffULL |
| 54 | |
| 55 | #define ATK_EC_ID 0x11060004ULL |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 56 | |
| 57 | enum atk_pack_member { |
| 58 | HWMON_PACK_FLAGS, |
| 59 | HWMON_PACK_NAME, |
| 60 | HWMON_PACK_LIMIT1, |
| 61 | HWMON_PACK_LIMIT2, |
| 62 | HWMON_PACK_ENABLE |
| 63 | }; |
| 64 | |
| 65 | /* New package format */ |
| 66 | #define _HWMON_NEW_PACK_SIZE 7 |
| 67 | #define _HWMON_NEW_PACK_FLAGS 0 |
| 68 | #define _HWMON_NEW_PACK_NAME 1 |
| 69 | #define _HWMON_NEW_PACK_UNK1 2 |
| 70 | #define _HWMON_NEW_PACK_UNK2 3 |
| 71 | #define _HWMON_NEW_PACK_LIMIT1 4 |
| 72 | #define _HWMON_NEW_PACK_LIMIT2 5 |
| 73 | #define _HWMON_NEW_PACK_ENABLE 6 |
| 74 | |
| 75 | /* Old package format */ |
| 76 | #define _HWMON_OLD_PACK_SIZE 5 |
| 77 | #define _HWMON_OLD_PACK_FLAGS 0 |
| 78 | #define _HWMON_OLD_PACK_NAME 1 |
| 79 | #define _HWMON_OLD_PACK_LIMIT1 2 |
| 80 | #define _HWMON_OLD_PACK_LIMIT2 3 |
| 81 | #define _HWMON_OLD_PACK_ENABLE 4 |
| 82 | |
| 83 | |
| 84 | struct atk_data { |
| 85 | struct device *hwmon_dev; |
| 86 | acpi_handle atk_handle; |
| 87 | struct acpi_device *acpi_dev; |
| 88 | |
| 89 | bool old_interface; |
| 90 | |
| 91 | /* old interface */ |
| 92 | acpi_handle rtmp_handle; |
| 93 | acpi_handle rvlt_handle; |
| 94 | acpi_handle rfan_handle; |
| 95 | /* new inteface */ |
| 96 | acpi_handle enumerate_handle; |
| 97 | acpi_handle read_handle; |
Luca Tettamanti | 9e6eba6 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 98 | acpi_handle write_handle; |
| 99 | |
| 100 | bool disable_ec; |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 101 | |
| 102 | int voltage_count; |
| 103 | int temperature_count; |
| 104 | int fan_count; |
| 105 | struct list_head sensor_list; |
Luca Tettamanti | 7e5eab1 | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 106 | |
| 107 | struct { |
| 108 | struct dentry *root; |
| 109 | u32 id; |
| 110 | } debugfs; |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 111 | }; |
| 112 | |
| 113 | |
| 114 | typedef ssize_t (*sysfs_show_func)(struct device *dev, |
| 115 | struct device_attribute *attr, char *buf); |
| 116 | |
| 117 | static const struct acpi_device_id atk_ids[] = { |
| 118 | {ATK_HID, 0}, |
| 119 | {"", 0}, |
| 120 | }; |
| 121 | MODULE_DEVICE_TABLE(acpi, atk_ids); |
| 122 | |
| 123 | #define ATTR_NAME_SIZE 16 /* Worst case is "tempN_input" */ |
| 124 | |
| 125 | struct atk_sensor_data { |
| 126 | struct list_head list; |
| 127 | struct atk_data *data; |
| 128 | struct device_attribute label_attr; |
| 129 | struct device_attribute input_attr; |
| 130 | struct device_attribute limit1_attr; |
| 131 | struct device_attribute limit2_attr; |
| 132 | char label_attr_name[ATTR_NAME_SIZE]; |
| 133 | char input_attr_name[ATTR_NAME_SIZE]; |
| 134 | char limit1_attr_name[ATTR_NAME_SIZE]; |
| 135 | char limit2_attr_name[ATTR_NAME_SIZE]; |
| 136 | u64 id; |
| 137 | u64 type; |
| 138 | u64 limit1; |
| 139 | u64 limit2; |
| 140 | u64 cached_value; |
| 141 | unsigned long last_updated; /* in jiffies */ |
| 142 | bool is_valid; |
| 143 | char const *acpi_name; |
| 144 | }; |
| 145 | |
Luca Tettamanti | 18e25555 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 146 | /* Return buffer format: |
| 147 | * [0-3] "value" is valid flag |
| 148 | * [4-7] value |
| 149 | * [8- ] unknown stuff on newer mobos |
| 150 | */ |
| 151 | struct atk_acpi_ret_buffer { |
| 152 | u32 flags; |
| 153 | u32 value; |
| 154 | u8 data[]; |
| 155 | }; |
| 156 | |
| 157 | /* Input buffer used for GITM and SITM methods */ |
| 158 | struct atk_acpi_input_buf { |
| 159 | u32 id; |
| 160 | u32 param1; |
| 161 | u32 param2; |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 162 | }; |
| 163 | |
| 164 | static int atk_add(struct acpi_device *device); |
| 165 | static int atk_remove(struct acpi_device *device, int type); |
| 166 | static void atk_print_sensor(struct atk_data *data, union acpi_object *obj); |
| 167 | static int atk_read_value(struct atk_sensor_data *sensor, u64 *value); |
| 168 | static void atk_free_sensors(struct atk_data *data); |
| 169 | |
| 170 | static struct acpi_driver atk_driver = { |
| 171 | .name = ATK_HID, |
| 172 | .class = "hwmon", |
| 173 | .ids = atk_ids, |
| 174 | .ops = { |
| 175 | .add = atk_add, |
| 176 | .remove = atk_remove, |
| 177 | }, |
| 178 | }; |
| 179 | |
| 180 | #define input_to_atk_sensor(attr) \ |
| 181 | container_of(attr, struct atk_sensor_data, input_attr) |
| 182 | |
| 183 | #define label_to_atk_sensor(attr) \ |
| 184 | container_of(attr, struct atk_sensor_data, label_attr) |
| 185 | |
| 186 | #define limit1_to_atk_sensor(attr) \ |
| 187 | container_of(attr, struct atk_sensor_data, limit1_attr) |
| 188 | |
| 189 | #define limit2_to_atk_sensor(attr) \ |
| 190 | container_of(attr, struct atk_sensor_data, limit2_attr) |
| 191 | |
| 192 | static ssize_t atk_input_show(struct device *dev, |
| 193 | struct device_attribute *attr, char *buf) |
| 194 | { |
| 195 | struct atk_sensor_data *s = input_to_atk_sensor(attr); |
| 196 | u64 value; |
| 197 | int err; |
| 198 | |
| 199 | err = atk_read_value(s, &value); |
| 200 | if (err) |
| 201 | return err; |
| 202 | |
| 203 | if (s->type == HWMON_TYPE_TEMP) |
| 204 | /* ACPI returns decidegree */ |
| 205 | value *= 100; |
| 206 | |
| 207 | return sprintf(buf, "%llu\n", value); |
| 208 | } |
| 209 | |
| 210 | static ssize_t atk_label_show(struct device *dev, |
| 211 | struct device_attribute *attr, char *buf) |
| 212 | { |
| 213 | struct atk_sensor_data *s = label_to_atk_sensor(attr); |
| 214 | |
| 215 | return sprintf(buf, "%s\n", s->acpi_name); |
| 216 | } |
| 217 | |
| 218 | static ssize_t atk_limit1_show(struct device *dev, |
| 219 | struct device_attribute *attr, char *buf) |
| 220 | { |
| 221 | struct atk_sensor_data *s = limit1_to_atk_sensor(attr); |
| 222 | u64 value = s->limit1; |
| 223 | |
| 224 | if (s->type == HWMON_TYPE_TEMP) |
| 225 | value *= 100; |
| 226 | |
| 227 | return sprintf(buf, "%lld\n", value); |
| 228 | } |
| 229 | |
| 230 | static ssize_t atk_limit2_show(struct device *dev, |
| 231 | struct device_attribute *attr, char *buf) |
| 232 | { |
| 233 | struct atk_sensor_data *s = limit2_to_atk_sensor(attr); |
| 234 | u64 value = s->limit2; |
| 235 | |
| 236 | if (s->type == HWMON_TYPE_TEMP) |
| 237 | value *= 100; |
| 238 | |
| 239 | return sprintf(buf, "%lld\n", value); |
| 240 | } |
| 241 | |
| 242 | static ssize_t atk_name_show(struct device *dev, |
| 243 | struct device_attribute *attr, char *buf) |
| 244 | { |
| 245 | return sprintf(buf, "atk0110\n"); |
| 246 | } |
| 247 | static struct device_attribute atk_name_attr = |
| 248 | __ATTR(name, 0444, atk_name_show, NULL); |
| 249 | |
| 250 | static void atk_init_attribute(struct device_attribute *attr, char *name, |
| 251 | sysfs_show_func show) |
| 252 | { |
| 253 | attr->attr.name = name; |
| 254 | attr->attr.mode = 0444; |
| 255 | attr->show = show; |
| 256 | attr->store = NULL; |
| 257 | } |
| 258 | |
| 259 | |
| 260 | static union acpi_object *atk_get_pack_member(struct atk_data *data, |
| 261 | union acpi_object *pack, |
| 262 | enum atk_pack_member m) |
| 263 | { |
| 264 | bool old_if = data->old_interface; |
| 265 | int offset; |
| 266 | |
| 267 | switch (m) { |
| 268 | case HWMON_PACK_FLAGS: |
| 269 | offset = old_if ? _HWMON_OLD_PACK_FLAGS : _HWMON_NEW_PACK_FLAGS; |
| 270 | break; |
| 271 | case HWMON_PACK_NAME: |
| 272 | offset = old_if ? _HWMON_OLD_PACK_NAME : _HWMON_NEW_PACK_NAME; |
| 273 | break; |
| 274 | case HWMON_PACK_LIMIT1: |
| 275 | offset = old_if ? _HWMON_OLD_PACK_LIMIT1 : |
| 276 | _HWMON_NEW_PACK_LIMIT1; |
| 277 | break; |
| 278 | case HWMON_PACK_LIMIT2: |
| 279 | offset = old_if ? _HWMON_OLD_PACK_LIMIT2 : |
| 280 | _HWMON_NEW_PACK_LIMIT2; |
| 281 | break; |
| 282 | case HWMON_PACK_ENABLE: |
| 283 | offset = old_if ? _HWMON_OLD_PACK_ENABLE : |
| 284 | _HWMON_NEW_PACK_ENABLE; |
| 285 | break; |
| 286 | default: |
| 287 | return NULL; |
| 288 | } |
| 289 | |
| 290 | return &pack->package.elements[offset]; |
| 291 | } |
| 292 | |
| 293 | |
| 294 | /* New package format is: |
| 295 | * - flag (int) |
| 296 | * class - used for de-muxing the request to the correct GITn |
| 297 | * type (volt, temp, fan) |
| 298 | * sensor id | |
| 299 | * sensor id - used for de-muxing the request _inside_ the GITn |
| 300 | * - name (str) |
| 301 | * - unknown (int) |
| 302 | * - unknown (int) |
| 303 | * - limit1 (int) |
| 304 | * - limit2 (int) |
| 305 | * - enable (int) |
| 306 | * |
| 307 | * The old package has the same format but it's missing the two unknown fields. |
| 308 | */ |
| 309 | static int validate_hwmon_pack(struct atk_data *data, union acpi_object *obj) |
| 310 | { |
| 311 | struct device *dev = &data->acpi_dev->dev; |
| 312 | union acpi_object *tmp; |
| 313 | bool old_if = data->old_interface; |
| 314 | int const expected_size = old_if ? _HWMON_OLD_PACK_SIZE : |
| 315 | _HWMON_NEW_PACK_SIZE; |
| 316 | |
| 317 | if (obj->type != ACPI_TYPE_PACKAGE) { |
| 318 | dev_warn(dev, "Invalid type: %d\n", obj->type); |
| 319 | return -EINVAL; |
| 320 | } |
| 321 | |
| 322 | if (obj->package.count != expected_size) { |
| 323 | dev_warn(dev, "Invalid package size: %d, expected: %d\n", |
| 324 | obj->package.count, expected_size); |
| 325 | return -EINVAL; |
| 326 | } |
| 327 | |
| 328 | tmp = atk_get_pack_member(data, obj, HWMON_PACK_FLAGS); |
| 329 | if (tmp->type != ACPI_TYPE_INTEGER) { |
| 330 | dev_warn(dev, "Invalid type (flag): %d\n", tmp->type); |
| 331 | return -EINVAL; |
| 332 | } |
| 333 | |
| 334 | tmp = atk_get_pack_member(data, obj, HWMON_PACK_NAME); |
| 335 | if (tmp->type != ACPI_TYPE_STRING) { |
| 336 | dev_warn(dev, "Invalid type (name): %d\n", tmp->type); |
| 337 | return -EINVAL; |
| 338 | } |
| 339 | |
| 340 | /* Don't check... we don't know what they're useful for anyway */ |
| 341 | #if 0 |
| 342 | tmp = &obj->package.elements[HWMON_PACK_UNK1]; |
| 343 | if (tmp->type != ACPI_TYPE_INTEGER) { |
| 344 | dev_warn(dev, "Invalid type (unk1): %d\n", tmp->type); |
| 345 | return -EINVAL; |
| 346 | } |
| 347 | |
| 348 | tmp = &obj->package.elements[HWMON_PACK_UNK2]; |
| 349 | if (tmp->type != ACPI_TYPE_INTEGER) { |
| 350 | dev_warn(dev, "Invalid type (unk2): %d\n", tmp->type); |
| 351 | return -EINVAL; |
| 352 | } |
| 353 | #endif |
| 354 | |
| 355 | tmp = atk_get_pack_member(data, obj, HWMON_PACK_LIMIT1); |
| 356 | if (tmp->type != ACPI_TYPE_INTEGER) { |
| 357 | dev_warn(dev, "Invalid type (limit1): %d\n", tmp->type); |
| 358 | return -EINVAL; |
| 359 | } |
| 360 | |
| 361 | tmp = atk_get_pack_member(data, obj, HWMON_PACK_LIMIT2); |
| 362 | if (tmp->type != ACPI_TYPE_INTEGER) { |
| 363 | dev_warn(dev, "Invalid type (limit2): %d\n", tmp->type); |
| 364 | return -EINVAL; |
| 365 | } |
| 366 | |
| 367 | tmp = atk_get_pack_member(data, obj, HWMON_PACK_ENABLE); |
| 368 | if (tmp->type != ACPI_TYPE_INTEGER) { |
| 369 | dev_warn(dev, "Invalid type (enable): %d\n", tmp->type); |
| 370 | return -EINVAL; |
| 371 | } |
| 372 | |
| 373 | atk_print_sensor(data, obj); |
| 374 | |
| 375 | return 0; |
| 376 | } |
| 377 | |
Luca Tettamanti | b900870 | 2009-05-08 20:27:28 +0200 | [diff] [blame] | 378 | #ifdef DEBUG |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 379 | static char const *atk_sensor_type(union acpi_object *flags) |
| 380 | { |
| 381 | u64 type = flags->integer.value & ATK_TYPE_MASK; |
| 382 | char const *what; |
| 383 | |
| 384 | switch (type) { |
| 385 | case HWMON_TYPE_VOLT: |
| 386 | what = "voltage"; |
| 387 | break; |
| 388 | case HWMON_TYPE_TEMP: |
| 389 | what = "temperature"; |
| 390 | break; |
| 391 | case HWMON_TYPE_FAN: |
| 392 | what = "fan"; |
| 393 | break; |
| 394 | default: |
| 395 | what = "unknown"; |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | return what; |
| 400 | } |
Luca Tettamanti | b900870 | 2009-05-08 20:27:28 +0200 | [diff] [blame] | 401 | #endif |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 402 | |
| 403 | static void atk_print_sensor(struct atk_data *data, union acpi_object *obj) |
| 404 | { |
| 405 | #ifdef DEBUG |
| 406 | struct device *dev = &data->acpi_dev->dev; |
| 407 | union acpi_object *flags; |
| 408 | union acpi_object *name; |
| 409 | union acpi_object *limit1; |
| 410 | union acpi_object *limit2; |
| 411 | union acpi_object *enable; |
| 412 | char const *what; |
| 413 | |
| 414 | flags = atk_get_pack_member(data, obj, HWMON_PACK_FLAGS); |
| 415 | name = atk_get_pack_member(data, obj, HWMON_PACK_NAME); |
| 416 | limit1 = atk_get_pack_member(data, obj, HWMON_PACK_LIMIT1); |
| 417 | limit2 = atk_get_pack_member(data, obj, HWMON_PACK_LIMIT2); |
| 418 | enable = atk_get_pack_member(data, obj, HWMON_PACK_ENABLE); |
| 419 | |
| 420 | what = atk_sensor_type(flags); |
| 421 | |
| 422 | dev_dbg(dev, "%s: %#llx %s [%llu-%llu] %s\n", what, |
| 423 | flags->integer.value, |
| 424 | name->string.pointer, |
| 425 | limit1->integer.value, limit2->integer.value, |
| 426 | enable->integer.value ? "enabled" : "disabled"); |
| 427 | #endif |
| 428 | } |
| 429 | |
| 430 | static int atk_read_value_old(struct atk_sensor_data *sensor, u64 *value) |
| 431 | { |
| 432 | struct atk_data *data = sensor->data; |
| 433 | struct device *dev = &data->acpi_dev->dev; |
| 434 | struct acpi_object_list params; |
| 435 | union acpi_object id; |
| 436 | acpi_status status; |
| 437 | acpi_handle method; |
| 438 | |
| 439 | switch (sensor->type) { |
| 440 | case HWMON_TYPE_VOLT: |
| 441 | method = data->rvlt_handle; |
| 442 | break; |
| 443 | case HWMON_TYPE_TEMP: |
| 444 | method = data->rtmp_handle; |
| 445 | break; |
| 446 | case HWMON_TYPE_FAN: |
| 447 | method = data->rfan_handle; |
| 448 | break; |
| 449 | default: |
| 450 | return -EINVAL; |
| 451 | } |
| 452 | |
| 453 | id.type = ACPI_TYPE_INTEGER; |
| 454 | id.integer.value = sensor->id; |
| 455 | |
| 456 | params.count = 1; |
| 457 | params.pointer = &id; |
| 458 | |
| 459 | status = acpi_evaluate_integer(method, NULL, ¶ms, value); |
| 460 | if (status != AE_OK) { |
| 461 | dev_warn(dev, "%s: ACPI exception: %s\n", __func__, |
| 462 | acpi_format_exception(status)); |
| 463 | return -EIO; |
| 464 | } |
| 465 | |
| 466 | return 0; |
| 467 | } |
| 468 | |
Luca Tettamanti | 18e25555 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 469 | static union acpi_object *atk_ggrp(struct atk_data *data, u16 mux) |
| 470 | { |
| 471 | struct device *dev = &data->acpi_dev->dev; |
| 472 | struct acpi_buffer buf; |
| 473 | acpi_status ret; |
| 474 | struct acpi_object_list params; |
| 475 | union acpi_object id; |
| 476 | union acpi_object *pack; |
| 477 | |
| 478 | id.type = ACPI_TYPE_INTEGER; |
| 479 | id.integer.value = mux; |
| 480 | params.count = 1; |
| 481 | params.pointer = &id; |
| 482 | |
| 483 | buf.length = ACPI_ALLOCATE_BUFFER; |
| 484 | ret = acpi_evaluate_object(data->enumerate_handle, NULL, ¶ms, &buf); |
| 485 | if (ret != AE_OK) { |
| 486 | dev_err(dev, "GGRP[%#x] ACPI exception: %s\n", mux, |
| 487 | acpi_format_exception(ret)); |
| 488 | return ERR_PTR(-EIO); |
| 489 | } |
| 490 | pack = buf.pointer; |
| 491 | if (pack->type != ACPI_TYPE_PACKAGE) { |
| 492 | /* Execution was successful, but the id was not found */ |
| 493 | ACPI_FREE(pack); |
| 494 | return ERR_PTR(-ENOENT); |
| 495 | } |
| 496 | |
| 497 | if (pack->package.count < 1) { |
| 498 | dev_err(dev, "GGRP[%#x] package is too small\n", mux); |
| 499 | ACPI_FREE(pack); |
| 500 | return ERR_PTR(-EIO); |
| 501 | } |
| 502 | return pack; |
| 503 | } |
| 504 | |
| 505 | static union acpi_object *atk_gitm(struct atk_data *data, u64 id) |
| 506 | { |
| 507 | struct device *dev = &data->acpi_dev->dev; |
| 508 | struct atk_acpi_input_buf buf; |
| 509 | union acpi_object tmp; |
| 510 | struct acpi_object_list params; |
| 511 | struct acpi_buffer ret; |
| 512 | union acpi_object *obj; |
| 513 | acpi_status status; |
| 514 | |
| 515 | buf.id = id; |
| 516 | buf.param1 = 0; |
| 517 | buf.param2 = 0; |
| 518 | |
| 519 | tmp.type = ACPI_TYPE_BUFFER; |
| 520 | tmp.buffer.pointer = (u8 *)&buf; |
| 521 | tmp.buffer.length = sizeof(buf); |
| 522 | |
| 523 | params.count = 1; |
| 524 | params.pointer = (void *)&tmp; |
| 525 | |
| 526 | ret.length = ACPI_ALLOCATE_BUFFER; |
| 527 | status = acpi_evaluate_object_typed(data->read_handle, NULL, ¶ms, |
| 528 | &ret, ACPI_TYPE_BUFFER); |
| 529 | if (status != AE_OK) { |
| 530 | dev_warn(dev, "GITM[%#llx] ACPI exception: %s\n", id, |
| 531 | acpi_format_exception(status)); |
| 532 | return ERR_PTR(-EIO); |
| 533 | } |
| 534 | obj = ret.pointer; |
| 535 | |
| 536 | /* Sanity check */ |
| 537 | if (obj->buffer.length < 8) { |
| 538 | dev_warn(dev, "Unexpected ASBF length: %u\n", |
| 539 | obj->buffer.length); |
| 540 | ACPI_FREE(obj); |
| 541 | return ERR_PTR(-EIO); |
| 542 | } |
| 543 | return obj; |
| 544 | } |
| 545 | |
Luca Tettamanti | 9e6eba6 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 546 | static union acpi_object *atk_sitm(struct atk_data *data, |
| 547 | struct atk_acpi_input_buf *buf) |
| 548 | { |
| 549 | struct device *dev = &data->acpi_dev->dev; |
| 550 | struct acpi_object_list params; |
| 551 | union acpi_object tmp; |
| 552 | struct acpi_buffer ret; |
| 553 | union acpi_object *obj; |
| 554 | acpi_status status; |
| 555 | |
| 556 | tmp.type = ACPI_TYPE_BUFFER; |
| 557 | tmp.buffer.pointer = (u8 *)buf; |
| 558 | tmp.buffer.length = sizeof(*buf); |
| 559 | |
| 560 | params.count = 1; |
| 561 | params.pointer = &tmp; |
| 562 | |
| 563 | ret.length = ACPI_ALLOCATE_BUFFER; |
| 564 | status = acpi_evaluate_object_typed(data->write_handle, NULL, ¶ms, |
| 565 | &ret, ACPI_TYPE_BUFFER); |
| 566 | if (status != AE_OK) { |
| 567 | dev_warn(dev, "SITM[%#x] ACPI exception: %s\n", buf->id, |
| 568 | acpi_format_exception(status)); |
| 569 | return ERR_PTR(-EIO); |
| 570 | } |
| 571 | obj = ret.pointer; |
| 572 | |
| 573 | /* Sanity check */ |
| 574 | if (obj->buffer.length < 8) { |
| 575 | dev_warn(dev, "Unexpected ASBF length: %u\n", |
| 576 | obj->buffer.length); |
| 577 | ACPI_FREE(obj); |
| 578 | return ERR_PTR(-EIO); |
| 579 | } |
| 580 | return obj; |
| 581 | } |
| 582 | |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 583 | static int atk_read_value_new(struct atk_sensor_data *sensor, u64 *value) |
| 584 | { |
| 585 | struct atk_data *data = sensor->data; |
| 586 | struct device *dev = &data->acpi_dev->dev; |
Luca Tettamanti | 18e25555 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 587 | union acpi_object *obj; |
| 588 | struct atk_acpi_ret_buffer *buf; |
| 589 | int err = 0; |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 590 | |
Luca Tettamanti | 18e25555 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 591 | obj = atk_gitm(data, sensor->id); |
| 592 | if (IS_ERR(obj)) |
| 593 | return PTR_ERR(obj); |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 594 | |
Luca Tettamanti | 18e25555 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 595 | buf = (struct atk_acpi_ret_buffer *)obj->buffer.pointer; |
| 596 | if (buf->flags == 0) { |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 597 | /* The reading is not valid, possible causes: |
| 598 | * - sensor failure |
| 599 | * - enumeration was FUBAR (and we didn't notice) |
| 600 | */ |
Luca Tettamanti | 18e25555 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 601 | dev_warn(dev, "Read failed, sensor = %#llx\n", sensor->id); |
| 602 | err = -EIO; |
| 603 | goto out; |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 604 | } |
| 605 | |
Luca Tettamanti | 18e25555 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 606 | *value = buf->value; |
| 607 | out: |
| 608 | ACPI_FREE(obj); |
| 609 | return err; |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | static int atk_read_value(struct atk_sensor_data *sensor, u64 *value) |
| 613 | { |
| 614 | int err; |
| 615 | |
| 616 | if (!sensor->is_valid || |
| 617 | time_after(jiffies, sensor->last_updated + CACHE_TIME)) { |
| 618 | if (sensor->data->old_interface) |
| 619 | err = atk_read_value_old(sensor, value); |
| 620 | else |
| 621 | err = atk_read_value_new(sensor, value); |
| 622 | |
| 623 | sensor->is_valid = true; |
| 624 | sensor->last_updated = jiffies; |
| 625 | sensor->cached_value = *value; |
| 626 | } else { |
| 627 | *value = sensor->cached_value; |
| 628 | err = 0; |
| 629 | } |
| 630 | |
| 631 | return err; |
| 632 | } |
| 633 | |
Luca Tettamanti | 7e5eab1 | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 634 | #ifdef CONFIG_DEBUG_FS |
| 635 | static int atk_debugfs_gitm_get(void *p, u64 *val) |
| 636 | { |
| 637 | struct atk_data *data = p; |
| 638 | union acpi_object *ret; |
| 639 | struct atk_acpi_ret_buffer *buf; |
| 640 | int err = 0; |
| 641 | |
| 642 | if (!data->read_handle) |
| 643 | return -ENODEV; |
| 644 | |
| 645 | if (!data->debugfs.id) |
| 646 | return -EINVAL; |
| 647 | |
| 648 | ret = atk_gitm(data, data->debugfs.id); |
| 649 | if (IS_ERR(ret)) |
| 650 | return PTR_ERR(ret); |
| 651 | |
| 652 | buf = (struct atk_acpi_ret_buffer *)ret->buffer.pointer; |
| 653 | if (buf->flags) |
| 654 | *val = buf->value; |
| 655 | else |
| 656 | err = -EIO; |
| 657 | |
| 658 | return err; |
| 659 | } |
| 660 | |
| 661 | DEFINE_SIMPLE_ATTRIBUTE(atk_debugfs_gitm, |
| 662 | atk_debugfs_gitm_get, |
| 663 | NULL, |
| 664 | "0x%08llx\n") |
| 665 | |
| 666 | static int atk_acpi_print(char *buf, size_t sz, union acpi_object *obj) |
| 667 | { |
| 668 | int ret = 0; |
| 669 | |
| 670 | switch (obj->type) { |
| 671 | case ACPI_TYPE_INTEGER: |
| 672 | ret = snprintf(buf, sz, "0x%08llx\n", obj->integer.value); |
| 673 | break; |
| 674 | case ACPI_TYPE_STRING: |
| 675 | ret = snprintf(buf, sz, "%s\n", obj->string.pointer); |
| 676 | break; |
| 677 | } |
| 678 | |
| 679 | return ret; |
| 680 | } |
| 681 | |
| 682 | static void atk_pack_print(char *buf, size_t sz, union acpi_object *pack) |
| 683 | { |
| 684 | int ret; |
| 685 | int i; |
| 686 | |
| 687 | for (i = 0; i < pack->package.count; i++) { |
| 688 | union acpi_object *obj = &pack->package.elements[i]; |
| 689 | |
| 690 | ret = atk_acpi_print(buf, sz, obj); |
| 691 | if (ret >= sz) |
| 692 | break; |
| 693 | buf += ret; |
| 694 | sz -= ret; |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | static int atk_debugfs_ggrp_open(struct inode *inode, struct file *file) |
| 699 | { |
| 700 | struct atk_data *data = inode->i_private; |
| 701 | char *buf = NULL; |
| 702 | union acpi_object *ret; |
| 703 | u8 cls; |
| 704 | int i; |
| 705 | |
| 706 | if (!data->enumerate_handle) |
| 707 | return -ENODEV; |
| 708 | if (!data->debugfs.id) |
| 709 | return -EINVAL; |
| 710 | |
| 711 | cls = (data->debugfs.id & 0xff000000) >> 24; |
| 712 | ret = atk_ggrp(data, cls); |
| 713 | if (IS_ERR(ret)) |
| 714 | return PTR_ERR(ret); |
| 715 | |
| 716 | for (i = 0; i < ret->package.count; i++) { |
| 717 | union acpi_object *pack = &ret->package.elements[i]; |
| 718 | union acpi_object *id; |
| 719 | |
| 720 | if (pack->type != ACPI_TYPE_PACKAGE) |
| 721 | continue; |
| 722 | if (!pack->package.count) |
| 723 | continue; |
| 724 | id = &pack->package.elements[0]; |
| 725 | if (id->integer.value == data->debugfs.id) { |
| 726 | /* Print the package */ |
| 727 | buf = kzalloc(512, GFP_KERNEL); |
| 728 | if (!buf) { |
| 729 | ACPI_FREE(ret); |
| 730 | return -ENOMEM; |
| 731 | } |
| 732 | atk_pack_print(buf, 512, pack); |
| 733 | break; |
| 734 | } |
| 735 | } |
| 736 | ACPI_FREE(ret); |
| 737 | |
| 738 | if (!buf) |
| 739 | return -EINVAL; |
| 740 | |
| 741 | file->private_data = buf; |
| 742 | |
| 743 | return nonseekable_open(inode, file); |
| 744 | } |
| 745 | |
| 746 | static ssize_t atk_debugfs_ggrp_read(struct file *file, char __user *buf, |
| 747 | size_t count, loff_t *pos) |
| 748 | { |
| 749 | char *str = file->private_data; |
| 750 | size_t len = strlen(str); |
| 751 | |
| 752 | return simple_read_from_buffer(buf, count, pos, str, len); |
| 753 | } |
| 754 | |
| 755 | static int atk_debugfs_ggrp_release(struct inode *inode, struct file *file) |
| 756 | { |
| 757 | kfree(file->private_data); |
| 758 | return 0; |
| 759 | } |
| 760 | |
| 761 | static const struct file_operations atk_debugfs_ggrp_fops = { |
| 762 | .read = atk_debugfs_ggrp_read, |
| 763 | .open = atk_debugfs_ggrp_open, |
| 764 | .release = atk_debugfs_ggrp_release, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 765 | .llseek = no_llseek, |
Luca Tettamanti | 7e5eab1 | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 766 | }; |
| 767 | |
| 768 | static void atk_debugfs_init(struct atk_data *data) |
| 769 | { |
| 770 | struct dentry *d; |
| 771 | struct dentry *f; |
| 772 | |
| 773 | data->debugfs.id = 0; |
| 774 | |
| 775 | d = debugfs_create_dir("asus_atk0110", NULL); |
| 776 | if (!d || IS_ERR(d)) |
| 777 | return; |
| 778 | |
| 779 | f = debugfs_create_x32("id", S_IRUSR | S_IWUSR, d, &data->debugfs.id); |
| 780 | if (!f || IS_ERR(f)) |
| 781 | goto cleanup; |
| 782 | |
| 783 | f = debugfs_create_file("gitm", S_IRUSR, d, data, |
| 784 | &atk_debugfs_gitm); |
| 785 | if (!f || IS_ERR(f)) |
| 786 | goto cleanup; |
| 787 | |
| 788 | f = debugfs_create_file("ggrp", S_IRUSR, d, data, |
| 789 | &atk_debugfs_ggrp_fops); |
| 790 | if (!f || IS_ERR(f)) |
| 791 | goto cleanup; |
| 792 | |
| 793 | data->debugfs.root = d; |
| 794 | |
| 795 | return; |
| 796 | cleanup: |
| 797 | debugfs_remove_recursive(d); |
| 798 | } |
| 799 | |
| 800 | static void atk_debugfs_cleanup(struct atk_data *data) |
| 801 | { |
| 802 | debugfs_remove_recursive(data->debugfs.root); |
| 803 | } |
| 804 | |
| 805 | #else /* CONFIG_DEBUG_FS */ |
| 806 | |
| 807 | static void atk_debugfs_init(struct atk_data *data) |
| 808 | { |
| 809 | } |
| 810 | |
| 811 | static void atk_debugfs_cleanup(struct atk_data *data) |
| 812 | { |
| 813 | } |
| 814 | #endif |
| 815 | |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 816 | static int atk_add_sensor(struct atk_data *data, union acpi_object *obj) |
| 817 | { |
| 818 | struct device *dev = &data->acpi_dev->dev; |
| 819 | union acpi_object *flags; |
| 820 | union acpi_object *name; |
| 821 | union acpi_object *limit1; |
| 822 | union acpi_object *limit2; |
| 823 | union acpi_object *enable; |
| 824 | struct atk_sensor_data *sensor; |
| 825 | char const *base_name; |
| 826 | char const *limit1_name; |
| 827 | char const *limit2_name; |
| 828 | u64 type; |
| 829 | int err; |
| 830 | int *num; |
| 831 | int start; |
| 832 | |
| 833 | if (obj->type != ACPI_TYPE_PACKAGE) { |
| 834 | /* wft is this? */ |
| 835 | dev_warn(dev, "Unknown type for ACPI object: (%d)\n", |
| 836 | obj->type); |
| 837 | return -EINVAL; |
| 838 | } |
| 839 | |
| 840 | err = validate_hwmon_pack(data, obj); |
| 841 | if (err) |
| 842 | return err; |
| 843 | |
| 844 | /* Ok, we have a valid hwmon package */ |
| 845 | type = atk_get_pack_member(data, obj, HWMON_PACK_FLAGS)->integer.value |
| 846 | & ATK_TYPE_MASK; |
| 847 | |
| 848 | switch (type) { |
| 849 | case HWMON_TYPE_VOLT: |
| 850 | base_name = "in"; |
| 851 | limit1_name = "min"; |
| 852 | limit2_name = "max"; |
| 853 | num = &data->voltage_count; |
| 854 | start = 0; |
| 855 | break; |
| 856 | case HWMON_TYPE_TEMP: |
| 857 | base_name = "temp"; |
| 858 | limit1_name = "max"; |
| 859 | limit2_name = "crit"; |
| 860 | num = &data->temperature_count; |
| 861 | start = 1; |
| 862 | break; |
| 863 | case HWMON_TYPE_FAN: |
| 864 | base_name = "fan"; |
| 865 | limit1_name = "min"; |
| 866 | limit2_name = "max"; |
| 867 | num = &data->fan_count; |
| 868 | start = 1; |
| 869 | break; |
| 870 | default: |
| 871 | dev_warn(dev, "Unknown sensor type: %#llx\n", type); |
| 872 | return -EINVAL; |
| 873 | } |
| 874 | |
| 875 | enable = atk_get_pack_member(data, obj, HWMON_PACK_ENABLE); |
| 876 | if (!enable->integer.value) |
| 877 | /* sensor is disabled */ |
| 878 | return 0; |
| 879 | |
| 880 | flags = atk_get_pack_member(data, obj, HWMON_PACK_FLAGS); |
| 881 | name = atk_get_pack_member(data, obj, HWMON_PACK_NAME); |
| 882 | limit1 = atk_get_pack_member(data, obj, HWMON_PACK_LIMIT1); |
| 883 | limit2 = atk_get_pack_member(data, obj, HWMON_PACK_LIMIT2); |
| 884 | |
| 885 | sensor = kzalloc(sizeof(*sensor), GFP_KERNEL); |
| 886 | if (!sensor) |
| 887 | return -ENOMEM; |
| 888 | |
| 889 | sensor->acpi_name = kstrdup(name->string.pointer, GFP_KERNEL); |
| 890 | if (!sensor->acpi_name) { |
| 891 | err = -ENOMEM; |
| 892 | goto out; |
| 893 | } |
| 894 | |
| 895 | INIT_LIST_HEAD(&sensor->list); |
| 896 | sensor->type = type; |
| 897 | sensor->data = data; |
| 898 | sensor->id = flags->integer.value; |
| 899 | sensor->limit1 = limit1->integer.value; |
Luca Tettamanti | 8d28249 | 2009-07-28 16:31:39 +0200 | [diff] [blame] | 900 | if (data->old_interface) |
| 901 | sensor->limit2 = limit2->integer.value; |
| 902 | else |
| 903 | /* The upper limit is expressed as delta from lower limit */ |
| 904 | sensor->limit2 = sensor->limit1 + limit2->integer.value; |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 905 | |
| 906 | snprintf(sensor->input_attr_name, ATTR_NAME_SIZE, |
| 907 | "%s%d_input", base_name, start + *num); |
| 908 | atk_init_attribute(&sensor->input_attr, |
| 909 | sensor->input_attr_name, |
| 910 | atk_input_show); |
| 911 | |
| 912 | snprintf(sensor->label_attr_name, ATTR_NAME_SIZE, |
| 913 | "%s%d_label", base_name, start + *num); |
| 914 | atk_init_attribute(&sensor->label_attr, |
| 915 | sensor->label_attr_name, |
| 916 | atk_label_show); |
| 917 | |
| 918 | snprintf(sensor->limit1_attr_name, ATTR_NAME_SIZE, |
| 919 | "%s%d_%s", base_name, start + *num, limit1_name); |
| 920 | atk_init_attribute(&sensor->limit1_attr, |
| 921 | sensor->limit1_attr_name, |
| 922 | atk_limit1_show); |
| 923 | |
| 924 | snprintf(sensor->limit2_attr_name, ATTR_NAME_SIZE, |
| 925 | "%s%d_%s", base_name, start + *num, limit2_name); |
| 926 | atk_init_attribute(&sensor->limit2_attr, |
| 927 | sensor->limit2_attr_name, |
| 928 | atk_limit2_show); |
| 929 | |
| 930 | list_add(&sensor->list, &data->sensor_list); |
| 931 | (*num)++; |
| 932 | |
| 933 | return 1; |
| 934 | out: |
| 935 | kfree(sensor->acpi_name); |
| 936 | kfree(sensor); |
| 937 | return err; |
| 938 | } |
| 939 | |
| 940 | static int atk_enumerate_old_hwmon(struct atk_data *data) |
| 941 | { |
| 942 | struct device *dev = &data->acpi_dev->dev; |
| 943 | struct acpi_buffer buf; |
| 944 | union acpi_object *pack; |
| 945 | acpi_status status; |
| 946 | int i, ret; |
| 947 | int count = 0; |
| 948 | |
| 949 | /* Voltages */ |
| 950 | buf.length = ACPI_ALLOCATE_BUFFER; |
| 951 | status = acpi_evaluate_object_typed(data->atk_handle, |
| 952 | METHOD_OLD_ENUM_VLT, NULL, &buf, ACPI_TYPE_PACKAGE); |
| 953 | if (status != AE_OK) { |
| 954 | dev_warn(dev, METHOD_OLD_ENUM_VLT ": ACPI exception: %s\n", |
| 955 | acpi_format_exception(status)); |
| 956 | |
| 957 | return -ENODEV; |
| 958 | } |
| 959 | |
| 960 | pack = buf.pointer; |
| 961 | for (i = 1; i < pack->package.count; i++) { |
| 962 | union acpi_object *obj = &pack->package.elements[i]; |
| 963 | |
| 964 | ret = atk_add_sensor(data, obj); |
| 965 | if (ret > 0) |
| 966 | count++; |
| 967 | } |
| 968 | ACPI_FREE(buf.pointer); |
| 969 | |
| 970 | /* Temperatures */ |
| 971 | buf.length = ACPI_ALLOCATE_BUFFER; |
| 972 | status = acpi_evaluate_object_typed(data->atk_handle, |
| 973 | METHOD_OLD_ENUM_TMP, NULL, &buf, ACPI_TYPE_PACKAGE); |
| 974 | if (status != AE_OK) { |
| 975 | dev_warn(dev, METHOD_OLD_ENUM_TMP ": ACPI exception: %s\n", |
| 976 | acpi_format_exception(status)); |
| 977 | |
| 978 | ret = -ENODEV; |
| 979 | goto cleanup; |
| 980 | } |
| 981 | |
| 982 | pack = buf.pointer; |
| 983 | for (i = 1; i < pack->package.count; i++) { |
| 984 | union acpi_object *obj = &pack->package.elements[i]; |
| 985 | |
| 986 | ret = atk_add_sensor(data, obj); |
| 987 | if (ret > 0) |
| 988 | count++; |
| 989 | } |
| 990 | ACPI_FREE(buf.pointer); |
| 991 | |
| 992 | /* Fans */ |
| 993 | buf.length = ACPI_ALLOCATE_BUFFER; |
| 994 | status = acpi_evaluate_object_typed(data->atk_handle, |
| 995 | METHOD_OLD_ENUM_FAN, NULL, &buf, ACPI_TYPE_PACKAGE); |
| 996 | if (status != AE_OK) { |
| 997 | dev_warn(dev, METHOD_OLD_ENUM_FAN ": ACPI exception: %s\n", |
| 998 | acpi_format_exception(status)); |
| 999 | |
| 1000 | ret = -ENODEV; |
| 1001 | goto cleanup; |
| 1002 | } |
| 1003 | |
| 1004 | pack = buf.pointer; |
| 1005 | for (i = 1; i < pack->package.count; i++) { |
| 1006 | union acpi_object *obj = &pack->package.elements[i]; |
| 1007 | |
| 1008 | ret = atk_add_sensor(data, obj); |
| 1009 | if (ret > 0) |
| 1010 | count++; |
| 1011 | } |
| 1012 | ACPI_FREE(buf.pointer); |
| 1013 | |
| 1014 | return count; |
| 1015 | cleanup: |
| 1016 | atk_free_sensors(data); |
| 1017 | return ret; |
| 1018 | } |
| 1019 | |
Luca Tettamanti | 9e6eba6 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 1020 | static int atk_ec_present(struct atk_data *data) |
| 1021 | { |
| 1022 | struct device *dev = &data->acpi_dev->dev; |
| 1023 | union acpi_object *pack; |
| 1024 | union acpi_object *ec; |
| 1025 | int ret; |
| 1026 | int i; |
| 1027 | |
| 1028 | pack = atk_ggrp(data, ATK_MUX_MGMT); |
| 1029 | if (IS_ERR(pack)) { |
| 1030 | if (PTR_ERR(pack) == -ENOENT) { |
| 1031 | /* The MGMT class does not exists - that's ok */ |
| 1032 | dev_dbg(dev, "Class %#llx not found\n", ATK_MUX_MGMT); |
| 1033 | return 0; |
| 1034 | } |
| 1035 | return PTR_ERR(pack); |
| 1036 | } |
| 1037 | |
| 1038 | /* Search the EC */ |
| 1039 | ec = NULL; |
| 1040 | for (i = 0; i < pack->package.count; i++) { |
| 1041 | union acpi_object *obj = &pack->package.elements[i]; |
| 1042 | union acpi_object *id; |
| 1043 | |
| 1044 | if (obj->type != ACPI_TYPE_PACKAGE) |
| 1045 | continue; |
| 1046 | |
| 1047 | id = &obj->package.elements[0]; |
| 1048 | if (id->type != ACPI_TYPE_INTEGER) |
| 1049 | continue; |
| 1050 | |
| 1051 | if (id->integer.value == ATK_EC_ID) { |
| 1052 | ec = obj; |
| 1053 | break; |
| 1054 | } |
| 1055 | } |
| 1056 | |
| 1057 | ret = (ec != NULL); |
| 1058 | if (!ret) |
| 1059 | /* The system has no EC */ |
| 1060 | dev_dbg(dev, "EC not found\n"); |
| 1061 | |
| 1062 | ACPI_FREE(pack); |
| 1063 | return ret; |
| 1064 | } |
| 1065 | |
| 1066 | static int atk_ec_enabled(struct atk_data *data) |
| 1067 | { |
| 1068 | struct device *dev = &data->acpi_dev->dev; |
| 1069 | union acpi_object *obj; |
| 1070 | struct atk_acpi_ret_buffer *buf; |
| 1071 | int err; |
| 1072 | |
| 1073 | obj = atk_gitm(data, ATK_EC_ID); |
| 1074 | if (IS_ERR(obj)) { |
| 1075 | dev_err(dev, "Unable to query EC status\n"); |
| 1076 | return PTR_ERR(obj); |
| 1077 | } |
| 1078 | buf = (struct atk_acpi_ret_buffer *)obj->buffer.pointer; |
| 1079 | |
| 1080 | if (buf->flags == 0) { |
| 1081 | dev_err(dev, "Unable to query EC status\n"); |
| 1082 | err = -EIO; |
| 1083 | } else { |
| 1084 | err = (buf->value != 0); |
| 1085 | dev_dbg(dev, "EC is %sabled\n", |
| 1086 | err ? "en" : "dis"); |
| 1087 | } |
| 1088 | |
| 1089 | ACPI_FREE(obj); |
| 1090 | return err; |
| 1091 | } |
| 1092 | |
| 1093 | static int atk_ec_ctl(struct atk_data *data, int enable) |
| 1094 | { |
| 1095 | struct device *dev = &data->acpi_dev->dev; |
| 1096 | union acpi_object *obj; |
| 1097 | struct atk_acpi_input_buf sitm; |
| 1098 | struct atk_acpi_ret_buffer *ec_ret; |
| 1099 | int err = 0; |
| 1100 | |
| 1101 | sitm.id = ATK_EC_ID; |
| 1102 | sitm.param1 = enable; |
| 1103 | sitm.param2 = 0; |
| 1104 | |
| 1105 | obj = atk_sitm(data, &sitm); |
| 1106 | if (IS_ERR(obj)) { |
| 1107 | dev_err(dev, "Failed to %sable the EC\n", |
| 1108 | enable ? "en" : "dis"); |
| 1109 | return PTR_ERR(obj); |
| 1110 | } |
| 1111 | ec_ret = (struct atk_acpi_ret_buffer *)obj->buffer.pointer; |
| 1112 | if (ec_ret->flags == 0) { |
| 1113 | dev_err(dev, "Failed to %sable the EC\n", |
| 1114 | enable ? "en" : "dis"); |
| 1115 | err = -EIO; |
| 1116 | } else { |
| 1117 | dev_info(dev, "EC %sabled\n", |
| 1118 | enable ? "en" : "dis"); |
| 1119 | } |
| 1120 | |
| 1121 | ACPI_FREE(obj); |
| 1122 | return err; |
| 1123 | } |
| 1124 | |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1125 | static int atk_enumerate_new_hwmon(struct atk_data *data) |
| 1126 | { |
| 1127 | struct device *dev = &data->acpi_dev->dev; |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1128 | union acpi_object *pack; |
| 1129 | int err; |
| 1130 | int i; |
| 1131 | |
Luca Tettamanti | 9e6eba6 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 1132 | err = atk_ec_present(data); |
| 1133 | if (err < 0) |
| 1134 | return err; |
| 1135 | if (err) { |
| 1136 | err = atk_ec_enabled(data); |
| 1137 | if (err < 0) |
| 1138 | return err; |
| 1139 | /* If the EC was disabled we will disable it again on unload */ |
| 1140 | data->disable_ec = err; |
| 1141 | |
| 1142 | err = atk_ec_ctl(data, 1); |
| 1143 | if (err) { |
| 1144 | data->disable_ec = false; |
| 1145 | return err; |
| 1146 | } |
| 1147 | } |
| 1148 | |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1149 | dev_dbg(dev, "Enumerating hwmon sensors\n"); |
| 1150 | |
Luca Tettamanti | 18e25555 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 1151 | pack = atk_ggrp(data, ATK_MUX_HWMON); |
| 1152 | if (IS_ERR(pack)) |
| 1153 | return PTR_ERR(pack); |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1154 | |
| 1155 | for (i = 0; i < pack->package.count; i++) { |
| 1156 | union acpi_object *obj = &pack->package.elements[i]; |
| 1157 | |
| 1158 | atk_add_sensor(data, obj); |
| 1159 | } |
| 1160 | |
| 1161 | err = data->voltage_count + data->temperature_count + data->fan_count; |
| 1162 | |
Luca Tettamanti | 18e25555 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 1163 | ACPI_FREE(pack); |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1164 | return err; |
| 1165 | } |
| 1166 | |
| 1167 | static int atk_create_files(struct atk_data *data) |
| 1168 | { |
| 1169 | struct atk_sensor_data *s; |
| 1170 | int err; |
| 1171 | |
| 1172 | list_for_each_entry(s, &data->sensor_list, list) { |
Jiri Kosina | a30dcb4 | 2010-04-15 02:45:25 +0200 | [diff] [blame] | 1173 | sysfs_attr_init(&s->input_attr.attr); |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1174 | err = device_create_file(data->hwmon_dev, &s->input_attr); |
| 1175 | if (err) |
| 1176 | return err; |
Jiri Kosina | a30dcb4 | 2010-04-15 02:45:25 +0200 | [diff] [blame] | 1177 | sysfs_attr_init(&s->label_attr.attr); |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1178 | err = device_create_file(data->hwmon_dev, &s->label_attr); |
| 1179 | if (err) |
| 1180 | return err; |
Jiri Kosina | a30dcb4 | 2010-04-15 02:45:25 +0200 | [diff] [blame] | 1181 | sysfs_attr_init(&s->limit1_attr.attr); |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1182 | err = device_create_file(data->hwmon_dev, &s->limit1_attr); |
| 1183 | if (err) |
| 1184 | return err; |
Jiri Kosina | a30dcb4 | 2010-04-15 02:45:25 +0200 | [diff] [blame] | 1185 | sysfs_attr_init(&s->limit2_attr.attr); |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1186 | err = device_create_file(data->hwmon_dev, &s->limit2_attr); |
| 1187 | if (err) |
| 1188 | return err; |
| 1189 | } |
| 1190 | |
| 1191 | err = device_create_file(data->hwmon_dev, &atk_name_attr); |
| 1192 | |
| 1193 | return err; |
| 1194 | } |
| 1195 | |
| 1196 | static void atk_remove_files(struct atk_data *data) |
| 1197 | { |
| 1198 | struct atk_sensor_data *s; |
| 1199 | |
| 1200 | list_for_each_entry(s, &data->sensor_list, list) { |
| 1201 | device_remove_file(data->hwmon_dev, &s->input_attr); |
| 1202 | device_remove_file(data->hwmon_dev, &s->label_attr); |
| 1203 | device_remove_file(data->hwmon_dev, &s->limit1_attr); |
| 1204 | device_remove_file(data->hwmon_dev, &s->limit2_attr); |
| 1205 | } |
| 1206 | device_remove_file(data->hwmon_dev, &atk_name_attr); |
| 1207 | } |
| 1208 | |
| 1209 | static void atk_free_sensors(struct atk_data *data) |
| 1210 | { |
| 1211 | struct list_head *head = &data->sensor_list; |
| 1212 | struct atk_sensor_data *s, *tmp; |
| 1213 | |
| 1214 | list_for_each_entry_safe(s, tmp, head, list) { |
| 1215 | kfree(s->acpi_name); |
| 1216 | kfree(s); |
| 1217 | } |
| 1218 | } |
| 1219 | |
| 1220 | static int atk_register_hwmon(struct atk_data *data) |
| 1221 | { |
| 1222 | struct device *dev = &data->acpi_dev->dev; |
| 1223 | int err; |
| 1224 | |
| 1225 | dev_dbg(dev, "registering hwmon device\n"); |
| 1226 | data->hwmon_dev = hwmon_device_register(dev); |
| 1227 | if (IS_ERR(data->hwmon_dev)) |
| 1228 | return PTR_ERR(data->hwmon_dev); |
| 1229 | |
| 1230 | dev_dbg(dev, "populating sysfs directory\n"); |
| 1231 | err = atk_create_files(data); |
| 1232 | if (err) |
| 1233 | goto remove; |
| 1234 | |
| 1235 | return 0; |
| 1236 | remove: |
| 1237 | /* Cleanup the registered files */ |
| 1238 | atk_remove_files(data); |
| 1239 | hwmon_device_unregister(data->hwmon_dev); |
| 1240 | return err; |
| 1241 | } |
| 1242 | |
Luca Tettamanti | 8ba406b | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 1243 | static int atk_probe_if(struct atk_data *data) |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1244 | { |
| 1245 | struct device *dev = &data->acpi_dev->dev; |
| 1246 | acpi_handle ret; |
| 1247 | acpi_status status; |
Luca Tettamanti | 8ba406b | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 1248 | int err = 0; |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1249 | |
| 1250 | /* RTMP: read temperature */ |
| 1251 | status = acpi_get_handle(data->atk_handle, METHOD_OLD_READ_TMP, &ret); |
Luca Tettamanti | 8ba406b | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 1252 | if (ACPI_SUCCESS(status)) |
| 1253 | data->rtmp_handle = ret; |
| 1254 | else |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1255 | dev_dbg(dev, "method " METHOD_OLD_READ_TMP " not found: %s\n", |
| 1256 | acpi_format_exception(status)); |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1257 | |
| 1258 | /* RVLT: read voltage */ |
| 1259 | status = acpi_get_handle(data->atk_handle, METHOD_OLD_READ_VLT, &ret); |
Luca Tettamanti | 8ba406b | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 1260 | if (ACPI_SUCCESS(status)) |
| 1261 | data->rvlt_handle = ret; |
| 1262 | else |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1263 | dev_dbg(dev, "method " METHOD_OLD_READ_VLT " not found: %s\n", |
| 1264 | acpi_format_exception(status)); |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1265 | |
| 1266 | /* RFAN: read fan status */ |
| 1267 | status = acpi_get_handle(data->atk_handle, METHOD_OLD_READ_FAN, &ret); |
Luca Tettamanti | 8ba406b | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 1268 | if (ACPI_SUCCESS(status)) |
| 1269 | data->rfan_handle = ret; |
| 1270 | else |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1271 | dev_dbg(dev, "method " METHOD_OLD_READ_FAN " not found: %s\n", |
| 1272 | acpi_format_exception(status)); |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1273 | |
| 1274 | /* Enumeration */ |
| 1275 | status = acpi_get_handle(data->atk_handle, METHOD_ENUMERATE, &ret); |
Luca Tettamanti | 8ba406b | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 1276 | if (ACPI_SUCCESS(status)) |
| 1277 | data->enumerate_handle = ret; |
| 1278 | else |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1279 | dev_dbg(dev, "method " METHOD_ENUMERATE " not found: %s\n", |
| 1280 | acpi_format_exception(status)); |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1281 | |
| 1282 | /* De-multiplexer (read) */ |
| 1283 | status = acpi_get_handle(data->atk_handle, METHOD_READ, &ret); |
Luca Tettamanti | 8ba406b | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 1284 | if (ACPI_SUCCESS(status)) |
| 1285 | data->read_handle = ret; |
| 1286 | else |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1287 | dev_dbg(dev, "method " METHOD_READ " not found: %s\n", |
| 1288 | acpi_format_exception(status)); |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1289 | |
Luca Tettamanti | 9e6eba6 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 1290 | /* De-multiplexer (write) */ |
| 1291 | status = acpi_get_handle(data->atk_handle, METHOD_WRITE, &ret); |
Luca Tettamanti | 8ba406b | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 1292 | if (ACPI_SUCCESS(status)) |
| 1293 | data->write_handle = ret; |
| 1294 | else |
| 1295 | dev_dbg(dev, "method " METHOD_WRITE " not found: %s\n", |
Luca Tettamanti | 9e6eba6 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 1296 | acpi_format_exception(status)); |
Luca Tettamanti | 9e6eba6 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 1297 | |
Luca Tettamanti | 8ba406b | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 1298 | /* Check for hwmon methods: first check "old" style methods; note that |
| 1299 | * both may be present: in this case we stick to the old interface; |
| 1300 | * analysis of multiple DSDTs indicates that when both interfaces |
| 1301 | * are present the new one (GGRP/GITM) is not functional. |
| 1302 | */ |
| 1303 | if (data->rtmp_handle && data->rvlt_handle && data->rfan_handle) |
| 1304 | data->old_interface = true; |
| 1305 | else if (data->enumerate_handle && data->read_handle && |
| 1306 | data->write_handle) |
| 1307 | data->old_interface = false; |
| 1308 | else |
| 1309 | err = -ENODEV; |
| 1310 | |
| 1311 | return err; |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1312 | } |
| 1313 | |
| 1314 | static int atk_add(struct acpi_device *device) |
| 1315 | { |
| 1316 | acpi_status ret; |
| 1317 | int err; |
| 1318 | struct acpi_buffer buf; |
| 1319 | union acpi_object *obj; |
| 1320 | struct atk_data *data; |
| 1321 | |
| 1322 | dev_dbg(&device->dev, "adding...\n"); |
| 1323 | |
| 1324 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
| 1325 | if (!data) |
| 1326 | return -ENOMEM; |
| 1327 | |
| 1328 | data->acpi_dev = device; |
| 1329 | data->atk_handle = device->handle; |
| 1330 | INIT_LIST_HEAD(&data->sensor_list); |
Luca Tettamanti | 9e6eba6 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 1331 | data->disable_ec = false; |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1332 | |
| 1333 | buf.length = ACPI_ALLOCATE_BUFFER; |
| 1334 | ret = acpi_evaluate_object_typed(data->atk_handle, BOARD_ID, NULL, |
| 1335 | &buf, ACPI_TYPE_PACKAGE); |
| 1336 | if (ret != AE_OK) { |
| 1337 | dev_dbg(&device->dev, "atk: method MBIF not found\n"); |
Luca Tettamanti | 5542482 | 2010-01-25 15:00:49 +0100 | [diff] [blame] | 1338 | } else { |
| 1339 | obj = buf.pointer; |
| 1340 | if (obj->package.count >= 2) { |
| 1341 | union acpi_object *id = &obj->package.elements[1]; |
| 1342 | if (id->type == ACPI_TYPE_STRING) |
| 1343 | dev_dbg(&device->dev, "board ID = %s\n", |
| 1344 | id->string.pointer); |
| 1345 | } |
| 1346 | ACPI_FREE(buf.pointer); |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1347 | } |
| 1348 | |
Luca Tettamanti | 8ba406b | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 1349 | err = atk_probe_if(data); |
| 1350 | if (err) { |
| 1351 | dev_err(&device->dev, "No usable hwmon interface detected\n"); |
| 1352 | goto out; |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1353 | } |
| 1354 | |
Luca Tettamanti | 8ba406b | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 1355 | if (data->old_interface) { |
| 1356 | dev_dbg(&device->dev, "Using old hwmon interface\n"); |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1357 | err = atk_enumerate_old_hwmon(data); |
Luca Tettamanti | 8ba406b | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 1358 | } else { |
| 1359 | dev_dbg(&device->dev, "Using new hwmon interface\n"); |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1360 | err = atk_enumerate_new_hwmon(data); |
Luca Tettamanti | 8ba406b | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 1361 | } |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1362 | if (err < 0) |
| 1363 | goto out; |
| 1364 | if (err == 0) { |
| 1365 | dev_info(&device->dev, |
| 1366 | "No usable sensor detected, bailing out\n"); |
| 1367 | err = -ENODEV; |
| 1368 | goto out; |
| 1369 | } |
| 1370 | |
| 1371 | err = atk_register_hwmon(data); |
| 1372 | if (err) |
| 1373 | goto cleanup; |
| 1374 | |
Luca Tettamanti | 7e5eab1 | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 1375 | atk_debugfs_init(data); |
| 1376 | |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1377 | device->driver_data = data; |
| 1378 | return 0; |
| 1379 | cleanup: |
| 1380 | atk_free_sensors(data); |
| 1381 | out: |
Luca Tettamanti | 9e6eba6 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 1382 | if (data->disable_ec) |
| 1383 | atk_ec_ctl(data, 0); |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1384 | kfree(data); |
| 1385 | return err; |
| 1386 | } |
| 1387 | |
| 1388 | static int atk_remove(struct acpi_device *device, int type) |
| 1389 | { |
| 1390 | struct atk_data *data = device->driver_data; |
| 1391 | dev_dbg(&device->dev, "removing...\n"); |
| 1392 | |
| 1393 | device->driver_data = NULL; |
| 1394 | |
Luca Tettamanti | 7e5eab1 | 2010-01-10 20:52:33 +0100 | [diff] [blame] | 1395 | atk_debugfs_cleanup(data); |
| 1396 | |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1397 | atk_remove_files(data); |
| 1398 | atk_free_sensors(data); |
| 1399 | hwmon_device_unregister(data->hwmon_dev); |
| 1400 | |
Luca Tettamanti | 9e6eba6 | 2009-10-09 20:35:18 +0200 | [diff] [blame] | 1401 | if (data->disable_ec) { |
| 1402 | if (atk_ec_ctl(data, 0)) |
| 1403 | dev_err(&device->dev, "Failed to disable EC\n"); |
| 1404 | } |
| 1405 | |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1406 | kfree(data); |
| 1407 | |
| 1408 | return 0; |
| 1409 | } |
| 1410 | |
| 1411 | static int __init atk0110_init(void) |
| 1412 | { |
| 1413 | int ret; |
| 1414 | |
Jean Delvare | 70dd6be | 2010-05-27 19:58:37 +0200 | [diff] [blame] | 1415 | /* Make sure it's safe to access the device through ACPI */ |
| 1416 | if (!acpi_resources_are_enforced()) { |
| 1417 | pr_err("atk: Resources not safely usable due to " |
| 1418 | "acpi_enforce_resources kernel parameter\n"); |
| 1419 | return -EBUSY; |
| 1420 | } |
| 1421 | |
Luca Tettamanti | 2c03d07 | 2009-04-07 15:32:59 +0200 | [diff] [blame] | 1422 | ret = acpi_bus_register_driver(&atk_driver); |
| 1423 | if (ret) |
| 1424 | pr_info("atk: acpi_bus_register_driver failed: %d\n", ret); |
| 1425 | |
| 1426 | return ret; |
| 1427 | } |
| 1428 | |
| 1429 | static void __exit atk0110_exit(void) |
| 1430 | { |
| 1431 | acpi_bus_unregister_driver(&atk_driver); |
| 1432 | } |
| 1433 | |
| 1434 | module_init(atk0110_init); |
| 1435 | module_exit(atk0110_exit); |
| 1436 | |
| 1437 | MODULE_LICENSE("GPL"); |