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"
28 * 2007-03-27 0.14 renamed to thinkpad_acpi and moved to
31 * 2006-11-22 0.13 new maintainer
32 * changelog now lives in git commit history, and will
33 * not be updated further in-file.
35 * 2005-08-17 0.12 fix compilation on 2.6.13-rc kernels
36 * 2005-03-17 0.11 support for 600e, 770x
37 * thanks to Jamie Lentin <lentinj@dial.pipex.com>
38 * support for 770e, G41
39 * G40 and G41 don't have a thinklight
40 * temperatures no longer experimental
41 * experimental brightness control
42 * experimental volume control
43 * experimental fan enable/disable
44 * 2005-01-16 0.10 fix module loading on R30, R31
45 * 2005-01-16 0.9 support for 570, R30, R31
46 * ultrabay support on A22p, A3x
47 * limit arg for cmos, led, beep, drop experimental status
48 * more capable led control on A21e, A22p, T20-22, X20
49 * experimental temperatures and fan speed
50 * experimental embedded controller register dump
51 * mark more functions as __init, drop incorrect __exit
53 * thanks to Henrik Brix Andersen <brix@gentoo.org>
54 * fix parameter passing on module loading
55 * thanks to Rusty Russell <rusty@rustcorp.com.au>
56 * thanks to Jim Radford <radford@blackbean.org>
57 * 2004-11-08 0.8 fix init error case, don't return from a macro
58 * thanks to Chris Wright <chrisw@osdl.org>
59 * 2004-10-23 0.7 fix module loading on A21e, A22p, T20, T21, X20
60 * fix led control on A21e
61 * 2004-10-19 0.6 use acpi_bus_register_driver() to claim HKEY device
62 * 2004-10-18 0.5 thinklight support on A21e, G40, R32, T20, T21, X20
63 * proc file format changed
64 * video_switch command
65 * experimental cmos control
66 * experimental led control
67 * experimental acpi sounds
68 * 2004-09-16 0.4 support for module parameters
69 * hotkey mask can be prefixed by 0x
70 * video output switching
71 * video expansion control
72 * ultrabay eject support
73 * removed lcd brightness/on/off control, didn't work
74 * 2004-08-17 0.3 support for R40
75 * lcd off, brightness control
77 * 2004-08-14 0.2 support for T series, X20
78 * bluetooth enable/disable
79 * hotkey events disabled by default
80 * removed fan control, currently useless
81 * 2004-08-09 0.1 initial release, support for X series
84 #include "thinkpad_acpi.h"
86 MODULE_AUTHOR("Borislav Deianov, Henrique de Moraes Holschuh");
87 MODULE_DESCRIPTION(IBM_DESC
);
88 MODULE_VERSION(IBM_VERSION
);
89 MODULE_LICENSE("GPL");
91 /* Please remove this in year 2009 */
92 MODULE_ALIAS("ibm_acpi");
94 #define __unused __attribute__ ((unused))
96 /****************************************************************************
97 ****************************************************************************
99 * ACPI Helpers and device model
101 ****************************************************************************
102 ****************************************************************************/
104 /*************************************************************************
108 static acpi_handle root_handle
= NULL
;
110 #define IBM_HANDLE(object, parent, paths...) \
111 static acpi_handle object##_handle; \
112 static acpi_handle *object##_parent = &parent##_handle; \
113 static char *object##_path; \
114 static char *object##_paths[] = { paths }
116 IBM_HANDLE(ec
, root
, "\\_SB.PCI0.ISA.EC0", /* 240, 240x */
117 "\\_SB.PCI.ISA.EC", /* 570 */
118 "\\_SB.PCI0.ISA0.EC0", /* 600e/x, 770e, 770x */
119 "\\_SB.PCI0.ISA.EC", /* A21e, A2xm/p, T20-22, X20-21 */
120 "\\_SB.PCI0.AD4S.EC0", /* i1400, R30 */
121 "\\_SB.PCI0.ICH3.EC0", /* R31 */
122 "\\_SB.PCI0.LPC.EC", /* all others */
125 IBM_HANDLE(ecrd
, ec
, "ECRD"); /* 570 */
126 IBM_HANDLE(ecwr
, ec
, "ECWR"); /* 570 */
129 /*************************************************************************
133 IBM_HANDLE(cmos
, root
, "\\UCMS", /* R50, R50e, R50p, R51, T4x, X31, X40 */
134 "\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */
135 "\\CMS", /* R40, R40e */
138 IBM_HANDLE(hkey
, ec
, "\\_SB.HKEY", /* 600e/x, 770e, 770x */
139 "^HKEY", /* R30, R31 */
140 "HKEY", /* all others */
144 /*************************************************************************
148 static int acpi_evalf(acpi_handle handle
,
149 void *res
, char *method
, char *fmt
, ...)
152 struct acpi_object_list params
;
153 union acpi_object in_objs
[IBM_MAX_ACPI_ARGS
];
154 struct acpi_buffer result
, *resultp
;
155 union acpi_object out_obj
;
163 printk(IBM_ERR
"acpi_evalf() called with empty format\n");
176 params
.pointer
= &in_objs
[0];
183 in_objs
[params
.count
].integer
.value
= va_arg(ap
, int);
184 in_objs
[params
.count
++].type
= ACPI_TYPE_INTEGER
;
186 /* add more types as needed */
188 printk(IBM_ERR
"acpi_evalf() called "
189 "with invalid format character '%c'\n", c
);
195 if (res_type
!= 'v') {
196 result
.length
= sizeof(out_obj
);
197 result
.pointer
= &out_obj
;
202 status
= acpi_evaluate_object(handle
, method
, ¶ms
, resultp
);
207 *(int *)res
= out_obj
.integer
.value
;
208 success
= status
== AE_OK
&& out_obj
.type
== ACPI_TYPE_INTEGER
;
211 success
= status
== AE_OK
;
213 /* add more types as needed */
215 printk(IBM_ERR
"acpi_evalf() called "
216 "with invalid format character '%c'\n", res_type
);
220 if (!success
&& !quiet
)
221 printk(IBM_ERR
"acpi_evalf(%s, %s, ...) failed: %d\n",
222 method
, fmt0
, status
);
227 static void __unused
acpi_print_int(acpi_handle handle
, char *method
)
231 if (acpi_evalf(handle
, &i
, method
, "d"))
232 printk(IBM_INFO
"%s = 0x%x\n", method
, i
);
234 printk(IBM_ERR
"error calling %s\n", method
);
237 static int acpi_ec_read(int i
, u8
* p
)
242 if (!acpi_evalf(ecrd_handle
, &v
, NULL
, "dd", i
))
246 if (ec_read(i
, p
) < 0)
253 static int acpi_ec_write(int i
, u8 v
)
256 if (!acpi_evalf(ecwr_handle
, NULL
, NULL
, "vdd", i
, v
))
259 if (ec_write(i
, v
) < 0)
266 static int _sta(acpi_handle handle
)
270 if (!handle
|| !acpi_evalf(handle
, &status
, "_STA", "d"))
276 /*************************************************************************
280 static void __init
ibm_handle_init(char *name
,
281 acpi_handle
* handle
, acpi_handle parent
,
282 char **paths
, int num_paths
, char **path
)
287 for (i
= 0; i
< num_paths
; i
++) {
288 status
= acpi_get_handle(parent
, paths
[i
], handle
);
289 if (ACPI_SUCCESS(status
)) {
298 static void dispatch_notify(acpi_handle handle
, u32 event
, void *data
)
300 struct ibm_struct
*ibm
= data
;
302 if (!ibm
|| !ibm
->notify
)
305 ibm
->notify(ibm
, event
);
308 static int __init
setup_notify(struct ibm_struct
*ibm
)
316 ret
= acpi_bus_get_device(*ibm
->handle
, &ibm
->device
);
318 printk(IBM_ERR
"%s device not present\n", ibm
->name
);
322 acpi_driver_data(ibm
->device
) = ibm
;
323 sprintf(acpi_device_class(ibm
->device
), "%s/%s",
324 IBM_ACPI_EVENT_PREFIX
,
327 status
= acpi_install_notify_handler(*ibm
->handle
, ibm
->type
,
328 dispatch_notify
, ibm
);
329 if (ACPI_FAILURE(status
)) {
330 if (status
== AE_ALREADY_EXISTS
) {
331 printk(IBM_NOTICE
"another device driver is already handling %s events\n",
334 printk(IBM_ERR
"acpi_install_notify_handler(%s) failed: %d\n",
339 ibm
->notify_installed
= 1;
343 static int __init
ibm_device_add(struct acpi_device
*device
)
348 static int __init
register_tpacpi_subdriver(struct ibm_struct
*ibm
)
352 ibm
->driver
= kzalloc(sizeof(struct acpi_driver
), GFP_KERNEL
);
354 printk(IBM_ERR
"kmalloc(ibm->driver) failed\n");
358 sprintf(ibm
->driver
->name
, "%s_%s", IBM_NAME
, ibm
->name
);
359 ibm
->driver
->ids
= ibm
->hid
;
360 ibm
->driver
->ops
.add
= &ibm_device_add
;
362 ret
= acpi_bus_register_driver(ibm
->driver
);
364 printk(IBM_ERR
"acpi_bus_register_driver(%s) failed: %d\n",
373 /****************************************************************************
374 ****************************************************************************
378 ****************************************************************************
379 ****************************************************************************/
381 static int dispatch_read(char *page
, char **start
, off_t off
, int count
,
382 int *eof
, void *data
)
384 struct ibm_struct
*ibm
= data
;
387 if (!ibm
|| !ibm
->read
)
390 len
= ibm
->read(page
);
394 if (len
<= off
+ count
)
406 static int dispatch_write(struct file
*file
, const char __user
* userbuf
,
407 unsigned long count
, void *data
)
409 struct ibm_struct
*ibm
= data
;
413 if (!ibm
|| !ibm
->write
)
416 kernbuf
= kmalloc(count
+ 2, GFP_KERNEL
);
420 if (copy_from_user(kernbuf
, userbuf
, count
)) {
426 strcat(kernbuf
, ",");
427 ret
= ibm
->write(kernbuf
);
436 static char *next_cmd(char **cmds
)
441 while ((end
= strchr(start
, ',')) && end
== start
)
453 /****************************************************************************
454 ****************************************************************************
458 ****************************************************************************
459 ****************************************************************************/
461 /*************************************************************************
462 * ibm-acpi init subdriver
465 static int thinkpad_acpi_driver_init(void)
467 printk(IBM_INFO
"%s v%s\n", IBM_DESC
, IBM_VERSION
);
468 printk(IBM_INFO
"%s\n", IBM_URL
);
470 if (ibm_thinkpad_ec_found
)
471 printk(IBM_INFO
"ThinkPad EC firmware %s\n",
472 ibm_thinkpad_ec_found
);
477 static int thinkpad_acpi_driver_read(char *p
)
481 len
+= sprintf(p
+ len
, "driver:\t\t%s\n", IBM_DESC
);
482 len
+= sprintf(p
+ len
, "version:\t%s\n", IBM_VERSION
);
487 /*************************************************************************
491 static int hotkey_supported
;
492 static int hotkey_mask_supported
;
493 static int hotkey_orig_status
;
494 static int hotkey_orig_mask
;
496 static int hotkey_init(void)
498 /* hotkey not supported on 570 */
499 hotkey_supported
= hkey_handle
!= NULL
;
501 if (hotkey_supported
) {
502 /* mask not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
503 A30, R30, R31, T20-22, X20-21, X22-24 */
504 hotkey_mask_supported
=
505 acpi_evalf(hkey_handle
, NULL
, "DHKN", "qv");
507 if (!hotkey_get(&hotkey_orig_status
, &hotkey_orig_mask
))
514 static void hotkey_exit(void)
516 if (hotkey_supported
)
517 hotkey_set(hotkey_orig_status
, hotkey_orig_mask
);
520 static void hotkey_notify(struct ibm_struct
*ibm
, u32 event
)
524 if (acpi_evalf(hkey_handle
, &hkey
, "MHKP", "d"))
525 acpi_bus_generate_event(ibm
->device
, event
, hkey
);
527 printk(IBM_ERR
"unknown hotkey event %d\n", event
);
528 acpi_bus_generate_event(ibm
->device
, event
, 0);
532 static int hotkey_get(int *status
, int *mask
)
534 if (!acpi_evalf(hkey_handle
, status
, "DHKC", "d"))
537 if (hotkey_mask_supported
)
538 if (!acpi_evalf(hkey_handle
, mask
, "DHKN", "d"))
544 static int hotkey_set(int status
, int mask
)
548 if (!acpi_evalf(hkey_handle
, NULL
, "MHKC", "vd", status
))
551 if (hotkey_mask_supported
)
552 for (i
= 0; i
< 32; i
++) {
553 int bit
= ((1 << i
) & mask
) != 0;
554 if (!acpi_evalf(hkey_handle
,
555 NULL
, "MHKM", "vdd", i
+ 1, bit
))
562 static int hotkey_read(char *p
)
567 if (!hotkey_supported
) {
568 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
572 if (!hotkey_get(&status
, &mask
))
575 len
+= sprintf(p
+ len
, "status:\t\t%s\n", enabled(status
, 0));
576 if (hotkey_mask_supported
) {
577 len
+= sprintf(p
+ len
, "mask:\t\t0x%04x\n", mask
);
578 len
+= sprintf(p
+ len
,
579 "commands:\tenable, disable, reset, <mask>\n");
581 len
+= sprintf(p
+ len
, "mask:\t\tnot supported\n");
582 len
+= sprintf(p
+ len
, "commands:\tenable, disable, reset\n");
588 static int hotkey_write(char *buf
)
594 if (!hotkey_supported
)
597 if (!hotkey_get(&status
, &mask
))
600 while ((cmd
= next_cmd(&buf
))) {
601 if (strlencmp(cmd
, "enable") == 0) {
603 } else if (strlencmp(cmd
, "disable") == 0) {
605 } else if (strlencmp(cmd
, "reset") == 0) {
606 status
= hotkey_orig_status
;
607 mask
= hotkey_orig_mask
;
608 } else if (sscanf(cmd
, "0x%x", &mask
) == 1) {
610 } else if (sscanf(cmd
, "%x", &mask
) == 1) {
617 if (do_cmd
&& !hotkey_set(status
, mask
))
623 /*************************************************************************
624 * Bluetooth subdriver
627 static int bluetooth_supported
;
629 static int bluetooth_init(void)
631 /* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
632 G4x, R30, R31, R40e, R50e, T20-22, X20-21 */
633 bluetooth_supported
= hkey_handle
&&
634 acpi_evalf(hkey_handle
, NULL
, "GBDC", "qv");
639 static int bluetooth_status(void)
643 if (!bluetooth_supported
||
644 !acpi_evalf(hkey_handle
, &status
, "GBDC", "d"))
650 static int bluetooth_read(char *p
)
653 int status
= bluetooth_status();
655 if (!bluetooth_supported
)
656 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
657 else if (!(status
& 1))
658 len
+= sprintf(p
+ len
, "status:\t\tnot installed\n");
660 len
+= sprintf(p
+ len
, "status:\t\t%s\n", enabled(status
, 1));
661 len
+= sprintf(p
+ len
, "commands:\tenable, disable\n");
667 static int bluetooth_write(char *buf
)
669 int status
= bluetooth_status();
673 if (!bluetooth_supported
)
676 while ((cmd
= next_cmd(&buf
))) {
677 if (strlencmp(cmd
, "enable") == 0) {
679 } else if (strlencmp(cmd
, "disable") == 0) {
686 if (do_cmd
&& !acpi_evalf(hkey_handle
, NULL
, "SBDC", "vd", status
))
692 /*************************************************************************
696 static int wan_supported
;
698 static int wan_init(void)
700 wan_supported
= hkey_handle
&&
701 acpi_evalf(hkey_handle
, NULL
, "GWAN", "qv");
706 static int wan_status(void)
710 if (!wan_supported
|| !acpi_evalf(hkey_handle
, &status
, "GWAN", "d"))
716 static int wan_read(char *p
)
719 int status
= wan_status();
722 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
723 else if (!(status
& 1))
724 len
+= sprintf(p
+ len
, "status:\t\tnot installed\n");
726 len
+= sprintf(p
+ len
, "status:\t\t%s\n", enabled(status
, 1));
727 len
+= sprintf(p
+ len
, "commands:\tenable, disable\n");
733 static int wan_write(char *buf
)
735 int status
= wan_status();
742 while ((cmd
= next_cmd(&buf
))) {
743 if (strlencmp(cmd
, "enable") == 0) {
745 } else if (strlencmp(cmd
, "disable") == 0) {
752 if (do_cmd
&& !acpi_evalf(hkey_handle
, NULL
, "SWAN", "vd", status
))
758 /*************************************************************************
762 static enum video_access_mode video_supported
;
763 static int video_orig_autosw
;
765 IBM_HANDLE(vid
, root
, "\\_SB.PCI.AGP.VGA", /* 570 */
766 "\\_SB.PCI0.AGP0.VID0", /* 600e/x, 770x */
767 "\\_SB.PCI0.VID0", /* 770e */
768 "\\_SB.PCI0.VID", /* A21e, G4x, R50e, X30, X40 */
769 "\\_SB.PCI0.AGP.VID", /* all others */
772 IBM_HANDLE(vid2
, root
, "\\_SB.PCI0.AGPB.VID"); /* G41 */
774 static int video_init(void)
778 if (vid2_handle
&& acpi_evalf(NULL
, &ivga
, "\\IVGA", "d") && ivga
)
779 /* G41, assume IVGA doesn't change */
780 vid_handle
= vid2_handle
;
783 /* video switching not supported on R30, R31 */
784 video_supported
= IBMACPI_VIDEO_NONE
;
785 else if (acpi_evalf(vid_handle
, &video_orig_autosw
, "SWIT", "qd"))
787 video_supported
= IBMACPI_VIDEO_570
;
788 else if (acpi_evalf(vid_handle
, &video_orig_autosw
, "^VADL", "qd"))
789 /* 600e/x, 770e, 770x */
790 video_supported
= IBMACPI_VIDEO_770
;
793 video_supported
= IBMACPI_VIDEO_NEW
;
798 static void video_exit(void)
800 acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", video_orig_autosw
);
803 static int video_status(void)
808 if (video_supported
== IBMACPI_VIDEO_570
) {
809 if (acpi_evalf(NULL
, &i
, "\\_SB.PHS", "dd", 0x87))
811 } else if (video_supported
== IBMACPI_VIDEO_770
) {
812 if (acpi_evalf(NULL
, &i
, "\\VCDL", "d"))
814 if (acpi_evalf(NULL
, &i
, "\\VCDC", "d"))
816 } else if (video_supported
== IBMACPI_VIDEO_NEW
) {
817 acpi_evalf(NULL
, NULL
, "\\VUPS", "vd", 1);
818 if (acpi_evalf(NULL
, &i
, "\\VCDC", "d"))
821 acpi_evalf(NULL
, NULL
, "\\VUPS", "vd", 0);
822 if (acpi_evalf(NULL
, &i
, "\\VCDL", "d"))
824 if (acpi_evalf(NULL
, &i
, "\\VCDD", "d"))
831 static int video_autosw(void)
835 if (video_supported
== IBMACPI_VIDEO_570
)
836 acpi_evalf(vid_handle
, &autosw
, "SWIT", "d");
837 else if (video_supported
== IBMACPI_VIDEO_770
||
838 video_supported
== IBMACPI_VIDEO_NEW
)
839 acpi_evalf(vid_handle
, &autosw
, "^VDEE", "d");
844 static int video_switch(void)
846 int autosw
= video_autosw();
849 if (!acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", 1))
851 ret
= video_supported
== IBMACPI_VIDEO_570
?
852 acpi_evalf(ec_handle
, NULL
, "_Q16", "v") :
853 acpi_evalf(vid_handle
, NULL
, "VSWT", "v");
854 acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", autosw
);
859 static int video_expand(void)
861 if (video_supported
== IBMACPI_VIDEO_570
)
862 return acpi_evalf(ec_handle
, NULL
, "_Q17", "v");
863 else if (video_supported
== IBMACPI_VIDEO_770
)
864 return acpi_evalf(vid_handle
, NULL
, "VEXP", "v");
866 return acpi_evalf(NULL
, NULL
, "\\VEXP", "v");
869 static int video_switch2(int status
)
873 if (video_supported
== IBMACPI_VIDEO_570
) {
874 ret
= acpi_evalf(NULL
, NULL
,
875 "\\_SB.PHS2", "vdd", 0x8b, status
| 0x80);
876 } else if (video_supported
== IBMACPI_VIDEO_770
) {
877 int autosw
= video_autosw();
878 if (!acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", 1))
881 ret
= acpi_evalf(vid_handle
, NULL
,
882 "ASWT", "vdd", status
* 0x100, 0);
884 acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", autosw
);
886 ret
= acpi_evalf(NULL
, NULL
, "\\VUPS", "vd", 0x80) &&
887 acpi_evalf(NULL
, NULL
, "\\VSDS", "vdd", status
, 1);
893 static int video_read(char *p
)
895 int status
= video_status();
896 int autosw
= video_autosw();
899 if (!video_supported
) {
900 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
904 len
+= sprintf(p
+ len
, "status:\t\tsupported\n");
905 len
+= sprintf(p
+ len
, "lcd:\t\t%s\n", enabled(status
, 0));
906 len
+= sprintf(p
+ len
, "crt:\t\t%s\n", enabled(status
, 1));
907 if (video_supported
== IBMACPI_VIDEO_NEW
)
908 len
+= sprintf(p
+ len
, "dvi:\t\t%s\n", enabled(status
, 3));
909 len
+= sprintf(p
+ len
, "auto:\t\t%s\n", enabled(autosw
, 0));
910 len
+= sprintf(p
+ len
, "commands:\tlcd_enable, lcd_disable\n");
911 len
+= sprintf(p
+ len
, "commands:\tcrt_enable, crt_disable\n");
912 if (video_supported
== IBMACPI_VIDEO_NEW
)
913 len
+= sprintf(p
+ len
, "commands:\tdvi_enable, dvi_disable\n");
914 len
+= sprintf(p
+ len
, "commands:\tauto_enable, auto_disable\n");
915 len
+= sprintf(p
+ len
, "commands:\tvideo_switch, expand_toggle\n");
920 static int video_write(char *buf
)
923 int enable
, disable
, status
;
925 if (!video_supported
)
928 enable
= disable
= 0;
930 while ((cmd
= next_cmd(&buf
))) {
931 if (strlencmp(cmd
, "lcd_enable") == 0) {
933 } else if (strlencmp(cmd
, "lcd_disable") == 0) {
935 } else if (strlencmp(cmd
, "crt_enable") == 0) {
937 } else if (strlencmp(cmd
, "crt_disable") == 0) {
939 } else if (video_supported
== IBMACPI_VIDEO_NEW
&&
940 strlencmp(cmd
, "dvi_enable") == 0) {
942 } else if (video_supported
== IBMACPI_VIDEO_NEW
&&
943 strlencmp(cmd
, "dvi_disable") == 0) {
945 } else if (strlencmp(cmd
, "auto_enable") == 0) {
946 if (!acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", 1))
948 } else if (strlencmp(cmd
, "auto_disable") == 0) {
949 if (!acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", 0))
951 } else if (strlencmp(cmd
, "video_switch") == 0) {
954 } else if (strlencmp(cmd
, "expand_toggle") == 0) {
961 if (enable
|| disable
) {
962 status
= (video_status() & 0x0f & ~disable
) | enable
;
963 if (!video_switch2(status
))
970 /*************************************************************************
971 * Light (thinklight) subdriver
974 static int light_supported
;
975 static int light_status_supported
;
977 IBM_HANDLE(lght
, root
, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */
978 IBM_HANDLE(ledb
, ec
, "LEDB"); /* G4x */
980 static int light_init(void)
982 /* light not supported on 570, 600e/x, 770e, 770x, G4x, R30, R31 */
983 light_supported
= (cmos_handle
|| lght_handle
) && !ledb_handle
;
986 /* light status not supported on
987 570, 600e/x, 770e, 770x, G4x, R30, R31, R32, X20 */
988 light_status_supported
= acpi_evalf(ec_handle
, NULL
,
994 static int light_read(char *p
)
999 if (!light_supported
) {
1000 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1001 } else if (!light_status_supported
) {
1002 len
+= sprintf(p
+ len
, "status:\t\tunknown\n");
1003 len
+= sprintf(p
+ len
, "commands:\ton, off\n");
1005 if (!acpi_evalf(ec_handle
, &status
, "KBLT", "d"))
1007 len
+= sprintf(p
+ len
, "status:\t\t%s\n", onoff(status
, 0));
1008 len
+= sprintf(p
+ len
, "commands:\ton, off\n");
1014 static int light_write(char *buf
)
1016 int cmos_cmd
, lght_cmd
;
1020 if (!light_supported
)
1023 while ((cmd
= next_cmd(&buf
))) {
1024 if (strlencmp(cmd
, "on") == 0) {
1027 } else if (strlencmp(cmd
, "off") == 0) {
1033 success
= cmos_handle
?
1034 acpi_evalf(cmos_handle
, NULL
, NULL
, "vd", cmos_cmd
) :
1035 acpi_evalf(lght_handle
, NULL
, NULL
, "vd", lght_cmd
);
1043 /*************************************************************************
1047 /* don't list other alternatives as we install a notify handler on the 570 */
1048 IBM_HANDLE(pci
, root
, "\\_SB.PCI"); /* 570 */
1050 #ifdef CONFIG_THINKPAD_ACPI_DOCK
1052 IBM_HANDLE(dock
, root
, "\\_SB.GDCK", /* X30, X31, X40 */
1053 "\\_SB.PCI0.DOCK", /* 600e/x,770e,770x,A2xm/p,T20-22,X20-21 */
1054 "\\_SB.PCI0.PCI1.DOCK", /* all others */
1055 "\\_SB.PCI.ISA.SLCE", /* 570 */
1056 ); /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */
1058 #define dock_docked() (_sta(dock_handle) & 1)
1060 static void dock_notify(struct ibm_struct
*ibm
, u32 event
)
1062 int docked
= dock_docked();
1063 int pci
= ibm
->hid
&& strstr(ibm
->hid
, IBM_PCI_HID
);
1065 if (event
== 1 && !pci
) /* 570 */
1066 acpi_bus_generate_event(ibm
->device
, event
, 1); /* button */
1067 else if (event
== 1 && pci
) /* 570 */
1068 acpi_bus_generate_event(ibm
->device
, event
, 3); /* dock */
1069 else if (event
== 3 && docked
)
1070 acpi_bus_generate_event(ibm
->device
, event
, 1); /* button */
1071 else if (event
== 3 && !docked
)
1072 acpi_bus_generate_event(ibm
->device
, event
, 2); /* undock */
1073 else if (event
== 0 && docked
)
1074 acpi_bus_generate_event(ibm
->device
, event
, 3); /* dock */
1076 printk(IBM_ERR
"unknown dock event %d, status %d\n",
1077 event
, _sta(dock_handle
));
1078 acpi_bus_generate_event(ibm
->device
, event
, 0); /* unknown */
1082 static int dock_read(char *p
)
1085 int docked
= dock_docked();
1088 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1090 len
+= sprintf(p
+ len
, "status:\t\tundocked\n");
1092 len
+= sprintf(p
+ len
, "status:\t\tdocked\n");
1093 len
+= sprintf(p
+ len
, "commands:\tdock, undock\n");
1099 static int dock_write(char *buf
)
1106 while ((cmd
= next_cmd(&buf
))) {
1107 if (strlencmp(cmd
, "undock") == 0) {
1108 if (!acpi_evalf(dock_handle
, NULL
, "_DCK", "vd", 0) ||
1109 !acpi_evalf(dock_handle
, NULL
, "_EJ0", "vd", 1))
1111 } else if (strlencmp(cmd
, "dock") == 0) {
1112 if (!acpi_evalf(dock_handle
, NULL
, "_DCK", "vd", 1))
1121 #endif /* CONFIG_THINKPAD_ACPI_DOCK */
1123 /*************************************************************************
1127 #ifdef CONFIG_THINKPAD_ACPI_BAY
1128 static int bay_status_supported
;
1129 static int bay_status2_supported
;
1130 static int bay_eject_supported
;
1131 static int bay_eject2_supported
;
1133 IBM_HANDLE(bay
, root
, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */
1134 "\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */
1135 "\\_SB.PCI0.SATA.SCND.MSTR", /* T60, X60, Z60 */
1136 "\\_SB.PCI0.IDE0.SCND.MSTR", /* all others */
1137 ); /* A21e, R30, R31 */
1138 IBM_HANDLE(bay_ej
, bay
, "_EJ3", /* 600e/x, A2xm/p, A3x */
1139 "_EJ0", /* all others */
1140 ); /* 570,A21e,G4x,R30,R31,R32,R40e,R50e */
1141 IBM_HANDLE(bay2
, root
, "\\_SB.PCI0.IDE0.PRIM.SLAV", /* A3x, R32 */
1142 "\\_SB.PCI0.IDE0.IDEP.IDPS", /* 600e/x, 770e, 770x */
1144 IBM_HANDLE(bay2_ej
, bay2
, "_EJ3", /* 600e/x, 770e, A3x */
1148 static int bay_init(void)
1150 bay_status_supported
= bay_handle
&&
1151 acpi_evalf(bay_handle
, NULL
, "_STA", "qv");
1152 bay_status2_supported
= bay2_handle
&&
1153 acpi_evalf(bay2_handle
, NULL
, "_STA", "qv");
1155 bay_eject_supported
= bay_handle
&& bay_ej_handle
&&
1156 (strlencmp(bay_ej_path
, "_EJ0") == 0 || experimental
);
1157 bay_eject2_supported
= bay2_handle
&& bay2_ej_handle
&&
1158 (strlencmp(bay2_ej_path
, "_EJ0") == 0 || experimental
);
1163 static void bay_notify(struct ibm_struct
*ibm
, u32 event
)
1165 acpi_bus_generate_event(ibm
->device
, event
, 0);
1168 #define bay_occupied(b) (_sta(b##_handle) & 1)
1170 static int bay_read(char *p
)
1173 int occupied
= bay_occupied(bay
);
1174 int occupied2
= bay_occupied(bay2
);
1177 len
+= sprintf(p
+ len
, "status:\t\t%s\n", bay_status_supported
?
1178 (occupied
? "occupied" : "unoccupied") :
1180 if (bay_status2_supported
)
1181 len
+= sprintf(p
+ len
, "status2:\t%s\n", occupied2
?
1182 "occupied" : "unoccupied");
1184 eject
= bay_eject_supported
&& occupied
;
1185 eject2
= bay_eject2_supported
&& occupied2
;
1187 if (eject
&& eject2
)
1188 len
+= sprintf(p
+ len
, "commands:\teject, eject2\n");
1190 len
+= sprintf(p
+ len
, "commands:\teject\n");
1192 len
+= sprintf(p
+ len
, "commands:\teject2\n");
1197 static int bay_write(char *buf
)
1201 if (!bay_eject_supported
&& !bay_eject2_supported
)
1204 while ((cmd
= next_cmd(&buf
))) {
1205 if (bay_eject_supported
&& strlencmp(cmd
, "eject") == 0) {
1206 if (!acpi_evalf(bay_ej_handle
, NULL
, NULL
, "vd", 1))
1208 } else if (bay_eject2_supported
&&
1209 strlencmp(cmd
, "eject2") == 0) {
1210 if (!acpi_evalf(bay2_ej_handle
, NULL
, NULL
, "vd", 1))
1218 #endif /* CONFIG_THINKPAD_ACPI_BAY */
1220 /*************************************************************************
1224 static int cmos_eval(int cmos_cmd
)
1227 return acpi_evalf(cmos_handle
, NULL
, NULL
, "vd", cmos_cmd
);
1232 static int cmos_read(char *p
)
1236 /* cmos not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
1237 R30, R31, T20-22, X20-21 */
1239 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1241 len
+= sprintf(p
+ len
, "status:\t\tsupported\n");
1242 len
+= sprintf(p
+ len
, "commands:\t<cmd> (<cmd> is 0-21)\n");
1248 static int cmos_write(char *buf
)
1256 while ((cmd
= next_cmd(&buf
))) {
1257 if (sscanf(cmd
, "%u", &cmos_cmd
) == 1 &&
1258 cmos_cmd
>= 0 && cmos_cmd
<= 21) {
1263 if (!cmos_eval(cmos_cmd
))
1271 /*************************************************************************
1275 static enum led_access_mode led_supported
;
1277 IBM_HANDLE(led
, ec
, "SLED", /* 570 */
1278 "SYSL", /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
1279 "LED", /* all others */
1282 static int led_init(void)
1285 /* led not supported on R30, R31 */
1286 led_supported
= IBMACPI_LED_NONE
;
1287 else if (strlencmp(led_path
, "SLED") == 0)
1289 led_supported
= IBMACPI_LED_570
;
1290 else if (strlencmp(led_path
, "SYSL") == 0)
1291 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
1292 led_supported
= IBMACPI_LED_OLD
;
1295 led_supported
= IBMACPI_LED_NEW
;
1300 #define led_status(s) ((s) == 0 ? "off" : ((s) == 1 ? "on" : "blinking"))
1302 static int led_read(char *p
)
1306 if (!led_supported
) {
1307 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1310 len
+= sprintf(p
+ len
, "status:\t\tsupported\n");
1312 if (led_supported
== IBMACPI_LED_570
) {
1315 for (i
= 0; i
< 8; i
++) {
1316 if (!acpi_evalf(ec_handle
,
1317 &status
, "GLED", "dd", 1 << i
))
1319 len
+= sprintf(p
+ len
, "%d:\t\t%s\n",
1320 i
, led_status(status
));
1324 len
+= sprintf(p
+ len
, "commands:\t"
1325 "<led> on, <led> off, <led> blink (<led> is 0-7)\n");
1330 /* off, on, blink */
1331 static const int led_sled_arg1
[] = { 0, 1, 3 };
1332 static const int led_exp_hlbl
[] = { 0, 0, 1 }; /* led# * */
1333 static const int led_exp_hlcl
[] = { 0, 1, 1 }; /* led# * */
1334 static const int led_led_arg1
[] = { 0, 0x80, 0xc0 };
1336 static int led_write(char *buf
)
1344 while ((cmd
= next_cmd(&buf
))) {
1345 if (sscanf(cmd
, "%d", &led
) != 1 || led
< 0 || led
> 7)
1348 if (strstr(cmd
, "off")) {
1350 } else if (strstr(cmd
, "on")) {
1352 } else if (strstr(cmd
, "blink")) {
1357 if (led_supported
== IBMACPI_LED_570
) {
1360 if (!acpi_evalf(led_handle
, NULL
, NULL
, "vdd",
1361 led
, led_sled_arg1
[ind
]))
1363 } else if (led_supported
== IBMACPI_LED_OLD
) {
1364 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */
1366 ret
= ec_write(IBMACPI_LED_EC_HLMS
, led
);
1369 ec_write(IBMACPI_LED_EC_HLBL
,
1370 led
* led_exp_hlbl
[ind
]);
1373 ec_write(IBMACPI_LED_EC_HLCL
,
1374 led
* led_exp_hlcl
[ind
]);
1379 if (!acpi_evalf(led_handle
, NULL
, NULL
, "vdd",
1380 led
, led_led_arg1
[ind
]))
1388 /*************************************************************************
1392 IBM_HANDLE(beep
, ec
, "BEEP"); /* all except R30, R31 */
1394 static int beep_read(char *p
)
1399 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1401 len
+= sprintf(p
+ len
, "status:\t\tsupported\n");
1402 len
+= sprintf(p
+ len
, "commands:\t<cmd> (<cmd> is 0-17)\n");
1408 static int beep_write(char *buf
)
1416 while ((cmd
= next_cmd(&buf
))) {
1417 if (sscanf(cmd
, "%u", &beep_cmd
) == 1 &&
1418 beep_cmd
>= 0 && beep_cmd
<= 17) {
1422 if (!acpi_evalf(beep_handle
, NULL
, NULL
, "vdd", beep_cmd
, 0))
1429 /*************************************************************************
1433 static enum thermal_access_mode thermal_read_mode
;
1435 static int thermal_init(void)
1439 int acpi_tmp7
= acpi_evalf(ec_handle
, NULL
, "TMP7", "qv");
1441 if (ibm_thinkpad_ec_found
&& experimental
) {
1443 * Direct EC access mode: sensors at registers
1444 * 0x78-0x7F, 0xC0-0xC7. Registers return 0x00 for
1445 * non-implemented, thermal sensors return 0x80 when
1450 for (i
= 0; i
< 8; i
++) {
1451 if (likely(acpi_ec_read(0x78 + i
, &t
))) {
1457 if (likely(acpi_ec_read(0xC0 + i
, &t
))) {
1465 /* This is sheer paranoia, but we handle it anyway */
1468 "ThinkPad ACPI EC access misbehaving, "
1469 "falling back to ACPI TMPx access mode\n");
1470 thermal_read_mode
= IBMACPI_THERMAL_ACPI_TMP07
;
1473 "ThinkPad ACPI EC access misbehaving, "
1474 "disabling thermal sensors access\n");
1475 thermal_read_mode
= IBMACPI_THERMAL_NONE
;
1480 IBMACPI_THERMAL_TPEC_16
: IBMACPI_THERMAL_TPEC_8
;
1482 } else if (acpi_tmp7
) {
1483 if (acpi_evalf(ec_handle
, NULL
, "UPDT", "qv")) {
1484 /* 600e/x, 770e, 770x */
1485 thermal_read_mode
= IBMACPI_THERMAL_ACPI_UPDT
;
1487 /* Standard ACPI TMPx access, max 8 sensors */
1488 thermal_read_mode
= IBMACPI_THERMAL_ACPI_TMP07
;
1491 /* temperatures not supported on 570, G4x, R30, R31, R32 */
1492 thermal_read_mode
= IBMACPI_THERMAL_NONE
;
1498 static int thermal_get_sensors(struct ibm_thermal_sensors_struct
*s
)
1502 char tmpi
[] = "TMPi";
1507 switch (thermal_read_mode
) {
1508 #if IBMACPI_MAX_THERMAL_SENSORS >= 16
1509 case IBMACPI_THERMAL_TPEC_16
:
1510 for (i
= 0; i
< 8; i
++) {
1511 if (!acpi_ec_read(0xC0 + i
, &tmp
))
1513 s
->temp
[i
+ 8] = tmp
* 1000;
1517 case IBMACPI_THERMAL_TPEC_8
:
1518 for (i
= 0; i
< 8; i
++) {
1519 if (!acpi_ec_read(0x78 + i
, &tmp
))
1521 s
->temp
[i
] = tmp
* 1000;
1523 return (thermal_read_mode
== IBMACPI_THERMAL_TPEC_16
) ? 16 : 8;
1525 case IBMACPI_THERMAL_ACPI_UPDT
:
1526 if (!acpi_evalf(ec_handle
, NULL
, "UPDT", "v"))
1528 for (i
= 0; i
< 8; i
++) {
1530 if (!acpi_evalf(ec_handle
, &t
, tmpi
, "d"))
1532 s
->temp
[i
] = (t
- 2732) * 100;
1536 case IBMACPI_THERMAL_ACPI_TMP07
:
1537 for (i
= 0; i
< 8; i
++) {
1539 if (!acpi_evalf(ec_handle
, &t
, tmpi
, "d"))
1541 s
->temp
[i
] = t
* 1000;
1545 case IBMACPI_THERMAL_NONE
:
1551 static int thermal_read(char *p
)
1555 struct ibm_thermal_sensors_struct t
;
1557 n
= thermal_get_sensors(&t
);
1558 if (unlikely(n
< 0))
1561 len
+= sprintf(p
+ len
, "temperatures:\t");
1564 for (i
= 0; i
< (n
- 1); i
++)
1565 len
+= sprintf(p
+ len
, "%d ", t
.temp
[i
] / 1000);
1566 len
+= sprintf(p
+ len
, "%d\n", t
.temp
[i
] / 1000);
1568 len
+= sprintf(p
+ len
, "not supported\n");
1573 /*************************************************************************
1577 static u8 ecdump_regs
[256];
1579 static int ecdump_read(char *p
)
1585 len
+= sprintf(p
+ len
, "EC "
1586 " +00 +01 +02 +03 +04 +05 +06 +07"
1587 " +08 +09 +0a +0b +0c +0d +0e +0f\n");
1588 for (i
= 0; i
< 256; i
+= 16) {
1589 len
+= sprintf(p
+ len
, "EC 0x%02x:", i
);
1590 for (j
= 0; j
< 16; j
++) {
1591 if (!acpi_ec_read(i
+ j
, &v
))
1593 if (v
!= ecdump_regs
[i
+ j
])
1594 len
+= sprintf(p
+ len
, " *%02x", v
);
1596 len
+= sprintf(p
+ len
, " %02x", v
);
1597 ecdump_regs
[i
+ j
] = v
;
1599 len
+= sprintf(p
+ len
, "\n");
1604 /* These are way too dangerous to advertise openly... */
1606 len
+= sprintf(p
+ len
, "commands:\t0x<offset> 0x<value>"
1607 " (<offset> is 00-ff, <value> is 00-ff)\n");
1608 len
+= sprintf(p
+ len
, "commands:\t0x<offset> <value> "
1609 " (<offset> is 00-ff, <value> is 0-255)\n");
1614 static int ecdump_write(char *buf
)
1619 while ((cmd
= next_cmd(&buf
))) {
1620 if (sscanf(cmd
, "0x%x 0x%x", &i
, &v
) == 2) {
1622 } else if (sscanf(cmd
, "0x%x %u", &i
, &v
) == 2) {
1626 if (i
>= 0 && i
< 256 && v
>= 0 && v
< 256) {
1627 if (!acpi_ec_write(i
, v
))
1636 /*************************************************************************
1637 * Backlight/brightness subdriver
1640 static struct backlight_device
*ibm_backlight_device
= NULL
;
1642 static struct backlight_properties ibm_backlight_data
= {
1643 .owner
= THIS_MODULE
,
1644 .get_brightness
= brightness_get
,
1645 .update_status
= brightness_update_status
,
1646 .max_brightness
= 7,
1649 static int brightness_init(void)
1653 b
= brightness_get(NULL
);
1657 ibm_backlight_device
= backlight_device_register("ibm", NULL
, NULL
,
1658 &ibm_backlight_data
);
1659 if (IS_ERR(ibm_backlight_device
)) {
1660 printk(IBM_ERR
"Could not register backlight device\n");
1661 return PTR_ERR(ibm_backlight_device
);
1664 ibm_backlight_device
->props
->brightness
= b
;
1665 brightness_update_status(ibm_backlight_device
);
1670 static void brightness_exit(void)
1672 if (ibm_backlight_device
) {
1673 backlight_device_unregister(ibm_backlight_device
);
1674 ibm_backlight_device
= NULL
;
1678 static int brightness_update_status(struct backlight_device
*bd
)
1680 return brightness_set(
1681 (bd
->props
->fb_blank
== FB_BLANK_UNBLANK
&&
1682 bd
->props
->power
== FB_BLANK_UNBLANK
) ?
1683 bd
->props
->brightness
: 0);
1686 static int brightness_get(struct backlight_device
*bd
)
1689 if (!acpi_ec_read(brightness_offset
, &level
))
1697 static int brightness_set(int value
)
1699 int cmos_cmd
, inc
, i
;
1700 int current_value
= brightness_get(NULL
);
1704 cmos_cmd
= value
> current_value
? TP_CMOS_BRIGHTNESS_UP
: TP_CMOS_BRIGHTNESS_DOWN
;
1705 inc
= value
> current_value
? 1 : -1;
1706 for (i
= current_value
; i
!= value
; i
+= inc
) {
1707 if (!cmos_eval(cmos_cmd
))
1709 if (!acpi_ec_write(brightness_offset
, i
+ inc
))
1716 static int brightness_read(char *p
)
1721 if ((level
= brightness_get(NULL
)) < 0) {
1722 len
+= sprintf(p
+ len
, "level:\t\tunreadable\n");
1724 len
+= sprintf(p
+ len
, "level:\t\t%d\n", level
& 0x7);
1725 len
+= sprintf(p
+ len
, "commands:\tup, down\n");
1726 len
+= sprintf(p
+ len
, "commands:\tlevel <level>"
1727 " (<level> is 0-7)\n");
1733 static int brightness_write(char *buf
)
1739 while ((cmd
= next_cmd(&buf
))) {
1740 if ((level
= brightness_get(NULL
)) < 0)
1744 if (strlencmp(cmd
, "up") == 0) {
1745 new_level
= level
== 7 ? 7 : level
+ 1;
1746 } else if (strlencmp(cmd
, "down") == 0) {
1747 new_level
= level
== 0 ? 0 : level
- 1;
1748 } else if (sscanf(cmd
, "level %d", &new_level
) == 1 &&
1749 new_level
>= 0 && new_level
<= 7) {
1754 brightness_set(new_level
);
1760 /*************************************************************************
1764 static int volume_read(char *p
)
1769 if (!acpi_ec_read(volume_offset
, &level
)) {
1770 len
+= sprintf(p
+ len
, "level:\t\tunreadable\n");
1772 len
+= sprintf(p
+ len
, "level:\t\t%d\n", level
& 0xf);
1773 len
+= sprintf(p
+ len
, "mute:\t\t%s\n", onoff(level
, 6));
1774 len
+= sprintf(p
+ len
, "commands:\tup, down, mute\n");
1775 len
+= sprintf(p
+ len
, "commands:\tlevel <level>"
1776 " (<level> is 0-15)\n");
1782 static int volume_write(char *buf
)
1784 int cmos_cmd
, inc
, i
;
1786 int new_level
, new_mute
;
1789 while ((cmd
= next_cmd(&buf
))) {
1790 if (!acpi_ec_read(volume_offset
, &level
))
1792 new_mute
= mute
= level
& 0x40;
1793 new_level
= level
= level
& 0xf;
1795 if (strlencmp(cmd
, "up") == 0) {
1799 new_level
= level
== 15 ? 15 : level
+ 1;
1800 } else if (strlencmp(cmd
, "down") == 0) {
1804 new_level
= level
== 0 ? 0 : level
- 1;
1805 } else if (sscanf(cmd
, "level %d", &new_level
) == 1 &&
1806 new_level
>= 0 && new_level
<= 15) {
1808 } else if (strlencmp(cmd
, "mute") == 0) {
1813 if (new_level
!= level
) { /* mute doesn't change */
1814 cmos_cmd
= new_level
> level
? TP_CMOS_VOLUME_UP
: TP_CMOS_VOLUME_DOWN
;
1815 inc
= new_level
> level
? 1 : -1;
1817 if (mute
&& (!cmos_eval(cmos_cmd
) ||
1818 !acpi_ec_write(volume_offset
, level
)))
1821 for (i
= level
; i
!= new_level
; i
+= inc
)
1822 if (!cmos_eval(cmos_cmd
) ||
1823 !acpi_ec_write(volume_offset
, i
+ inc
))
1826 if (mute
&& (!cmos_eval(TP_CMOS_VOLUME_MUTE
) ||
1827 !acpi_ec_write(volume_offset
,
1832 if (new_mute
!= mute
) { /* level doesn't change */
1833 cmos_cmd
= new_mute
? TP_CMOS_VOLUME_MUTE
: TP_CMOS_VOLUME_UP
;
1835 if (!cmos_eval(cmos_cmd
) ||
1836 !acpi_ec_write(volume_offset
, level
+ new_mute
))
1845 /*************************************************************************
1852 * IBMACPI_FAN_RD_ACPI_GFAN:
1853 * ACPI GFAN method: returns fan level
1855 * see IBMACPI_FAN_WR_ACPI_SFAN
1856 * EC 0x2f not available if GFAN exists
1858 * IBMACPI_FAN_WR_ACPI_SFAN:
1859 * ACPI SFAN method: sets fan level, 0 (stop) to 7 (max)
1861 * EC 0x2f might be available *for reading*, but never for writing.
1863 * IBMACPI_FAN_WR_TPEC:
1864 * ThinkPad EC register 0x2f (HFSP): fan control loop mode Supported
1865 * on almost all ThinkPads
1867 * Fan speed changes of any sort (including those caused by the
1868 * disengaged mode) are usually done slowly by the firmware as the
1869 * maximum ammount of fan duty cycle change per second seems to be
1872 * Reading is not available if GFAN exists.
1873 * Writing is not available if SFAN exists.
1876 * 7 automatic mode engaged;
1877 * (default operation mode of the ThinkPad)
1878 * fan level is ignored in this mode.
1879 * 6 disengage mode (takes precedence over bit 7);
1880 * not available on all thinkpads. May disable
1881 * the tachometer, and speeds up fan to 100% duty-cycle,
1882 * which speeds it up far above the standard RPM
1883 * levels. It is not impossible that it could cause
1885 * 5-3 unused in some models. Extra bits for fan level
1886 * in others, but still useless as all values above
1887 * 7 map to the same speed as level 7 in these models.
1888 * 2-0 fan level (0..7 usually)
1890 * 0x07 = max (set when temperatures critical)
1891 * Some ThinkPads may have other levels, see
1892 * IBMACPI_FAN_WR_ACPI_FANS (X31/X40/X41)
1894 * FIRMWARE BUG: on some models, EC 0x2f might not be initialized at
1895 * boot. Apparently the EC does not intialize it, so unless ACPI DSDT
1896 * does so, its initial value is meaningless (0x07).
1898 * For firmware bugs, refer to:
1899 * http://thinkwiki.org/wiki/Embedded_Controller_Firmware#Firmware_Issues
1903 * ThinkPad EC register 0x84 (LSB), 0x85 (MSB):
1904 * Main fan tachometer reading (in RPM)
1906 * This register is present on all ThinkPads with a new-style EC, and
1907 * it is known not to be present on the A21m/e, and T22, as there is
1908 * something else in offset 0x84 according to the ACPI DSDT. Other
1909 * ThinkPads from this same time period (and earlier) probably lack the
1910 * tachometer as well.
1912 * Unfortunately a lot of ThinkPads with new-style ECs but whose firwmare
1913 * was never fixed by IBM to report the EC firmware version string
1914 * probably support the tachometer (like the early X models), so
1915 * detecting it is quite hard. We need more data to know for sure.
1917 * FIRMWARE BUG: always read 0x84 first, otherwise incorrect readings
1920 * FIRMWARE BUG: when EC 0x2f bit 6 is set (disengaged mode), this
1921 * register is not invalidated in ThinkPads that disable tachometer
1922 * readings. Thus, the tachometer readings go stale.
1924 * For firmware bugs, refer to:
1925 * http://thinkwiki.org/wiki/Embedded_Controller_Firmware#Firmware_Issues
1927 * IBMACPI_FAN_WR_ACPI_FANS:
1928 * ThinkPad X31, X40, X41. Not available in the X60.
1930 * FANS ACPI handle: takes three arguments: low speed, medium speed,
1931 * high speed. ACPI DSDT seems to map these three speeds to levels
1932 * as follows: STOP LOW LOW MED MED HIGH HIGH HIGH HIGH
1933 * (this map is stored on FAN0..FAN8 as "0,1,1,2,2,3,3,3,3")
1935 * The speeds are stored on handles
1936 * (FANA:FAN9), (FANC:FANB), (FANE:FAND).
1938 * There are three default speed sets, acessible as handles:
1939 * FS1L,FS1M,FS1H; FS2L,FS2M,FS2H; FS3L,FS3M,FS3H
1941 * ACPI DSDT switches which set is in use depending on various
1944 * IBMACPI_FAN_WR_TPEC is also available and should be used to
1945 * command the fan. The X31/X40/X41 seems to have 8 fan levels,
1946 * but the ACPI tables just mention level 7.
1949 static enum fan_status_access_mode fan_status_access_mode
;
1950 static enum fan_control_access_mode fan_control_access_mode
;
1951 static enum fan_control_commands fan_control_commands
;
1953 static int fan_control_status_known
;
1954 static u8 fan_control_initial_status
;
1956 static void fan_watchdog_fire(struct work_struct
*ignored
);
1957 static int fan_watchdog_maxinterval
;
1958 static DECLARE_DELAYED_WORK(fan_watchdog_task
, fan_watchdog_fire
);
1960 IBM_HANDLE(fans
, ec
, "FANS"); /* X31, X40, X41 */
1961 IBM_HANDLE(gfan
, ec
, "GFAN", /* 570 */
1962 "\\FSPD", /* 600e/x, 770e, 770x */
1964 IBM_HANDLE(sfan
, ec
, "SFAN", /* 570 */
1965 "JFNS", /* 770x-JL */
1968 static int fan_init(void)
1970 fan_status_access_mode
= IBMACPI_FAN_NONE
;
1971 fan_control_access_mode
= IBMACPI_FAN_WR_NONE
;
1972 fan_control_commands
= 0;
1973 fan_control_status_known
= 1;
1974 fan_watchdog_maxinterval
= 0;
1977 /* 570, 600e/x, 770e, 770x */
1978 fan_status_access_mode
= IBMACPI_FAN_RD_ACPI_GFAN
;
1980 /* all other ThinkPads: note that even old-style
1981 * ThinkPad ECs supports the fan control register */
1982 if (likely(acpi_ec_read(fan_status_offset
,
1983 &fan_control_initial_status
))) {
1984 fan_status_access_mode
= IBMACPI_FAN_RD_TPEC
;
1986 /* In some ThinkPads, neither the EC nor the ACPI
1987 * DSDT initialize the fan status, and it ends up
1988 * being set to 0x07 when it *could* be either
1991 * Enable for TP-1Y (T43), TP-78 (R51e),
1992 * TP-76 (R52), TP-70 (T43, R52), which are known
1994 if (fan_control_initial_status
== 0x07 &&
1995 ibm_thinkpad_ec_found
&&
1996 ((ibm_thinkpad_ec_found
[0] == '1' &&
1997 ibm_thinkpad_ec_found
[1] == 'Y') ||
1998 (ibm_thinkpad_ec_found
[0] == '7' &&
1999 (ibm_thinkpad_ec_found
[1] == '6' ||
2000 ibm_thinkpad_ec_found
[1] == '8' ||
2001 ibm_thinkpad_ec_found
[1] == '0'))
2004 "fan_init: initial fan status is "
2005 "unknown, assuming it is in auto "
2007 fan_control_status_known
= 0;
2011 "ThinkPad ACPI EC access misbehaving, "
2012 "fan status and control unavailable\n");
2019 fan_control_access_mode
= IBMACPI_FAN_WR_ACPI_SFAN
;
2020 fan_control_commands
|=
2021 IBMACPI_FAN_CMD_LEVEL
| IBMACPI_FAN_CMD_ENABLE
;
2024 /* gfan without sfan means no fan control */
2025 /* all other models implement TP EC 0x2f control */
2029 fan_control_access_mode
=
2030 IBMACPI_FAN_WR_ACPI_FANS
;
2031 fan_control_commands
|=
2032 IBMACPI_FAN_CMD_SPEED
|
2033 IBMACPI_FAN_CMD_LEVEL
|
2034 IBMACPI_FAN_CMD_ENABLE
;
2036 fan_control_access_mode
= IBMACPI_FAN_WR_TPEC
;
2037 fan_control_commands
|=
2038 IBMACPI_FAN_CMD_LEVEL
|
2039 IBMACPI_FAN_CMD_ENABLE
;
2047 static int fan_get_status(u8
*status
)
2052 * Add IBMACPI_FAN_RD_ACPI_FANS ? */
2054 switch (fan_status_access_mode
) {
2055 case IBMACPI_FAN_RD_ACPI_GFAN
:
2056 /* 570, 600e/x, 770e, 770x */
2058 if (unlikely(!acpi_evalf(gfan_handle
, &s
, NULL
, "d")))
2066 case IBMACPI_FAN_RD_TPEC
:
2067 /* all except 570, 600e/x, 770e, 770x */
2068 if (unlikely(!acpi_ec_read(fan_status_offset
, &s
)))
2083 static void fan_exit(void)
2085 cancel_delayed_work(&fan_watchdog_task
);
2086 flush_scheduled_work();
2089 static int fan_get_speed(unsigned int *speed
)
2093 switch (fan_status_access_mode
) {
2094 case IBMACPI_FAN_RD_TPEC
:
2095 /* all except 570, 600e/x, 770e, 770x */
2096 if (unlikely(!acpi_ec_read(fan_rpm_offset
, &lo
) ||
2097 !acpi_ec_read(fan_rpm_offset
+ 1, &hi
)))
2101 *speed
= (hi
<< 8) | lo
;
2112 static void fan_watchdog_fire(struct work_struct
*ignored
)
2114 printk(IBM_NOTICE
"fan watchdog: enabling fan\n");
2115 if (fan_set_enable()) {
2116 printk(IBM_ERR
"fan watchdog: error while enabling fan\n");
2117 /* reschedule for later */
2118 fan_watchdog_reset();
2122 static void fan_watchdog_reset(void)
2124 static int fan_watchdog_active
= 0;
2126 if (fan_watchdog_active
)
2127 cancel_delayed_work(&fan_watchdog_task
);
2129 if (fan_watchdog_maxinterval
> 0) {
2130 fan_watchdog_active
= 1;
2131 if (!schedule_delayed_work(&fan_watchdog_task
,
2132 msecs_to_jiffies(fan_watchdog_maxinterval
2134 printk(IBM_ERR
"failed to schedule the fan watchdog, "
2135 "watchdog will not trigger\n");
2138 fan_watchdog_active
= 0;
2141 static int fan_set_level(int level
)
2143 switch (fan_control_access_mode
) {
2144 case IBMACPI_FAN_WR_ACPI_SFAN
:
2145 if (level
>= 0 && level
<= 7) {
2146 if (!acpi_evalf(sfan_handle
, NULL
, NULL
, "vd", level
))
2152 case IBMACPI_FAN_WR_ACPI_FANS
:
2153 case IBMACPI_FAN_WR_TPEC
:
2154 if ((level
!= IBMACPI_FAN_EC_AUTO
) &&
2155 (level
!= IBMACPI_FAN_EC_DISENGAGED
) &&
2156 ((level
< 0) || (level
> 7)))
2159 if (!acpi_ec_write(fan_status_offset
, level
))
2162 fan_control_status_known
= 1;
2171 static int fan_set_enable(void)
2176 switch (fan_control_access_mode
) {
2177 case IBMACPI_FAN_WR_ACPI_FANS
:
2178 case IBMACPI_FAN_WR_TPEC
:
2179 if ((rc
= fan_get_status(&s
)) < 0)
2182 /* Don't go out of emergency fan mode */
2184 s
= IBMACPI_FAN_EC_AUTO
;
2186 if (!acpi_ec_write(fan_status_offset
, s
))
2189 fan_control_status_known
= 1;
2192 case IBMACPI_FAN_WR_ACPI_SFAN
:
2193 if ((rc
= fan_get_status(&s
)) < 0)
2198 /* Set fan to at least level 4 */
2202 if (!acpi_evalf(sfan_handle
, NULL
, NULL
, "vd", s
))
2212 static int fan_set_disable(void)
2214 switch (fan_control_access_mode
) {
2215 case IBMACPI_FAN_WR_ACPI_FANS
:
2216 case IBMACPI_FAN_WR_TPEC
:
2217 if (!acpi_ec_write(fan_status_offset
, 0x00))
2220 fan_control_status_known
= 1;
2223 case IBMACPI_FAN_WR_ACPI_SFAN
:
2224 if (!acpi_evalf(sfan_handle
, NULL
, NULL
, "vd", 0x00))
2234 static int fan_set_speed(int speed
)
2236 switch (fan_control_access_mode
) {
2237 case IBMACPI_FAN_WR_ACPI_FANS
:
2238 if (speed
>= 0 && speed
<= 65535) {
2239 if (!acpi_evalf(fans_handle
, NULL
, NULL
, "vddd",
2240 speed
, speed
, speed
))
2252 static int fan_read(char *p
)
2257 unsigned int speed
= 0;
2259 switch (fan_status_access_mode
) {
2260 case IBMACPI_FAN_RD_ACPI_GFAN
:
2261 /* 570, 600e/x, 770e, 770x */
2262 if ((rc
= fan_get_status(&status
)) < 0)
2265 len
+= sprintf(p
+ len
, "status:\t\t%s\n"
2267 (status
!= 0) ? "enabled" : "disabled", status
);
2270 case IBMACPI_FAN_RD_TPEC
:
2271 /* all except 570, 600e/x, 770e, 770x */
2272 if ((rc
= fan_get_status(&status
)) < 0)
2275 if (unlikely(!fan_control_status_known
)) {
2276 if (status
!= fan_control_initial_status
)
2277 fan_control_status_known
= 1;
2279 /* Return most likely status. In fact, it
2280 * might be the only possible status */
2281 status
= IBMACPI_FAN_EC_AUTO
;
2284 len
+= sprintf(p
+ len
, "status:\t\t%s\n",
2285 (status
!= 0) ? "enabled" : "disabled");
2287 /* No ThinkPad boots on disengaged mode, we can safely
2288 * assume the tachometer is online if fan control status
2290 if ((rc
= fan_get_speed(&speed
)) < 0)
2293 len
+= sprintf(p
+ len
, "speed:\t\t%d\n", speed
);
2295 if (status
& IBMACPI_FAN_EC_DISENGAGED
)
2296 /* Disengaged mode takes precedence */
2297 len
+= sprintf(p
+ len
, "level:\t\tdisengaged\n");
2298 else if (status
& IBMACPI_FAN_EC_AUTO
)
2299 len
+= sprintf(p
+ len
, "level:\t\tauto\n");
2301 len
+= sprintf(p
+ len
, "level:\t\t%d\n", status
);
2304 case IBMACPI_FAN_NONE
:
2306 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
2309 if (fan_control_commands
& IBMACPI_FAN_CMD_LEVEL
) {
2310 len
+= sprintf(p
+ len
, "commands:\tlevel <level>");
2312 switch (fan_control_access_mode
) {
2313 case IBMACPI_FAN_WR_ACPI_SFAN
:
2314 len
+= sprintf(p
+ len
, " (<level> is 0-7)\n");
2318 len
+= sprintf(p
+ len
, " (<level> is 0-7, "
2319 "auto, disengaged)\n");
2324 if (fan_control_commands
& IBMACPI_FAN_CMD_ENABLE
)
2325 len
+= sprintf(p
+ len
, "commands:\tenable, disable\n"
2326 "commands:\twatchdog <timeout> (<timeout> is 0 (off), "
2327 "1-120 (seconds))\n");
2329 if (fan_control_commands
& IBMACPI_FAN_CMD_SPEED
)
2330 len
+= sprintf(p
+ len
, "commands:\tspeed <speed>"
2331 " (<speed> is 0-65535)\n");
2336 static int fan_write_cmd_level(const char *cmd
, int *rc
)
2340 if (strlencmp(cmd
, "level auto") == 0)
2341 level
= IBMACPI_FAN_EC_AUTO
;
2342 else if (strlencmp(cmd
, "level disengaged") == 0)
2343 level
= IBMACPI_FAN_EC_DISENGAGED
;
2344 else if (sscanf(cmd
, "level %d", &level
) != 1)
2347 if ((*rc
= fan_set_level(level
)) == -ENXIO
)
2348 printk(IBM_ERR
"level command accepted for unsupported "
2349 "access mode %d", fan_control_access_mode
);
2354 static int fan_write_cmd_enable(const char *cmd
, int *rc
)
2356 if (strlencmp(cmd
, "enable") != 0)
2359 if ((*rc
= fan_set_enable()) == -ENXIO
)
2360 printk(IBM_ERR
"enable command accepted for unsupported "
2361 "access mode %d", fan_control_access_mode
);
2366 static int fan_write_cmd_disable(const char *cmd
, int *rc
)
2368 if (strlencmp(cmd
, "disable") != 0)
2371 if ((*rc
= fan_set_disable()) == -ENXIO
)
2372 printk(IBM_ERR
"disable command accepted for unsupported "
2373 "access mode %d", fan_control_access_mode
);
2378 static int fan_write_cmd_speed(const char *cmd
, int *rc
)
2383 * Support speed <low> <medium> <high> ? */
2385 if (sscanf(cmd
, "speed %d", &speed
) != 1)
2388 if ((*rc
= fan_set_speed(speed
)) == -ENXIO
)
2389 printk(IBM_ERR
"speed command accepted for unsupported "
2390 "access mode %d", fan_control_access_mode
);
2395 static int fan_write_cmd_watchdog(const char *cmd
, int *rc
)
2399 if (sscanf(cmd
, "watchdog %d", &interval
) != 1)
2402 if (interval
< 0 || interval
> 120)
2405 fan_watchdog_maxinterval
= interval
;
2410 static int fan_write(char *buf
)
2415 while (!rc
&& (cmd
= next_cmd(&buf
))) {
2416 if (!((fan_control_commands
& IBMACPI_FAN_CMD_LEVEL
) &&
2417 fan_write_cmd_level(cmd
, &rc
)) &&
2418 !((fan_control_commands
& IBMACPI_FAN_CMD_ENABLE
) &&
2419 (fan_write_cmd_enable(cmd
, &rc
) ||
2420 fan_write_cmd_disable(cmd
, &rc
) ||
2421 fan_write_cmd_watchdog(cmd
, &rc
))) &&
2422 !((fan_control_commands
& IBMACPI_FAN_CMD_SPEED
) &&
2423 fan_write_cmd_speed(cmd
, &rc
))
2427 fan_watchdog_reset();
2433 /****************************************************************************
2434 ****************************************************************************
2438 ****************************************************************************
2439 ****************************************************************************/
2442 static struct proc_dir_entry
*proc_dir
= NULL
;
2444 /* Subdriver registry */
2445 static struct ibm_struct ibms
[] = {
2448 .init
= thinkpad_acpi_driver_init
,
2449 .read
= thinkpad_acpi_driver_read
,
2453 .hid
= IBM_HKEY_HID
,
2454 .init
= hotkey_init
,
2455 .read
= hotkey_read
,
2456 .write
= hotkey_write
,
2457 .exit
= hotkey_exit
,
2458 .notify
= hotkey_notify
,
2459 .handle
= &hkey_handle
,
2460 .type
= ACPI_DEVICE_NOTIFY
,
2463 .name
= "bluetooth",
2464 .init
= bluetooth_init
,
2465 .read
= bluetooth_read
,
2466 .write
= bluetooth_write
,
2479 .write
= video_write
,
2486 .write
= light_write
,
2488 #ifdef CONFIG_THINKPAD_ACPI_DOCK
2492 .write
= dock_write
,
2493 .notify
= dock_notify
,
2494 .handle
= &dock_handle
,
2495 .type
= ACPI_SYSTEM_NOTIFY
,
2500 .notify
= dock_notify
,
2501 .handle
= &pci_handle
,
2502 .type
= ACPI_SYSTEM_NOTIFY
,
2505 #ifdef CONFIG_THINKPAD_ACPI_BAY
2511 .notify
= bay_notify
,
2512 .handle
= &bay_handle
,
2513 .type
= ACPI_SYSTEM_NOTIFY
,
2515 #endif /* CONFIG_THINKPAD_ACPI_BAY */
2519 .write
= cmos_write
,
2530 .write
= beep_write
,
2534 .init
= thermal_init
,
2535 .read
= thermal_read
,
2539 .read
= ecdump_read
,
2540 .write
= ecdump_write
,
2544 .name
= "brightness",
2545 .read
= brightness_read
,
2546 .write
= brightness_write
,
2547 .init
= brightness_init
,
2548 .exit
= brightness_exit
,
2552 .read
= volume_read
,
2553 .write
= volume_write
,
2566 * Module and infrastructure proble, init and exit handling
2569 static int __init
ibm_init(struct ibm_struct
*ibm
)
2572 struct proc_dir_entry
*entry
;
2574 if (ibm
->experimental
&& !experimental
)
2578 ret
= register_tpacpi_subdriver(ibm
);
2581 ibm
->driver_registered
= 1;
2588 ibm
->init_called
= 1;
2592 entry
= create_proc_entry(ibm
->name
,
2593 S_IFREG
| S_IRUGO
| S_IWUSR
,
2596 printk(IBM_ERR
"unable to create proc entry %s\n",
2600 entry
->owner
= THIS_MODULE
;
2602 entry
->read_proc
= &dispatch_read
;
2604 entry
->write_proc
= &dispatch_write
;
2605 ibm
->proc_created
= 1;
2609 ret
= setup_notify(ibm
);
2610 if (ret
== -ENODEV
) {
2611 printk(IBM_NOTICE
"disabling subdriver %s\n",
2623 static void ibm_exit(struct ibm_struct
*ibm
)
2625 if (ibm
->notify_installed
)
2626 acpi_remove_notify_handler(*ibm
->handle
, ibm
->type
,
2629 if (ibm
->proc_created
)
2630 remove_proc_entry(ibm
->name
, proc_dir
);
2632 if (ibm
->init_called
&& ibm
->exit
)
2635 if (ibm
->driver_registered
) {
2636 acpi_bus_unregister_driver(ibm
->driver
);
2643 static char *ibm_thinkpad_ec_found
= NULL
;
2645 static char* __init
check_dmi_for_ec(void)
2647 struct dmi_device
*dev
= NULL
;
2648 char ec_fw_string
[18];
2651 * ThinkPad T23 or newer, A31 or newer, R50e or newer,
2652 * X32 or newer, all Z series; Some models must have an
2653 * up-to-date BIOS or they will not be detected.
2655 * See http://thinkwiki.org/wiki/List_of_DMI_IDs
2657 while ((dev
= dmi_find_device(DMI_DEV_TYPE_OEM_STRING
, NULL
, dev
))) {
2658 if (sscanf(dev
->name
,
2659 "IBM ThinkPad Embedded Controller -[%17c",
2660 ec_fw_string
) == 1) {
2661 ec_fw_string
[sizeof(ec_fw_string
) - 1] = 0;
2662 ec_fw_string
[strcspn(ec_fw_string
, " ]")] = 0;
2663 return kstrdup(ec_fw_string
, GFP_KERNEL
);
2669 /* Module init, exit, parameters */
2671 static int __init
set_ibm_param(const char *val
, struct kernel_param
*kp
)
2675 for (i
= 0; i
< ARRAY_SIZE(ibms
); i
++)
2676 if (strcmp(ibms
[i
].name
, kp
->name
) == 0 && ibms
[i
].write
) {
2677 if (strlen(val
) > sizeof(ibms
[i
].param
) - 2)
2679 strcpy(ibms
[i
].param
, val
);
2680 strcat(ibms
[i
].param
, ",");
2687 static int experimental
;
2688 module_param(experimental
, int, 0);
2690 #define IBM_PARAM(feature) \
2691 module_param_call(feature, set_ibm_param, NULL, NULL, 0)
2694 IBM_PARAM(bluetooth
);
2697 #ifdef CONFIG_THINKPAD_ACPI_DOCK
2700 #ifdef CONFIG_THINKPAD_ACPI_BAY
2702 #endif /* CONFIG_THINKPAD_ACPI_BAY */
2707 IBM_PARAM(brightness
);
2711 static int __init
acpi_ibm_init(void)
2718 /* ec is required because many other handles are relative to it */
2719 IBM_HANDLE_INIT(ec
);
2721 printk(IBM_ERR
"ec object not found\n");
2725 /* Models with newer firmware report the EC in DMI */
2726 ibm_thinkpad_ec_found
= check_dmi_for_ec();
2728 /* these handles are not required */
2729 IBM_HANDLE_INIT(vid
);
2730 IBM_HANDLE_INIT(vid2
);
2731 IBM_HANDLE_INIT(ledb
);
2732 IBM_HANDLE_INIT(led
);
2733 IBM_HANDLE_INIT(hkey
);
2734 IBM_HANDLE_INIT(lght
);
2735 IBM_HANDLE_INIT(cmos
);
2736 #ifdef CONFIG_THINKPAD_ACPI_DOCK
2737 IBM_HANDLE_INIT(dock
);
2739 IBM_HANDLE_INIT(pci
);
2740 #ifdef CONFIG_THINKPAD_ACPI_BAY
2741 IBM_HANDLE_INIT(bay
);
2743 IBM_HANDLE_INIT(bay_ej
);
2744 IBM_HANDLE_INIT(bay2
);
2746 IBM_HANDLE_INIT(bay2_ej
);
2747 #endif /* CONFIG_THINKPAD_ACPI_BAY */
2748 IBM_HANDLE_INIT(beep
);
2749 IBM_HANDLE_INIT(ecrd
);
2750 IBM_HANDLE_INIT(ecwr
);
2751 IBM_HANDLE_INIT(fans
);
2752 IBM_HANDLE_INIT(gfan
);
2753 IBM_HANDLE_INIT(sfan
);
2755 proc_dir
= proc_mkdir(IBM_DIR
, acpi_root_dir
);
2757 printk(IBM_ERR
"unable to create proc dir %s", IBM_DIR
);
2761 proc_dir
->owner
= THIS_MODULE
;
2763 for (i
= 0; i
< ARRAY_SIZE(ibms
); i
++) {
2764 ret
= ibm_init(&ibms
[i
]);
2765 if (ret
>= 0 && *ibms
[i
].param
)
2766 ret
= ibms
[i
].write(ibms
[i
].param
);
2776 static void acpi_ibm_exit(void)
2780 for (i
= ARRAY_SIZE(ibms
) - 1; i
>= 0; i
--)
2784 remove_proc_entry(IBM_DIR
, acpi_root_dir
);
2786 if (ibm_thinkpad_ec_found
)
2787 kfree(ibm_thinkpad_ec_found
);
2790 module_init(acpi_ibm_init
);
2791 module_exit(acpi_ibm_exit
);