2 * ibm_acpi.c - IBM ThinkPad ACPI Extras
5 * Copyright (C) 2004-2005 Borislav Deianov <borislav@users.sf.net>
6 * Copyright (C) 2006 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #define IBM_VERSION "0.13"
28 * 2006-11-22 0.13 new maintainer
29 * changelog now lives in git commit history, and will
30 * not be updated further in-file.
32 * 2005-08-17 0.12 fix compilation on 2.6.13-rc kernels
33 * 2005-03-17 0.11 support for 600e, 770x
34 * thanks to Jamie Lentin <lentinj@dial.pipex.com>
35 * support for 770e, G41
36 * G40 and G41 don't have a thinklight
37 * temperatures no longer experimental
38 * experimental brightness control
39 * experimental volume control
40 * experimental fan enable/disable
41 * 2005-01-16 0.10 fix module loading on R30, R31
42 * 2005-01-16 0.9 support for 570, R30, R31
43 * ultrabay support on A22p, A3x
44 * limit arg for cmos, led, beep, drop experimental status
45 * more capable led control on A21e, A22p, T20-22, X20
46 * experimental temperatures and fan speed
47 * experimental embedded controller register dump
48 * mark more functions as __init, drop incorrect __exit
50 * thanks to Henrik Brix Andersen <brix@gentoo.org>
51 * fix parameter passing on module loading
52 * thanks to Rusty Russell <rusty@rustcorp.com.au>
53 * thanks to Jim Radford <radford@blackbean.org>
54 * 2004-11-08 0.8 fix init error case, don't return from a macro
55 * thanks to Chris Wright <chrisw@osdl.org>
56 * 2004-10-23 0.7 fix module loading on A21e, A22p, T20, T21, X20
57 * fix led control on A21e
58 * 2004-10-19 0.6 use acpi_bus_register_driver() to claim HKEY device
59 * 2004-10-18 0.5 thinklight support on A21e, G40, R32, T20, T21, X20
60 * proc file format changed
61 * video_switch command
62 * experimental cmos control
63 * experimental led control
64 * experimental acpi sounds
65 * 2004-09-16 0.4 support for module parameters
66 * hotkey mask can be prefixed by 0x
67 * video output switching
68 * video expansion control
69 * ultrabay eject support
70 * removed lcd brightness/on/off control, didn't work
71 * 2004-08-17 0.3 support for R40
72 * lcd off, brightness control
74 * 2004-08-14 0.2 support for T series, X20
75 * bluetooth enable/disable
76 * hotkey events disabled by default
77 * removed fan control, currently useless
78 * 2004-08-09 0.1 initial release, support for X series
83 MODULE_AUTHOR("Borislav Deianov, Henrique de Moraes Holschuh");
84 MODULE_DESCRIPTION(IBM_DESC
);
85 MODULE_VERSION(IBM_VERSION
);
86 MODULE_LICENSE("GPL");
88 #define __unused __attribute__ ((unused))
90 /****************************************************************************
91 ****************************************************************************
93 * ACPI Helpers and device model
95 ****************************************************************************
96 ****************************************************************************/
98 /*************************************************************************
102 static acpi_handle root_handle
= NULL
;
104 #define IBM_HANDLE(object, parent, paths...) \
105 static acpi_handle object##_handle; \
106 static acpi_handle *object##_parent = &parent##_handle; \
107 static char *object##_path; \
108 static char *object##_paths[] = { paths }
110 IBM_HANDLE(ec
, root
, "\\_SB.PCI0.ISA.EC0", /* 240, 240x */
111 "\\_SB.PCI.ISA.EC", /* 570 */
112 "\\_SB.PCI0.ISA0.EC0", /* 600e/x, 770e, 770x */
113 "\\_SB.PCI0.ISA.EC", /* A21e, A2xm/p, T20-22, X20-21 */
114 "\\_SB.PCI0.AD4S.EC0", /* i1400, R30 */
115 "\\_SB.PCI0.ICH3.EC0", /* R31 */
116 "\\_SB.PCI0.LPC.EC", /* all others */
119 IBM_HANDLE(ecrd
, ec
, "ECRD"); /* 570 */
120 IBM_HANDLE(ecwr
, ec
, "ECWR"); /* 570 */
123 /*************************************************************************
127 IBM_HANDLE(cmos
, root
, "\\UCMS", /* R50, R50e, R50p, R51, T4x, X31, X40 */
128 "\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */
129 "\\CMS", /* R40, R40e */
132 IBM_HANDLE(hkey
, ec
, "\\_SB.HKEY", /* 600e/x, 770e, 770x */
133 "^HKEY", /* R30, R31 */
134 "HKEY", /* all others */
138 /*************************************************************************
142 static int acpi_evalf(acpi_handle handle
,
143 void *res
, char *method
, char *fmt
, ...)
146 struct acpi_object_list params
;
147 union acpi_object in_objs
[IBM_MAX_ACPI_ARGS
];
148 struct acpi_buffer result
, *resultp
;
149 union acpi_object out_obj
;
157 printk(IBM_ERR
"acpi_evalf() called with empty format\n");
170 params
.pointer
= &in_objs
[0];
177 in_objs
[params
.count
].integer
.value
= va_arg(ap
, int);
178 in_objs
[params
.count
++].type
= ACPI_TYPE_INTEGER
;
180 /* add more types as needed */
182 printk(IBM_ERR
"acpi_evalf() called "
183 "with invalid format character '%c'\n", c
);
189 if (res_type
!= 'v') {
190 result
.length
= sizeof(out_obj
);
191 result
.pointer
= &out_obj
;
196 status
= acpi_evaluate_object(handle
, method
, ¶ms
, resultp
);
201 *(int *)res
= out_obj
.integer
.value
;
202 success
= status
== AE_OK
&& out_obj
.type
== ACPI_TYPE_INTEGER
;
205 success
= status
== AE_OK
;
207 /* add more types as needed */
209 printk(IBM_ERR
"acpi_evalf() called "
210 "with invalid format character '%c'\n", res_type
);
214 if (!success
&& !quiet
)
215 printk(IBM_ERR
"acpi_evalf(%s, %s, ...) failed: %d\n",
216 method
, fmt0
, status
);
221 static void __unused
acpi_print_int(acpi_handle handle
, char *method
)
225 if (acpi_evalf(handle
, &i
, method
, "d"))
226 printk(IBM_INFO
"%s = 0x%x\n", method
, i
);
228 printk(IBM_ERR
"error calling %s\n", method
);
231 static int acpi_ec_read(int i
, u8
* p
)
236 if (!acpi_evalf(ecrd_handle
, &v
, NULL
, "dd", i
))
240 if (ec_read(i
, p
) < 0)
247 static int acpi_ec_write(int i
, u8 v
)
250 if (!acpi_evalf(ecwr_handle
, NULL
, NULL
, "vdd", i
, v
))
253 if (ec_write(i
, v
) < 0)
260 static int _sta(acpi_handle handle
)
264 if (!handle
|| !acpi_evalf(handle
, &status
, "_STA", "d"))
270 /*************************************************************************
274 static void __init
ibm_handle_init(char *name
,
275 acpi_handle
* handle
, acpi_handle parent
,
276 char **paths
, int num_paths
, char **path
)
281 for (i
= 0; i
< num_paths
; i
++) {
282 status
= acpi_get_handle(parent
, paths
[i
], handle
);
283 if (ACPI_SUCCESS(status
)) {
292 static void dispatch_notify(acpi_handle handle
, u32 event
, void *data
)
294 struct ibm_struct
*ibm
= data
;
296 if (!ibm
|| !ibm
->notify
)
299 ibm
->notify(ibm
, event
);
302 static int __init
setup_notify(struct ibm_struct
*ibm
)
310 ret
= acpi_bus_get_device(*ibm
->handle
, &ibm
->device
);
312 printk(IBM_ERR
"%s device not present\n", ibm
->name
);
316 acpi_driver_data(ibm
->device
) = ibm
;
317 sprintf(acpi_device_class(ibm
->device
), "%s/%s", IBM_NAME
, ibm
->name
);
319 status
= acpi_install_notify_handler(*ibm
->handle
, ibm
->type
,
320 dispatch_notify
, ibm
);
321 if (ACPI_FAILURE(status
)) {
322 if (status
== AE_ALREADY_EXISTS
) {
323 printk(IBM_NOTICE
"another device driver is already handling %s events\n",
326 printk(IBM_ERR
"acpi_install_notify_handler(%s) failed: %d\n",
331 ibm
->notify_installed
= 1;
335 static int __init
ibm_device_add(struct acpi_device
*device
)
340 static int __init
register_ibmacpi_subdriver(struct ibm_struct
*ibm
)
344 ibm
->driver
= kzalloc(sizeof(struct acpi_driver
), GFP_KERNEL
);
346 printk(IBM_ERR
"kmalloc(ibm->driver) failed\n");
350 sprintf(ibm
->driver
->name
, "%s_%s", IBM_NAME
, ibm
->name
);
351 ibm
->driver
->ids
= ibm
->hid
;
352 ibm
->driver
->ops
.add
= &ibm_device_add
;
354 ret
= acpi_bus_register_driver(ibm
->driver
);
356 printk(IBM_ERR
"acpi_bus_register_driver(%s) failed: %d\n",
365 /****************************************************************************
366 ****************************************************************************
370 ****************************************************************************
371 ****************************************************************************/
373 static int dispatch_read(char *page
, char **start
, off_t off
, int count
,
374 int *eof
, void *data
)
376 struct ibm_struct
*ibm
= data
;
379 if (!ibm
|| !ibm
->read
)
382 len
= ibm
->read(page
);
386 if (len
<= off
+ count
)
398 static int dispatch_write(struct file
*file
, const char __user
* userbuf
,
399 unsigned long count
, void *data
)
401 struct ibm_struct
*ibm
= data
;
405 if (!ibm
|| !ibm
->write
)
408 kernbuf
= kmalloc(count
+ 2, GFP_KERNEL
);
412 if (copy_from_user(kernbuf
, userbuf
, count
)) {
418 strcat(kernbuf
, ",");
419 ret
= ibm
->write(kernbuf
);
428 static char *next_cmd(char **cmds
)
433 while ((end
= strchr(start
, ',')) && end
== start
)
445 /****************************************************************************
446 ****************************************************************************
450 ****************************************************************************
451 ****************************************************************************/
453 /*************************************************************************
454 * ibm-acpi init subdriver
457 static int ibm_acpi_driver_init(void)
459 printk(IBM_INFO
"%s v%s\n", IBM_DESC
, IBM_VERSION
);
460 printk(IBM_INFO
"%s\n", IBM_URL
);
462 if (ibm_thinkpad_ec_found
)
463 printk(IBM_INFO
"ThinkPad EC firmware %s\n",
464 ibm_thinkpad_ec_found
);
469 static int ibm_acpi_driver_read(char *p
)
473 len
+= sprintf(p
+ len
, "driver:\t\t%s\n", IBM_DESC
);
474 len
+= sprintf(p
+ len
, "version:\t%s\n", IBM_VERSION
);
479 /*************************************************************************
483 static int hotkey_supported
;
484 static int hotkey_mask_supported
;
485 static int hotkey_orig_status
;
486 static int hotkey_orig_mask
;
488 static int hotkey_init(void)
490 /* hotkey not supported on 570 */
491 hotkey_supported
= hkey_handle
!= NULL
;
493 if (hotkey_supported
) {
494 /* mask not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
495 A30, R30, R31, T20-22, X20-21, X22-24 */
496 hotkey_mask_supported
=
497 acpi_evalf(hkey_handle
, NULL
, "DHKN", "qv");
499 if (!hotkey_get(&hotkey_orig_status
, &hotkey_orig_mask
))
506 static void hotkey_exit(void)
508 if (hotkey_supported
)
509 hotkey_set(hotkey_orig_status
, hotkey_orig_mask
);
512 static void hotkey_notify(struct ibm_struct
*ibm
, u32 event
)
516 if (acpi_evalf(hkey_handle
, &hkey
, "MHKP", "d"))
517 acpi_bus_generate_event(ibm
->device
, event
, hkey
);
519 printk(IBM_ERR
"unknown hotkey event %d\n", event
);
520 acpi_bus_generate_event(ibm
->device
, event
, 0);
524 static int hotkey_get(int *status
, int *mask
)
526 if (!acpi_evalf(hkey_handle
, status
, "DHKC", "d"))
529 if (hotkey_mask_supported
)
530 if (!acpi_evalf(hkey_handle
, mask
, "DHKN", "d"))
536 static int hotkey_set(int status
, int mask
)
540 if (!acpi_evalf(hkey_handle
, NULL
, "MHKC", "vd", status
))
543 if (hotkey_mask_supported
)
544 for (i
= 0; i
< 32; i
++) {
545 int bit
= ((1 << i
) & mask
) != 0;
546 if (!acpi_evalf(hkey_handle
,
547 NULL
, "MHKM", "vdd", i
+ 1, bit
))
554 static int hotkey_read(char *p
)
559 if (!hotkey_supported
) {
560 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
564 if (!hotkey_get(&status
, &mask
))
567 len
+= sprintf(p
+ len
, "status:\t\t%s\n", enabled(status
, 0));
568 if (hotkey_mask_supported
) {
569 len
+= sprintf(p
+ len
, "mask:\t\t0x%04x\n", mask
);
570 len
+= sprintf(p
+ len
,
571 "commands:\tenable, disable, reset, <mask>\n");
573 len
+= sprintf(p
+ len
, "mask:\t\tnot supported\n");
574 len
+= sprintf(p
+ len
, "commands:\tenable, disable, reset\n");
580 static int hotkey_write(char *buf
)
586 if (!hotkey_supported
)
589 if (!hotkey_get(&status
, &mask
))
592 while ((cmd
= next_cmd(&buf
))) {
593 if (strlencmp(cmd
, "enable") == 0) {
595 } else if (strlencmp(cmd
, "disable") == 0) {
597 } else if (strlencmp(cmd
, "reset") == 0) {
598 status
= hotkey_orig_status
;
599 mask
= hotkey_orig_mask
;
600 } else if (sscanf(cmd
, "0x%x", &mask
) == 1) {
602 } else if (sscanf(cmd
, "%x", &mask
) == 1) {
609 if (do_cmd
&& !hotkey_set(status
, mask
))
615 /*************************************************************************
616 * Bluetooth subdriver
619 static int bluetooth_supported
;
621 static int bluetooth_init(void)
623 /* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
624 G4x, R30, R31, R40e, R50e, T20-22, X20-21 */
625 bluetooth_supported
= hkey_handle
&&
626 acpi_evalf(hkey_handle
, NULL
, "GBDC", "qv");
631 static int bluetooth_status(void)
635 if (!bluetooth_supported
||
636 !acpi_evalf(hkey_handle
, &status
, "GBDC", "d"))
642 static int bluetooth_read(char *p
)
645 int status
= bluetooth_status();
647 if (!bluetooth_supported
)
648 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
649 else if (!(status
& 1))
650 len
+= sprintf(p
+ len
, "status:\t\tnot installed\n");
652 len
+= sprintf(p
+ len
, "status:\t\t%s\n", enabled(status
, 1));
653 len
+= sprintf(p
+ len
, "commands:\tenable, disable\n");
659 static int bluetooth_write(char *buf
)
661 int status
= bluetooth_status();
665 if (!bluetooth_supported
)
668 while ((cmd
= next_cmd(&buf
))) {
669 if (strlencmp(cmd
, "enable") == 0) {
671 } else if (strlencmp(cmd
, "disable") == 0) {
678 if (do_cmd
&& !acpi_evalf(hkey_handle
, NULL
, "SBDC", "vd", status
))
684 /*************************************************************************
688 static int wan_supported
;
690 static int wan_init(void)
692 wan_supported
= hkey_handle
&&
693 acpi_evalf(hkey_handle
, NULL
, "GWAN", "qv");
698 static int wan_status(void)
702 if (!wan_supported
|| !acpi_evalf(hkey_handle
, &status
, "GWAN", "d"))
708 static int wan_read(char *p
)
711 int status
= wan_status();
714 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
715 else if (!(status
& 1))
716 len
+= sprintf(p
+ len
, "status:\t\tnot installed\n");
718 len
+= sprintf(p
+ len
, "status:\t\t%s\n", enabled(status
, 1));
719 len
+= sprintf(p
+ len
, "commands:\tenable, disable\n");
725 static int wan_write(char *buf
)
727 int status
= wan_status();
734 while ((cmd
= next_cmd(&buf
))) {
735 if (strlencmp(cmd
, "enable") == 0) {
737 } else if (strlencmp(cmd
, "disable") == 0) {
744 if (do_cmd
&& !acpi_evalf(hkey_handle
, NULL
, "SWAN", "vd", status
))
750 /*************************************************************************
754 static enum video_access_mode video_supported
;
755 static int video_orig_autosw
;
757 IBM_HANDLE(vid
, root
, "\\_SB.PCI.AGP.VGA", /* 570 */
758 "\\_SB.PCI0.AGP0.VID0", /* 600e/x, 770x */
759 "\\_SB.PCI0.VID0", /* 770e */
760 "\\_SB.PCI0.VID", /* A21e, G4x, R50e, X30, X40 */
761 "\\_SB.PCI0.AGP.VID", /* all others */
764 IBM_HANDLE(vid2
, root
, "\\_SB.PCI0.AGPB.VID"); /* G41 */
766 static int video_init(void)
770 if (vid2_handle
&& acpi_evalf(NULL
, &ivga
, "\\IVGA", "d") && ivga
)
771 /* G41, assume IVGA doesn't change */
772 vid_handle
= vid2_handle
;
775 /* video switching not supported on R30, R31 */
776 video_supported
= IBMACPI_VIDEO_NONE
;
777 else if (acpi_evalf(vid_handle
, &video_orig_autosw
, "SWIT", "qd"))
779 video_supported
= IBMACPI_VIDEO_570
;
780 else if (acpi_evalf(vid_handle
, &video_orig_autosw
, "^VADL", "qd"))
781 /* 600e/x, 770e, 770x */
782 video_supported
= IBMACPI_VIDEO_770
;
785 video_supported
= IBMACPI_VIDEO_NEW
;
790 static void video_exit(void)
792 acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", video_orig_autosw
);
795 static int video_status(void)
800 if (video_supported
== IBMACPI_VIDEO_570
) {
801 if (acpi_evalf(NULL
, &i
, "\\_SB.PHS", "dd", 0x87))
803 } else if (video_supported
== IBMACPI_VIDEO_770
) {
804 if (acpi_evalf(NULL
, &i
, "\\VCDL", "d"))
806 if (acpi_evalf(NULL
, &i
, "\\VCDC", "d"))
808 } else if (video_supported
== IBMACPI_VIDEO_NEW
) {
809 acpi_evalf(NULL
, NULL
, "\\VUPS", "vd", 1);
810 if (acpi_evalf(NULL
, &i
, "\\VCDC", "d"))
813 acpi_evalf(NULL
, NULL
, "\\VUPS", "vd", 0);
814 if (acpi_evalf(NULL
, &i
, "\\VCDL", "d"))
816 if (acpi_evalf(NULL
, &i
, "\\VCDD", "d"))
823 static int video_autosw(void)
827 if (video_supported
== IBMACPI_VIDEO_570
)
828 acpi_evalf(vid_handle
, &autosw
, "SWIT", "d");
829 else if (video_supported
== IBMACPI_VIDEO_770
||
830 video_supported
== IBMACPI_VIDEO_NEW
)
831 acpi_evalf(vid_handle
, &autosw
, "^VDEE", "d");
836 static int video_switch(void)
838 int autosw
= video_autosw();
841 if (!acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", 1))
843 ret
= video_supported
== IBMACPI_VIDEO_570
?
844 acpi_evalf(ec_handle
, NULL
, "_Q16", "v") :
845 acpi_evalf(vid_handle
, NULL
, "VSWT", "v");
846 acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", autosw
);
851 static int video_expand(void)
853 if (video_supported
== IBMACPI_VIDEO_570
)
854 return acpi_evalf(ec_handle
, NULL
, "_Q17", "v");
855 else if (video_supported
== IBMACPI_VIDEO_770
)
856 return acpi_evalf(vid_handle
, NULL
, "VEXP", "v");
858 return acpi_evalf(NULL
, NULL
, "\\VEXP", "v");
861 static int video_switch2(int status
)
865 if (video_supported
== IBMACPI_VIDEO_570
) {
866 ret
= acpi_evalf(NULL
, NULL
,
867 "\\_SB.PHS2", "vdd", 0x8b, status
| 0x80);
868 } else if (video_supported
== IBMACPI_VIDEO_770
) {
869 int autosw
= video_autosw();
870 if (!acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", 1))
873 ret
= acpi_evalf(vid_handle
, NULL
,
874 "ASWT", "vdd", status
* 0x100, 0);
876 acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", autosw
);
878 ret
= acpi_evalf(NULL
, NULL
, "\\VUPS", "vd", 0x80) &&
879 acpi_evalf(NULL
, NULL
, "\\VSDS", "vdd", status
, 1);
885 static int video_read(char *p
)
887 int status
= video_status();
888 int autosw
= video_autosw();
891 if (!video_supported
) {
892 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
896 len
+= sprintf(p
+ len
, "status:\t\tsupported\n");
897 len
+= sprintf(p
+ len
, "lcd:\t\t%s\n", enabled(status
, 0));
898 len
+= sprintf(p
+ len
, "crt:\t\t%s\n", enabled(status
, 1));
899 if (video_supported
== IBMACPI_VIDEO_NEW
)
900 len
+= sprintf(p
+ len
, "dvi:\t\t%s\n", enabled(status
, 3));
901 len
+= sprintf(p
+ len
, "auto:\t\t%s\n", enabled(autosw
, 0));
902 len
+= sprintf(p
+ len
, "commands:\tlcd_enable, lcd_disable\n");
903 len
+= sprintf(p
+ len
, "commands:\tcrt_enable, crt_disable\n");
904 if (video_supported
== IBMACPI_VIDEO_NEW
)
905 len
+= sprintf(p
+ len
, "commands:\tdvi_enable, dvi_disable\n");
906 len
+= sprintf(p
+ len
, "commands:\tauto_enable, auto_disable\n");
907 len
+= sprintf(p
+ len
, "commands:\tvideo_switch, expand_toggle\n");
912 static int video_write(char *buf
)
915 int enable
, disable
, status
;
917 if (!video_supported
)
920 enable
= disable
= 0;
922 while ((cmd
= next_cmd(&buf
))) {
923 if (strlencmp(cmd
, "lcd_enable") == 0) {
925 } else if (strlencmp(cmd
, "lcd_disable") == 0) {
927 } else if (strlencmp(cmd
, "crt_enable") == 0) {
929 } else if (strlencmp(cmd
, "crt_disable") == 0) {
931 } else if (video_supported
== IBMACPI_VIDEO_NEW
&&
932 strlencmp(cmd
, "dvi_enable") == 0) {
934 } else if (video_supported
== IBMACPI_VIDEO_NEW
&&
935 strlencmp(cmd
, "dvi_disable") == 0) {
937 } else if (strlencmp(cmd
, "auto_enable") == 0) {
938 if (!acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", 1))
940 } else if (strlencmp(cmd
, "auto_disable") == 0) {
941 if (!acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", 0))
943 } else if (strlencmp(cmd
, "video_switch") == 0) {
946 } else if (strlencmp(cmd
, "expand_toggle") == 0) {
953 if (enable
|| disable
) {
954 status
= (video_status() & 0x0f & ~disable
) | enable
;
955 if (!video_switch2(status
))
962 /*************************************************************************
963 * Light (thinklight) subdriver
966 static int light_supported
;
967 static int light_status_supported
;
969 IBM_HANDLE(lght
, root
, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */
970 IBM_HANDLE(ledb
, ec
, "LEDB"); /* G4x */
972 static int light_init(void)
974 /* light not supported on 570, 600e/x, 770e, 770x, G4x, R30, R31 */
975 light_supported
= (cmos_handle
|| lght_handle
) && !ledb_handle
;
978 /* light status not supported on
979 570, 600e/x, 770e, 770x, G4x, R30, R31, R32, X20 */
980 light_status_supported
= acpi_evalf(ec_handle
, NULL
,
986 static int light_read(char *p
)
991 if (!light_supported
) {
992 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
993 } else if (!light_status_supported
) {
994 len
+= sprintf(p
+ len
, "status:\t\tunknown\n");
995 len
+= sprintf(p
+ len
, "commands:\ton, off\n");
997 if (!acpi_evalf(ec_handle
, &status
, "KBLT", "d"))
999 len
+= sprintf(p
+ len
, "status:\t\t%s\n", onoff(status
, 0));
1000 len
+= sprintf(p
+ len
, "commands:\ton, off\n");
1006 static int light_write(char *buf
)
1008 int cmos_cmd
, lght_cmd
;
1012 if (!light_supported
)
1015 while ((cmd
= next_cmd(&buf
))) {
1016 if (strlencmp(cmd
, "on") == 0) {
1019 } else if (strlencmp(cmd
, "off") == 0) {
1025 success
= cmos_handle
?
1026 acpi_evalf(cmos_handle
, NULL
, NULL
, "vd", cmos_cmd
) :
1027 acpi_evalf(lght_handle
, NULL
, NULL
, "vd", lght_cmd
);
1035 /*************************************************************************
1039 /* don't list other alternatives as we install a notify handler on the 570 */
1040 IBM_HANDLE(pci
, root
, "\\_SB.PCI"); /* 570 */
1042 #ifdef CONFIG_ACPI_IBM_DOCK
1044 IBM_HANDLE(dock
, root
, "\\_SB.GDCK", /* X30, X31, X40 */
1045 "\\_SB.PCI0.DOCK", /* 600e/x,770e,770x,A2xm/p,T20-22,X20-21 */
1046 "\\_SB.PCI0.PCI1.DOCK", /* all others */
1047 "\\_SB.PCI.ISA.SLCE", /* 570 */
1048 ); /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */
1050 #define dock_docked() (_sta(dock_handle) & 1)
1052 static void dock_notify(struct ibm_struct
*ibm
, u32 event
)
1054 int docked
= dock_docked();
1055 int pci
= ibm
->hid
&& strstr(ibm
->hid
, IBM_PCI_HID
);
1057 if (event
== 1 && !pci
) /* 570 */
1058 acpi_bus_generate_event(ibm
->device
, event
, 1); /* button */
1059 else if (event
== 1 && pci
) /* 570 */
1060 acpi_bus_generate_event(ibm
->device
, event
, 3); /* dock */
1061 else if (event
== 3 && docked
)
1062 acpi_bus_generate_event(ibm
->device
, event
, 1); /* button */
1063 else if (event
== 3 && !docked
)
1064 acpi_bus_generate_event(ibm
->device
, event
, 2); /* undock */
1065 else if (event
== 0 && docked
)
1066 acpi_bus_generate_event(ibm
->device
, event
, 3); /* dock */
1068 printk(IBM_ERR
"unknown dock event %d, status %d\n",
1069 event
, _sta(dock_handle
));
1070 acpi_bus_generate_event(ibm
->device
, event
, 0); /* unknown */
1074 static int dock_read(char *p
)
1077 int docked
= dock_docked();
1080 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1082 len
+= sprintf(p
+ len
, "status:\t\tundocked\n");
1084 len
+= sprintf(p
+ len
, "status:\t\tdocked\n");
1085 len
+= sprintf(p
+ len
, "commands:\tdock, undock\n");
1091 static int dock_write(char *buf
)
1098 while ((cmd
= next_cmd(&buf
))) {
1099 if (strlencmp(cmd
, "undock") == 0) {
1100 if (!acpi_evalf(dock_handle
, NULL
, "_DCK", "vd", 0) ||
1101 !acpi_evalf(dock_handle
, NULL
, "_EJ0", "vd", 1))
1103 } else if (strlencmp(cmd
, "dock") == 0) {
1104 if (!acpi_evalf(dock_handle
, NULL
, "_DCK", "vd", 1))
1113 #endif /* CONFIG_ACPI_IBM_DOCK */
1115 /*************************************************************************
1119 #ifdef CONFIG_ACPI_IBM_BAY
1120 static int bay_status_supported
;
1121 static int bay_status2_supported
;
1122 static int bay_eject_supported
;
1123 static int bay_eject2_supported
;
1125 IBM_HANDLE(bay
, root
, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */
1126 "\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */
1127 "\\_SB.PCI0.SATA.SCND.MSTR", /* T60, X60, Z60 */
1128 "\\_SB.PCI0.IDE0.SCND.MSTR", /* all others */
1129 ); /* A21e, R30, R31 */
1130 IBM_HANDLE(bay_ej
, bay
, "_EJ3", /* 600e/x, A2xm/p, A3x */
1131 "_EJ0", /* all others */
1132 ); /* 570,A21e,G4x,R30,R31,R32,R40e,R50e */
1133 IBM_HANDLE(bay2
, root
, "\\_SB.PCI0.IDE0.PRIM.SLAV", /* A3x, R32 */
1134 "\\_SB.PCI0.IDE0.IDEP.IDPS", /* 600e/x, 770e, 770x */
1136 IBM_HANDLE(bay2_ej
, bay2
, "_EJ3", /* 600e/x, 770e, A3x */
1140 static int bay_init(void)
1142 bay_status_supported
= bay_handle
&&
1143 acpi_evalf(bay_handle
, NULL
, "_STA", "qv");
1144 bay_status2_supported
= bay2_handle
&&
1145 acpi_evalf(bay2_handle
, NULL
, "_STA", "qv");
1147 bay_eject_supported
= bay_handle
&& bay_ej_handle
&&
1148 (strlencmp(bay_ej_path
, "_EJ0") == 0 || experimental
);
1149 bay_eject2_supported
= bay2_handle
&& bay2_ej_handle
&&
1150 (strlencmp(bay2_ej_path
, "_EJ0") == 0 || experimental
);
1155 static void bay_notify(struct ibm_struct
*ibm
, u32 event
)
1157 acpi_bus_generate_event(ibm
->device
, event
, 0);
1160 #define bay_occupied(b) (_sta(b##_handle) & 1)
1162 static int bay_read(char *p
)
1165 int occupied
= bay_occupied(bay
);
1166 int occupied2
= bay_occupied(bay2
);
1169 len
+= sprintf(p
+ len
, "status:\t\t%s\n", bay_status_supported
?
1170 (occupied
? "occupied" : "unoccupied") :
1172 if (bay_status2_supported
)
1173 len
+= sprintf(p
+ len
, "status2:\t%s\n", occupied2
?
1174 "occupied" : "unoccupied");
1176 eject
= bay_eject_supported
&& occupied
;
1177 eject2
= bay_eject2_supported
&& occupied2
;
1179 if (eject
&& eject2
)
1180 len
+= sprintf(p
+ len
, "commands:\teject, eject2\n");
1182 len
+= sprintf(p
+ len
, "commands:\teject\n");
1184 len
+= sprintf(p
+ len
, "commands:\teject2\n");
1189 static int bay_write(char *buf
)
1193 if (!bay_eject_supported
&& !bay_eject2_supported
)
1196 while ((cmd
= next_cmd(&buf
))) {
1197 if (bay_eject_supported
&& strlencmp(cmd
, "eject") == 0) {
1198 if (!acpi_evalf(bay_ej_handle
, NULL
, NULL
, "vd", 1))
1200 } else if (bay_eject2_supported
&&
1201 strlencmp(cmd
, "eject2") == 0) {
1202 if (!acpi_evalf(bay2_ej_handle
, NULL
, NULL
, "vd", 1))
1210 #endif /* CONFIG_ACPI_IBM_BAY */
1212 /*************************************************************************
1216 static int cmos_eval(int cmos_cmd
)
1219 return acpi_evalf(cmos_handle
, NULL
, NULL
, "vd", cmos_cmd
);
1224 static int cmos_read(char *p
)
1228 /* cmos not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
1229 R30, R31, T20-22, X20-21 */
1231 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1233 len
+= sprintf(p
+ len
, "status:\t\tsupported\n");
1234 len
+= sprintf(p
+ len
, "commands:\t<cmd> (<cmd> is 0-21)\n");
1240 static int cmos_write(char *buf
)
1248 while ((cmd
= next_cmd(&buf
))) {
1249 if (sscanf(cmd
, "%u", &cmos_cmd
) == 1 &&
1250 cmos_cmd
>= 0 && cmos_cmd
<= 21) {
1255 if (!cmos_eval(cmos_cmd
))
1263 /*************************************************************************
1267 static enum led_access_mode led_supported
;
1269 IBM_HANDLE(led
, ec
, "SLED", /* 570 */
1270 "SYSL", /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
1271 "LED", /* all others */
1274 static int led_init(void)
1277 /* led not supported on R30, R31 */
1278 led_supported
= IBMACPI_LED_NONE
;
1279 else if (strlencmp(led_path
, "SLED") == 0)
1281 led_supported
= IBMACPI_LED_570
;
1282 else if (strlencmp(led_path
, "SYSL") == 0)
1283 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
1284 led_supported
= IBMACPI_LED_OLD
;
1287 led_supported
= IBMACPI_LED_NEW
;
1292 #define led_status(s) ((s) == 0 ? "off" : ((s) == 1 ? "on" : "blinking"))
1294 static int led_read(char *p
)
1298 if (!led_supported
) {
1299 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1302 len
+= sprintf(p
+ len
, "status:\t\tsupported\n");
1304 if (led_supported
== IBMACPI_LED_570
) {
1307 for (i
= 0; i
< 8; i
++) {
1308 if (!acpi_evalf(ec_handle
,
1309 &status
, "GLED", "dd", 1 << i
))
1311 len
+= sprintf(p
+ len
, "%d:\t\t%s\n",
1312 i
, led_status(status
));
1316 len
+= sprintf(p
+ len
, "commands:\t"
1317 "<led> on, <led> off, <led> blink (<led> is 0-7)\n");
1322 /* off, on, blink */
1323 static const int led_sled_arg1
[] = { 0, 1, 3 };
1324 static const int led_exp_hlbl
[] = { 0, 0, 1 }; /* led# * */
1325 static const int led_exp_hlcl
[] = { 0, 1, 1 }; /* led# * */
1326 static const int led_led_arg1
[] = { 0, 0x80, 0xc0 };
1328 static int led_write(char *buf
)
1336 while ((cmd
= next_cmd(&buf
))) {
1337 if (sscanf(cmd
, "%d", &led
) != 1 || led
< 0 || led
> 7)
1340 if (strstr(cmd
, "off")) {
1342 } else if (strstr(cmd
, "on")) {
1344 } else if (strstr(cmd
, "blink")) {
1349 if (led_supported
== IBMACPI_LED_570
) {
1352 if (!acpi_evalf(led_handle
, NULL
, NULL
, "vdd",
1353 led
, led_sled_arg1
[ind
]))
1355 } else if (led_supported
== IBMACPI_LED_OLD
) {
1356 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */
1358 ret
= ec_write(IBMACPI_LED_EC_HLMS
, led
);
1361 ec_write(IBMACPI_LED_EC_HLBL
,
1362 led
* led_exp_hlbl
[ind
]);
1365 ec_write(IBMACPI_LED_EC_HLCL
,
1366 led
* led_exp_hlcl
[ind
]);
1371 if (!acpi_evalf(led_handle
, NULL
, NULL
, "vdd",
1372 led
, led_led_arg1
[ind
]))
1380 /*************************************************************************
1384 IBM_HANDLE(beep
, ec
, "BEEP"); /* all except R30, R31 */
1386 static int beep_read(char *p
)
1391 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1393 len
+= sprintf(p
+ len
, "status:\t\tsupported\n");
1394 len
+= sprintf(p
+ len
, "commands:\t<cmd> (<cmd> is 0-17)\n");
1400 static int beep_write(char *buf
)
1408 while ((cmd
= next_cmd(&buf
))) {
1409 if (sscanf(cmd
, "%u", &beep_cmd
) == 1 &&
1410 beep_cmd
>= 0 && beep_cmd
<= 17) {
1414 if (!acpi_evalf(beep_handle
, NULL
, NULL
, "vdd", beep_cmd
, 0))
1421 /*************************************************************************
1425 static enum thermal_access_mode thermal_read_mode
;
1427 static int thermal_init(void)
1431 int acpi_tmp7
= acpi_evalf(ec_handle
, NULL
, "TMP7", "qv");
1433 if (ibm_thinkpad_ec_found
&& experimental
) {
1435 * Direct EC access mode: sensors at registers
1436 * 0x78-0x7F, 0xC0-0xC7. Registers return 0x00 for
1437 * non-implemented, thermal sensors return 0x80 when
1442 for (i
= 0; i
< 8; i
++) {
1443 if (likely(acpi_ec_read(0x78 + i
, &t
))) {
1449 if (likely(acpi_ec_read(0xC0 + i
, &t
))) {
1457 /* This is sheer paranoia, but we handle it anyway */
1460 "ThinkPad ACPI EC access misbehaving, "
1461 "falling back to ACPI TMPx access mode\n");
1462 thermal_read_mode
= IBMACPI_THERMAL_ACPI_TMP07
;
1465 "ThinkPad ACPI EC access misbehaving, "
1466 "disabling thermal sensors access\n");
1467 thermal_read_mode
= IBMACPI_THERMAL_NONE
;
1472 IBMACPI_THERMAL_TPEC_16
: IBMACPI_THERMAL_TPEC_8
;
1474 } else if (acpi_tmp7
) {
1475 if (acpi_evalf(ec_handle
, NULL
, "UPDT", "qv")) {
1476 /* 600e/x, 770e, 770x */
1477 thermal_read_mode
= IBMACPI_THERMAL_ACPI_UPDT
;
1479 /* Standard ACPI TMPx access, max 8 sensors */
1480 thermal_read_mode
= IBMACPI_THERMAL_ACPI_TMP07
;
1483 /* temperatures not supported on 570, G4x, R30, R31, R32 */
1484 thermal_read_mode
= IBMACPI_THERMAL_NONE
;
1490 static int thermal_get_sensors(struct ibm_thermal_sensors_struct
*s
)
1494 char tmpi
[] = "TMPi";
1499 switch (thermal_read_mode
) {
1500 #if IBMACPI_MAX_THERMAL_SENSORS >= 16
1501 case IBMACPI_THERMAL_TPEC_16
:
1502 for (i
= 0; i
< 8; i
++) {
1503 if (!acpi_ec_read(0xC0 + i
, &tmp
))
1505 s
->temp
[i
+ 8] = tmp
* 1000;
1509 case IBMACPI_THERMAL_TPEC_8
:
1510 for (i
= 0; i
< 8; i
++) {
1511 if (!acpi_ec_read(0x78 + i
, &tmp
))
1513 s
->temp
[i
] = tmp
* 1000;
1515 return (thermal_read_mode
== IBMACPI_THERMAL_TPEC_16
) ? 16 : 8;
1517 case IBMACPI_THERMAL_ACPI_UPDT
:
1518 if (!acpi_evalf(ec_handle
, NULL
, "UPDT", "v"))
1520 for (i
= 0; i
< 8; i
++) {
1522 if (!acpi_evalf(ec_handle
, &t
, tmpi
, "d"))
1524 s
->temp
[i
] = (t
- 2732) * 100;
1528 case IBMACPI_THERMAL_ACPI_TMP07
:
1529 for (i
= 0; i
< 8; i
++) {
1531 if (!acpi_evalf(ec_handle
, &t
, tmpi
, "d"))
1533 s
->temp
[i
] = t
* 1000;
1537 case IBMACPI_THERMAL_NONE
:
1543 static int thermal_read(char *p
)
1547 struct ibm_thermal_sensors_struct t
;
1549 n
= thermal_get_sensors(&t
);
1550 if (unlikely(n
< 0))
1553 len
+= sprintf(p
+ len
, "temperatures:\t");
1556 for (i
= 0; i
< (n
- 1); i
++)
1557 len
+= sprintf(p
+ len
, "%d ", t
.temp
[i
] / 1000);
1558 len
+= sprintf(p
+ len
, "%d\n", t
.temp
[i
] / 1000);
1560 len
+= sprintf(p
+ len
, "not supported\n");
1565 /*************************************************************************
1569 static u8 ecdump_regs
[256];
1571 static int ecdump_read(char *p
)
1577 len
+= sprintf(p
+ len
, "EC "
1578 " +00 +01 +02 +03 +04 +05 +06 +07"
1579 " +08 +09 +0a +0b +0c +0d +0e +0f\n");
1580 for (i
= 0; i
< 256; i
+= 16) {
1581 len
+= sprintf(p
+ len
, "EC 0x%02x:", i
);
1582 for (j
= 0; j
< 16; j
++) {
1583 if (!acpi_ec_read(i
+ j
, &v
))
1585 if (v
!= ecdump_regs
[i
+ j
])
1586 len
+= sprintf(p
+ len
, " *%02x", v
);
1588 len
+= sprintf(p
+ len
, " %02x", v
);
1589 ecdump_regs
[i
+ j
] = v
;
1591 len
+= sprintf(p
+ len
, "\n");
1596 /* These are way too dangerous to advertise openly... */
1598 len
+= sprintf(p
+ len
, "commands:\t0x<offset> 0x<value>"
1599 " (<offset> is 00-ff, <value> is 00-ff)\n");
1600 len
+= sprintf(p
+ len
, "commands:\t0x<offset> <value> "
1601 " (<offset> is 00-ff, <value> is 0-255)\n");
1606 static int ecdump_write(char *buf
)
1611 while ((cmd
= next_cmd(&buf
))) {
1612 if (sscanf(cmd
, "0x%x 0x%x", &i
, &v
) == 2) {
1614 } else if (sscanf(cmd
, "0x%x %u", &i
, &v
) == 2) {
1618 if (i
>= 0 && i
< 256 && v
>= 0 && v
< 256) {
1619 if (!acpi_ec_write(i
, v
))
1628 /*************************************************************************
1629 * Backlight/brightness subdriver
1632 static struct backlight_device
*ibm_backlight_device
= NULL
;
1634 static struct backlight_ops ibm_backlight_data
= {
1635 .get_brightness
= brightness_get
,
1636 .update_status
= brightness_update_status
,
1639 static int brightness_init(void)
1643 b
= brightness_get(NULL
);
1647 ibm_backlight_device
= backlight_device_register("ibm", NULL
, NULL
,
1648 &ibm_backlight_data
);
1649 if (IS_ERR(ibm_backlight_device
)) {
1650 printk(IBM_ERR
"Could not register backlight device\n");
1651 return PTR_ERR(ibm_backlight_device
);
1654 ibm_backlight_device
->props
.max_brightness
= 7;
1655 ibm_backlight_device
->props
.brightness
= b
;
1656 backlight_update_status(ibm_backlight_device
);
1661 static void brightness_exit(void)
1663 if (ibm_backlight_device
) {
1664 backlight_device_unregister(ibm_backlight_device
);
1665 ibm_backlight_device
= NULL
;
1669 static int brightness_update_status(struct backlight_device
*bd
)
1671 return brightness_set(
1672 (bd
->props
.fb_blank
== FB_BLANK_UNBLANK
&&
1673 bd
->props
.power
== FB_BLANK_UNBLANK
) ?
1674 bd
->props
.brightness
: 0);
1677 static int brightness_get(struct backlight_device
*bd
)
1680 if (!acpi_ec_read(brightness_offset
, &level
))
1688 static int brightness_set(int value
)
1690 int cmos_cmd
, inc
, i
;
1691 int current_value
= brightness_get(NULL
);
1695 cmos_cmd
= value
> current_value
? TP_CMOS_BRIGHTNESS_UP
: TP_CMOS_BRIGHTNESS_DOWN
;
1696 inc
= value
> current_value
? 1 : -1;
1697 for (i
= current_value
; i
!= value
; i
+= inc
) {
1698 if (!cmos_eval(cmos_cmd
))
1700 if (!acpi_ec_write(brightness_offset
, i
+ inc
))
1707 static int brightness_read(char *p
)
1712 if ((level
= brightness_get(NULL
)) < 0) {
1713 len
+= sprintf(p
+ len
, "level:\t\tunreadable\n");
1715 len
+= sprintf(p
+ len
, "level:\t\t%d\n", level
& 0x7);
1716 len
+= sprintf(p
+ len
, "commands:\tup, down\n");
1717 len
+= sprintf(p
+ len
, "commands:\tlevel <level>"
1718 " (<level> is 0-7)\n");
1724 static int brightness_write(char *buf
)
1730 while ((cmd
= next_cmd(&buf
))) {
1731 if ((level
= brightness_get(NULL
)) < 0)
1735 if (strlencmp(cmd
, "up") == 0) {
1736 new_level
= level
== 7 ? 7 : level
+ 1;
1737 } else if (strlencmp(cmd
, "down") == 0) {
1738 new_level
= level
== 0 ? 0 : level
- 1;
1739 } else if (sscanf(cmd
, "level %d", &new_level
) == 1 &&
1740 new_level
>= 0 && new_level
<= 7) {
1745 brightness_set(new_level
);
1751 /*************************************************************************
1755 static int volume_read(char *p
)
1760 if (!acpi_ec_read(volume_offset
, &level
)) {
1761 len
+= sprintf(p
+ len
, "level:\t\tunreadable\n");
1763 len
+= sprintf(p
+ len
, "level:\t\t%d\n", level
& 0xf);
1764 len
+= sprintf(p
+ len
, "mute:\t\t%s\n", onoff(level
, 6));
1765 len
+= sprintf(p
+ len
, "commands:\tup, down, mute\n");
1766 len
+= sprintf(p
+ len
, "commands:\tlevel <level>"
1767 " (<level> is 0-15)\n");
1773 static int volume_write(char *buf
)
1775 int cmos_cmd
, inc
, i
;
1777 int new_level
, new_mute
;
1780 while ((cmd
= next_cmd(&buf
))) {
1781 if (!acpi_ec_read(volume_offset
, &level
))
1783 new_mute
= mute
= level
& 0x40;
1784 new_level
= level
= level
& 0xf;
1786 if (strlencmp(cmd
, "up") == 0) {
1790 new_level
= level
== 15 ? 15 : level
+ 1;
1791 } else if (strlencmp(cmd
, "down") == 0) {
1795 new_level
= level
== 0 ? 0 : level
- 1;
1796 } else if (sscanf(cmd
, "level %d", &new_level
) == 1 &&
1797 new_level
>= 0 && new_level
<= 15) {
1799 } else if (strlencmp(cmd
, "mute") == 0) {
1804 if (new_level
!= level
) { /* mute doesn't change */
1805 cmos_cmd
= new_level
> level
? TP_CMOS_VOLUME_UP
: TP_CMOS_VOLUME_DOWN
;
1806 inc
= new_level
> level
? 1 : -1;
1808 if (mute
&& (!cmos_eval(cmos_cmd
) ||
1809 !acpi_ec_write(volume_offset
, level
)))
1812 for (i
= level
; i
!= new_level
; i
+= inc
)
1813 if (!cmos_eval(cmos_cmd
) ||
1814 !acpi_ec_write(volume_offset
, i
+ inc
))
1817 if (mute
&& (!cmos_eval(TP_CMOS_VOLUME_MUTE
) ||
1818 !acpi_ec_write(volume_offset
,
1823 if (new_mute
!= mute
) { /* level doesn't change */
1824 cmos_cmd
= new_mute
? TP_CMOS_VOLUME_MUTE
: TP_CMOS_VOLUME_UP
;
1826 if (!cmos_eval(cmos_cmd
) ||
1827 !acpi_ec_write(volume_offset
, level
+ new_mute
))
1836 /*************************************************************************
1843 * IBMACPI_FAN_RD_ACPI_GFAN:
1844 * ACPI GFAN method: returns fan level
1846 * see IBMACPI_FAN_WR_ACPI_SFAN
1847 * EC 0x2f not available if GFAN exists
1849 * IBMACPI_FAN_WR_ACPI_SFAN:
1850 * ACPI SFAN method: sets fan level, 0 (stop) to 7 (max)
1852 * EC 0x2f might be available *for reading*, but never for writing.
1854 * IBMACPI_FAN_WR_TPEC:
1855 * ThinkPad EC register 0x2f (HFSP): fan control loop mode Supported
1856 * on almost all ThinkPads
1858 * Fan speed changes of any sort (including those caused by the
1859 * disengaged mode) are usually done slowly by the firmware as the
1860 * maximum ammount of fan duty cycle change per second seems to be
1863 * Reading is not available if GFAN exists.
1864 * Writing is not available if SFAN exists.
1867 * 7 automatic mode engaged;
1868 * (default operation mode of the ThinkPad)
1869 * fan level is ignored in this mode.
1870 * 6 disengage mode (takes precedence over bit 7);
1871 * not available on all thinkpads. May disable
1872 * the tachometer, and speeds up fan to 100% duty-cycle,
1873 * which speeds it up far above the standard RPM
1874 * levels. It is not impossible that it could cause
1876 * 5-3 unused in some models. Extra bits for fan level
1877 * in others, but still useless as all values above
1878 * 7 map to the same speed as level 7 in these models.
1879 * 2-0 fan level (0..7 usually)
1881 * 0x07 = max (set when temperatures critical)
1882 * Some ThinkPads may have other levels, see
1883 * IBMACPI_FAN_WR_ACPI_FANS (X31/X40/X41)
1885 * FIRMWARE BUG: on some models, EC 0x2f might not be initialized at
1886 * boot. Apparently the EC does not intialize it, so unless ACPI DSDT
1887 * does so, its initial value is meaningless (0x07).
1889 * For firmware bugs, refer to:
1890 * http://thinkwiki.org/wiki/Embedded_Controller_Firmware#Firmware_Issues
1894 * ThinkPad EC register 0x84 (LSB), 0x85 (MSB):
1895 * Main fan tachometer reading (in RPM)
1897 * This register is present on all ThinkPads with a new-style EC, and
1898 * it is known not to be present on the A21m/e, and T22, as there is
1899 * something else in offset 0x84 according to the ACPI DSDT. Other
1900 * ThinkPads from this same time period (and earlier) probably lack the
1901 * tachometer as well.
1903 * Unfortunately a lot of ThinkPads with new-style ECs but whose firwmare
1904 * was never fixed by IBM to report the EC firmware version string
1905 * probably support the tachometer (like the early X models), so
1906 * detecting it is quite hard. We need more data to know for sure.
1908 * FIRMWARE BUG: always read 0x84 first, otherwise incorrect readings
1911 * FIRMWARE BUG: when EC 0x2f bit 6 is set (disengaged mode), this
1912 * register is not invalidated in ThinkPads that disable tachometer
1913 * readings. Thus, the tachometer readings go stale.
1915 * For firmware bugs, refer to:
1916 * http://thinkwiki.org/wiki/Embedded_Controller_Firmware#Firmware_Issues
1918 * IBMACPI_FAN_WR_ACPI_FANS:
1919 * ThinkPad X31, X40, X41. Not available in the X60.
1921 * FANS ACPI handle: takes three arguments: low speed, medium speed,
1922 * high speed. ACPI DSDT seems to map these three speeds to levels
1923 * as follows: STOP LOW LOW MED MED HIGH HIGH HIGH HIGH
1924 * (this map is stored on FAN0..FAN8 as "0,1,1,2,2,3,3,3,3")
1926 * The speeds are stored on handles
1927 * (FANA:FAN9), (FANC:FANB), (FANE:FAND).
1929 * There are three default speed sets, acessible as handles:
1930 * FS1L,FS1M,FS1H; FS2L,FS2M,FS2H; FS3L,FS3M,FS3H
1932 * ACPI DSDT switches which set is in use depending on various
1935 * IBMACPI_FAN_WR_TPEC is also available and should be used to
1936 * command the fan. The X31/X40/X41 seems to have 8 fan levels,
1937 * but the ACPI tables just mention level 7.
1940 static enum fan_status_access_mode fan_status_access_mode
;
1941 static enum fan_control_access_mode fan_control_access_mode
;
1942 static enum fan_control_commands fan_control_commands
;
1944 static int fan_control_status_known
;
1945 static u8 fan_control_initial_status
;
1947 static void fan_watchdog_fire(struct work_struct
*ignored
);
1948 static int fan_watchdog_maxinterval
;
1949 static DECLARE_DELAYED_WORK(fan_watchdog_task
, fan_watchdog_fire
);
1951 IBM_HANDLE(fans
, ec
, "FANS"); /* X31, X40, X41 */
1952 IBM_HANDLE(gfan
, ec
, "GFAN", /* 570 */
1953 "\\FSPD", /* 600e/x, 770e, 770x */
1955 IBM_HANDLE(sfan
, ec
, "SFAN", /* 570 */
1956 "JFNS", /* 770x-JL */
1959 static int fan_init(void)
1961 fan_status_access_mode
= IBMACPI_FAN_NONE
;
1962 fan_control_access_mode
= IBMACPI_FAN_WR_NONE
;
1963 fan_control_commands
= 0;
1964 fan_control_status_known
= 1;
1965 fan_watchdog_maxinterval
= 0;
1968 /* 570, 600e/x, 770e, 770x */
1969 fan_status_access_mode
= IBMACPI_FAN_RD_ACPI_GFAN
;
1971 /* all other ThinkPads: note that even old-style
1972 * ThinkPad ECs supports the fan control register */
1973 if (likely(acpi_ec_read(fan_status_offset
,
1974 &fan_control_initial_status
))) {
1975 fan_status_access_mode
= IBMACPI_FAN_RD_TPEC
;
1977 /* In some ThinkPads, neither the EC nor the ACPI
1978 * DSDT initialize the fan status, and it ends up
1979 * being set to 0x07 when it *could* be either
1982 * Enable for TP-1Y (T43), TP-78 (R51e),
1983 * TP-76 (R52), TP-70 (T43, R52), which are known
1985 if (fan_control_initial_status
== 0x07 &&
1986 ibm_thinkpad_ec_found
&&
1987 ((ibm_thinkpad_ec_found
[0] == '1' &&
1988 ibm_thinkpad_ec_found
[1] == 'Y') ||
1989 (ibm_thinkpad_ec_found
[0] == '7' &&
1990 (ibm_thinkpad_ec_found
[1] == '6' ||
1991 ibm_thinkpad_ec_found
[1] == '8' ||
1992 ibm_thinkpad_ec_found
[1] == '0'))
1995 "fan_init: initial fan status is "
1996 "unknown, assuming it is in auto "
1998 fan_control_status_known
= 0;
2002 "ThinkPad ACPI EC access misbehaving, "
2003 "fan status and control unavailable\n");
2010 fan_control_access_mode
= IBMACPI_FAN_WR_ACPI_SFAN
;
2011 fan_control_commands
|=
2012 IBMACPI_FAN_CMD_LEVEL
| IBMACPI_FAN_CMD_ENABLE
;
2015 /* gfan without sfan means no fan control */
2016 /* all other models implement TP EC 0x2f control */
2020 fan_control_access_mode
=
2021 IBMACPI_FAN_WR_ACPI_FANS
;
2022 fan_control_commands
|=
2023 IBMACPI_FAN_CMD_SPEED
|
2024 IBMACPI_FAN_CMD_LEVEL
|
2025 IBMACPI_FAN_CMD_ENABLE
;
2027 fan_control_access_mode
= IBMACPI_FAN_WR_TPEC
;
2028 fan_control_commands
|=
2029 IBMACPI_FAN_CMD_LEVEL
|
2030 IBMACPI_FAN_CMD_ENABLE
;
2038 static int fan_get_status(u8
*status
)
2043 * Add IBMACPI_FAN_RD_ACPI_FANS ? */
2045 switch (fan_status_access_mode
) {
2046 case IBMACPI_FAN_RD_ACPI_GFAN
:
2047 /* 570, 600e/x, 770e, 770x */
2049 if (unlikely(!acpi_evalf(gfan_handle
, &s
, NULL
, "d")))
2057 case IBMACPI_FAN_RD_TPEC
:
2058 /* all except 570, 600e/x, 770e, 770x */
2059 if (unlikely(!acpi_ec_read(fan_status_offset
, &s
)))
2074 static void fan_exit(void)
2076 cancel_delayed_work(&fan_watchdog_task
);
2077 flush_scheduled_work();
2080 static int fan_get_speed(unsigned int *speed
)
2084 switch (fan_status_access_mode
) {
2085 case IBMACPI_FAN_RD_TPEC
:
2086 /* all except 570, 600e/x, 770e, 770x */
2087 if (unlikely(!acpi_ec_read(fan_rpm_offset
, &lo
) ||
2088 !acpi_ec_read(fan_rpm_offset
+ 1, &hi
)))
2092 *speed
= (hi
<< 8) | lo
;
2103 static void fan_watchdog_fire(struct work_struct
*ignored
)
2105 printk(IBM_NOTICE
"fan watchdog: enabling fan\n");
2106 if (fan_set_enable()) {
2107 printk(IBM_ERR
"fan watchdog: error while enabling fan\n");
2108 /* reschedule for later */
2109 fan_watchdog_reset();
2113 static void fan_watchdog_reset(void)
2115 static int fan_watchdog_active
= 0;
2117 if (fan_watchdog_active
)
2118 cancel_delayed_work(&fan_watchdog_task
);
2120 if (fan_watchdog_maxinterval
> 0) {
2121 fan_watchdog_active
= 1;
2122 if (!schedule_delayed_work(&fan_watchdog_task
,
2123 msecs_to_jiffies(fan_watchdog_maxinterval
2125 printk(IBM_ERR
"failed to schedule the fan watchdog, "
2126 "watchdog will not trigger\n");
2129 fan_watchdog_active
= 0;
2132 static int fan_set_level(int level
)
2134 switch (fan_control_access_mode
) {
2135 case IBMACPI_FAN_WR_ACPI_SFAN
:
2136 if (level
>= 0 && level
<= 7) {
2137 if (!acpi_evalf(sfan_handle
, NULL
, NULL
, "vd", level
))
2143 case IBMACPI_FAN_WR_ACPI_FANS
:
2144 case IBMACPI_FAN_WR_TPEC
:
2145 if ((level
!= IBMACPI_FAN_EC_AUTO
) &&
2146 (level
!= IBMACPI_FAN_EC_DISENGAGED
) &&
2147 ((level
< 0) || (level
> 7)))
2150 if (!acpi_ec_write(fan_status_offset
, level
))
2153 fan_control_status_known
= 1;
2162 static int fan_set_enable(void)
2167 switch (fan_control_access_mode
) {
2168 case IBMACPI_FAN_WR_ACPI_FANS
:
2169 case IBMACPI_FAN_WR_TPEC
:
2170 if ((rc
= fan_get_status(&s
)) < 0)
2173 /* Don't go out of emergency fan mode */
2175 s
= IBMACPI_FAN_EC_AUTO
;
2177 if (!acpi_ec_write(fan_status_offset
, s
))
2180 fan_control_status_known
= 1;
2183 case IBMACPI_FAN_WR_ACPI_SFAN
:
2184 if ((rc
= fan_get_status(&s
)) < 0)
2189 /* Set fan to at least level 4 */
2193 if (!acpi_evalf(sfan_handle
, NULL
, NULL
, "vd", s
))
2203 static int fan_set_disable(void)
2205 switch (fan_control_access_mode
) {
2206 case IBMACPI_FAN_WR_ACPI_FANS
:
2207 case IBMACPI_FAN_WR_TPEC
:
2208 if (!acpi_ec_write(fan_status_offset
, 0x00))
2211 fan_control_status_known
= 1;
2214 case IBMACPI_FAN_WR_ACPI_SFAN
:
2215 if (!acpi_evalf(sfan_handle
, NULL
, NULL
, "vd", 0x00))
2225 static int fan_set_speed(int speed
)
2227 switch (fan_control_access_mode
) {
2228 case IBMACPI_FAN_WR_ACPI_FANS
:
2229 if (speed
>= 0 && speed
<= 65535) {
2230 if (!acpi_evalf(fans_handle
, NULL
, NULL
, "vddd",
2231 speed
, speed
, speed
))
2243 static int fan_read(char *p
)
2248 unsigned int speed
= 0;
2250 switch (fan_status_access_mode
) {
2251 case IBMACPI_FAN_RD_ACPI_GFAN
:
2252 /* 570, 600e/x, 770e, 770x */
2253 if ((rc
= fan_get_status(&status
)) < 0)
2256 len
+= sprintf(p
+ len
, "status:\t\t%s\n"
2258 (status
!= 0) ? "enabled" : "disabled", status
);
2261 case IBMACPI_FAN_RD_TPEC
:
2262 /* all except 570, 600e/x, 770e, 770x */
2263 if ((rc
= fan_get_status(&status
)) < 0)
2266 if (unlikely(!fan_control_status_known
)) {
2267 if (status
!= fan_control_initial_status
)
2268 fan_control_status_known
= 1;
2270 /* Return most likely status. In fact, it
2271 * might be the only possible status */
2272 status
= IBMACPI_FAN_EC_AUTO
;
2275 len
+= sprintf(p
+ len
, "status:\t\t%s\n",
2276 (status
!= 0) ? "enabled" : "disabled");
2278 /* No ThinkPad boots on disengaged mode, we can safely
2279 * assume the tachometer is online if fan control status
2281 if ((rc
= fan_get_speed(&speed
)) < 0)
2284 len
+= sprintf(p
+ len
, "speed:\t\t%d\n", speed
);
2286 if (status
& IBMACPI_FAN_EC_DISENGAGED
)
2287 /* Disengaged mode takes precedence */
2288 len
+= sprintf(p
+ len
, "level:\t\tdisengaged\n");
2289 else if (status
& IBMACPI_FAN_EC_AUTO
)
2290 len
+= sprintf(p
+ len
, "level:\t\tauto\n");
2292 len
+= sprintf(p
+ len
, "level:\t\t%d\n", status
);
2295 case IBMACPI_FAN_NONE
:
2297 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
2300 if (fan_control_commands
& IBMACPI_FAN_CMD_LEVEL
) {
2301 len
+= sprintf(p
+ len
, "commands:\tlevel <level>");
2303 switch (fan_control_access_mode
) {
2304 case IBMACPI_FAN_WR_ACPI_SFAN
:
2305 len
+= sprintf(p
+ len
, " (<level> is 0-7)\n");
2309 len
+= sprintf(p
+ len
, " (<level> is 0-7, "
2310 "auto, disengaged)\n");
2315 if (fan_control_commands
& IBMACPI_FAN_CMD_ENABLE
)
2316 len
+= sprintf(p
+ len
, "commands:\tenable, disable\n"
2317 "commands:\twatchdog <timeout> (<timeout> is 0 (off), "
2318 "1-120 (seconds))\n");
2320 if (fan_control_commands
& IBMACPI_FAN_CMD_SPEED
)
2321 len
+= sprintf(p
+ len
, "commands:\tspeed <speed>"
2322 " (<speed> is 0-65535)\n");
2327 static int fan_write_cmd_level(const char *cmd
, int *rc
)
2331 if (strlencmp(cmd
, "level auto") == 0)
2332 level
= IBMACPI_FAN_EC_AUTO
;
2333 else if (strlencmp(cmd
, "level disengaged") == 0)
2334 level
= IBMACPI_FAN_EC_DISENGAGED
;
2335 else if (sscanf(cmd
, "level %d", &level
) != 1)
2338 if ((*rc
= fan_set_level(level
)) == -ENXIO
)
2339 printk(IBM_ERR
"level command accepted for unsupported "
2340 "access mode %d", fan_control_access_mode
);
2345 static int fan_write_cmd_enable(const char *cmd
, int *rc
)
2347 if (strlencmp(cmd
, "enable") != 0)
2350 if ((*rc
= fan_set_enable()) == -ENXIO
)
2351 printk(IBM_ERR
"enable command accepted for unsupported "
2352 "access mode %d", fan_control_access_mode
);
2357 static int fan_write_cmd_disable(const char *cmd
, int *rc
)
2359 if (strlencmp(cmd
, "disable") != 0)
2362 if ((*rc
= fan_set_disable()) == -ENXIO
)
2363 printk(IBM_ERR
"disable command accepted for unsupported "
2364 "access mode %d", fan_control_access_mode
);
2369 static int fan_write_cmd_speed(const char *cmd
, int *rc
)
2374 * Support speed <low> <medium> <high> ? */
2376 if (sscanf(cmd
, "speed %d", &speed
) != 1)
2379 if ((*rc
= fan_set_speed(speed
)) == -ENXIO
)
2380 printk(IBM_ERR
"speed command accepted for unsupported "
2381 "access mode %d", fan_control_access_mode
);
2386 static int fan_write_cmd_watchdog(const char *cmd
, int *rc
)
2390 if (sscanf(cmd
, "watchdog %d", &interval
) != 1)
2393 if (interval
< 0 || interval
> 120)
2396 fan_watchdog_maxinterval
= interval
;
2401 static int fan_write(char *buf
)
2406 while (!rc
&& (cmd
= next_cmd(&buf
))) {
2407 if (!((fan_control_commands
& IBMACPI_FAN_CMD_LEVEL
) &&
2408 fan_write_cmd_level(cmd
, &rc
)) &&
2409 !((fan_control_commands
& IBMACPI_FAN_CMD_ENABLE
) &&
2410 (fan_write_cmd_enable(cmd
, &rc
) ||
2411 fan_write_cmd_disable(cmd
, &rc
) ||
2412 fan_write_cmd_watchdog(cmd
, &rc
))) &&
2413 !((fan_control_commands
& IBMACPI_FAN_CMD_SPEED
) &&
2414 fan_write_cmd_speed(cmd
, &rc
))
2418 fan_watchdog_reset();
2424 /****************************************************************************
2425 ****************************************************************************
2429 ****************************************************************************
2430 ****************************************************************************/
2433 static struct proc_dir_entry
*proc_dir
= NULL
;
2435 /* Subdriver registry */
2436 static struct ibm_struct ibms
[] = {
2439 .init
= ibm_acpi_driver_init
,
2440 .read
= ibm_acpi_driver_read
,
2444 .hid
= IBM_HKEY_HID
,
2445 .init
= hotkey_init
,
2446 .read
= hotkey_read
,
2447 .write
= hotkey_write
,
2448 .exit
= hotkey_exit
,
2449 .notify
= hotkey_notify
,
2450 .handle
= &hkey_handle
,
2451 .type
= ACPI_DEVICE_NOTIFY
,
2454 .name
= "bluetooth",
2455 .init
= bluetooth_init
,
2456 .read
= bluetooth_read
,
2457 .write
= bluetooth_write
,
2470 .write
= video_write
,
2477 .write
= light_write
,
2479 #ifdef CONFIG_ACPI_IBM_DOCK
2483 .write
= dock_write
,
2484 .notify
= dock_notify
,
2485 .handle
= &dock_handle
,
2486 .type
= ACPI_SYSTEM_NOTIFY
,
2491 .notify
= dock_notify
,
2492 .handle
= &pci_handle
,
2493 .type
= ACPI_SYSTEM_NOTIFY
,
2496 #ifdef CONFIG_ACPI_IBM_BAY
2502 .notify
= bay_notify
,
2503 .handle
= &bay_handle
,
2504 .type
= ACPI_SYSTEM_NOTIFY
,
2506 #endif /* CONFIG_ACPI_IBM_BAY */
2510 .write
= cmos_write
,
2521 .write
= beep_write
,
2525 .init
= thermal_init
,
2526 .read
= thermal_read
,
2530 .read
= ecdump_read
,
2531 .write
= ecdump_write
,
2535 .name
= "brightness",
2536 .read
= brightness_read
,
2537 .write
= brightness_write
,
2538 .init
= brightness_init
,
2539 .exit
= brightness_exit
,
2543 .read
= volume_read
,
2544 .write
= volume_write
,
2557 * Module and infrastructure proble, init and exit handling
2560 static int __init
ibm_init(struct ibm_struct
*ibm
)
2563 struct proc_dir_entry
*entry
;
2565 if (ibm
->experimental
&& !experimental
)
2569 ret
= register_ibmacpi_subdriver(ibm
);
2572 ibm
->driver_registered
= 1;
2579 ibm
->init_called
= 1;
2583 entry
= create_proc_entry(ibm
->name
,
2584 S_IFREG
| S_IRUGO
| S_IWUSR
,
2587 printk(IBM_ERR
"unable to create proc entry %s\n",
2591 entry
->owner
= THIS_MODULE
;
2593 entry
->read_proc
= &dispatch_read
;
2595 entry
->write_proc
= &dispatch_write
;
2596 ibm
->proc_created
= 1;
2600 ret
= setup_notify(ibm
);
2601 if (ret
== -ENODEV
) {
2602 printk(IBM_NOTICE
"disabling subdriver %s\n",
2614 static void ibm_exit(struct ibm_struct
*ibm
)
2616 if (ibm
->notify_installed
)
2617 acpi_remove_notify_handler(*ibm
->handle
, ibm
->type
,
2620 if (ibm
->proc_created
)
2621 remove_proc_entry(ibm
->name
, proc_dir
);
2623 if (ibm
->init_called
&& ibm
->exit
)
2626 if (ibm
->driver_registered
) {
2627 acpi_bus_unregister_driver(ibm
->driver
);
2634 static char *ibm_thinkpad_ec_found
= NULL
;
2636 static char* __init
check_dmi_for_ec(void)
2638 struct dmi_device
*dev
= NULL
;
2639 char ec_fw_string
[18];
2642 * ThinkPad T23 or newer, A31 or newer, R50e or newer,
2643 * X32 or newer, all Z series; Some models must have an
2644 * up-to-date BIOS or they will not be detected.
2646 * See http://thinkwiki.org/wiki/List_of_DMI_IDs
2648 while ((dev
= dmi_find_device(DMI_DEV_TYPE_OEM_STRING
, NULL
, dev
))) {
2649 if (sscanf(dev
->name
,
2650 "IBM ThinkPad Embedded Controller -[%17c",
2651 ec_fw_string
) == 1) {
2652 ec_fw_string
[sizeof(ec_fw_string
) - 1] = 0;
2653 ec_fw_string
[strcspn(ec_fw_string
, " ]")] = 0;
2654 return kstrdup(ec_fw_string
, GFP_KERNEL
);
2660 /* Module init, exit, parameters */
2662 static int __init
set_ibm_param(const char *val
, struct kernel_param
*kp
)
2666 for (i
= 0; i
< ARRAY_SIZE(ibms
); i
++)
2667 if (strcmp(ibms
[i
].name
, kp
->name
) == 0 && ibms
[i
].write
) {
2668 if (strlen(val
) > sizeof(ibms
[i
].param
) - 2)
2670 strcpy(ibms
[i
].param
, val
);
2671 strcat(ibms
[i
].param
, ",");
2678 static int experimental
;
2679 module_param(experimental
, int, 0);
2681 #define IBM_PARAM(feature) \
2682 module_param_call(feature, set_ibm_param, NULL, NULL, 0)
2685 IBM_PARAM(bluetooth
);
2688 #ifdef CONFIG_ACPI_IBM_DOCK
2691 #ifdef CONFIG_ACPI_IBM_BAY
2693 #endif /* CONFIG_ACPI_IBM_BAY */
2698 IBM_PARAM(brightness
);
2702 static int __init
acpi_ibm_init(void)
2709 /* ec is required because many other handles are relative to it */
2710 IBM_HANDLE_INIT(ec
);
2712 printk(IBM_ERR
"ec object not found\n");
2716 /* Models with newer firmware report the EC in DMI */
2717 ibm_thinkpad_ec_found
= check_dmi_for_ec();
2719 /* these handles are not required */
2720 IBM_HANDLE_INIT(vid
);
2721 IBM_HANDLE_INIT(vid2
);
2722 IBM_HANDLE_INIT(ledb
);
2723 IBM_HANDLE_INIT(led
);
2724 IBM_HANDLE_INIT(hkey
);
2725 IBM_HANDLE_INIT(lght
);
2726 IBM_HANDLE_INIT(cmos
);
2727 #ifdef CONFIG_ACPI_IBM_DOCK
2728 IBM_HANDLE_INIT(dock
);
2730 IBM_HANDLE_INIT(pci
);
2731 #ifdef CONFIG_ACPI_IBM_BAY
2732 IBM_HANDLE_INIT(bay
);
2734 IBM_HANDLE_INIT(bay_ej
);
2735 IBM_HANDLE_INIT(bay2
);
2737 IBM_HANDLE_INIT(bay2_ej
);
2738 #endif /* CONFIG_ACPI_IBM_BAY */
2739 IBM_HANDLE_INIT(beep
);
2740 IBM_HANDLE_INIT(ecrd
);
2741 IBM_HANDLE_INIT(ecwr
);
2742 IBM_HANDLE_INIT(fans
);
2743 IBM_HANDLE_INIT(gfan
);
2744 IBM_HANDLE_INIT(sfan
);
2746 proc_dir
= proc_mkdir(IBM_DIR
, acpi_root_dir
);
2748 printk(IBM_ERR
"unable to create proc dir %s", IBM_DIR
);
2752 proc_dir
->owner
= THIS_MODULE
;
2754 for (i
= 0; i
< ARRAY_SIZE(ibms
); i
++) {
2755 ret
= ibm_init(&ibms
[i
]);
2756 if (ret
>= 0 && *ibms
[i
].param
)
2757 ret
= ibms
[i
].write(ibms
[i
].param
);
2767 static void acpi_ibm_exit(void)
2771 for (i
= ARRAY_SIZE(ibms
) - 1; i
>= 0; i
--)
2775 remove_proc_entry(IBM_DIR
, acpi_root_dir
);
2777 if (ibm_thinkpad_ec_found
)
2778 kfree(ibm_thinkpad_ec_found
);
2781 module_init(acpi_ibm_init
);
2782 module_exit(acpi_ibm_exit
);