2 * thinkpad_acpi.c - ThinkPad ACPI Extras
5 * Copyright (C) 2004-2005 Borislav Deianov <borislav@users.sf.net>
6 * Copyright (C) 2006-2007 Henrique de Moraes Holschuh <hmh@hmh.eng.br>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 #define IBM_VERSION "0.14"
25 #define TPACPI_SYSFS_VERSION 0x000200
29 * 2007-03-27 0.14 renamed to thinkpad_acpi and moved to
32 * 2006-11-22 0.13 new maintainer
33 * changelog now lives in git commit history, and will
34 * not be updated further in-file.
36 * 2005-08-17 0.12 fix compilation on 2.6.13-rc kernels
37 * 2005-03-17 0.11 support for 600e, 770x
38 * thanks to Jamie Lentin <lentinj@dial.pipex.com>
39 * support for 770e, G41
40 * G40 and G41 don't have a thinklight
41 * temperatures no longer experimental
42 * experimental brightness control
43 * experimental volume control
44 * experimental fan enable/disable
45 * 2005-01-16 0.10 fix module loading on R30, R31
46 * 2005-01-16 0.9 support for 570, R30, R31
47 * ultrabay support on A22p, A3x
48 * limit arg for cmos, led, beep, drop experimental status
49 * more capable led control on A21e, A22p, T20-22, X20
50 * experimental temperatures and fan speed
51 * experimental embedded controller register dump
52 * mark more functions as __init, drop incorrect __exit
54 * thanks to Henrik Brix Andersen <brix@gentoo.org>
55 * fix parameter passing on module loading
56 * thanks to Rusty Russell <rusty@rustcorp.com.au>
57 * thanks to Jim Radford <radford@blackbean.org>
58 * 2004-11-08 0.8 fix init error case, don't return from a macro
59 * thanks to Chris Wright <chrisw@osdl.org>
60 * 2004-10-23 0.7 fix module loading on A21e, A22p, T20, T21, X20
61 * fix led control on A21e
62 * 2004-10-19 0.6 use acpi_bus_register_driver() to claim HKEY device
63 * 2004-10-18 0.5 thinklight support on A21e, G40, R32, T20, T21, X20
64 * proc file format changed
65 * video_switch command
66 * experimental cmos control
67 * experimental led control
68 * experimental acpi sounds
69 * 2004-09-16 0.4 support for module parameters
70 * hotkey mask can be prefixed by 0x
71 * video output switching
72 * video expansion control
73 * ultrabay eject support
74 * removed lcd brightness/on/off control, didn't work
75 * 2004-08-17 0.3 support for R40
76 * lcd off, brightness control
78 * 2004-08-14 0.2 support for T series, X20
79 * bluetooth enable/disable
80 * hotkey events disabled by default
81 * removed fan control, currently useless
82 * 2004-08-09 0.1 initial release, support for X series
85 #include "thinkpad_acpi.h"
87 MODULE_AUTHOR("Borislav Deianov, Henrique de Moraes Holschuh");
88 MODULE_DESCRIPTION(IBM_DESC
);
89 MODULE_VERSION(IBM_VERSION
);
90 MODULE_LICENSE("GPL");
92 /* Please remove this in year 2009 */
93 MODULE_ALIAS("ibm_acpi");
96 * DMI matching for module autoloading
98 * See http://thinkwiki.org/wiki/List_of_DMI_IDs
99 * See http://thinkwiki.org/wiki/BIOS_Upgrade_Downloads
101 * Only models listed in thinkwiki will be supported, so add yours
102 * if it is not there yet.
104 #define IBM_BIOS_MODULE_ALIAS(__type) \
105 MODULE_ALIAS("dmi:bvnIBM:bvr" __type "ET??WW")
107 /* Non-ancient thinkpads */
108 MODULE_ALIAS("dmi:bvnIBM:*:svnIBM:*:pvrThinkPad*:rvnIBM:*");
109 MODULE_ALIAS("dmi:bvnLENOVO:*:svnLENOVO:*:pvrThinkPad*:rvnLENOVO:*");
111 /* Ancient thinkpad BIOSes have to be identified by
112 * BIOS type or model number, and there are far less
113 * BIOS types than model numbers... */
114 IBM_BIOS_MODULE_ALIAS("I[B,D,H,I,M,N,O,T,W,V,Y,Z]");
115 IBM_BIOS_MODULE_ALIAS("1[0,3,6,8,A-G,I,K,M-P,S,T]");
116 IBM_BIOS_MODULE_ALIAS("K[U,X-Z]");
118 #define __unused __attribute__ ((unused))
120 /****************************************************************************
121 ****************************************************************************
123 * ACPI Helpers and device model
125 ****************************************************************************
126 ****************************************************************************/
128 /*************************************************************************
132 static acpi_handle root_handle
;
134 #define IBM_HANDLE(object, parent, paths...) \
135 static acpi_handle object##_handle; \
136 static acpi_handle *object##_parent = &parent##_handle; \
137 static char *object##_path; \
138 static char *object##_paths[] = { paths }
140 IBM_HANDLE(ec
, root
, "\\_SB.PCI0.ISA.EC0", /* 240, 240x */
141 "\\_SB.PCI.ISA.EC", /* 570 */
142 "\\_SB.PCI0.ISA0.EC0", /* 600e/x, 770e, 770x */
143 "\\_SB.PCI0.ISA.EC", /* A21e, A2xm/p, T20-22, X20-21 */
144 "\\_SB.PCI0.AD4S.EC0", /* i1400, R30 */
145 "\\_SB.PCI0.ICH3.EC0", /* R31 */
146 "\\_SB.PCI0.LPC.EC", /* all others */
149 IBM_HANDLE(ecrd
, ec
, "ECRD"); /* 570 */
150 IBM_HANDLE(ecwr
, ec
, "ECWR"); /* 570 */
153 /*************************************************************************
157 IBM_HANDLE(cmos
, root
, "\\UCMS", /* R50, R50e, R50p, R51, T4x, X31, X40 */
158 "\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */
159 "\\CMS", /* R40, R40e */
162 IBM_HANDLE(hkey
, ec
, "\\_SB.HKEY", /* 600e/x, 770e, 770x */
163 "^HKEY", /* R30, R31 */
164 "HKEY", /* all others */
168 /*************************************************************************
172 static int acpi_evalf(acpi_handle handle
,
173 void *res
, char *method
, char *fmt
, ...)
176 struct acpi_object_list params
;
177 union acpi_object in_objs
[IBM_MAX_ACPI_ARGS
];
178 struct acpi_buffer result
, *resultp
;
179 union acpi_object out_obj
;
187 printk(IBM_ERR
"acpi_evalf() called with empty format\n");
200 params
.pointer
= &in_objs
[0];
207 in_objs
[params
.count
].integer
.value
= va_arg(ap
, int);
208 in_objs
[params
.count
++].type
= ACPI_TYPE_INTEGER
;
210 /* add more types as needed */
212 printk(IBM_ERR
"acpi_evalf() called "
213 "with invalid format character '%c'\n", c
);
219 if (res_type
!= 'v') {
220 result
.length
= sizeof(out_obj
);
221 result
.pointer
= &out_obj
;
226 status
= acpi_evaluate_object(handle
, method
, ¶ms
, resultp
);
231 *(int *)res
= out_obj
.integer
.value
;
232 success
= status
== AE_OK
&& out_obj
.type
== ACPI_TYPE_INTEGER
;
235 success
= status
== AE_OK
;
237 /* add more types as needed */
239 printk(IBM_ERR
"acpi_evalf() called "
240 "with invalid format character '%c'\n", res_type
);
244 if (!success
&& !quiet
)
245 printk(IBM_ERR
"acpi_evalf(%s, %s, ...) failed: %d\n",
246 method
, fmt0
, status
);
251 static void __unused
acpi_print_int(acpi_handle handle
, char *method
)
255 if (acpi_evalf(handle
, &i
, method
, "d"))
256 printk(IBM_INFO
"%s = 0x%x\n", method
, i
);
258 printk(IBM_ERR
"error calling %s\n", method
);
261 static int acpi_ec_read(int i
, u8
* p
)
266 if (!acpi_evalf(ecrd_handle
, &v
, NULL
, "dd", i
))
270 if (ec_read(i
, p
) < 0)
277 static int acpi_ec_write(int i
, u8 v
)
280 if (!acpi_evalf(ecwr_handle
, NULL
, NULL
, "vdd", i
, v
))
283 if (ec_write(i
, v
) < 0)
290 static int _sta(acpi_handle handle
)
294 if (!handle
|| !acpi_evalf(handle
, &status
, "_STA", "d"))
300 static int issue_thinkpad_cmos_command(int cmos_cmd
)
305 if (!acpi_evalf(cmos_handle
, NULL
, NULL
, "vd", cmos_cmd
))
311 /*************************************************************************
315 static void drv_acpi_handle_init(char *name
,
316 acpi_handle
*handle
, acpi_handle parent
,
317 char **paths
, int num_paths
, char **path
)
322 vdbg_printk(TPACPI_DBG_INIT
, "trying to locate ACPI handle for %s\n",
325 for (i
= 0; i
< num_paths
; i
++) {
326 status
= acpi_get_handle(parent
, paths
[i
], handle
);
327 if (ACPI_SUCCESS(status
)) {
329 dbg_printk(TPACPI_DBG_INIT
,
330 "Found ACPI handle %s for %s\n",
336 vdbg_printk(TPACPI_DBG_INIT
, "ACPI handle for %s not found\n",
341 static void dispatch_acpi_notify(acpi_handle handle
, u32 event
, void *data
)
343 struct ibm_struct
*ibm
= data
;
345 if (!ibm
|| !ibm
->acpi
|| !ibm
->acpi
->notify
)
348 ibm
->acpi
->notify(ibm
, event
);
351 static int __init
setup_acpi_notify(struct ibm_struct
*ibm
)
358 if (!*ibm
->acpi
->handle
)
361 vdbg_printk(TPACPI_DBG_INIT
,
362 "setting up ACPI notify for %s\n", ibm
->name
);
364 rc
= acpi_bus_get_device(*ibm
->acpi
->handle
, &ibm
->acpi
->device
);
366 printk(IBM_ERR
"acpi_bus_get_device(%s) failed: %d\n",
371 acpi_driver_data(ibm
->acpi
->device
) = ibm
;
372 sprintf(acpi_device_class(ibm
->acpi
->device
), "%s/%s",
373 IBM_ACPI_EVENT_PREFIX
,
376 status
= acpi_install_notify_handler(*ibm
->acpi
->handle
,
377 ibm
->acpi
->type
, dispatch_acpi_notify
, ibm
);
378 if (ACPI_FAILURE(status
)) {
379 if (status
== AE_ALREADY_EXISTS
) {
380 printk(IBM_NOTICE
"another device driver is already handling %s events\n",
383 printk(IBM_ERR
"acpi_install_notify_handler(%s) failed: %d\n",
388 ibm
->flags
.acpi_notify_installed
= 1;
392 static int __init
tpacpi_device_add(struct acpi_device
*device
)
397 static int __init
register_tpacpi_subdriver(struct ibm_struct
*ibm
)
401 dbg_printk(TPACPI_DBG_INIT
,
402 "registering %s as an ACPI driver\n", ibm
->name
);
406 ibm
->acpi
->driver
= kzalloc(sizeof(struct acpi_driver
), GFP_KERNEL
);
407 if (!ibm
->acpi
->driver
) {
408 printk(IBM_ERR
"kzalloc(ibm->driver) failed\n");
412 sprintf(ibm
->acpi
->driver
->name
, "%s_%s", IBM_NAME
, ibm
->name
);
413 ibm
->acpi
->driver
->ids
= ibm
->acpi
->hid
;
414 ibm
->acpi
->driver
->ops
.add
= &tpacpi_device_add
;
416 rc
= acpi_bus_register_driver(ibm
->acpi
->driver
);
418 printk(IBM_ERR
"acpi_bus_register_driver(%s) failed: %d\n",
420 kfree(ibm
->acpi
->driver
);
421 ibm
->acpi
->driver
= NULL
;
423 ibm
->flags
.acpi_driver_registered
= 1;
429 /****************************************************************************
430 ****************************************************************************
434 ****************************************************************************
435 ****************************************************************************/
437 static int dispatch_procfs_read(char *page
, char **start
, off_t off
,
438 int count
, int *eof
, void *data
)
440 struct ibm_struct
*ibm
= data
;
443 if (!ibm
|| !ibm
->read
)
446 len
= ibm
->read(page
);
450 if (len
<= off
+ count
)
462 static int dispatch_procfs_write(struct file
*file
,
463 const char __user
* userbuf
,
464 unsigned long count
, void *data
)
466 struct ibm_struct
*ibm
= data
;
470 if (!ibm
|| !ibm
->write
)
473 kernbuf
= kmalloc(count
+ 2, GFP_KERNEL
);
477 if (copy_from_user(kernbuf
, userbuf
, count
)) {
483 strcat(kernbuf
, ",");
484 ret
= ibm
->write(kernbuf
);
493 static char *next_cmd(char **cmds
)
498 while ((end
= strchr(start
, ',')) && end
== start
)
510 /****************************************************************************
511 ****************************************************************************
513 * Device model: hwmon and platform
515 ****************************************************************************
516 ****************************************************************************/
518 static struct platform_device
*tpacpi_pdev
;
519 static struct class_device
*tpacpi_hwmon
;
521 static struct platform_driver tpacpi_pdriver
= {
523 .name
= IBM_DRVR_NAME
,
524 .owner
= THIS_MODULE
,
529 /*************************************************************************
530 * thinkpad-acpi driver attributes
533 /* interface_version --------------------------------------------------- */
534 static ssize_t
tpacpi_driver_interface_version_show(
535 struct device_driver
*drv
,
538 return snprintf(buf
, PAGE_SIZE
, "0x%08x\n", TPACPI_SYSFS_VERSION
);
541 static DRIVER_ATTR(interface_version
, S_IRUGO
,
542 tpacpi_driver_interface_version_show
, NULL
);
544 /* debug_level --------------------------------------------------------- */
545 static ssize_t
tpacpi_driver_debug_show(struct device_driver
*drv
,
548 return snprintf(buf
, PAGE_SIZE
, "0x%04x\n", dbg_level
);
551 static ssize_t
tpacpi_driver_debug_store(struct device_driver
*drv
,
552 const char *buf
, size_t count
)
556 if (parse_strtoul(buf
, 0xffff, &t
))
564 static DRIVER_ATTR(debug_level
, S_IWUSR
| S_IRUGO
,
565 tpacpi_driver_debug_show
, tpacpi_driver_debug_store
);
567 /* version ------------------------------------------------------------- */
568 static ssize_t
tpacpi_driver_version_show(struct device_driver
*drv
,
571 return snprintf(buf
, PAGE_SIZE
, "%s v%s\n", IBM_DESC
, IBM_VERSION
);
574 static DRIVER_ATTR(version
, S_IRUGO
,
575 tpacpi_driver_version_show
, NULL
);
577 /* --------------------------------------------------------------------- */
579 static struct driver_attribute
* tpacpi_driver_attributes
[] = {
580 &driver_attr_debug_level
, &driver_attr_version
,
581 &driver_attr_interface_version
,
584 static int __init
tpacpi_create_driver_attributes(struct device_driver
*drv
)
590 while (!res
&& i
< ARRAY_SIZE(tpacpi_driver_attributes
)) {
591 res
= driver_create_file(drv
, tpacpi_driver_attributes
[i
]);
598 static void tpacpi_remove_driver_attributes(struct device_driver
*drv
)
602 for(i
= 0; i
< ARRAY_SIZE(tpacpi_driver_attributes
); i
++)
603 driver_remove_file(drv
, tpacpi_driver_attributes
[i
]);
606 /*************************************************************************
607 * sysfs support helpers
610 struct attribute_set_obj
{
611 struct attribute_set s
;
613 } __attribute__((packed
));
615 static struct attribute_set
*create_attr_set(unsigned int max_members
,
618 struct attribute_set_obj
*sobj
;
620 if (max_members
== 0)
623 /* Allocates space for implicit NULL at the end too */
624 sobj
= kzalloc(sizeof(struct attribute_set_obj
) +
625 max_members
* sizeof(struct attribute
*),
629 sobj
->s
.max_members
= max_members
;
630 sobj
->s
.group
.attrs
= &sobj
->a
;
631 sobj
->s
.group
.name
= name
;
636 /* not multi-threaded safe, use it in a single thread per set */
637 static int add_to_attr_set(struct attribute_set
* s
, struct attribute
*attr
)
642 if (s
->members
>= s
->max_members
)
645 s
->group
.attrs
[s
->members
] = attr
;
651 static int add_many_to_attr_set(struct attribute_set
* s
,
652 struct attribute
**attr
,
657 for (i
= 0; i
< count
; i
++) {
658 res
= add_to_attr_set(s
, attr
[i
]);
666 static void delete_attr_set(struct attribute_set
* s
, struct kobject
*kobj
)
668 sysfs_remove_group(kobj
, &s
->group
);
672 static int parse_strtoul(const char *buf
,
673 unsigned long max
, unsigned long *value
)
677 *value
= simple_strtoul(buf
, &endp
, 0);
678 while (*endp
&& isspace(*endp
))
680 if (*endp
|| *value
> max
)
686 /****************************************************************************
687 ****************************************************************************
691 ****************************************************************************
692 ****************************************************************************/
694 /*************************************************************************
695 * thinkpad-acpi init subdriver
698 static int __init
thinkpad_acpi_driver_init(struct ibm_init_struct
*iibm
)
700 printk(IBM_INFO
"%s v%s\n", IBM_DESC
, IBM_VERSION
);
701 printk(IBM_INFO
"%s\n", IBM_URL
);
703 if (ibm_thinkpad_ec_found
)
704 printk(IBM_INFO
"ThinkPad EC firmware %s\n",
705 ibm_thinkpad_ec_found
);
710 static int thinkpad_acpi_driver_read(char *p
)
714 len
+= sprintf(p
+ len
, "driver:\t\t%s\n", IBM_DESC
);
715 len
+= sprintf(p
+ len
, "version:\t%s\n", IBM_VERSION
);
720 static struct ibm_struct thinkpad_acpi_driver_data
= {
722 .read
= thinkpad_acpi_driver_read
,
725 /*************************************************************************
729 static int hotkey_orig_status
;
730 static u32 hotkey_orig_mask
;
731 static u32 hotkey_all_mask
;
732 static u32 hotkey_reserved_mask
= 0x00778000;
734 static struct attribute_set
*hotkey_dev_attributes
;
736 static int hotkey_get_wlsw(int *status
)
738 if (!acpi_evalf(hkey_handle
, status
, "WLSW", "d"))
743 /* sysfs hotkey enable ------------------------------------------------- */
744 static ssize_t
hotkey_enable_show(struct device
*dev
,
745 struct device_attribute
*attr
,
751 res
= hotkey_get(&status
, &mask
);
755 return snprintf(buf
, PAGE_SIZE
, "%d\n", status
);
758 static ssize_t
hotkey_enable_store(struct device
*dev
,
759 struct device_attribute
*attr
,
760 const char *buf
, size_t count
)
766 if (parse_strtoul(buf
, 1, &t
))
769 res
= hotkey_get(&status
, &mask
);
771 res
= hotkey_set(t
, mask
);
773 return (res
) ? res
: count
;
776 static struct device_attribute dev_attr_hotkey_enable
=
777 __ATTR(hotkey_enable
, S_IWUSR
| S_IRUGO
,
778 hotkey_enable_show
, hotkey_enable_store
);
780 /* sysfs hotkey mask --------------------------------------------------- */
781 static ssize_t
hotkey_mask_show(struct device
*dev
,
782 struct device_attribute
*attr
,
788 res
= hotkey_get(&status
, &mask
);
792 return snprintf(buf
, PAGE_SIZE
, "0x%08x\n", mask
);
795 static ssize_t
hotkey_mask_store(struct device
*dev
,
796 struct device_attribute
*attr
,
797 const char *buf
, size_t count
)
803 if (parse_strtoul(buf
, 0xffffffffUL
, &t
))
806 res
= hotkey_get(&status
, &mask
);
808 hotkey_set(status
, t
);
810 return (res
) ? res
: count
;
813 static struct device_attribute dev_attr_hotkey_mask
=
814 __ATTR(hotkey_mask
, S_IWUSR
| S_IRUGO
,
815 hotkey_mask_show
, hotkey_mask_store
);
817 /* sysfs hotkey bios_enabled ------------------------------------------- */
818 static ssize_t
hotkey_bios_enabled_show(struct device
*dev
,
819 struct device_attribute
*attr
,
822 return snprintf(buf
, PAGE_SIZE
, "%d\n", hotkey_orig_status
);
825 static struct device_attribute dev_attr_hotkey_bios_enabled
=
826 __ATTR(hotkey_bios_enabled
, S_IRUGO
, hotkey_bios_enabled_show
, NULL
);
828 /* sysfs hotkey bios_mask ---------------------------------------------- */
829 static ssize_t
hotkey_bios_mask_show(struct device
*dev
,
830 struct device_attribute
*attr
,
833 return snprintf(buf
, PAGE_SIZE
, "0x%08x\n", hotkey_orig_mask
);
836 static struct device_attribute dev_attr_hotkey_bios_mask
=
837 __ATTR(hotkey_bios_mask
, S_IRUGO
, hotkey_bios_mask_show
, NULL
);
839 /* sysfs hotkey all_mask ----------------------------------------------- */
840 static ssize_t
hotkey_all_mask_show(struct device
*dev
,
841 struct device_attribute
*attr
,
844 return snprintf(buf
, PAGE_SIZE
, "0x%08x\n", hotkey_all_mask
);
847 static struct device_attribute dev_attr_hotkey_all_mask
=
848 __ATTR(hotkey_all_mask
, S_IRUGO
, hotkey_all_mask_show
, NULL
);
850 /* sysfs hotkey recommended_mask --------------------------------------- */
851 static ssize_t
hotkey_recommended_mask_show(struct device
*dev
,
852 struct device_attribute
*attr
,
855 return snprintf(buf
, PAGE_SIZE
, "0x%08x\n",
856 hotkey_all_mask
& ~hotkey_reserved_mask
);
859 static struct device_attribute dev_attr_hotkey_recommended_mask
=
860 __ATTR(hotkey_recommended_mask
, S_IRUGO
,
861 hotkey_recommended_mask_show
, NULL
);
863 /* sysfs hotkey radio_sw ----------------------------------------------- */
864 static ssize_t
hotkey_radio_sw_show(struct device
*dev
,
865 struct device_attribute
*attr
,
869 res
= hotkey_get_wlsw(&s
);
873 return snprintf(buf
, PAGE_SIZE
, "%d\n", !!s
);
876 static struct device_attribute dev_attr_hotkey_radio_sw
=
877 __ATTR(hotkey_radio_sw
, S_IRUGO
, hotkey_radio_sw_show
, NULL
);
879 /* --------------------------------------------------------------------- */
881 static struct attribute
*hotkey_mask_attributes
[] = {
882 &dev_attr_hotkey_mask
.attr
,
883 &dev_attr_hotkey_bios_enabled
.attr
,
884 &dev_attr_hotkey_bios_mask
.attr
,
885 &dev_attr_hotkey_all_mask
.attr
,
886 &dev_attr_hotkey_recommended_mask
.attr
,
889 static int __init
hotkey_init(struct ibm_init_struct
*iibm
)
894 vdbg_printk(TPACPI_DBG_INIT
, "initializing hotkey subdriver\n");
896 IBM_ACPIHANDLE_INIT(hkey
);
897 mutex_init(&hotkey_mutex
);
899 /* hotkey not supported on 570 */
900 tp_features
.hotkey
= hkey_handle
!= NULL
;
902 vdbg_printk(TPACPI_DBG_INIT
, "hotkeys are %s\n",
903 str_supported(tp_features
.hotkey
));
905 if (tp_features
.hotkey
) {
906 hotkey_dev_attributes
= create_attr_set(7, NULL
);
907 if (!hotkey_dev_attributes
)
909 res
= add_to_attr_set(hotkey_dev_attributes
,
910 &dev_attr_hotkey_enable
.attr
);
914 /* mask not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
915 A30, R30, R31, T20-22, X20-21, X22-24 */
916 tp_features
.hotkey_mask
=
917 acpi_evalf(hkey_handle
, NULL
, "DHKN", "qv");
919 vdbg_printk(TPACPI_DBG_INIT
, "hotkey masks are %s\n",
920 str_supported(tp_features
.hotkey_mask
));
922 if (tp_features
.hotkey_mask
) {
923 /* MHKA available in A31, R40, R40e, T4x, X31, and later */
924 if (!acpi_evalf(hkey_handle
, &hotkey_all_mask
,
926 hotkey_all_mask
= 0x080cU
; /* FN+F12, FN+F4, FN+F3 */
929 res
= hotkey_get(&hotkey_orig_status
, &hotkey_orig_mask
);
930 if (!res
&& tp_features
.hotkey_mask
) {
931 res
= add_many_to_attr_set(hotkey_dev_attributes
,
932 hotkey_mask_attributes
,
933 ARRAY_SIZE(hotkey_mask_attributes
));
936 /* Not all thinkpads have a hardware radio switch */
937 if (!res
&& acpi_evalf(hkey_handle
, &status
, "WLSW", "qd")) {
938 tp_features
.hotkey_wlsw
= 1;
940 "radio switch found; radios are %s\n",
942 res
= add_to_attr_set(hotkey_dev_attributes
,
943 &dev_attr_hotkey_radio_sw
.attr
);
947 res
= register_attr_set_with_sysfs(
948 hotkey_dev_attributes
,
949 &tpacpi_pdev
->dev
.kobj
);
954 return (tp_features
.hotkey
)? 0 : 1;
957 static void hotkey_exit(void)
961 if (tp_features
.hotkey
) {
962 dbg_printk(TPACPI_DBG_EXIT
, "restoring original hotkey mask\n");
963 res
= hotkey_set(hotkey_orig_status
, hotkey_orig_mask
);
965 printk(IBM_ERR
"failed to restore hotkey to BIOS defaults\n");
968 if (hotkey_dev_attributes
) {
969 delete_attr_set(hotkey_dev_attributes
, &tpacpi_pdev
->dev
.kobj
);
970 hotkey_dev_attributes
= NULL
;
974 static void hotkey_notify(struct ibm_struct
*ibm
, u32 event
)
978 if (event
== 0x80 && acpi_evalf(hkey_handle
, &hkey
, "MHKP", "d")) {
979 acpi_bus_generate_event(ibm
->acpi
->device
, event
, hkey
);
981 printk(IBM_ERR
"unknown hotkey notification event %d\n", event
);
982 acpi_bus_generate_event(ibm
->acpi
->device
, event
, 0);
987 * Call with hotkey_mutex held
989 static int hotkey_get(int *status
, u32
*mask
)
991 if (!acpi_evalf(hkey_handle
, status
, "DHKC", "d"))
994 if (tp_features
.hotkey_mask
)
995 if (!acpi_evalf(hkey_handle
, mask
, "DHKN", "d"))
1002 * Call with hotkey_mutex held
1004 static int hotkey_set(int status
, u32 mask
)
1008 if (!acpi_evalf(hkey_handle
, NULL
, "MHKC", "vd", status
))
1011 if (tp_features
.hotkey_mask
)
1012 for (i
= 0; i
< 32; i
++) {
1013 int bit
= ((1 << i
) & mask
) != 0;
1014 if (!acpi_evalf(hkey_handle
,
1015 NULL
, "MHKM", "vdd", i
+ 1, bit
))
1022 /* procfs -------------------------------------------------------------- */
1023 static int hotkey_read(char *p
)
1029 if (!tp_features
.hotkey
) {
1030 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1034 res
= mutex_lock_interruptible(&hotkey_mutex
);
1037 res
= hotkey_get(&status
, &mask
);
1038 mutex_unlock(&hotkey_mutex
);
1042 len
+= sprintf(p
+ len
, "status:\t\t%s\n", enabled(status
, 0));
1043 if (tp_features
.hotkey_mask
) {
1044 len
+= sprintf(p
+ len
, "mask:\t\t0x%08x\n", mask
);
1045 len
+= sprintf(p
+ len
,
1046 "commands:\tenable, disable, reset, <mask>\n");
1048 len
+= sprintf(p
+ len
, "mask:\t\tnot supported\n");
1049 len
+= sprintf(p
+ len
, "commands:\tenable, disable, reset\n");
1055 static int hotkey_write(char *buf
)
1062 if (!tp_features
.hotkey
)
1065 res
= mutex_lock_interruptible(&hotkey_mutex
);
1069 res
= hotkey_get(&status
, &mask
);
1074 while ((cmd
= next_cmd(&buf
))) {
1075 if (strlencmp(cmd
, "enable") == 0) {
1077 } else if (strlencmp(cmd
, "disable") == 0) {
1079 } else if (strlencmp(cmd
, "reset") == 0) {
1080 status
= hotkey_orig_status
;
1081 mask
= hotkey_orig_mask
;
1082 } else if (sscanf(cmd
, "0x%x", &mask
) == 1) {
1084 } else if (sscanf(cmd
, "%x", &mask
) == 1) {
1094 res
= hotkey_set(status
, mask
);
1097 mutex_unlock(&hotkey_mutex
);
1101 static struct tp_acpi_drv_struct ibm_hotkey_acpidriver
= {
1102 .hid
= IBM_HKEY_HID
,
1103 .notify
= hotkey_notify
,
1104 .handle
= &hkey_handle
,
1105 .type
= ACPI_DEVICE_NOTIFY
,
1108 static struct ibm_struct hotkey_driver_data
= {
1110 .read
= hotkey_read
,
1111 .write
= hotkey_write
,
1112 .exit
= hotkey_exit
,
1113 .acpi
= &ibm_hotkey_acpidriver
,
1116 /*************************************************************************
1117 * Bluetooth subdriver
1120 /* sysfs bluetooth enable ---------------------------------------------- */
1121 static ssize_t
bluetooth_enable_show(struct device
*dev
,
1122 struct device_attribute
*attr
,
1127 status
= bluetooth_get_radiosw();
1131 return snprintf(buf
, PAGE_SIZE
, "%d\n", status
? 1 : 0);
1134 static ssize_t
bluetooth_enable_store(struct device
*dev
,
1135 struct device_attribute
*attr
,
1136 const char *buf
, size_t count
)
1141 if (parse_strtoul(buf
, 1, &t
))
1144 res
= bluetooth_set_radiosw(t
);
1146 return (res
) ? res
: count
;
1149 static struct device_attribute dev_attr_bluetooth_enable
=
1150 __ATTR(bluetooth_enable
, S_IWUSR
| S_IRUGO
,
1151 bluetooth_enable_show
, bluetooth_enable_store
);
1153 /* --------------------------------------------------------------------- */
1155 static struct attribute
*bluetooth_attributes
[] = {
1156 &dev_attr_bluetooth_enable
.attr
,
1160 static const struct attribute_group bluetooth_attr_group
= {
1161 .attrs
= bluetooth_attributes
,
1164 static int __init
bluetooth_init(struct ibm_init_struct
*iibm
)
1169 vdbg_printk(TPACPI_DBG_INIT
, "initializing bluetooth subdriver\n");
1171 IBM_ACPIHANDLE_INIT(hkey
);
1173 /* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
1174 G4x, R30, R31, R40e, R50e, T20-22, X20-21 */
1175 tp_features
.bluetooth
= hkey_handle
&&
1176 acpi_evalf(hkey_handle
, &status
, "GBDC", "qd");
1178 vdbg_printk(TPACPI_DBG_INIT
, "bluetooth is %s, status 0x%02x\n",
1179 str_supported(tp_features
.bluetooth
),
1182 if (tp_features
.bluetooth
) {
1183 if (!(status
& TP_ACPI_BLUETOOTH_HWPRESENT
)) {
1184 /* no bluetooth hardware present in system */
1185 tp_features
.bluetooth
= 0;
1186 dbg_printk(TPACPI_DBG_INIT
,
1187 "bluetooth hardware not installed\n");
1189 res
= sysfs_create_group(&tpacpi_pdev
->dev
.kobj
,
1190 &bluetooth_attr_group
);
1196 return (tp_features
.bluetooth
)? 0 : 1;
1199 static void bluetooth_exit(void)
1201 sysfs_remove_group(&tpacpi_pdev
->dev
.kobj
,
1202 &bluetooth_attr_group
);
1205 static int bluetooth_get_radiosw(void)
1209 if (!tp_features
.bluetooth
)
1212 if (!acpi_evalf(hkey_handle
, &status
, "GBDC", "d"))
1215 return ((status
& TP_ACPI_BLUETOOTH_RADIOSSW
) != 0);
1218 static int bluetooth_set_radiosw(int radio_on
)
1222 if (!tp_features
.bluetooth
)
1225 if (!acpi_evalf(hkey_handle
, &status
, "GBDC", "d"))
1228 status
|= TP_ACPI_BLUETOOTH_RADIOSSW
;
1230 status
&= ~TP_ACPI_BLUETOOTH_RADIOSSW
;
1231 if (!acpi_evalf(hkey_handle
, NULL
, "SBDC", "vd", status
))
1237 /* procfs -------------------------------------------------------------- */
1238 static int bluetooth_read(char *p
)
1241 int status
= bluetooth_get_radiosw();
1243 if (!tp_features
.bluetooth
)
1244 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1246 len
+= sprintf(p
+ len
, "status:\t\t%s\n",
1247 (status
)? "enabled" : "disabled");
1248 len
+= sprintf(p
+ len
, "commands:\tenable, disable\n");
1254 static int bluetooth_write(char *buf
)
1258 if (!tp_features
.bluetooth
)
1261 while ((cmd
= next_cmd(&buf
))) {
1262 if (strlencmp(cmd
, "enable") == 0) {
1263 bluetooth_set_radiosw(1);
1264 } else if (strlencmp(cmd
, "disable") == 0) {
1265 bluetooth_set_radiosw(0);
1273 static struct ibm_struct bluetooth_driver_data
= {
1274 .name
= "bluetooth",
1275 .read
= bluetooth_read
,
1276 .write
= bluetooth_write
,
1277 .exit
= bluetooth_exit
,
1280 /*************************************************************************
1284 /* sysfs wan enable ---------------------------------------------------- */
1285 static ssize_t
wan_enable_show(struct device
*dev
,
1286 struct device_attribute
*attr
,
1291 status
= wan_get_radiosw();
1295 return snprintf(buf
, PAGE_SIZE
, "%d\n", status
? 1 : 0);
1298 static ssize_t
wan_enable_store(struct device
*dev
,
1299 struct device_attribute
*attr
,
1300 const char *buf
, size_t count
)
1305 if (parse_strtoul(buf
, 1, &t
))
1308 res
= wan_set_radiosw(t
);
1310 return (res
) ? res
: count
;
1313 static struct device_attribute dev_attr_wan_enable
=
1314 __ATTR(wwan_enable
, S_IWUSR
| S_IRUGO
,
1315 wan_enable_show
, wan_enable_store
);
1317 /* --------------------------------------------------------------------- */
1319 static struct attribute
*wan_attributes
[] = {
1320 &dev_attr_wan_enable
.attr
,
1324 static const struct attribute_group wan_attr_group
= {
1325 .attrs
= wan_attributes
,
1328 static int __init
wan_init(struct ibm_init_struct
*iibm
)
1333 vdbg_printk(TPACPI_DBG_INIT
, "initializing wan subdriver\n");
1335 IBM_ACPIHANDLE_INIT(hkey
);
1337 tp_features
.wan
= hkey_handle
&&
1338 acpi_evalf(hkey_handle
, &status
, "GWAN", "qd");
1340 vdbg_printk(TPACPI_DBG_INIT
, "wan is %s, status 0x%02x\n",
1341 str_supported(tp_features
.wan
),
1344 if (tp_features
.wan
) {
1345 if (!(status
& TP_ACPI_WANCARD_HWPRESENT
)) {
1346 /* no wan hardware present in system */
1347 tp_features
.wan
= 0;
1348 dbg_printk(TPACPI_DBG_INIT
,
1349 "wan hardware not installed\n");
1351 res
= sysfs_create_group(&tpacpi_pdev
->dev
.kobj
,
1358 return (tp_features
.wan
)? 0 : 1;
1361 static void wan_exit(void)
1363 sysfs_remove_group(&tpacpi_pdev
->dev
.kobj
,
1367 static int wan_get_radiosw(void)
1371 if (!tp_features
.wan
)
1374 if (!acpi_evalf(hkey_handle
, &status
, "GWAN", "d"))
1377 return ((status
& TP_ACPI_WANCARD_RADIOSSW
) != 0);
1380 static int wan_set_radiosw(int radio_on
)
1384 if (!tp_features
.wan
)
1387 if (!acpi_evalf(hkey_handle
, &status
, "GWAN", "d"))
1390 status
|= TP_ACPI_WANCARD_RADIOSSW
;
1392 status
&= ~TP_ACPI_WANCARD_RADIOSSW
;
1393 if (!acpi_evalf(hkey_handle
, NULL
, "SWAN", "vd", status
))
1399 /* procfs -------------------------------------------------------------- */
1400 static int wan_read(char *p
)
1403 int status
= wan_get_radiosw();
1405 if (!tp_features
.wan
)
1406 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1408 len
+= sprintf(p
+ len
, "status:\t\t%s\n",
1409 (status
)? "enabled" : "disabled");
1410 len
+= sprintf(p
+ len
, "commands:\tenable, disable\n");
1416 static int wan_write(char *buf
)
1420 if (!tp_features
.wan
)
1423 while ((cmd
= next_cmd(&buf
))) {
1424 if (strlencmp(cmd
, "enable") == 0) {
1426 } else if (strlencmp(cmd
, "disable") == 0) {
1435 static struct ibm_struct wan_driver_data
= {
1440 .flags
.experimental
= 1,
1443 /*************************************************************************
1447 static enum video_access_mode video_supported
;
1448 static int video_orig_autosw
;
1450 IBM_HANDLE(vid
, root
, "\\_SB.PCI.AGP.VGA", /* 570 */
1451 "\\_SB.PCI0.AGP0.VID0", /* 600e/x, 770x */
1452 "\\_SB.PCI0.VID0", /* 770e */
1453 "\\_SB.PCI0.VID", /* A21e, G4x, R50e, X30, X40 */
1454 "\\_SB.PCI0.AGP.VID", /* all others */
1457 IBM_HANDLE(vid2
, root
, "\\_SB.PCI0.AGPB.VID"); /* G41 */
1459 static int __init
video_init(struct ibm_init_struct
*iibm
)
1463 vdbg_printk(TPACPI_DBG_INIT
, "initializing video subdriver\n");
1465 IBM_ACPIHANDLE_INIT(vid
);
1466 IBM_ACPIHANDLE_INIT(vid2
);
1468 if (vid2_handle
&& acpi_evalf(NULL
, &ivga
, "\\IVGA", "d") && ivga
)
1469 /* G41, assume IVGA doesn't change */
1470 vid_handle
= vid2_handle
;
1473 /* video switching not supported on R30, R31 */
1474 video_supported
= TPACPI_VIDEO_NONE
;
1475 else if (acpi_evalf(vid_handle
, &video_orig_autosw
, "SWIT", "qd"))
1477 video_supported
= TPACPI_VIDEO_570
;
1478 else if (acpi_evalf(vid_handle
, &video_orig_autosw
, "^VADL", "qd"))
1479 /* 600e/x, 770e, 770x */
1480 video_supported
= TPACPI_VIDEO_770
;
1483 video_supported
= TPACPI_VIDEO_NEW
;
1485 vdbg_printk(TPACPI_DBG_INIT
, "video is %s, mode %d\n",
1486 str_supported(video_supported
!= TPACPI_VIDEO_NONE
),
1489 return (video_supported
!= TPACPI_VIDEO_NONE
)? 0 : 1;
1492 static void video_exit(void)
1494 dbg_printk(TPACPI_DBG_EXIT
,
1495 "restoring original video autoswitch mode\n");
1496 if (video_autosw_set(video_orig_autosw
))
1497 printk(IBM_ERR
"error while trying to restore original "
1498 "video autoswitch mode\n");
1501 static int video_outputsw_get(void)
1506 switch (video_supported
) {
1507 case TPACPI_VIDEO_570
:
1508 if (!acpi_evalf(NULL
, &i
, "\\_SB.PHS", "dd",
1509 TP_ACPI_VIDEO_570_PHSCMD
))
1511 status
= i
& TP_ACPI_VIDEO_570_PHSMASK
;
1513 case TPACPI_VIDEO_770
:
1514 if (!acpi_evalf(NULL
, &i
, "\\VCDL", "d"))
1517 status
|= TP_ACPI_VIDEO_S_LCD
;
1518 if (!acpi_evalf(NULL
, &i
, "\\VCDC", "d"))
1521 status
|= TP_ACPI_VIDEO_S_CRT
;
1523 case TPACPI_VIDEO_NEW
:
1524 if (!acpi_evalf(NULL
, NULL
, "\\VUPS", "vd", 1) ||
1525 !acpi_evalf(NULL
, &i
, "\\VCDC", "d"))
1528 status
|= TP_ACPI_VIDEO_S_CRT
;
1530 if (!acpi_evalf(NULL
, NULL
, "\\VUPS", "vd", 0) ||
1531 !acpi_evalf(NULL
, &i
, "\\VCDL", "d"))
1534 status
|= TP_ACPI_VIDEO_S_LCD
;
1535 if (!acpi_evalf(NULL
, &i
, "\\VCDD", "d"))
1538 status
|= TP_ACPI_VIDEO_S_DVI
;
1547 static int video_outputsw_set(int status
)
1552 switch (video_supported
) {
1553 case TPACPI_VIDEO_570
:
1554 res
= acpi_evalf(NULL
, NULL
,
1555 "\\_SB.PHS2", "vdd",
1556 TP_ACPI_VIDEO_570_PHS2CMD
,
1557 status
| TP_ACPI_VIDEO_570_PHS2SET
);
1559 case TPACPI_VIDEO_770
:
1560 autosw
= video_autosw_get();
1564 res
= video_autosw_set(1);
1567 res
= acpi_evalf(vid_handle
, NULL
,
1568 "ASWT", "vdd", status
* 0x100, 0);
1569 if (!autosw
&& video_autosw_set(autosw
)) {
1570 printk(IBM_ERR
"video auto-switch left enabled due to error\n");
1574 case TPACPI_VIDEO_NEW
:
1575 res
= acpi_evalf(NULL
, NULL
, "\\VUPS", "vd", 0x80) &&
1576 acpi_evalf(NULL
, NULL
, "\\VSDS", "vdd", status
, 1);
1582 return (res
)? 0 : -EIO
;
1585 static int video_autosw_get(void)
1589 switch (video_supported
) {
1590 case TPACPI_VIDEO_570
:
1591 if (!acpi_evalf(vid_handle
, &autosw
, "SWIT", "d"))
1594 case TPACPI_VIDEO_770
:
1595 case TPACPI_VIDEO_NEW
:
1596 if (!acpi_evalf(vid_handle
, &autosw
, "^VDEE", "d"))
1606 static int video_autosw_set(int enable
)
1608 if (!acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", (enable
)? 1 : 0))
1613 static int video_outputsw_cycle(void)
1615 int autosw
= video_autosw_get();
1621 switch (video_supported
) {
1622 case TPACPI_VIDEO_570
:
1623 res
= video_autosw_set(1);
1626 res
= acpi_evalf(ec_handle
, NULL
, "_Q16", "v");
1628 case TPACPI_VIDEO_770
:
1629 case TPACPI_VIDEO_NEW
:
1630 res
= video_autosw_set(1);
1633 res
= acpi_evalf(vid_handle
, NULL
, "VSWT", "v");
1638 if (!autosw
&& video_autosw_set(autosw
)) {
1639 printk(IBM_ERR
"video auto-switch left enabled due to error\n");
1643 return (res
)? 0 : -EIO
;
1646 static int video_expand_toggle(void)
1648 switch (video_supported
) {
1649 case TPACPI_VIDEO_570
:
1650 return acpi_evalf(ec_handle
, NULL
, "_Q17", "v")?
1652 case TPACPI_VIDEO_770
:
1653 return acpi_evalf(vid_handle
, NULL
, "VEXP", "v")?
1655 case TPACPI_VIDEO_NEW
:
1656 return acpi_evalf(NULL
, NULL
, "\\VEXP", "v")?
1664 static int video_read(char *p
)
1669 if (video_supported
== TPACPI_VIDEO_NONE
) {
1670 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1674 status
= video_outputsw_get();
1678 autosw
= video_autosw_get();
1682 len
+= sprintf(p
+ len
, "status:\t\tsupported\n");
1683 len
+= sprintf(p
+ len
, "lcd:\t\t%s\n", enabled(status
, 0));
1684 len
+= sprintf(p
+ len
, "crt:\t\t%s\n", enabled(status
, 1));
1685 if (video_supported
== TPACPI_VIDEO_NEW
)
1686 len
+= sprintf(p
+ len
, "dvi:\t\t%s\n", enabled(status
, 3));
1687 len
+= sprintf(p
+ len
, "auto:\t\t%s\n", enabled(autosw
, 0));
1688 len
+= sprintf(p
+ len
, "commands:\tlcd_enable, lcd_disable\n");
1689 len
+= sprintf(p
+ len
, "commands:\tcrt_enable, crt_disable\n");
1690 if (video_supported
== TPACPI_VIDEO_NEW
)
1691 len
+= sprintf(p
+ len
, "commands:\tdvi_enable, dvi_disable\n");
1692 len
+= sprintf(p
+ len
, "commands:\tauto_enable, auto_disable\n");
1693 len
+= sprintf(p
+ len
, "commands:\tvideo_switch, expand_toggle\n");
1698 static int video_write(char *buf
)
1701 int enable
, disable
, status
;
1704 if (video_supported
== TPACPI_VIDEO_NONE
)
1710 while ((cmd
= next_cmd(&buf
))) {
1711 if (strlencmp(cmd
, "lcd_enable") == 0) {
1712 enable
|= TP_ACPI_VIDEO_S_LCD
;
1713 } else if (strlencmp(cmd
, "lcd_disable") == 0) {
1714 disable
|= TP_ACPI_VIDEO_S_LCD
;
1715 } else if (strlencmp(cmd
, "crt_enable") == 0) {
1716 enable
|= TP_ACPI_VIDEO_S_CRT
;
1717 } else if (strlencmp(cmd
, "crt_disable") == 0) {
1718 disable
|= TP_ACPI_VIDEO_S_CRT
;
1719 } else if (video_supported
== TPACPI_VIDEO_NEW
&&
1720 strlencmp(cmd
, "dvi_enable") == 0) {
1721 enable
|= TP_ACPI_VIDEO_S_DVI
;
1722 } else if (video_supported
== TPACPI_VIDEO_NEW
&&
1723 strlencmp(cmd
, "dvi_disable") == 0) {
1724 disable
|= TP_ACPI_VIDEO_S_DVI
;
1725 } else if (strlencmp(cmd
, "auto_enable") == 0) {
1726 res
= video_autosw_set(1);
1729 } else if (strlencmp(cmd
, "auto_disable") == 0) {
1730 res
= video_autosw_set(0);
1733 } else if (strlencmp(cmd
, "video_switch") == 0) {
1734 res
= video_outputsw_cycle();
1737 } else if (strlencmp(cmd
, "expand_toggle") == 0) {
1738 res
= video_expand_toggle();
1745 if (enable
|| disable
) {
1746 status
= video_outputsw_get();
1749 res
= video_outputsw_set((status
& ~disable
) | enable
);
1757 static struct ibm_struct video_driver_data
= {
1760 .write
= video_write
,
1764 /*************************************************************************
1765 * Light (thinklight) subdriver
1768 IBM_HANDLE(lght
, root
, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */
1769 IBM_HANDLE(ledb
, ec
, "LEDB"); /* G4x */
1771 static int __init
light_init(struct ibm_init_struct
*iibm
)
1773 vdbg_printk(TPACPI_DBG_INIT
, "initializing light subdriver\n");
1775 IBM_ACPIHANDLE_INIT(ledb
);
1776 IBM_ACPIHANDLE_INIT(lght
);
1777 IBM_ACPIHANDLE_INIT(cmos
);
1779 /* light not supported on 570, 600e/x, 770e, 770x, G4x, R30, R31 */
1780 tp_features
.light
= (cmos_handle
|| lght_handle
) && !ledb_handle
;
1782 if (tp_features
.light
)
1783 /* light status not supported on
1784 570, 600e/x, 770e, 770x, G4x, R30, R31, R32, X20 */
1785 tp_features
.light_status
=
1786 acpi_evalf(ec_handle
, NULL
, "KBLT", "qv");
1788 vdbg_printk(TPACPI_DBG_INIT
, "light is %s\n",
1789 str_supported(tp_features
.light
));
1791 return (tp_features
.light
)? 0 : 1;
1794 static int light_read(char *p
)
1799 if (!tp_features
.light
) {
1800 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1801 } else if (!tp_features
.light_status
) {
1802 len
+= sprintf(p
+ len
, "status:\t\tunknown\n");
1803 len
+= sprintf(p
+ len
, "commands:\ton, off\n");
1805 if (!acpi_evalf(ec_handle
, &status
, "KBLT", "d"))
1807 len
+= sprintf(p
+ len
, "status:\t\t%s\n", onoff(status
, 0));
1808 len
+= sprintf(p
+ len
, "commands:\ton, off\n");
1814 static int light_write(char *buf
)
1816 int cmos_cmd
, lght_cmd
;
1820 if (!tp_features
.light
)
1823 while ((cmd
= next_cmd(&buf
))) {
1824 if (strlencmp(cmd
, "on") == 0) {
1827 } else if (strlencmp(cmd
, "off") == 0) {
1833 success
= cmos_handle
?
1834 acpi_evalf(cmos_handle
, NULL
, NULL
, "vd", cmos_cmd
) :
1835 acpi_evalf(lght_handle
, NULL
, NULL
, "vd", lght_cmd
);
1843 static struct ibm_struct light_driver_data
= {
1846 .write
= light_write
,
1849 /*************************************************************************
1853 #ifdef CONFIG_THINKPAD_ACPI_DOCK
1855 IBM_HANDLE(dock
, root
, "\\_SB.GDCK", /* X30, X31, X40 */
1856 "\\_SB.PCI0.DOCK", /* 600e/x,770e,770x,A2xm/p,T20-22,X20-21 */
1857 "\\_SB.PCI0.PCI1.DOCK", /* all others */
1858 "\\_SB.PCI.ISA.SLCE", /* 570 */
1859 ); /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */
1861 /* don't list other alternatives as we install a notify handler on the 570 */
1862 IBM_HANDLE(pci
, root
, "\\_SB.PCI"); /* 570 */
1864 static struct tp_acpi_drv_struct ibm_dock_acpidriver
[2] = {
1866 .notify
= dock_notify
,
1867 .handle
= &dock_handle
,
1868 .type
= ACPI_SYSTEM_NOTIFY
,
1872 .notify
= dock_notify
,
1873 .handle
= &pci_handle
,
1874 .type
= ACPI_SYSTEM_NOTIFY
,
1878 static struct ibm_struct dock_driver_data
[2] = {
1882 .write
= dock_write
,
1883 .acpi
= &ibm_dock_acpidriver
[0],
1887 .acpi
= &ibm_dock_acpidriver
[1],
1891 #define dock_docked() (_sta(dock_handle) & 1)
1893 static int __init
dock_init(struct ibm_init_struct
*iibm
)
1895 vdbg_printk(TPACPI_DBG_INIT
, "initializing dock subdriver\n");
1897 IBM_ACPIHANDLE_INIT(dock
);
1899 vdbg_printk(TPACPI_DBG_INIT
, "dock is %s\n",
1900 str_supported(dock_handle
!= NULL
));
1902 return (dock_handle
)? 0 : 1;
1905 static int __init
dock_init2(struct ibm_init_struct
*iibm
)
1909 vdbg_printk(TPACPI_DBG_INIT
, "initializing dock subdriver part 2\n");
1911 if (dock_driver_data
[0].flags
.acpi_driver_registered
&&
1912 dock_driver_data
[0].flags
.acpi_notify_installed
) {
1913 IBM_ACPIHANDLE_INIT(pci
);
1914 dock2_needed
= (pci_handle
!= NULL
);
1915 vdbg_printk(TPACPI_DBG_INIT
,
1916 "dock PCI handler for the TP 570 is %s\n",
1917 str_supported(dock2_needed
));
1919 vdbg_printk(TPACPI_DBG_INIT
,
1920 "dock subdriver part 2 not required\n");
1924 return (dock2_needed
)? 0 : 1;
1927 static void dock_notify(struct ibm_struct
*ibm
, u32 event
)
1929 int docked
= dock_docked();
1930 int pci
= ibm
->acpi
->hid
&& strstr(ibm
->acpi
->hid
, IBM_PCI_HID
);
1932 if (event
== 1 && !pci
) /* 570 */
1933 acpi_bus_generate_event(ibm
->acpi
->device
, event
, 1); /* button */
1934 else if (event
== 1 && pci
) /* 570 */
1935 acpi_bus_generate_event(ibm
->acpi
->device
, event
, 3); /* dock */
1936 else if (event
== 3 && docked
)
1937 acpi_bus_generate_event(ibm
->acpi
->device
, event
, 1); /* button */
1938 else if (event
== 3 && !docked
)
1939 acpi_bus_generate_event(ibm
->acpi
->device
, event
, 2); /* undock */
1940 else if (event
== 0 && docked
)
1941 acpi_bus_generate_event(ibm
->acpi
->device
, event
, 3); /* dock */
1943 printk(IBM_ERR
"unknown dock event %d, status %d\n",
1944 event
, _sta(dock_handle
));
1945 acpi_bus_generate_event(ibm
->acpi
->device
, event
, 0); /* unknown */
1949 static int dock_read(char *p
)
1952 int docked
= dock_docked();
1955 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1957 len
+= sprintf(p
+ len
, "status:\t\tundocked\n");
1959 len
+= sprintf(p
+ len
, "status:\t\tdocked\n");
1960 len
+= sprintf(p
+ len
, "commands:\tdock, undock\n");
1966 static int dock_write(char *buf
)
1973 while ((cmd
= next_cmd(&buf
))) {
1974 if (strlencmp(cmd
, "undock") == 0) {
1975 if (!acpi_evalf(dock_handle
, NULL
, "_DCK", "vd", 0) ||
1976 !acpi_evalf(dock_handle
, NULL
, "_EJ0", "vd", 1))
1978 } else if (strlencmp(cmd
, "dock") == 0) {
1979 if (!acpi_evalf(dock_handle
, NULL
, "_DCK", "vd", 1))
1988 #endif /* CONFIG_THINKPAD_ACPI_DOCK */
1990 /*************************************************************************
1994 #ifdef CONFIG_THINKPAD_ACPI_BAY
1995 IBM_HANDLE(bay
, root
, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */
1996 "\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */
1997 "\\_SB.PCI0.SATA.SCND.MSTR", /* T60, X60, Z60 */
1998 "\\_SB.PCI0.IDE0.SCND.MSTR", /* all others */
1999 ); /* A21e, R30, R31 */
2000 IBM_HANDLE(bay_ej
, bay
, "_EJ3", /* 600e/x, A2xm/p, A3x */
2001 "_EJ0", /* all others */
2002 ); /* 570,A21e,G4x,R30,R31,R32,R40e,R50e */
2003 IBM_HANDLE(bay2
, root
, "\\_SB.PCI0.IDE0.PRIM.SLAV", /* A3x, R32 */
2004 "\\_SB.PCI0.IDE0.IDEP.IDPS", /* 600e/x, 770e, 770x */
2006 IBM_HANDLE(bay2_ej
, bay2
, "_EJ3", /* 600e/x, 770e, A3x */
2010 static int __init
bay_init(struct ibm_init_struct
*iibm
)
2012 vdbg_printk(TPACPI_DBG_INIT
, "initializing bay subdriver\n");
2014 IBM_ACPIHANDLE_INIT(bay
);
2016 IBM_ACPIHANDLE_INIT(bay_ej
);
2017 IBM_ACPIHANDLE_INIT(bay2
);
2019 IBM_ACPIHANDLE_INIT(bay2_ej
);
2021 tp_features
.bay_status
= bay_handle
&&
2022 acpi_evalf(bay_handle
, NULL
, "_STA", "qv");
2023 tp_features
.bay_status2
= bay2_handle
&&
2024 acpi_evalf(bay2_handle
, NULL
, "_STA", "qv");
2026 tp_features
.bay_eject
= bay_handle
&& bay_ej_handle
&&
2027 (strlencmp(bay_ej_path
, "_EJ0") == 0 || experimental
);
2028 tp_features
.bay_eject2
= bay2_handle
&& bay2_ej_handle
&&
2029 (strlencmp(bay2_ej_path
, "_EJ0") == 0 || experimental
);
2031 vdbg_printk(TPACPI_DBG_INIT
,
2032 "bay 1: status %s, eject %s; bay 2: status %s, eject %s\n",
2033 str_supported(tp_features
.bay_status
),
2034 str_supported(tp_features
.bay_eject
),
2035 str_supported(tp_features
.bay_status2
),
2036 str_supported(tp_features
.bay_eject2
));
2038 return (tp_features
.bay_status
|| tp_features
.bay_eject
||
2039 tp_features
.bay_status2
|| tp_features
.bay_eject2
)? 0 : 1;
2042 static void bay_notify(struct ibm_struct
*ibm
, u32 event
)
2044 acpi_bus_generate_event(ibm
->acpi
->device
, event
, 0);
2047 #define bay_occupied(b) (_sta(b##_handle) & 1)
2049 static int bay_read(char *p
)
2052 int occupied
= bay_occupied(bay
);
2053 int occupied2
= bay_occupied(bay2
);
2056 len
+= sprintf(p
+ len
, "status:\t\t%s\n",
2057 tp_features
.bay_status
?
2058 (occupied
? "occupied" : "unoccupied") :
2060 if (tp_features
.bay_status2
)
2061 len
+= sprintf(p
+ len
, "status2:\t%s\n", occupied2
?
2062 "occupied" : "unoccupied");
2064 eject
= tp_features
.bay_eject
&& occupied
;
2065 eject2
= tp_features
.bay_eject2
&& occupied2
;
2067 if (eject
&& eject2
)
2068 len
+= sprintf(p
+ len
, "commands:\teject, eject2\n");
2070 len
+= sprintf(p
+ len
, "commands:\teject\n");
2072 len
+= sprintf(p
+ len
, "commands:\teject2\n");
2077 static int bay_write(char *buf
)
2081 if (!tp_features
.bay_eject
&& !tp_features
.bay_eject2
)
2084 while ((cmd
= next_cmd(&buf
))) {
2085 if (tp_features
.bay_eject
&& strlencmp(cmd
, "eject") == 0) {
2086 if (!acpi_evalf(bay_ej_handle
, NULL
, NULL
, "vd", 1))
2088 } else if (tp_features
.bay_eject2
&&
2089 strlencmp(cmd
, "eject2") == 0) {
2090 if (!acpi_evalf(bay2_ej_handle
, NULL
, NULL
, "vd", 1))
2099 static struct tp_acpi_drv_struct ibm_bay_acpidriver
= {
2100 .notify
= bay_notify
,
2101 .handle
= &bay_handle
,
2102 .type
= ACPI_SYSTEM_NOTIFY
,
2105 static struct ibm_struct bay_driver_data
= {
2109 .acpi
= &ibm_bay_acpidriver
,
2112 #endif /* CONFIG_THINKPAD_ACPI_BAY */
2114 /*************************************************************************
2118 /* sysfs cmos_command -------------------------------------------------- */
2119 static ssize_t
cmos_command_store(struct device
*dev
,
2120 struct device_attribute
*attr
,
2121 const char *buf
, size_t count
)
2123 unsigned long cmos_cmd
;
2126 if (parse_strtoul(buf
, 21, &cmos_cmd
))
2129 res
= issue_thinkpad_cmos_command(cmos_cmd
);
2130 return (res
)? res
: count
;
2133 static struct device_attribute dev_attr_cmos_command
=
2134 __ATTR(cmos_command
, S_IWUSR
, NULL
, cmos_command_store
);
2136 /* --------------------------------------------------------------------- */
2138 static int __init
cmos_init(struct ibm_init_struct
*iibm
)
2142 vdbg_printk(TPACPI_DBG_INIT
,
2143 "initializing cmos commands subdriver\n");
2145 IBM_ACPIHANDLE_INIT(cmos
);
2147 vdbg_printk(TPACPI_DBG_INIT
, "cmos commands are %s\n",
2148 str_supported(cmos_handle
!= NULL
));
2150 res
= device_create_file(&tpacpi_pdev
->dev
, &dev_attr_cmos_command
);
2154 return (cmos_handle
)? 0 : 1;
2157 static void cmos_exit(void)
2159 device_remove_file(&tpacpi_pdev
->dev
, &dev_attr_cmos_command
);
2162 static int cmos_read(char *p
)
2166 /* cmos not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
2167 R30, R31, T20-22, X20-21 */
2169 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
2171 len
+= sprintf(p
+ len
, "status:\t\tsupported\n");
2172 len
+= sprintf(p
+ len
, "commands:\t<cmd> (<cmd> is 0-21)\n");
2178 static int cmos_write(char *buf
)
2183 while ((cmd
= next_cmd(&buf
))) {
2184 if (sscanf(cmd
, "%u", &cmos_cmd
) == 1 &&
2185 cmos_cmd
>= 0 && cmos_cmd
<= 21) {
2190 res
= issue_thinkpad_cmos_command(cmos_cmd
);
2198 static struct ibm_struct cmos_driver_data
= {
2201 .write
= cmos_write
,
2205 /*************************************************************************
2209 static enum led_access_mode led_supported
;
2211 IBM_HANDLE(led
, ec
, "SLED", /* 570 */
2212 "SYSL", /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
2213 "LED", /* all others */
2216 static int __init
led_init(struct ibm_init_struct
*iibm
)
2218 vdbg_printk(TPACPI_DBG_INIT
, "initializing LED subdriver\n");
2220 IBM_ACPIHANDLE_INIT(led
);
2223 /* led not supported on R30, R31 */
2224 led_supported
= TPACPI_LED_NONE
;
2225 else if (strlencmp(led_path
, "SLED") == 0)
2227 led_supported
= TPACPI_LED_570
;
2228 else if (strlencmp(led_path
, "SYSL") == 0)
2229 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
2230 led_supported
= TPACPI_LED_OLD
;
2233 led_supported
= TPACPI_LED_NEW
;
2235 vdbg_printk(TPACPI_DBG_INIT
, "LED commands are %s, mode %d\n",
2236 str_supported(led_supported
), led_supported
);
2238 return (led_supported
!= TPACPI_LED_NONE
)? 0 : 1;
2241 #define led_status(s) ((s) == 0 ? "off" : ((s) == 1 ? "on" : "blinking"))
2243 static int led_read(char *p
)
2247 if (!led_supported
) {
2248 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
2251 len
+= sprintf(p
+ len
, "status:\t\tsupported\n");
2253 if (led_supported
== TPACPI_LED_570
) {
2256 for (i
= 0; i
< 8; i
++) {
2257 if (!acpi_evalf(ec_handle
,
2258 &status
, "GLED", "dd", 1 << i
))
2260 len
+= sprintf(p
+ len
, "%d:\t\t%s\n",
2261 i
, led_status(status
));
2265 len
+= sprintf(p
+ len
, "commands:\t"
2266 "<led> on, <led> off, <led> blink (<led> is 0-7)\n");
2271 /* off, on, blink */
2272 static const int led_sled_arg1
[] = { 0, 1, 3 };
2273 static const int led_exp_hlbl
[] = { 0, 0, 1 }; /* led# * */
2274 static const int led_exp_hlcl
[] = { 0, 1, 1 }; /* led# * */
2275 static const int led_led_arg1
[] = { 0, 0x80, 0xc0 };
2277 static int led_write(char *buf
)
2285 while ((cmd
= next_cmd(&buf
))) {
2286 if (sscanf(cmd
, "%d", &led
) != 1 || led
< 0 || led
> 7)
2289 if (strstr(cmd
, "off")) {
2291 } else if (strstr(cmd
, "on")) {
2293 } else if (strstr(cmd
, "blink")) {
2298 if (led_supported
== TPACPI_LED_570
) {
2301 if (!acpi_evalf(led_handle
, NULL
, NULL
, "vdd",
2302 led
, led_sled_arg1
[ind
]))
2304 } else if (led_supported
== TPACPI_LED_OLD
) {
2305 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */
2307 ret
= ec_write(TPACPI_LED_EC_HLMS
, led
);
2310 ec_write(TPACPI_LED_EC_HLBL
,
2311 led
* led_exp_hlbl
[ind
]);
2314 ec_write(TPACPI_LED_EC_HLCL
,
2315 led
* led_exp_hlcl
[ind
]);
2320 if (!acpi_evalf(led_handle
, NULL
, NULL
, "vdd",
2321 led
, led_led_arg1
[ind
]))
2329 static struct ibm_struct led_driver_data
= {
2335 /*************************************************************************
2339 IBM_HANDLE(beep
, ec
, "BEEP"); /* all except R30, R31 */
2341 static int __init
beep_init(struct ibm_init_struct
*iibm
)
2343 vdbg_printk(TPACPI_DBG_INIT
, "initializing beep subdriver\n");
2345 IBM_ACPIHANDLE_INIT(beep
);
2347 vdbg_printk(TPACPI_DBG_INIT
, "beep is %s\n",
2348 str_supported(beep_handle
!= NULL
));
2350 return (beep_handle
)? 0 : 1;
2353 static int beep_read(char *p
)
2358 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
2360 len
+= sprintf(p
+ len
, "status:\t\tsupported\n");
2361 len
+= sprintf(p
+ len
, "commands:\t<cmd> (<cmd> is 0-17)\n");
2367 static int beep_write(char *buf
)
2375 while ((cmd
= next_cmd(&buf
))) {
2376 if (sscanf(cmd
, "%u", &beep_cmd
) == 1 &&
2377 beep_cmd
>= 0 && beep_cmd
<= 17) {
2381 if (!acpi_evalf(beep_handle
, NULL
, NULL
, "vdd", beep_cmd
, 0))
2388 static struct ibm_struct beep_driver_data
= {
2391 .write
= beep_write
,
2394 /*************************************************************************
2398 static enum thermal_access_mode thermal_read_mode
;
2400 /* sysfs temp##_input -------------------------------------------------- */
2402 static ssize_t
thermal_temp_input_show(struct device
*dev
,
2403 struct device_attribute
*attr
,
2406 struct sensor_device_attribute
*sensor_attr
=
2407 to_sensor_dev_attr(attr
);
2408 int idx
= sensor_attr
->index
;
2412 res
= thermal_get_sensor(idx
, &value
);
2415 if (value
== TP_EC_THERMAL_TMP_NA
* 1000)
2418 return snprintf(buf
, PAGE_SIZE
, "%d\n", value
);
2421 #define THERMAL_SENSOR_ATTR_TEMP(_idxA, _idxB) \
2422 SENSOR_ATTR(temp##_idxA##_input, S_IRUGO, thermal_temp_input_show, NULL, _idxB)
2424 static struct sensor_device_attribute sensor_dev_attr_thermal_temp_input
[] = {
2425 THERMAL_SENSOR_ATTR_TEMP(1, 0),
2426 THERMAL_SENSOR_ATTR_TEMP(2, 1),
2427 THERMAL_SENSOR_ATTR_TEMP(3, 2),
2428 THERMAL_SENSOR_ATTR_TEMP(4, 3),
2429 THERMAL_SENSOR_ATTR_TEMP(5, 4),
2430 THERMAL_SENSOR_ATTR_TEMP(6, 5),
2431 THERMAL_SENSOR_ATTR_TEMP(7, 6),
2432 THERMAL_SENSOR_ATTR_TEMP(8, 7),
2433 THERMAL_SENSOR_ATTR_TEMP(9, 8),
2434 THERMAL_SENSOR_ATTR_TEMP(10, 9),
2435 THERMAL_SENSOR_ATTR_TEMP(11, 10),
2436 THERMAL_SENSOR_ATTR_TEMP(12, 11),
2437 THERMAL_SENSOR_ATTR_TEMP(13, 12),
2438 THERMAL_SENSOR_ATTR_TEMP(14, 13),
2439 THERMAL_SENSOR_ATTR_TEMP(15, 14),
2440 THERMAL_SENSOR_ATTR_TEMP(16, 15),
2443 #define THERMAL_ATTRS(X) \
2444 &sensor_dev_attr_thermal_temp_input[X].dev_attr.attr
2446 static struct attribute
*thermal_temp_input_attr
[] = {
2466 static const struct attribute_group thermal_temp_input16_group
= {
2467 .attrs
= thermal_temp_input_attr
2470 static const struct attribute_group thermal_temp_input8_group
= {
2471 .attrs
= &thermal_temp_input_attr
[8]
2474 #undef THERMAL_SENSOR_ATTR_TEMP
2475 #undef THERMAL_ATTRS
2477 /* --------------------------------------------------------------------- */
2479 static int __init
thermal_init(struct ibm_init_struct
*iibm
)
2486 vdbg_printk(TPACPI_DBG_INIT
, "initializing thermal subdriver\n");
2488 acpi_tmp7
= acpi_evalf(ec_handle
, NULL
, "TMP7", "qv");
2490 if (ibm_thinkpad_ec_found
&& experimental
) {
2492 * Direct EC access mode: sensors at registers
2493 * 0x78-0x7F, 0xC0-0xC7. Registers return 0x00 for
2494 * non-implemented, thermal sensors return 0x80 when
2499 for (i
= 0; i
< 8; i
++) {
2500 if (acpi_ec_read(TP_EC_THERMAL_TMP0
+ i
, &t
)) {
2506 if (acpi_ec_read(TP_EC_THERMAL_TMP8
+ i
, &t
)) {
2514 /* This is sheer paranoia, but we handle it anyway */
2517 "ThinkPad ACPI EC access misbehaving, "
2518 "falling back to ACPI TMPx access mode\n");
2519 thermal_read_mode
= TPACPI_THERMAL_ACPI_TMP07
;
2522 "ThinkPad ACPI EC access misbehaving, "
2523 "disabling thermal sensors access\n");
2524 thermal_read_mode
= TPACPI_THERMAL_NONE
;
2529 TPACPI_THERMAL_TPEC_16
: TPACPI_THERMAL_TPEC_8
;
2531 } else if (acpi_tmp7
) {
2532 if (acpi_evalf(ec_handle
, NULL
, "UPDT", "qv")) {
2533 /* 600e/x, 770e, 770x */
2534 thermal_read_mode
= TPACPI_THERMAL_ACPI_UPDT
;
2536 /* Standard ACPI TMPx access, max 8 sensors */
2537 thermal_read_mode
= TPACPI_THERMAL_ACPI_TMP07
;
2540 /* temperatures not supported on 570, G4x, R30, R31, R32 */
2541 thermal_read_mode
= TPACPI_THERMAL_NONE
;
2544 vdbg_printk(TPACPI_DBG_INIT
, "thermal is %s, mode %d\n",
2545 str_supported(thermal_read_mode
!= TPACPI_THERMAL_NONE
),
2548 switch(thermal_read_mode
) {
2549 case TPACPI_THERMAL_TPEC_16
:
2550 res
= sysfs_create_group(&tpacpi_pdev
->dev
.kobj
,
2551 &thermal_temp_input16_group
);
2555 case TPACPI_THERMAL_TPEC_8
:
2556 case TPACPI_THERMAL_ACPI_TMP07
:
2557 case TPACPI_THERMAL_ACPI_UPDT
:
2558 res
= sysfs_create_group(&tpacpi_pdev
->dev
.kobj
,
2559 &thermal_temp_input8_group
);
2563 case TPACPI_THERMAL_NONE
:
2571 static void thermal_exit(void)
2573 switch(thermal_read_mode
) {
2574 case TPACPI_THERMAL_TPEC_16
:
2575 sysfs_remove_group(&tpacpi_pdev
->dev
.kobj
,
2576 &thermal_temp_input16_group
);
2578 case TPACPI_THERMAL_TPEC_8
:
2579 case TPACPI_THERMAL_ACPI_TMP07
:
2580 case TPACPI_THERMAL_ACPI_UPDT
:
2581 sysfs_remove_group(&tpacpi_pdev
->dev
.kobj
,
2582 &thermal_temp_input16_group
);
2584 case TPACPI_THERMAL_NONE
:
2590 /* idx is zero-based */
2591 static int thermal_get_sensor(int idx
, s32
*value
)
2597 t
= TP_EC_THERMAL_TMP0
;
2599 switch (thermal_read_mode
) {
2600 #if TPACPI_MAX_THERMAL_SENSORS >= 16
2601 case TPACPI_THERMAL_TPEC_16
:
2602 if (idx
>= 8 && idx
<= 15) {
2603 t
= TP_EC_THERMAL_TMP8
;
2608 case TPACPI_THERMAL_TPEC_8
:
2610 if (!acpi_ec_read(t
+ idx
, &tmp
))
2612 *value
= tmp
* 1000;
2617 case TPACPI_THERMAL_ACPI_UPDT
:
2619 snprintf(tmpi
, sizeof(tmpi
), "TMP%c", '0' + idx
);
2620 if (!acpi_evalf(ec_handle
, NULL
, "UPDT", "v"))
2622 if (!acpi_evalf(ec_handle
, &t
, tmpi
, "d"))
2624 *value
= (t
- 2732) * 100;
2629 case TPACPI_THERMAL_ACPI_TMP07
:
2631 snprintf(tmpi
, sizeof(tmpi
), "TMP%c", '0' + idx
);
2632 if (!acpi_evalf(ec_handle
, &t
, tmpi
, "d"))
2639 case TPACPI_THERMAL_NONE
:
2647 static int thermal_get_sensors(struct ibm_thermal_sensors_struct
*s
)
2658 if (thermal_read_mode
== TPACPI_THERMAL_TPEC_16
)
2661 for(i
= 0 ; i
< n
; i
++) {
2662 res
= thermal_get_sensor(i
, &s
->temp
[i
]);
2670 static int thermal_read(char *p
)
2674 struct ibm_thermal_sensors_struct t
;
2676 n
= thermal_get_sensors(&t
);
2677 if (unlikely(n
< 0))
2680 len
+= sprintf(p
+ len
, "temperatures:\t");
2683 for (i
= 0; i
< (n
- 1); i
++)
2684 len
+= sprintf(p
+ len
, "%d ", t
.temp
[i
] / 1000);
2685 len
+= sprintf(p
+ len
, "%d\n", t
.temp
[i
] / 1000);
2687 len
+= sprintf(p
+ len
, "not supported\n");
2692 static struct ibm_struct thermal_driver_data
= {
2694 .read
= thermal_read
,
2695 .exit
= thermal_exit
,
2698 /*************************************************************************
2702 static u8 ecdump_regs
[256];
2704 static int ecdump_read(char *p
)
2710 len
+= sprintf(p
+ len
, "EC "
2711 " +00 +01 +02 +03 +04 +05 +06 +07"
2712 " +08 +09 +0a +0b +0c +0d +0e +0f\n");
2713 for (i
= 0; i
< 256; i
+= 16) {
2714 len
+= sprintf(p
+ len
, "EC 0x%02x:", i
);
2715 for (j
= 0; j
< 16; j
++) {
2716 if (!acpi_ec_read(i
+ j
, &v
))
2718 if (v
!= ecdump_regs
[i
+ j
])
2719 len
+= sprintf(p
+ len
, " *%02x", v
);
2721 len
+= sprintf(p
+ len
, " %02x", v
);
2722 ecdump_regs
[i
+ j
] = v
;
2724 len
+= sprintf(p
+ len
, "\n");
2729 /* These are way too dangerous to advertise openly... */
2731 len
+= sprintf(p
+ len
, "commands:\t0x<offset> 0x<value>"
2732 " (<offset> is 00-ff, <value> is 00-ff)\n");
2733 len
+= sprintf(p
+ len
, "commands:\t0x<offset> <value> "
2734 " (<offset> is 00-ff, <value> is 0-255)\n");
2739 static int ecdump_write(char *buf
)
2744 while ((cmd
= next_cmd(&buf
))) {
2745 if (sscanf(cmd
, "0x%x 0x%x", &i
, &v
) == 2) {
2747 } else if (sscanf(cmd
, "0x%x %u", &i
, &v
) == 2) {
2751 if (i
>= 0 && i
< 256 && v
>= 0 && v
< 256) {
2752 if (!acpi_ec_write(i
, v
))
2761 static struct ibm_struct ecdump_driver_data
= {
2763 .read
= ecdump_read
,
2764 .write
= ecdump_write
,
2765 .flags
.experimental
= 1,
2768 /*************************************************************************
2769 * Backlight/brightness subdriver
2772 static struct backlight_device
*ibm_backlight_device
;
2774 static struct backlight_properties ibm_backlight_data
= {
2775 .owner
= THIS_MODULE
,
2776 .get_brightness
= brightness_get
,
2777 .update_status
= brightness_update_status
,
2778 .max_brightness
= 7,
2781 static int __init
brightness_init(struct ibm_init_struct
*iibm
)
2785 vdbg_printk(TPACPI_DBG_INIT
, "initializing brightness subdriver\n");
2787 b
= brightness_get(NULL
);
2791 ibm_backlight_device
= backlight_device_register(
2792 TPACPI_BACKLIGHT_DEV_NAME
, NULL
, NULL
,
2793 &ibm_backlight_data
);
2794 if (IS_ERR(ibm_backlight_device
)) {
2795 printk(IBM_ERR
"Could not register backlight device\n");
2796 return PTR_ERR(ibm_backlight_device
);
2798 vdbg_printk(TPACPI_DBG_INIT
, "brightness is supported\n");
2800 ibm_backlight_device
->props
->brightness
= b
;
2801 brightness_update_status(ibm_backlight_device
);
2806 static void brightness_exit(void)
2808 if (ibm_backlight_device
) {
2809 vdbg_printk(TPACPI_DBG_EXIT
,
2810 "calling backlight_device_unregister()\n");
2811 backlight_device_unregister(ibm_backlight_device
);
2812 ibm_backlight_device
= NULL
;
2816 static int brightness_update_status(struct backlight_device
*bd
)
2818 return brightness_set(
2819 (bd
->props
->fb_blank
== FB_BLANK_UNBLANK
&&
2820 bd
->props
->power
== FB_BLANK_UNBLANK
) ?
2821 bd
->props
->brightness
: 0);
2824 static int brightness_get(struct backlight_device
*bd
)
2827 if (!acpi_ec_read(brightness_offset
, &level
))
2835 static int brightness_set(int value
)
2837 int cmos_cmd
, inc
, i
;
2838 int current_value
= brightness_get(NULL
);
2842 cmos_cmd
= value
> current_value
? TP_CMOS_BRIGHTNESS_UP
: TP_CMOS_BRIGHTNESS_DOWN
;
2843 inc
= value
> current_value
? 1 : -1;
2844 for (i
= current_value
; i
!= value
; i
+= inc
) {
2845 if (issue_thinkpad_cmos_command(cmos_cmd
))
2847 if (!acpi_ec_write(brightness_offset
, i
+ inc
))
2854 static int brightness_read(char *p
)
2859 if ((level
= brightness_get(NULL
)) < 0) {
2860 len
+= sprintf(p
+ len
, "level:\t\tunreadable\n");
2862 len
+= sprintf(p
+ len
, "level:\t\t%d\n", level
& 0x7);
2863 len
+= sprintf(p
+ len
, "commands:\tup, down\n");
2864 len
+= sprintf(p
+ len
, "commands:\tlevel <level>"
2865 " (<level> is 0-7)\n");
2871 static int brightness_write(char *buf
)
2877 while ((cmd
= next_cmd(&buf
))) {
2878 if ((level
= brightness_get(NULL
)) < 0)
2882 if (strlencmp(cmd
, "up") == 0) {
2883 new_level
= level
== 7 ? 7 : level
+ 1;
2884 } else if (strlencmp(cmd
, "down") == 0) {
2885 new_level
= level
== 0 ? 0 : level
- 1;
2886 } else if (sscanf(cmd
, "level %d", &new_level
) == 1 &&
2887 new_level
>= 0 && new_level
<= 7) {
2892 brightness_set(new_level
);
2898 static struct ibm_struct brightness_driver_data
= {
2899 .name
= "brightness",
2900 .read
= brightness_read
,
2901 .write
= brightness_write
,
2902 .exit
= brightness_exit
,
2905 /*************************************************************************
2909 static int volume_read(char *p
)
2914 if (!acpi_ec_read(volume_offset
, &level
)) {
2915 len
+= sprintf(p
+ len
, "level:\t\tunreadable\n");
2917 len
+= sprintf(p
+ len
, "level:\t\t%d\n", level
& 0xf);
2918 len
+= sprintf(p
+ len
, "mute:\t\t%s\n", onoff(level
, 6));
2919 len
+= sprintf(p
+ len
, "commands:\tup, down, mute\n");
2920 len
+= sprintf(p
+ len
, "commands:\tlevel <level>"
2921 " (<level> is 0-15)\n");
2927 static int volume_write(char *buf
)
2929 int cmos_cmd
, inc
, i
;
2931 int new_level
, new_mute
;
2934 while ((cmd
= next_cmd(&buf
))) {
2935 if (!acpi_ec_read(volume_offset
, &level
))
2937 new_mute
= mute
= level
& 0x40;
2938 new_level
= level
= level
& 0xf;
2940 if (strlencmp(cmd
, "up") == 0) {
2944 new_level
= level
== 15 ? 15 : level
+ 1;
2945 } else if (strlencmp(cmd
, "down") == 0) {
2949 new_level
= level
== 0 ? 0 : level
- 1;
2950 } else if (sscanf(cmd
, "level %d", &new_level
) == 1 &&
2951 new_level
>= 0 && new_level
<= 15) {
2953 } else if (strlencmp(cmd
, "mute") == 0) {
2958 if (new_level
!= level
) { /* mute doesn't change */
2959 cmos_cmd
= new_level
> level
? TP_CMOS_VOLUME_UP
: TP_CMOS_VOLUME_DOWN
;
2960 inc
= new_level
> level
? 1 : -1;
2962 if (mute
&& (issue_thinkpad_cmos_command(cmos_cmd
) ||
2963 !acpi_ec_write(volume_offset
, level
)))
2966 for (i
= level
; i
!= new_level
; i
+= inc
)
2967 if (issue_thinkpad_cmos_command(cmos_cmd
) ||
2968 !acpi_ec_write(volume_offset
, i
+ inc
))
2971 if (mute
&& (issue_thinkpad_cmos_command(TP_CMOS_VOLUME_MUTE
) ||
2972 !acpi_ec_write(volume_offset
,
2977 if (new_mute
!= mute
) { /* level doesn't change */
2978 cmos_cmd
= new_mute
? TP_CMOS_VOLUME_MUTE
: TP_CMOS_VOLUME_UP
;
2980 if (issue_thinkpad_cmos_command(cmos_cmd
) ||
2981 !acpi_ec_write(volume_offset
, level
+ new_mute
))
2989 static struct ibm_struct volume_driver_data
= {
2991 .read
= volume_read
,
2992 .write
= volume_write
,
2995 /*************************************************************************
3002 * TPACPI_FAN_RD_ACPI_GFAN:
3003 * ACPI GFAN method: returns fan level
3005 * see TPACPI_FAN_WR_ACPI_SFAN
3006 * EC 0x2f (HFSP) not available if GFAN exists
3008 * TPACPI_FAN_WR_ACPI_SFAN:
3009 * ACPI SFAN method: sets fan level, 0 (stop) to 7 (max)
3011 * EC 0x2f (HFSP) might be available *for reading*, but do not use
3014 * TPACPI_FAN_WR_TPEC:
3015 * ThinkPad EC register 0x2f (HFSP): fan control loop mode
3016 * Supported on almost all ThinkPads
3018 * Fan speed changes of any sort (including those caused by the
3019 * disengaged mode) are usually done slowly by the firmware as the
3020 * maximum ammount of fan duty cycle change per second seems to be
3023 * Reading is not available if GFAN exists.
3024 * Writing is not available if SFAN exists.
3027 * 7 automatic mode engaged;
3028 * (default operation mode of the ThinkPad)
3029 * fan level is ignored in this mode.
3030 * 6 full speed mode (takes precedence over bit 7);
3031 * not available on all thinkpads. May disable
3032 * the tachometer while the fan controller ramps up
3033 * the speed (which can take up to a few *minutes*).
3034 * Speeds up fan to 100% duty-cycle, which is far above
3035 * the standard RPM levels. It is not impossible that
3036 * it could cause hardware damage.
3037 * 5-3 unused in some models. Extra bits for fan level
3038 * in others, but still useless as all values above
3039 * 7 map to the same speed as level 7 in these models.
3040 * 2-0 fan level (0..7 usually)
3042 * 0x07 = max (set when temperatures critical)
3043 * Some ThinkPads may have other levels, see
3044 * TPACPI_FAN_WR_ACPI_FANS (X31/X40/X41)
3046 * FIRMWARE BUG: on some models, EC 0x2f might not be initialized at
3047 * boot. Apparently the EC does not intialize it, so unless ACPI DSDT
3048 * does so, its initial value is meaningless (0x07).
3050 * For firmware bugs, refer to:
3051 * http://thinkwiki.org/wiki/Embedded_Controller_Firmware#Firmware_Issues
3055 * ThinkPad EC register 0x84 (LSB), 0x85 (MSB):
3056 * Main fan tachometer reading (in RPM)
3058 * This register is present on all ThinkPads with a new-style EC, and
3059 * it is known not to be present on the A21m/e, and T22, as there is
3060 * something else in offset 0x84 according to the ACPI DSDT. Other
3061 * ThinkPads from this same time period (and earlier) probably lack the
3062 * tachometer as well.
3064 * Unfortunately a lot of ThinkPads with new-style ECs but whose firwmare
3065 * was never fixed by IBM to report the EC firmware version string
3066 * probably support the tachometer (like the early X models), so
3067 * detecting it is quite hard. We need more data to know for sure.
3069 * FIRMWARE BUG: always read 0x84 first, otherwise incorrect readings
3072 * FIRMWARE BUG: may go stale while the EC is switching to full speed
3075 * For firmware bugs, refer to:
3076 * http://thinkwiki.org/wiki/Embedded_Controller_Firmware#Firmware_Issues
3078 * TPACPI_FAN_WR_ACPI_FANS:
3079 * ThinkPad X31, X40, X41. Not available in the X60.
3081 * FANS ACPI handle: takes three arguments: low speed, medium speed,
3082 * high speed. ACPI DSDT seems to map these three speeds to levels
3083 * as follows: STOP LOW LOW MED MED HIGH HIGH HIGH HIGH
3084 * (this map is stored on FAN0..FAN8 as "0,1,1,2,2,3,3,3,3")
3086 * The speeds are stored on handles
3087 * (FANA:FAN9), (FANC:FANB), (FANE:FAND).
3089 * There are three default speed sets, acessible as handles:
3090 * FS1L,FS1M,FS1H; FS2L,FS2M,FS2H; FS3L,FS3M,FS3H
3092 * ACPI DSDT switches which set is in use depending on various
3095 * TPACPI_FAN_WR_TPEC is also available and should be used to
3096 * command the fan. The X31/X40/X41 seems to have 8 fan levels,
3097 * but the ACPI tables just mention level 7.
3100 static enum fan_status_access_mode fan_status_access_mode
;
3101 static enum fan_control_access_mode fan_control_access_mode
;
3102 static enum fan_control_commands fan_control_commands
;
3104 static u8 fan_control_initial_status
;
3105 static u8 fan_control_desired_level
;
3107 static void fan_watchdog_fire(struct work_struct
*ignored
);
3108 static int fan_watchdog_maxinterval
;
3109 static DECLARE_DELAYED_WORK(fan_watchdog_task
, fan_watchdog_fire
);
3111 IBM_HANDLE(fans
, ec
, "FANS"); /* X31, X40, X41 */
3112 IBM_HANDLE(gfan
, ec
, "GFAN", /* 570 */
3113 "\\FSPD", /* 600e/x, 770e, 770x */
3115 IBM_HANDLE(sfan
, ec
, "SFAN", /* 570 */
3116 "JFNS", /* 770x-JL */
3120 * SYSFS fan layout: hwmon compatible (device)
3123 * 0: "disengaged" mode
3125 * 2: native EC "auto" mode (recommended, hardware default)
3127 * pwm*: set speed in manual mode, ignored otherwise.
3128 * 0 is level 0; 255 is level 7. Intermediate points done with linear
3131 * fan*_input: tachometer reading, RPM
3134 * SYSFS fan layout: extensions
3136 * fan_watchdog (driver):
3137 * fan watchdog interval in seconds, 0 disables (default), max 120
3140 /* sysfs fan pwm1_enable ----------------------------------------------- */
3141 static ssize_t
fan_pwm1_enable_show(struct device
*dev
,
3142 struct device_attribute
*attr
,
3148 res
= fan_get_status_safe(&status
);
3152 if (unlikely(tp_features
.fan_ctrl_status_undef
)) {
3153 if (status
!= fan_control_initial_status
) {
3154 tp_features
.fan_ctrl_status_undef
= 0;
3156 /* Return most likely status. In fact, it
3157 * might be the only possible status */
3158 status
= TP_EC_FAN_AUTO
;
3162 if (status
& TP_EC_FAN_FULLSPEED
) {
3164 } else if (status
& TP_EC_FAN_AUTO
) {
3169 return snprintf(buf
, PAGE_SIZE
, "%d\n", mode
);
3172 static ssize_t
fan_pwm1_enable_store(struct device
*dev
,
3173 struct device_attribute
*attr
,
3174 const char *buf
, size_t count
)
3179 if (parse_strtoul(buf
, 2, &t
))
3184 level
= TP_EC_FAN_FULLSPEED
;
3187 level
= TPACPI_FAN_LAST_LEVEL
;
3190 level
= TP_EC_FAN_AUTO
;
3193 /* reserved for software-controlled auto mode */
3199 res
= fan_set_level_safe(level
);
3205 fan_watchdog_reset();
3210 static struct device_attribute dev_attr_fan_pwm1_enable
=
3211 __ATTR(pwm1_enable
, S_IWUSR
| S_IRUGO
,
3212 fan_pwm1_enable_show
, fan_pwm1_enable_store
);
3214 /* sysfs fan pwm1 ------------------------------------------------------ */
3215 static ssize_t
fan_pwm1_show(struct device
*dev
,
3216 struct device_attribute
*attr
,
3222 res
= fan_get_status_safe(&status
);
3226 if (unlikely(tp_features
.fan_ctrl_status_undef
)) {
3227 if (status
!= fan_control_initial_status
) {
3228 tp_features
.fan_ctrl_status_undef
= 0;
3230 status
= TP_EC_FAN_AUTO
;
3235 (TP_EC_FAN_AUTO
| TP_EC_FAN_FULLSPEED
)) != 0)
3236 status
= fan_control_desired_level
;
3241 return snprintf(buf
, PAGE_SIZE
, "%u\n", (status
* 255) / 7);
3244 static ssize_t
fan_pwm1_store(struct device
*dev
,
3245 struct device_attribute
*attr
,
3246 const char *buf
, size_t count
)
3250 u8 status
, newlevel
;
3252 if (parse_strtoul(buf
, 255, &s
))
3255 /* scale down from 0-255 to 0-7 */
3256 newlevel
= (s
>> 5) & 0x07;
3258 rc
= mutex_lock_interruptible(&fan_mutex
);
3262 rc
= fan_get_status(&status
);
3263 if (!rc
&& (status
&
3264 (TP_EC_FAN_AUTO
| TP_EC_FAN_FULLSPEED
)) == 0) {
3265 rc
= fan_set_level(newlevel
);
3269 fan_update_desired_level(newlevel
);
3270 fan_watchdog_reset();
3274 mutex_unlock(&fan_mutex
);
3275 return (rc
)? rc
: count
;
3278 static struct device_attribute dev_attr_fan_pwm1
=
3279 __ATTR(pwm1
, S_IWUSR
| S_IRUGO
,
3280 fan_pwm1_show
, fan_pwm1_store
);
3282 /* sysfs fan fan1_input ------------------------------------------------ */
3283 static ssize_t
fan_fan1_input_show(struct device
*dev
,
3284 struct device_attribute
*attr
,
3290 res
= fan_get_speed(&speed
);
3294 return snprintf(buf
, PAGE_SIZE
, "%u\n", speed
);
3297 static struct device_attribute dev_attr_fan_fan1_input
=
3298 __ATTR(fan1_input
, S_IRUGO
,
3299 fan_fan1_input_show
, NULL
);
3301 /* sysfs fan fan_watchdog (driver) ------------------------------------- */
3302 static ssize_t
fan_fan_watchdog_show(struct device_driver
*drv
,
3305 return snprintf(buf
, PAGE_SIZE
, "%u\n", fan_watchdog_maxinterval
);
3308 static ssize_t
fan_fan_watchdog_store(struct device_driver
*drv
,
3309 const char *buf
, size_t count
)
3313 if (parse_strtoul(buf
, 120, &t
))
3316 if (!fan_control_allowed
)
3319 fan_watchdog_maxinterval
= t
;
3320 fan_watchdog_reset();
3325 static DRIVER_ATTR(fan_watchdog
, S_IWUSR
| S_IRUGO
,
3326 fan_fan_watchdog_show
, fan_fan_watchdog_store
);
3328 /* --------------------------------------------------------------------- */
3329 static struct attribute
*fan_attributes
[] = {
3330 &dev_attr_fan_pwm1_enable
.attr
, &dev_attr_fan_pwm1
.attr
,
3331 &dev_attr_fan_fan1_input
.attr
,
3335 static const struct attribute_group fan_attr_group
= {
3336 .attrs
= fan_attributes
,
3339 static int __init
fan_init(struct ibm_init_struct
*iibm
)
3343 vdbg_printk(TPACPI_DBG_INIT
, "initializing fan subdriver\n");
3345 mutex_init(&fan_mutex
);
3346 fan_status_access_mode
= TPACPI_FAN_NONE
;
3347 fan_control_access_mode
= TPACPI_FAN_WR_NONE
;
3348 fan_control_commands
= 0;
3349 fan_watchdog_maxinterval
= 0;
3350 tp_features
.fan_ctrl_status_undef
= 0;
3351 fan_control_desired_level
= 7;
3353 IBM_ACPIHANDLE_INIT(fans
);
3354 IBM_ACPIHANDLE_INIT(gfan
);
3355 IBM_ACPIHANDLE_INIT(sfan
);
3358 /* 570, 600e/x, 770e, 770x */
3359 fan_status_access_mode
= TPACPI_FAN_RD_ACPI_GFAN
;
3361 /* all other ThinkPads: note that even old-style
3362 * ThinkPad ECs supports the fan control register */
3363 if (likely(acpi_ec_read(fan_status_offset
,
3364 &fan_control_initial_status
))) {
3365 fan_status_access_mode
= TPACPI_FAN_RD_TPEC
;
3367 /* In some ThinkPads, neither the EC nor the ACPI
3368 * DSDT initialize the fan status, and it ends up
3369 * being set to 0x07 when it *could* be either
3372 * Enable for TP-1Y (T43), TP-78 (R51e),
3373 * TP-76 (R52), TP-70 (T43, R52), which are known
3375 if (fan_control_initial_status
== 0x07 &&
3376 ibm_thinkpad_ec_found
&&
3377 ((ibm_thinkpad_ec_found
[0] == '1' &&
3378 ibm_thinkpad_ec_found
[1] == 'Y') ||
3379 (ibm_thinkpad_ec_found
[0] == '7' &&
3380 (ibm_thinkpad_ec_found
[1] == '6' ||
3381 ibm_thinkpad_ec_found
[1] == '8' ||
3382 ibm_thinkpad_ec_found
[1] == '0'))
3385 "fan_init: initial fan status is "
3386 "unknown, assuming it is in auto "
3388 tp_features
.fan_ctrl_status_undef
= 1;
3392 "ThinkPad ACPI EC access misbehaving, "
3393 "fan status and control unavailable\n");
3400 fan_control_access_mode
= TPACPI_FAN_WR_ACPI_SFAN
;
3401 fan_control_commands
|=
3402 TPACPI_FAN_CMD_LEVEL
| TPACPI_FAN_CMD_ENABLE
;
3405 /* gfan without sfan means no fan control */
3406 /* all other models implement TP EC 0x2f control */
3410 fan_control_access_mode
=
3411 TPACPI_FAN_WR_ACPI_FANS
;
3412 fan_control_commands
|=
3413 TPACPI_FAN_CMD_SPEED
|
3414 TPACPI_FAN_CMD_LEVEL
|
3415 TPACPI_FAN_CMD_ENABLE
;
3417 fan_control_access_mode
= TPACPI_FAN_WR_TPEC
;
3418 fan_control_commands
|=
3419 TPACPI_FAN_CMD_LEVEL
|
3420 TPACPI_FAN_CMD_ENABLE
;
3425 vdbg_printk(TPACPI_DBG_INIT
, "fan is %s, modes %d, %d\n",
3426 str_supported(fan_status_access_mode
!= TPACPI_FAN_NONE
||
3427 fan_control_access_mode
!= TPACPI_FAN_WR_NONE
),
3428 fan_status_access_mode
, fan_control_access_mode
);
3430 /* fan control master switch */
3431 if (!fan_control_allowed
) {
3432 fan_control_access_mode
= TPACPI_FAN_WR_NONE
;
3433 fan_control_commands
= 0;
3434 dbg_printk(TPACPI_DBG_INIT
,
3435 "fan control features disabled by parameter\n");
3438 /* update fan_control_desired_level */
3439 if (fan_status_access_mode
!= TPACPI_FAN_NONE
)
3440 fan_get_status_safe(NULL
);
3442 if (fan_status_access_mode
!= TPACPI_FAN_NONE
||
3443 fan_control_access_mode
!= TPACPI_FAN_WR_NONE
) {
3444 rc
= sysfs_create_group(&tpacpi_pdev
->dev
.kobj
,
3447 rc
= driver_create_file(&tpacpi_pdriver
.driver
,
3448 &driver_attr_fan_watchdog
);
3457 * Call with fan_mutex held
3459 static void fan_update_desired_level(u8 status
)
3462 (TP_EC_FAN_AUTO
| TP_EC_FAN_FULLSPEED
)) == 0) {
3464 fan_control_desired_level
= 7;
3466 fan_control_desired_level
= status
;
3470 static int fan_get_status(u8
*status
)
3475 * Add TPACPI_FAN_RD_ACPI_FANS ? */
3477 switch (fan_status_access_mode
) {
3478 case TPACPI_FAN_RD_ACPI_GFAN
:
3479 /* 570, 600e/x, 770e, 770x */
3481 if (unlikely(!acpi_evalf(gfan_handle
, &s
, NULL
, "d")))
3489 case TPACPI_FAN_RD_TPEC
:
3490 /* all except 570, 600e/x, 770e, 770x */
3491 if (unlikely(!acpi_ec_read(fan_status_offset
, &s
)))
3506 static int fan_get_status_safe(u8
*status
)
3511 rc
= mutex_lock_interruptible(&fan_mutex
);
3514 rc
= fan_get_status(&s
);
3516 fan_update_desired_level(s
);
3517 mutex_unlock(&fan_mutex
);
3525 static void fan_exit(void)
3527 vdbg_printk(TPACPI_DBG_EXIT
, "cancelling any pending fan watchdog tasks\n");
3529 /* FIXME: can we really do this unconditionally? */
3530 sysfs_remove_group(&tpacpi_pdev
->dev
.kobj
, &fan_attr_group
);
3531 driver_remove_file(&tpacpi_pdriver
.driver
, &driver_attr_fan_watchdog
);
3533 cancel_delayed_work(&fan_watchdog_task
);
3534 flush_scheduled_work();
3537 static int fan_get_speed(unsigned int *speed
)
3541 switch (fan_status_access_mode
) {
3542 case TPACPI_FAN_RD_TPEC
:
3543 /* all except 570, 600e/x, 770e, 770x */
3544 if (unlikely(!acpi_ec_read(fan_rpm_offset
, &lo
) ||
3545 !acpi_ec_read(fan_rpm_offset
+ 1, &hi
)))
3549 *speed
= (hi
<< 8) | lo
;
3560 static void fan_watchdog_fire(struct work_struct
*ignored
)
3564 printk(IBM_NOTICE
"fan watchdog: enabling fan\n");
3565 rc
= fan_set_enable();
3567 printk(IBM_ERR
"fan watchdog: error %d while enabling fan, "
3568 "will try again later...\n", -rc
);
3569 /* reschedule for later */
3570 fan_watchdog_reset();
3574 static void fan_watchdog_reset(void)
3576 static int fan_watchdog_active
;
3578 if (fan_control_access_mode
== TPACPI_FAN_WR_NONE
)
3581 if (fan_watchdog_active
)
3582 cancel_delayed_work(&fan_watchdog_task
);
3584 if (fan_watchdog_maxinterval
> 0) {
3585 fan_watchdog_active
= 1;
3586 if (!schedule_delayed_work(&fan_watchdog_task
,
3587 msecs_to_jiffies(fan_watchdog_maxinterval
3589 printk(IBM_ERR
"failed to schedule the fan watchdog, "
3590 "watchdog will not trigger\n");
3593 fan_watchdog_active
= 0;
3596 static int fan_set_level(int level
)
3598 if (!fan_control_allowed
)
3601 switch (fan_control_access_mode
) {
3602 case TPACPI_FAN_WR_ACPI_SFAN
:
3603 if (level
>= 0 && level
<= 7) {
3604 if (!acpi_evalf(sfan_handle
, NULL
, NULL
, "vd", level
))
3610 case TPACPI_FAN_WR_ACPI_FANS
:
3611 case TPACPI_FAN_WR_TPEC
:
3612 if ((level
!= TP_EC_FAN_AUTO
) &&
3613 (level
!= TP_EC_FAN_FULLSPEED
) &&
3614 ((level
< 0) || (level
> 7)))
3617 /* safety net should the EC not support AUTO
3618 * or FULLSPEED mode bits and just ignore them */
3619 if (level
& TP_EC_FAN_FULLSPEED
)
3620 level
|= 7; /* safety min speed 7 */
3621 else if (level
& TP_EC_FAN_FULLSPEED
)
3622 level
|= 4; /* safety min speed 4 */
3624 if (!acpi_ec_write(fan_status_offset
, level
))
3627 tp_features
.fan_ctrl_status_undef
= 0;
3636 static int fan_set_level_safe(int level
)
3640 if (!fan_control_allowed
)
3643 rc
= mutex_lock_interruptible(&fan_mutex
);
3647 if (level
== TPACPI_FAN_LAST_LEVEL
)
3648 level
= fan_control_desired_level
;
3650 rc
= fan_set_level(level
);
3652 fan_update_desired_level(level
);
3654 mutex_unlock(&fan_mutex
);
3658 static int fan_set_enable(void)
3663 if (!fan_control_allowed
)
3666 rc
= mutex_lock_interruptible(&fan_mutex
);
3670 switch (fan_control_access_mode
) {
3671 case TPACPI_FAN_WR_ACPI_FANS
:
3672 case TPACPI_FAN_WR_TPEC
:
3673 rc
= fan_get_status(&s
);
3677 /* Don't go out of emergency fan mode */
3680 s
|= TP_EC_FAN_AUTO
| 4; /* min fan speed 4 */
3683 if (!acpi_ec_write(fan_status_offset
, s
))
3686 tp_features
.fan_ctrl_status_undef
= 0;
3691 case TPACPI_FAN_WR_ACPI_SFAN
:
3692 rc
= fan_get_status(&s
);
3698 /* Set fan to at least level 4 */
3701 if (!acpi_evalf(sfan_handle
, NULL
, NULL
, "vd", s
))
3711 mutex_unlock(&fan_mutex
);
3715 static int fan_set_disable(void)
3719 if (!fan_control_allowed
)
3722 rc
= mutex_lock_interruptible(&fan_mutex
);
3727 switch (fan_control_access_mode
) {
3728 case TPACPI_FAN_WR_ACPI_FANS
:
3729 case TPACPI_FAN_WR_TPEC
:
3730 if (!acpi_ec_write(fan_status_offset
, 0x00))
3733 fan_control_desired_level
= 0;
3734 tp_features
.fan_ctrl_status_undef
= 0;
3738 case TPACPI_FAN_WR_ACPI_SFAN
:
3739 if (!acpi_evalf(sfan_handle
, NULL
, NULL
, "vd", 0x00))
3742 fan_control_desired_level
= 0;
3750 mutex_unlock(&fan_mutex
);
3754 static int fan_set_speed(int speed
)
3758 if (!fan_control_allowed
)
3761 rc
= mutex_lock_interruptible(&fan_mutex
);
3766 switch (fan_control_access_mode
) {
3767 case TPACPI_FAN_WR_ACPI_FANS
:
3768 if (speed
>= 0 && speed
<= 65535) {
3769 if (!acpi_evalf(fans_handle
, NULL
, NULL
, "vddd",
3770 speed
, speed
, speed
))
3780 mutex_unlock(&fan_mutex
);
3784 static int fan_read(char *p
)
3789 unsigned int speed
= 0;
3791 switch (fan_status_access_mode
) {
3792 case TPACPI_FAN_RD_ACPI_GFAN
:
3793 /* 570, 600e/x, 770e, 770x */
3794 if ((rc
= fan_get_status_safe(&status
)) < 0)
3797 len
+= sprintf(p
+ len
, "status:\t\t%s\n"
3799 (status
!= 0) ? "enabled" : "disabled", status
);
3802 case TPACPI_FAN_RD_TPEC
:
3803 /* all except 570, 600e/x, 770e, 770x */
3804 if ((rc
= fan_get_status_safe(&status
)) < 0)
3807 if (unlikely(tp_features
.fan_ctrl_status_undef
)) {
3808 if (status
!= fan_control_initial_status
)
3809 tp_features
.fan_ctrl_status_undef
= 0;
3811 /* Return most likely status. In fact, it
3812 * might be the only possible status */
3813 status
= TP_EC_FAN_AUTO
;
3816 len
+= sprintf(p
+ len
, "status:\t\t%s\n",
3817 (status
!= 0) ? "enabled" : "disabled");
3819 if ((rc
= fan_get_speed(&speed
)) < 0)
3822 len
+= sprintf(p
+ len
, "speed:\t\t%d\n", speed
);
3824 if (status
& TP_EC_FAN_FULLSPEED
)
3825 /* Disengaged mode takes precedence */
3826 len
+= sprintf(p
+ len
, "level:\t\tdisengaged\n");
3827 else if (status
& TP_EC_FAN_AUTO
)
3828 len
+= sprintf(p
+ len
, "level:\t\tauto\n");
3830 len
+= sprintf(p
+ len
, "level:\t\t%d\n", status
);
3833 case TPACPI_FAN_NONE
:
3835 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
3838 if (fan_control_commands
& TPACPI_FAN_CMD_LEVEL
) {
3839 len
+= sprintf(p
+ len
, "commands:\tlevel <level>");
3841 switch (fan_control_access_mode
) {
3842 case TPACPI_FAN_WR_ACPI_SFAN
:
3843 len
+= sprintf(p
+ len
, " (<level> is 0-7)\n");
3847 len
+= sprintf(p
+ len
, " (<level> is 0-7, "
3848 "auto, disengaged, full-speed)\n");
3853 if (fan_control_commands
& TPACPI_FAN_CMD_ENABLE
)
3854 len
+= sprintf(p
+ len
, "commands:\tenable, disable\n"
3855 "commands:\twatchdog <timeout> (<timeout> is 0 (off), "
3856 "1-120 (seconds))\n");
3858 if (fan_control_commands
& TPACPI_FAN_CMD_SPEED
)
3859 len
+= sprintf(p
+ len
, "commands:\tspeed <speed>"
3860 " (<speed> is 0-65535)\n");
3865 static int fan_write_cmd_level(const char *cmd
, int *rc
)
3869 if (strlencmp(cmd
, "level auto") == 0)
3870 level
= TP_EC_FAN_AUTO
;
3871 else if ((strlencmp(cmd
, "level disengaged") == 0) |
3872 (strlencmp(cmd
, "level full-speed") == 0))
3873 level
= TP_EC_FAN_FULLSPEED
;
3874 else if (sscanf(cmd
, "level %d", &level
) != 1)
3877 if ((*rc
= fan_set_level_safe(level
)) == -ENXIO
)
3878 printk(IBM_ERR
"level command accepted for unsupported "
3879 "access mode %d", fan_control_access_mode
);
3884 static int fan_write_cmd_enable(const char *cmd
, int *rc
)
3886 if (strlencmp(cmd
, "enable") != 0)
3889 if ((*rc
= fan_set_enable()) == -ENXIO
)
3890 printk(IBM_ERR
"enable command accepted for unsupported "
3891 "access mode %d", fan_control_access_mode
);
3896 static int fan_write_cmd_disable(const char *cmd
, int *rc
)
3898 if (strlencmp(cmd
, "disable") != 0)
3901 if ((*rc
= fan_set_disable()) == -ENXIO
)
3902 printk(IBM_ERR
"disable command accepted for unsupported "
3903 "access mode %d", fan_control_access_mode
);
3908 static int fan_write_cmd_speed(const char *cmd
, int *rc
)
3913 * Support speed <low> <medium> <high> ? */
3915 if (sscanf(cmd
, "speed %d", &speed
) != 1)
3918 if ((*rc
= fan_set_speed(speed
)) == -ENXIO
)
3919 printk(IBM_ERR
"speed command accepted for unsupported "
3920 "access mode %d", fan_control_access_mode
);
3925 static int fan_write_cmd_watchdog(const char *cmd
, int *rc
)
3929 if (sscanf(cmd
, "watchdog %d", &interval
) != 1)
3932 if (interval
< 0 || interval
> 120)
3935 fan_watchdog_maxinterval
= interval
;
3940 static int fan_write(char *buf
)
3945 while (!rc
&& (cmd
= next_cmd(&buf
))) {
3946 if (!((fan_control_commands
& TPACPI_FAN_CMD_LEVEL
) &&
3947 fan_write_cmd_level(cmd
, &rc
)) &&
3948 !((fan_control_commands
& TPACPI_FAN_CMD_ENABLE
) &&
3949 (fan_write_cmd_enable(cmd
, &rc
) ||
3950 fan_write_cmd_disable(cmd
, &rc
) ||
3951 fan_write_cmd_watchdog(cmd
, &rc
))) &&
3952 !((fan_control_commands
& TPACPI_FAN_CMD_SPEED
) &&
3953 fan_write_cmd_speed(cmd
, &rc
))
3957 fan_watchdog_reset();
3963 static struct ibm_struct fan_driver_data
= {
3970 /****************************************************************************
3971 ****************************************************************************
3975 ****************************************************************************
3976 ****************************************************************************/
3979 static struct proc_dir_entry
*proc_dir
;
3981 /* Subdriver registry */
3982 static LIST_HEAD(tpacpi_all_drivers
);
3986 * Module and infrastructure proble, init and exit handling
3989 #ifdef CONFIG_THINKPAD_ACPI_DEBUG
3990 static const char * __init
str_supported(int is_supported
)
3992 static char text_unsupported
[] __initdata
= "not supported";
3994 return (is_supported
)? &text_unsupported
[4] : &text_unsupported
[0];
3996 #endif /* CONFIG_THINKPAD_ACPI_DEBUG */
3998 static int __init
ibm_init(struct ibm_init_struct
*iibm
)
4001 struct ibm_struct
*ibm
= iibm
->data
;
4002 struct proc_dir_entry
*entry
;
4004 BUG_ON(ibm
== NULL
);
4006 INIT_LIST_HEAD(&ibm
->all_drivers
);
4008 if (ibm
->flags
.experimental
&& !experimental
)
4011 dbg_printk(TPACPI_DBG_INIT
,
4012 "probing for %s\n", ibm
->name
);
4015 ret
= iibm
->init(iibm
);
4017 return 0; /* probe failed */
4021 ibm
->flags
.init_called
= 1;
4025 if (ibm
->acpi
->hid
) {
4026 ret
= register_tpacpi_subdriver(ibm
);
4031 if (ibm
->acpi
->notify
) {
4032 ret
= setup_acpi_notify(ibm
);
4033 if (ret
== -ENODEV
) {
4034 printk(IBM_NOTICE
"disabling subdriver %s\n",
4044 dbg_printk(TPACPI_DBG_INIT
,
4045 "%s installed\n", ibm
->name
);
4048 entry
= create_proc_entry(ibm
->name
,
4049 S_IFREG
| S_IRUGO
| S_IWUSR
,
4052 printk(IBM_ERR
"unable to create proc entry %s\n",
4057 entry
->owner
= THIS_MODULE
;
4059 entry
->read_proc
= &dispatch_procfs_read
;
4061 entry
->write_proc
= &dispatch_procfs_write
;
4062 ibm
->flags
.proc_created
= 1;
4065 list_add_tail(&ibm
->all_drivers
, &tpacpi_all_drivers
);
4070 dbg_printk(TPACPI_DBG_INIT
,
4071 "%s: at error exit path with result %d\n",
4075 return (ret
< 0)? ret
: 0;
4078 static void ibm_exit(struct ibm_struct
*ibm
)
4080 dbg_printk(TPACPI_DBG_EXIT
, "removing %s\n", ibm
->name
);
4082 list_del_init(&ibm
->all_drivers
);
4084 if (ibm
->flags
.acpi_notify_installed
) {
4085 dbg_printk(TPACPI_DBG_EXIT
,
4086 "%s: acpi_remove_notify_handler\n", ibm
->name
);
4088 acpi_remove_notify_handler(*ibm
->acpi
->handle
,
4090 dispatch_acpi_notify
);
4091 ibm
->flags
.acpi_notify_installed
= 0;
4092 ibm
->flags
.acpi_notify_installed
= 0;
4095 if (ibm
->flags
.proc_created
) {
4096 dbg_printk(TPACPI_DBG_EXIT
,
4097 "%s: remove_proc_entry\n", ibm
->name
);
4098 remove_proc_entry(ibm
->name
, proc_dir
);
4099 ibm
->flags
.proc_created
= 0;
4102 if (ibm
->flags
.acpi_driver_registered
) {
4103 dbg_printk(TPACPI_DBG_EXIT
,
4104 "%s: acpi_bus_unregister_driver\n", ibm
->name
);
4106 acpi_bus_unregister_driver(ibm
->acpi
->driver
);
4107 kfree(ibm
->acpi
->driver
);
4108 ibm
->acpi
->driver
= NULL
;
4109 ibm
->flags
.acpi_driver_registered
= 0;
4112 if (ibm
->flags
.init_called
&& ibm
->exit
) {
4114 ibm
->flags
.init_called
= 0;
4117 dbg_printk(TPACPI_DBG_INIT
, "finished removing %s\n", ibm
->name
);
4122 static char *ibm_thinkpad_ec_found
;
4124 static char* __init
check_dmi_for_ec(void)
4126 struct dmi_device
*dev
= NULL
;
4127 char ec_fw_string
[18];
4130 * ThinkPad T23 or newer, A31 or newer, R50e or newer,
4131 * X32 or newer, all Z series; Some models must have an
4132 * up-to-date BIOS or they will not be detected.
4134 * See http://thinkwiki.org/wiki/List_of_DMI_IDs
4136 while ((dev
= dmi_find_device(DMI_DEV_TYPE_OEM_STRING
, NULL
, dev
))) {
4137 if (sscanf(dev
->name
,
4138 "IBM ThinkPad Embedded Controller -[%17c",
4139 ec_fw_string
) == 1) {
4140 ec_fw_string
[sizeof(ec_fw_string
) - 1] = 0;
4141 ec_fw_string
[strcspn(ec_fw_string
, " ]")] = 0;
4142 return kstrdup(ec_fw_string
, GFP_KERNEL
);
4148 static int __init
probe_for_thinkpad(void)
4156 * Non-ancient models have better DMI tagging, but very old models
4159 is_thinkpad
= dmi_name_in_vendors("ThinkPad");
4161 /* ec is required because many other handles are relative to it */
4162 IBM_ACPIHANDLE_INIT(ec
);
4166 "Not yet supported ThinkPad detected!\n");
4171 * Risks a regression on very old machines, but reduces potential
4172 * false positives a damn great deal
4175 is_thinkpad
= dmi_name_in_vendors("IBM");
4177 if (!is_thinkpad
&& !force_load
)
4184 /* Module init, exit, parameters */
4186 static struct ibm_init_struct ibms_init
[] __initdata
= {
4188 .init
= thinkpad_acpi_driver_init
,
4189 .data
= &thinkpad_acpi_driver_data
,
4192 .init
= hotkey_init
,
4193 .data
= &hotkey_driver_data
,
4196 .init
= bluetooth_init
,
4197 .data
= &bluetooth_driver_data
,
4201 .data
= &wan_driver_data
,
4205 .data
= &video_driver_data
,
4209 .data
= &light_driver_data
,
4211 #ifdef CONFIG_THINKPAD_ACPI_DOCK
4214 .data
= &dock_driver_data
[0],
4218 .data
= &dock_driver_data
[1],
4221 #ifdef CONFIG_THINKPAD_ACPI_BAY
4224 .data
= &bay_driver_data
,
4229 .data
= &cmos_driver_data
,
4233 .data
= &led_driver_data
,
4237 .data
= &beep_driver_data
,
4240 .init
= thermal_init
,
4241 .data
= &thermal_driver_data
,
4244 .data
= &ecdump_driver_data
,
4247 .init
= brightness_init
,
4248 .data
= &brightness_driver_data
,
4251 .data
= &volume_driver_data
,
4255 .data
= &fan_driver_data
,
4259 static int __init
set_ibm_param(const char *val
, struct kernel_param
*kp
)
4262 struct ibm_struct
*ibm
;
4264 for (i
= 0; i
< ARRAY_SIZE(ibms_init
); i
++) {
4265 ibm
= ibms_init
[i
].data
;
4266 BUG_ON(ibm
== NULL
);
4268 if (strcmp(ibm
->name
, kp
->name
) == 0 && ibm
->write
) {
4269 if (strlen(val
) > sizeof(ibms_init
[i
].param
) - 2)
4271 strcpy(ibms_init
[i
].param
, val
);
4272 strcat(ibms_init
[i
].param
, ",");
4280 static int experimental
;
4281 module_param(experimental
, int, 0);
4283 static u32 dbg_level
;
4284 module_param_named(debug
, dbg_level
, uint
, 0);
4286 static int force_load
;
4287 module_param(force_load
, int, 0);
4289 static int fan_control_allowed
;
4290 module_param_named(fan_control
, fan_control_allowed
, int, 0);
4292 #define IBM_PARAM(feature) \
4293 module_param_call(feature, set_ibm_param, NULL, NULL, 0)
4296 IBM_PARAM(bluetooth
);
4299 #ifdef CONFIG_THINKPAD_ACPI_DOCK
4302 #ifdef CONFIG_THINKPAD_ACPI_BAY
4304 #endif /* CONFIG_THINKPAD_ACPI_BAY */
4309 IBM_PARAM(brightness
);
4313 static int __init
thinkpad_acpi_module_init(void)
4317 /* Driver-level probe */
4318 ret
= probe_for_thinkpad();
4322 /* Driver initialization */
4323 ibm_thinkpad_ec_found
= check_dmi_for_ec();
4324 IBM_ACPIHANDLE_INIT(ecrd
);
4325 IBM_ACPIHANDLE_INIT(ecwr
);
4327 proc_dir
= proc_mkdir(IBM_PROC_DIR
, acpi_root_dir
);
4329 printk(IBM_ERR
"unable to create proc dir " IBM_PROC_DIR
);
4330 thinkpad_acpi_module_exit();
4333 proc_dir
->owner
= THIS_MODULE
;
4335 ret
= platform_driver_register(&tpacpi_pdriver
);
4337 printk(IBM_ERR
"unable to register platform driver\n");
4338 thinkpad_acpi_module_exit();
4341 ret
= tpacpi_create_driver_attributes(&tpacpi_pdriver
.driver
);
4343 printk(IBM_ERR
"unable to create sysfs driver attributes\n");
4344 thinkpad_acpi_module_exit();
4349 /* Device initialization */
4350 tpacpi_pdev
= platform_device_register_simple(IBM_DRVR_NAME
, -1,
4352 if (IS_ERR(tpacpi_pdev
)) {
4353 ret
= PTR_ERR(tpacpi_pdev
);
4355 printk(IBM_ERR
"unable to register platform device\n");
4356 thinkpad_acpi_module_exit();
4359 tpacpi_hwmon
= hwmon_device_register(&tpacpi_pdev
->dev
);
4360 if (IS_ERR(tpacpi_hwmon
)) {
4361 ret
= PTR_ERR(tpacpi_hwmon
);
4362 tpacpi_hwmon
= NULL
;
4363 printk(IBM_ERR
"unable to register hwmon device\n");
4364 thinkpad_acpi_module_exit();
4367 for (i
= 0; i
< ARRAY_SIZE(ibms_init
); i
++) {
4368 ret
= ibm_init(&ibms_init
[i
]);
4369 if (ret
>= 0 && *ibms_init
[i
].param
)
4370 ret
= ibms_init
[i
].data
->write(ibms_init
[i
].param
);
4372 thinkpad_acpi_module_exit();
4380 static void thinkpad_acpi_module_exit(void)
4382 struct ibm_struct
*ibm
, *itmp
;
4384 list_for_each_entry_safe_reverse(ibm
, itmp
,
4385 &tpacpi_all_drivers
,
4390 dbg_printk(TPACPI_DBG_INIT
, "finished subdriver exit path...\n");
4393 hwmon_device_unregister(tpacpi_hwmon
);
4396 platform_device_unregister(tpacpi_pdev
);
4398 tpacpi_remove_driver_attributes(&tpacpi_pdriver
.driver
);
4399 platform_driver_unregister(&tpacpi_pdriver
);
4402 remove_proc_entry(IBM_PROC_DIR
, acpi_root_dir
);
4404 kfree(ibm_thinkpad_ec_found
);
4407 module_init(thinkpad_acpi_module_init
);
4408 module_exit(thinkpad_acpi_module_exit
);