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 static int experimental
;
91 module_param(experimental
, int, 0);
93 static acpi_handle root_handle
= NULL
;
95 #define IBM_HANDLE(object, parent, paths...) \
96 static acpi_handle object##_handle; \
97 static acpi_handle *object##_parent = &parent##_handle; \
98 static char *object##_path; \
99 static char *object##_paths[] = { paths }
101 IBM_HANDLE(ec
, root
, "\\_SB.PCI0.ISA.EC0", /* 240, 240x */
102 "\\_SB.PCI.ISA.EC", /* 570 */
103 "\\_SB.PCI0.ISA0.EC0", /* 600e/x, 770e, 770x */
104 "\\_SB.PCI0.ISA.EC", /* A21e, A2xm/p, T20-22, X20-21 */
105 "\\_SB.PCI0.AD4S.EC0", /* i1400, R30 */
106 "\\_SB.PCI0.ICH3.EC0", /* R31 */
107 "\\_SB.PCI0.LPC.EC", /* all others */
110 IBM_HANDLE(vid
, root
, "\\_SB.PCI.AGP.VGA", /* 570 */
111 "\\_SB.PCI0.AGP0.VID0", /* 600e/x, 770x */
112 "\\_SB.PCI0.VID0", /* 770e */
113 "\\_SB.PCI0.VID", /* A21e, G4x, R50e, X30, X40 */
114 "\\_SB.PCI0.AGP.VID", /* all others */
117 IBM_HANDLE(vid2
, root
, "\\_SB.PCI0.AGPB.VID"); /* G41 */
119 IBM_HANDLE(cmos
, root
, "\\UCMS", /* R50, R50e, R50p, R51, T4x, X31, X40 */
120 "\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */
121 "\\CMS", /* R40, R40e */
123 #ifdef CONFIG_ACPI_IBM_DOCK
124 IBM_HANDLE(dock
, root
, "\\_SB.GDCK", /* X30, X31, X40 */
125 "\\_SB.PCI0.DOCK", /* 600e/x,770e,770x,A2xm/p,T20-22,X20-21 */
126 "\\_SB.PCI0.PCI1.DOCK", /* all others */
127 "\\_SB.PCI.ISA.SLCE", /* 570 */
128 ); /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */
130 #ifdef CONFIG_ACPI_IBM_BAY
131 IBM_HANDLE(bay
, root
, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */
132 "\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */
133 "\\_SB.PCI0.SATA.SCND.MSTR", /* T60, X60, Z60 */
134 "\\_SB.PCI0.IDE0.SCND.MSTR", /* all others */
135 ); /* A21e, R30, R31 */
137 IBM_HANDLE(bay_ej
, bay
, "_EJ3", /* 600e/x, A2xm/p, A3x */
138 "_EJ0", /* all others */
139 ); /* 570,A21e,G4x,R30,R31,R32,R40e,R50e */
141 IBM_HANDLE(bay2
, root
, "\\_SB.PCI0.IDE0.PRIM.SLAV", /* A3x, R32 */
142 "\\_SB.PCI0.IDE0.IDEP.IDPS", /* 600e/x, 770e, 770x */
145 IBM_HANDLE(bay2_ej
, bay2
, "_EJ3", /* 600e/x, 770e, A3x */
148 #endif /* CONFIG_ACPI_IBM_BAY */
150 /* don't list other alternatives as we install a notify handler on the 570 */
151 IBM_HANDLE(pci
, root
, "\\_SB.PCI"); /* 570 */
153 IBM_HANDLE(hkey
, ec
, "\\_SB.HKEY", /* 600e/x, 770e, 770x */
154 "^HKEY", /* R30, R31 */
155 "HKEY", /* all others */
158 IBM_HANDLE(lght
, root
, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */
159 IBM_HANDLE(ledb
, ec
, "LEDB"); /* G4x */
161 IBM_HANDLE(led
, ec
, "SLED", /* 570 */
162 "SYSL", /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
163 "LED", /* all others */
166 IBM_HANDLE(beep
, ec
, "BEEP"); /* all except R30, R31 */
167 IBM_HANDLE(ecrd
, ec
, "ECRD"); /* 570 */
168 IBM_HANDLE(ecwr
, ec
, "ECWR"); /* 570 */
169 IBM_HANDLE(fans
, ec
, "FANS"); /* X31, X40, X41 */
171 IBM_HANDLE(gfan
, ec
, "GFAN", /* 570 */
172 "\\FSPD", /* 600e/x, 770e, 770x */
175 IBM_HANDLE(sfan
, ec
, "SFAN", /* 570 */
176 "JFNS", /* 770x-JL */
182 * IBMACPI_FAN_RD_ACPI_GFAN:
183 * ACPI GFAN method: returns fan level
185 * see IBMACPI_FAN_WR_ACPI_SFAN
186 * EC 0x2f not available if GFAN exists
188 * IBMACPI_FAN_WR_ACPI_SFAN:
189 * ACPI SFAN method: sets fan level, 0 (stop) to 7 (max)
191 * EC 0x2f might be available *for reading*, but never for writing.
193 * IBMACPI_FAN_WR_TPEC:
194 * ThinkPad EC register 0x2f (HFSP): fan control loop mode Supported
195 * on almost all ThinkPads
197 * Fan speed changes of any sort (including those caused by the
198 * disengaged mode) are usually done slowly by the firmware as the
199 * maximum ammount of fan duty cycle change per second seems to be
202 * Reading is not available if GFAN exists.
203 * Writing is not available if SFAN exists.
206 * 7 automatic mode engaged;
207 * (default operation mode of the ThinkPad)
208 * fan level is ignored in this mode.
209 * 6 disengage mode (takes precedence over bit 7);
210 * not available on all thinkpads. May disable
211 * the tachometer, and speeds up fan to 100% duty-cycle,
212 * which speeds it up far above the standard RPM
213 * levels. It is not impossible that it could cause
215 * 5-3 unused in some models. Extra bits for fan level
216 * in others, but still useless as all values above
217 * 7 map to the same speed as level 7 in these models.
218 * 2-0 fan level (0..7 usually)
220 * 0x07 = max (set when temperatures critical)
221 * Some ThinkPads may have other levels, see
222 * IBMACPI_FAN_WR_ACPI_FANS (X31/X40/X41)
224 * FIRMWARE BUG: on some models, EC 0x2f might not be initialized at
225 * boot. Apparently the EC does not intialize it, so unless ACPI DSDT
226 * does so, its initial value is meaningless (0x07).
228 * For firmware bugs, refer to:
229 * http://thinkwiki.org/wiki/Embedded_Controller_Firmware#Firmware_Issues
233 * ThinkPad EC register 0x84 (LSB), 0x85 (MSB):
234 * Main fan tachometer reading (in RPM)
236 * This register is present on all ThinkPads with a new-style EC, and
237 * it is known not to be present on the A21m/e, and T22, as there is
238 * something else in offset 0x84 according to the ACPI DSDT. Other
239 * ThinkPads from this same time period (and earlier) probably lack the
240 * tachometer as well.
242 * Unfortunately a lot of ThinkPads with new-style ECs but whose firwmare
243 * was never fixed by IBM to report the EC firmware version string
244 * probably support the tachometer (like the early X models), so
245 * detecting it is quite hard. We need more data to know for sure.
247 * FIRMWARE BUG: always read 0x84 first, otherwise incorrect readings
250 * FIRMWARE BUG: when EC 0x2f bit 6 is set (disengaged mode), this
251 * register is not invalidated in ThinkPads that disable tachometer
252 * readings. Thus, the tachometer readings go stale.
254 * For firmware bugs, refer to:
255 * http://thinkwiki.org/wiki/Embedded_Controller_Firmware#Firmware_Issues
257 * IBMACPI_FAN_WR_ACPI_FANS:
258 * ThinkPad X31, X40, X41. Not available in the X60.
260 * FANS ACPI handle: takes three arguments: low speed, medium speed,
261 * high speed. ACPI DSDT seems to map these three speeds to levels
262 * as follows: STOP LOW LOW MED MED HIGH HIGH HIGH HIGH
263 * (this map is stored on FAN0..FAN8 as "0,1,1,2,2,3,3,3,3")
265 * The speeds are stored on handles
266 * (FANA:FAN9), (FANC:FANB), (FANE:FAND).
268 * There are three default speed sets, acessible as handles:
269 * FS1L,FS1M,FS1H; FS2L,FS2M,FS2H; FS3L,FS3M,FS3H
271 * ACPI DSDT switches which set is in use depending on various
274 * IBMACPI_FAN_WR_TPEC is also available and should be used to
275 * command the fan. The X31/X40/X41 seems to have 8 fan levels,
276 * but the ACPI tables just mention level 7.
279 static char *ibm_thinkpad_ec_found
= NULL
;
281 static struct proc_dir_entry
*proc_dir
= NULL
;
283 static struct backlight_device
*ibm_backlight_device
= NULL
;
285 static int acpi_evalf(acpi_handle handle
,
286 void *res
, char *method
, char *fmt
, ...)
289 struct acpi_object_list params
;
290 union acpi_object in_objs
[IBM_MAX_ACPI_ARGS
];
291 struct acpi_buffer result
, *resultp
;
292 union acpi_object out_obj
;
300 printk(IBM_ERR
"acpi_evalf() called with empty format\n");
313 params
.pointer
= &in_objs
[0];
320 in_objs
[params
.count
].integer
.value
= va_arg(ap
, int);
321 in_objs
[params
.count
++].type
= ACPI_TYPE_INTEGER
;
323 /* add more types as needed */
325 printk(IBM_ERR
"acpi_evalf() called "
326 "with invalid format character '%c'\n", c
);
332 if (res_type
!= 'v') {
333 result
.length
= sizeof(out_obj
);
334 result
.pointer
= &out_obj
;
339 status
= acpi_evaluate_object(handle
, method
, ¶ms
, resultp
);
344 *(int *)res
= out_obj
.integer
.value
;
345 success
= status
== AE_OK
&& out_obj
.type
== ACPI_TYPE_INTEGER
;
348 success
= status
== AE_OK
;
350 /* add more types as needed */
352 printk(IBM_ERR
"acpi_evalf() called "
353 "with invalid format character '%c'\n", res_type
);
357 if (!success
&& !quiet
)
358 printk(IBM_ERR
"acpi_evalf(%s, %s, ...) failed: %d\n",
359 method
, fmt0
, status
);
364 static void __unused
acpi_print_int(acpi_handle handle
, char *method
)
368 if (acpi_evalf(handle
, &i
, method
, "d"))
369 printk(IBM_INFO
"%s = 0x%x\n", method
, i
);
371 printk(IBM_ERR
"error calling %s\n", method
);
374 static char *next_cmd(char **cmds
)
379 while ((end
= strchr(start
, ',')) && end
== start
)
390 static int ibm_acpi_driver_init(void)
392 printk(IBM_INFO
"%s v%s\n", IBM_DESC
, IBM_VERSION
);
393 printk(IBM_INFO
"%s\n", IBM_URL
);
395 if (ibm_thinkpad_ec_found
)
396 printk(IBM_INFO
"ThinkPad EC firmware %s\n",
397 ibm_thinkpad_ec_found
);
402 static int ibm_acpi_driver_read(char *p
)
406 len
+= sprintf(p
+ len
, "driver:\t\t%s\n", IBM_DESC
);
407 len
+= sprintf(p
+ len
, "version:\t%s\n", IBM_VERSION
);
412 static int hotkey_supported
;
413 static int hotkey_mask_supported
;
414 static int hotkey_orig_status
;
415 static int hotkey_orig_mask
;
417 static int hotkey_get(int *status
, int *mask
)
419 if (!acpi_evalf(hkey_handle
, status
, "DHKC", "d"))
422 if (hotkey_mask_supported
)
423 if (!acpi_evalf(hkey_handle
, mask
, "DHKN", "d"))
429 static int hotkey_set(int status
, int mask
)
433 if (!acpi_evalf(hkey_handle
, NULL
, "MHKC", "vd", status
))
436 if (hotkey_mask_supported
)
437 for (i
= 0; i
< 32; i
++) {
438 int bit
= ((1 << i
) & mask
) != 0;
439 if (!acpi_evalf(hkey_handle
,
440 NULL
, "MHKM", "vdd", i
+ 1, bit
))
447 static int hotkey_init(void)
449 /* hotkey not supported on 570 */
450 hotkey_supported
= hkey_handle
!= NULL
;
452 if (hotkey_supported
) {
453 /* mask not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
454 A30, R30, R31, T20-22, X20-21, X22-24 */
455 hotkey_mask_supported
=
456 acpi_evalf(hkey_handle
, NULL
, "DHKN", "qv");
458 if (!hotkey_get(&hotkey_orig_status
, &hotkey_orig_mask
))
465 static int hotkey_read(char *p
)
470 if (!hotkey_supported
) {
471 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
475 if (!hotkey_get(&status
, &mask
))
478 len
+= sprintf(p
+ len
, "status:\t\t%s\n", enabled(status
, 0));
479 if (hotkey_mask_supported
) {
480 len
+= sprintf(p
+ len
, "mask:\t\t0x%04x\n", mask
);
481 len
+= sprintf(p
+ len
,
482 "commands:\tenable, disable, reset, <mask>\n");
484 len
+= sprintf(p
+ len
, "mask:\t\tnot supported\n");
485 len
+= sprintf(p
+ len
, "commands:\tenable, disable, reset\n");
491 static int hotkey_write(char *buf
)
497 if (!hotkey_supported
)
500 if (!hotkey_get(&status
, &mask
))
503 while ((cmd
= next_cmd(&buf
))) {
504 if (strlencmp(cmd
, "enable") == 0) {
506 } else if (strlencmp(cmd
, "disable") == 0) {
508 } else if (strlencmp(cmd
, "reset") == 0) {
509 status
= hotkey_orig_status
;
510 mask
= hotkey_orig_mask
;
511 } else if (sscanf(cmd
, "0x%x", &mask
) == 1) {
513 } else if (sscanf(cmd
, "%x", &mask
) == 1) {
520 if (do_cmd
&& !hotkey_set(status
, mask
))
526 static void hotkey_exit(void)
528 if (hotkey_supported
)
529 hotkey_set(hotkey_orig_status
, hotkey_orig_mask
);
532 static void hotkey_notify(struct ibm_struct
*ibm
, u32 event
)
536 if (acpi_evalf(hkey_handle
, &hkey
, "MHKP", "d"))
537 acpi_bus_generate_event(ibm
->device
, event
, hkey
);
539 printk(IBM_ERR
"unknown hotkey event %d\n", event
);
540 acpi_bus_generate_event(ibm
->device
, event
, 0);
544 static int bluetooth_supported
;
546 static int bluetooth_init(void)
548 /* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
549 G4x, R30, R31, R40e, R50e, T20-22, X20-21 */
550 bluetooth_supported
= hkey_handle
&&
551 acpi_evalf(hkey_handle
, NULL
, "GBDC", "qv");
556 static int bluetooth_status(void)
560 if (!bluetooth_supported
||
561 !acpi_evalf(hkey_handle
, &status
, "GBDC", "d"))
567 static int bluetooth_read(char *p
)
570 int status
= bluetooth_status();
572 if (!bluetooth_supported
)
573 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
574 else if (!(status
& 1))
575 len
+= sprintf(p
+ len
, "status:\t\tnot installed\n");
577 len
+= sprintf(p
+ len
, "status:\t\t%s\n", enabled(status
, 1));
578 len
+= sprintf(p
+ len
, "commands:\tenable, disable\n");
584 static int bluetooth_write(char *buf
)
586 int status
= bluetooth_status();
590 if (!bluetooth_supported
)
593 while ((cmd
= next_cmd(&buf
))) {
594 if (strlencmp(cmd
, "enable") == 0) {
596 } else if (strlencmp(cmd
, "disable") == 0) {
603 if (do_cmd
&& !acpi_evalf(hkey_handle
, NULL
, "SBDC", "vd", status
))
609 static int wan_supported
;
611 static int wan_init(void)
613 wan_supported
= hkey_handle
&&
614 acpi_evalf(hkey_handle
, NULL
, "GWAN", "qv");
619 static int wan_status(void)
623 if (!wan_supported
|| !acpi_evalf(hkey_handle
, &status
, "GWAN", "d"))
629 static int wan_read(char *p
)
632 int status
= wan_status();
635 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
636 else if (!(status
& 1))
637 len
+= sprintf(p
+ len
, "status:\t\tnot installed\n");
639 len
+= sprintf(p
+ len
, "status:\t\t%s\n", enabled(status
, 1));
640 len
+= sprintf(p
+ len
, "commands:\tenable, disable\n");
646 static int wan_write(char *buf
)
648 int status
= wan_status();
655 while ((cmd
= next_cmd(&buf
))) {
656 if (strlencmp(cmd
, "enable") == 0) {
658 } else if (strlencmp(cmd
, "disable") == 0) {
665 if (do_cmd
&& !acpi_evalf(hkey_handle
, NULL
, "SWAN", "vd", status
))
671 static enum video_access_mode video_supported
;
672 static int video_orig_autosw
;
674 static int video_init(void)
678 if (vid2_handle
&& acpi_evalf(NULL
, &ivga
, "\\IVGA", "d") && ivga
)
679 /* G41, assume IVGA doesn't change */
680 vid_handle
= vid2_handle
;
683 /* video switching not supported on R30, R31 */
684 video_supported
= IBMACPI_VIDEO_NONE
;
685 else if (acpi_evalf(vid_handle
, &video_orig_autosw
, "SWIT", "qd"))
687 video_supported
= IBMACPI_VIDEO_570
;
688 else if (acpi_evalf(vid_handle
, &video_orig_autosw
, "^VADL", "qd"))
689 /* 600e/x, 770e, 770x */
690 video_supported
= IBMACPI_VIDEO_770
;
693 video_supported
= IBMACPI_VIDEO_NEW
;
698 static int video_status(void)
703 if (video_supported
== IBMACPI_VIDEO_570
) {
704 if (acpi_evalf(NULL
, &i
, "\\_SB.PHS", "dd", 0x87))
706 } else if (video_supported
== IBMACPI_VIDEO_770
) {
707 if (acpi_evalf(NULL
, &i
, "\\VCDL", "d"))
709 if (acpi_evalf(NULL
, &i
, "\\VCDC", "d"))
711 } else if (video_supported
== IBMACPI_VIDEO_NEW
) {
712 acpi_evalf(NULL
, NULL
, "\\VUPS", "vd", 1);
713 if (acpi_evalf(NULL
, &i
, "\\VCDC", "d"))
716 acpi_evalf(NULL
, NULL
, "\\VUPS", "vd", 0);
717 if (acpi_evalf(NULL
, &i
, "\\VCDL", "d"))
719 if (acpi_evalf(NULL
, &i
, "\\VCDD", "d"))
726 static int video_autosw(void)
730 if (video_supported
== IBMACPI_VIDEO_570
)
731 acpi_evalf(vid_handle
, &autosw
, "SWIT", "d");
732 else if (video_supported
== IBMACPI_VIDEO_770
||
733 video_supported
== IBMACPI_VIDEO_NEW
)
734 acpi_evalf(vid_handle
, &autosw
, "^VDEE", "d");
739 static int video_read(char *p
)
741 int status
= video_status();
742 int autosw
= video_autosw();
745 if (!video_supported
) {
746 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
750 len
+= sprintf(p
+ len
, "status:\t\tsupported\n");
751 len
+= sprintf(p
+ len
, "lcd:\t\t%s\n", enabled(status
, 0));
752 len
+= sprintf(p
+ len
, "crt:\t\t%s\n", enabled(status
, 1));
753 if (video_supported
== IBMACPI_VIDEO_NEW
)
754 len
+= sprintf(p
+ len
, "dvi:\t\t%s\n", enabled(status
, 3));
755 len
+= sprintf(p
+ len
, "auto:\t\t%s\n", enabled(autosw
, 0));
756 len
+= sprintf(p
+ len
, "commands:\tlcd_enable, lcd_disable\n");
757 len
+= sprintf(p
+ len
, "commands:\tcrt_enable, crt_disable\n");
758 if (video_supported
== IBMACPI_VIDEO_NEW
)
759 len
+= sprintf(p
+ len
, "commands:\tdvi_enable, dvi_disable\n");
760 len
+= sprintf(p
+ len
, "commands:\tauto_enable, auto_disable\n");
761 len
+= sprintf(p
+ len
, "commands:\tvideo_switch, expand_toggle\n");
766 static int video_switch(void)
768 int autosw
= video_autosw();
771 if (!acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", 1))
773 ret
= video_supported
== IBMACPI_VIDEO_570
?
774 acpi_evalf(ec_handle
, NULL
, "_Q16", "v") :
775 acpi_evalf(vid_handle
, NULL
, "VSWT", "v");
776 acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", autosw
);
781 static int video_expand(void)
783 if (video_supported
== IBMACPI_VIDEO_570
)
784 return acpi_evalf(ec_handle
, NULL
, "_Q17", "v");
785 else if (video_supported
== IBMACPI_VIDEO_770
)
786 return acpi_evalf(vid_handle
, NULL
, "VEXP", "v");
788 return acpi_evalf(NULL
, NULL
, "\\VEXP", "v");
791 static int video_switch2(int status
)
795 if (video_supported
== IBMACPI_VIDEO_570
) {
796 ret
= acpi_evalf(NULL
, NULL
,
797 "\\_SB.PHS2", "vdd", 0x8b, status
| 0x80);
798 } else if (video_supported
== IBMACPI_VIDEO_770
) {
799 int autosw
= video_autosw();
800 if (!acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", 1))
803 ret
= acpi_evalf(vid_handle
, NULL
,
804 "ASWT", "vdd", status
* 0x100, 0);
806 acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", autosw
);
808 ret
= acpi_evalf(NULL
, NULL
, "\\VUPS", "vd", 0x80) &&
809 acpi_evalf(NULL
, NULL
, "\\VSDS", "vdd", status
, 1);
815 static int video_write(char *buf
)
818 int enable
, disable
, status
;
820 if (!video_supported
)
823 enable
= disable
= 0;
825 while ((cmd
= next_cmd(&buf
))) {
826 if (strlencmp(cmd
, "lcd_enable") == 0) {
828 } else if (strlencmp(cmd
, "lcd_disable") == 0) {
830 } else if (strlencmp(cmd
, "crt_enable") == 0) {
832 } else if (strlencmp(cmd
, "crt_disable") == 0) {
834 } else if (video_supported
== IBMACPI_VIDEO_NEW
&&
835 strlencmp(cmd
, "dvi_enable") == 0) {
837 } else if (video_supported
== IBMACPI_VIDEO_NEW
&&
838 strlencmp(cmd
, "dvi_disable") == 0) {
840 } else if (strlencmp(cmd
, "auto_enable") == 0) {
841 if (!acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", 1))
843 } else if (strlencmp(cmd
, "auto_disable") == 0) {
844 if (!acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", 0))
846 } else if (strlencmp(cmd
, "video_switch") == 0) {
849 } else if (strlencmp(cmd
, "expand_toggle") == 0) {
856 if (enable
|| disable
) {
857 status
= (video_status() & 0x0f & ~disable
) | enable
;
858 if (!video_switch2(status
))
865 static void video_exit(void)
867 acpi_evalf(vid_handle
, NULL
, "_DOS", "vd", video_orig_autosw
);
870 static int light_supported
;
871 static int light_status_supported
;
873 static int light_init(void)
875 /* light not supported on 570, 600e/x, 770e, 770x, G4x, R30, R31 */
876 light_supported
= (cmos_handle
|| lght_handle
) && !ledb_handle
;
879 /* light status not supported on
880 570, 600e/x, 770e, 770x, G4x, R30, R31, R32, X20 */
881 light_status_supported
= acpi_evalf(ec_handle
, NULL
,
887 static int light_read(char *p
)
892 if (!light_supported
) {
893 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
894 } else if (!light_status_supported
) {
895 len
+= sprintf(p
+ len
, "status:\t\tunknown\n");
896 len
+= sprintf(p
+ len
, "commands:\ton, off\n");
898 if (!acpi_evalf(ec_handle
, &status
, "KBLT", "d"))
900 len
+= sprintf(p
+ len
, "status:\t\t%s\n", onoff(status
, 0));
901 len
+= sprintf(p
+ len
, "commands:\ton, off\n");
907 static int light_write(char *buf
)
909 int cmos_cmd
, lght_cmd
;
913 if (!light_supported
)
916 while ((cmd
= next_cmd(&buf
))) {
917 if (strlencmp(cmd
, "on") == 0) {
920 } else if (strlencmp(cmd
, "off") == 0) {
926 success
= cmos_handle
?
927 acpi_evalf(cmos_handle
, NULL
, NULL
, "vd", cmos_cmd
) :
928 acpi_evalf(lght_handle
, NULL
, NULL
, "vd", lght_cmd
);
936 #if defined(CONFIG_ACPI_IBM_DOCK) || defined(CONFIG_ACPI_IBM_BAY)
937 static int _sta(acpi_handle handle
)
941 if (!handle
|| !acpi_evalf(handle
, &status
, "_STA", "d"))
948 #ifdef CONFIG_ACPI_IBM_DOCK
949 #define dock_docked() (_sta(dock_handle) & 1)
951 static int dock_read(char *p
)
954 int docked
= dock_docked();
957 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
959 len
+= sprintf(p
+ len
, "status:\t\tundocked\n");
961 len
+= sprintf(p
+ len
, "status:\t\tdocked\n");
962 len
+= sprintf(p
+ len
, "commands:\tdock, undock\n");
968 static int dock_write(char *buf
)
975 while ((cmd
= next_cmd(&buf
))) {
976 if (strlencmp(cmd
, "undock") == 0) {
977 if (!acpi_evalf(dock_handle
, NULL
, "_DCK", "vd", 0) ||
978 !acpi_evalf(dock_handle
, NULL
, "_EJ0", "vd", 1))
980 } else if (strlencmp(cmd
, "dock") == 0) {
981 if (!acpi_evalf(dock_handle
, NULL
, "_DCK", "vd", 1))
990 static void dock_notify(struct ibm_struct
*ibm
, u32 event
)
992 int docked
= dock_docked();
993 int pci
= ibm
->hid
&& strstr(ibm
->hid
, IBM_PCI_HID
);
995 if (event
== 1 && !pci
) /* 570 */
996 acpi_bus_generate_event(ibm
->device
, event
, 1); /* button */
997 else if (event
== 1 && pci
) /* 570 */
998 acpi_bus_generate_event(ibm
->device
, event
, 3); /* dock */
999 else if (event
== 3 && docked
)
1000 acpi_bus_generate_event(ibm
->device
, event
, 1); /* button */
1001 else if (event
== 3 && !docked
)
1002 acpi_bus_generate_event(ibm
->device
, event
, 2); /* undock */
1003 else if (event
== 0 && docked
)
1004 acpi_bus_generate_event(ibm
->device
, event
, 3); /* dock */
1006 printk(IBM_ERR
"unknown dock event %d, status %d\n",
1007 event
, _sta(dock_handle
));
1008 acpi_bus_generate_event(ibm
->device
, event
, 0); /* unknown */
1013 #ifdef CONFIG_ACPI_IBM_BAY
1014 static int bay_status_supported
;
1015 static int bay_status2_supported
;
1016 static int bay_eject_supported
;
1017 static int bay_eject2_supported
;
1019 static int bay_init(void)
1021 bay_status_supported
= bay_handle
&&
1022 acpi_evalf(bay_handle
, NULL
, "_STA", "qv");
1023 bay_status2_supported
= bay2_handle
&&
1024 acpi_evalf(bay2_handle
, NULL
, "_STA", "qv");
1026 bay_eject_supported
= bay_handle
&& bay_ej_handle
&&
1027 (strlencmp(bay_ej_path
, "_EJ0") == 0 || experimental
);
1028 bay_eject2_supported
= bay2_handle
&& bay2_ej_handle
&&
1029 (strlencmp(bay2_ej_path
, "_EJ0") == 0 || experimental
);
1034 #define bay_occupied(b) (_sta(b##_handle) & 1)
1036 static int bay_read(char *p
)
1039 int occupied
= bay_occupied(bay
);
1040 int occupied2
= bay_occupied(bay2
);
1043 len
+= sprintf(p
+ len
, "status:\t\t%s\n", bay_status_supported
?
1044 (occupied
? "occupied" : "unoccupied") :
1046 if (bay_status2_supported
)
1047 len
+= sprintf(p
+ len
, "status2:\t%s\n", occupied2
?
1048 "occupied" : "unoccupied");
1050 eject
= bay_eject_supported
&& occupied
;
1051 eject2
= bay_eject2_supported
&& occupied2
;
1053 if (eject
&& eject2
)
1054 len
+= sprintf(p
+ len
, "commands:\teject, eject2\n");
1056 len
+= sprintf(p
+ len
, "commands:\teject\n");
1058 len
+= sprintf(p
+ len
, "commands:\teject2\n");
1063 static int bay_write(char *buf
)
1067 if (!bay_eject_supported
&& !bay_eject2_supported
)
1070 while ((cmd
= next_cmd(&buf
))) {
1071 if (bay_eject_supported
&& strlencmp(cmd
, "eject") == 0) {
1072 if (!acpi_evalf(bay_ej_handle
, NULL
, NULL
, "vd", 1))
1074 } else if (bay_eject2_supported
&&
1075 strlencmp(cmd
, "eject2") == 0) {
1076 if (!acpi_evalf(bay2_ej_handle
, NULL
, NULL
, "vd", 1))
1085 static void bay_notify(struct ibm_struct
*ibm
, u32 event
)
1087 acpi_bus_generate_event(ibm
->device
, event
, 0);
1089 #endif /* CONFIG_ACPI_IBM_BAY */
1091 static int cmos_read(char *p
)
1095 /* cmos not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
1096 R30, R31, T20-22, X20-21 */
1098 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1100 len
+= sprintf(p
+ len
, "status:\t\tsupported\n");
1101 len
+= sprintf(p
+ len
, "commands:\t<cmd> (<cmd> is 0-21)\n");
1107 static int cmos_eval(int cmos_cmd
)
1110 return acpi_evalf(cmos_handle
, NULL
, NULL
, "vd", cmos_cmd
);
1115 static int cmos_write(char *buf
)
1123 while ((cmd
= next_cmd(&buf
))) {
1124 if (sscanf(cmd
, "%u", &cmos_cmd
) == 1 &&
1125 cmos_cmd
>= 0 && cmos_cmd
<= 21) {
1130 if (!cmos_eval(cmos_cmd
))
1137 static enum led_access_mode led_supported
;
1139 static int led_init(void)
1142 /* led not supported on R30, R31 */
1143 led_supported
= IBMACPI_LED_NONE
;
1144 else if (strlencmp(led_path
, "SLED") == 0)
1146 led_supported
= IBMACPI_LED_570
;
1147 else if (strlencmp(led_path
, "SYSL") == 0)
1148 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
1149 led_supported
= IBMACPI_LED_OLD
;
1152 led_supported
= IBMACPI_LED_NEW
;
1157 #define led_status(s) ((s) == 0 ? "off" : ((s) == 1 ? "on" : "blinking"))
1159 static int led_read(char *p
)
1163 if (!led_supported
) {
1164 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1167 len
+= sprintf(p
+ len
, "status:\t\tsupported\n");
1169 if (led_supported
== IBMACPI_LED_570
) {
1172 for (i
= 0; i
< 8; i
++) {
1173 if (!acpi_evalf(ec_handle
,
1174 &status
, "GLED", "dd", 1 << i
))
1176 len
+= sprintf(p
+ len
, "%d:\t\t%s\n",
1177 i
, led_status(status
));
1181 len
+= sprintf(p
+ len
, "commands:\t"
1182 "<led> on, <led> off, <led> blink (<led> is 0-7)\n");
1187 /* off, on, blink */
1188 static const int led_sled_arg1
[] = { 0, 1, 3 };
1189 static const int led_exp_hlbl
[] = { 0, 0, 1 }; /* led# * */
1190 static const int led_exp_hlcl
[] = { 0, 1, 1 }; /* led# * */
1191 static const int led_led_arg1
[] = { 0, 0x80, 0xc0 };
1193 static int led_write(char *buf
)
1201 while ((cmd
= next_cmd(&buf
))) {
1202 if (sscanf(cmd
, "%d", &led
) != 1 || led
< 0 || led
> 7)
1205 if (strstr(cmd
, "off")) {
1207 } else if (strstr(cmd
, "on")) {
1209 } else if (strstr(cmd
, "blink")) {
1214 if (led_supported
== IBMACPI_LED_570
) {
1217 if (!acpi_evalf(led_handle
, NULL
, NULL
, "vdd",
1218 led
, led_sled_arg1
[ind
]))
1220 } else if (led_supported
== IBMACPI_LED_OLD
) {
1221 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */
1223 ret
= ec_write(IBMACPI_LED_EC_HLMS
, led
);
1226 ec_write(IBMACPI_LED_EC_HLBL
,
1227 led
* led_exp_hlbl
[ind
]);
1230 ec_write(IBMACPI_LED_EC_HLCL
,
1231 led
* led_exp_hlcl
[ind
]);
1236 if (!acpi_evalf(led_handle
, NULL
, NULL
, "vdd",
1237 led
, led_led_arg1
[ind
]))
1245 static int beep_read(char *p
)
1250 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1252 len
+= sprintf(p
+ len
, "status:\t\tsupported\n");
1253 len
+= sprintf(p
+ len
, "commands:\t<cmd> (<cmd> is 0-17)\n");
1259 static int beep_write(char *buf
)
1267 while ((cmd
= next_cmd(&buf
))) {
1268 if (sscanf(cmd
, "%u", &beep_cmd
) == 1 &&
1269 beep_cmd
>= 0 && beep_cmd
<= 17) {
1273 if (!acpi_evalf(beep_handle
, NULL
, NULL
, "vdd", beep_cmd
, 0))
1280 static int acpi_ec_read(int i
, u8
* p
)
1285 if (!acpi_evalf(ecrd_handle
, &v
, NULL
, "dd", i
))
1289 if (ec_read(i
, p
) < 0)
1296 static int acpi_ec_write(int i
, u8 v
)
1299 if (!acpi_evalf(ecwr_handle
, NULL
, NULL
, "vdd", i
, v
))
1302 if (ec_write(i
, v
) < 0)
1309 static enum thermal_access_mode thermal_read_mode
;
1311 static int thermal_init(void)
1315 int acpi_tmp7
= acpi_evalf(ec_handle
, NULL
, "TMP7", "qv");
1317 if (ibm_thinkpad_ec_found
&& experimental
) {
1319 * Direct EC access mode: sensors at registers
1320 * 0x78-0x7F, 0xC0-0xC7. Registers return 0x00 for
1321 * non-implemented, thermal sensors return 0x80 when
1326 for (i
= 0; i
< 8; i
++) {
1327 if (likely(acpi_ec_read(0x78 + i
, &t
))) {
1333 if (likely(acpi_ec_read(0xC0 + i
, &t
))) {
1341 /* This is sheer paranoia, but we handle it anyway */
1344 "ThinkPad ACPI EC access misbehaving, "
1345 "falling back to ACPI TMPx access mode\n");
1346 thermal_read_mode
= IBMACPI_THERMAL_ACPI_TMP07
;
1349 "ThinkPad ACPI EC access misbehaving, "
1350 "disabling thermal sensors access\n");
1351 thermal_read_mode
= IBMACPI_THERMAL_NONE
;
1356 IBMACPI_THERMAL_TPEC_16
: IBMACPI_THERMAL_TPEC_8
;
1358 } else if (acpi_tmp7
) {
1359 if (acpi_evalf(ec_handle
, NULL
, "UPDT", "qv")) {
1360 /* 600e/x, 770e, 770x */
1361 thermal_read_mode
= IBMACPI_THERMAL_ACPI_UPDT
;
1363 /* Standard ACPI TMPx access, max 8 sensors */
1364 thermal_read_mode
= IBMACPI_THERMAL_ACPI_TMP07
;
1367 /* temperatures not supported on 570, G4x, R30, R31, R32 */
1368 thermal_read_mode
= IBMACPI_THERMAL_NONE
;
1374 static int thermal_get_sensors(struct ibm_thermal_sensors_struct
*s
)
1378 char tmpi
[] = "TMPi";
1383 switch (thermal_read_mode
) {
1384 #if IBMACPI_MAX_THERMAL_SENSORS >= 16
1385 case IBMACPI_THERMAL_TPEC_16
:
1386 for (i
= 0; i
< 8; i
++) {
1387 if (!acpi_ec_read(0xC0 + i
, &tmp
))
1389 s
->temp
[i
+ 8] = tmp
* 1000;
1393 case IBMACPI_THERMAL_TPEC_8
:
1394 for (i
= 0; i
< 8; i
++) {
1395 if (!acpi_ec_read(0x78 + i
, &tmp
))
1397 s
->temp
[i
] = tmp
* 1000;
1399 return (thermal_read_mode
== IBMACPI_THERMAL_TPEC_16
) ? 16 : 8;
1401 case IBMACPI_THERMAL_ACPI_UPDT
:
1402 if (!acpi_evalf(ec_handle
, NULL
, "UPDT", "v"))
1404 for (i
= 0; i
< 8; i
++) {
1406 if (!acpi_evalf(ec_handle
, &t
, tmpi
, "d"))
1408 s
->temp
[i
] = (t
- 2732) * 100;
1412 case IBMACPI_THERMAL_ACPI_TMP07
:
1413 for (i
= 0; i
< 8; i
++) {
1415 if (!acpi_evalf(ec_handle
, &t
, tmpi
, "d"))
1417 s
->temp
[i
] = t
* 1000;
1421 case IBMACPI_THERMAL_NONE
:
1427 static int thermal_read(char *p
)
1431 struct ibm_thermal_sensors_struct t
;
1433 n
= thermal_get_sensors(&t
);
1434 if (unlikely(n
< 0))
1437 len
+= sprintf(p
+ len
, "temperatures:\t");
1440 for (i
= 0; i
< (n
- 1); i
++)
1441 len
+= sprintf(p
+ len
, "%d ", t
.temp
[i
] / 1000);
1442 len
+= sprintf(p
+ len
, "%d\n", t
.temp
[i
] / 1000);
1444 len
+= sprintf(p
+ len
, "not supported\n");
1449 static u8 ecdump_regs
[256];
1451 static int ecdump_read(char *p
)
1457 len
+= sprintf(p
+ len
, "EC "
1458 " +00 +01 +02 +03 +04 +05 +06 +07"
1459 " +08 +09 +0a +0b +0c +0d +0e +0f\n");
1460 for (i
= 0; i
< 256; i
+= 16) {
1461 len
+= sprintf(p
+ len
, "EC 0x%02x:", i
);
1462 for (j
= 0; j
< 16; j
++) {
1463 if (!acpi_ec_read(i
+ j
, &v
))
1465 if (v
!= ecdump_regs
[i
+ j
])
1466 len
+= sprintf(p
+ len
, " *%02x", v
);
1468 len
+= sprintf(p
+ len
, " %02x", v
);
1469 ecdump_regs
[i
+ j
] = v
;
1471 len
+= sprintf(p
+ len
, "\n");
1476 /* These are way too dangerous to advertise openly... */
1478 len
+= sprintf(p
+ len
, "commands:\t0x<offset> 0x<value>"
1479 " (<offset> is 00-ff, <value> is 00-ff)\n");
1480 len
+= sprintf(p
+ len
, "commands:\t0x<offset> <value> "
1481 " (<offset> is 00-ff, <value> is 0-255)\n");
1486 static int ecdump_write(char *buf
)
1491 while ((cmd
= next_cmd(&buf
))) {
1492 if (sscanf(cmd
, "0x%x 0x%x", &i
, &v
) == 2) {
1494 } else if (sscanf(cmd
, "0x%x %u", &i
, &v
) == 2) {
1498 if (i
>= 0 && i
< 256 && v
>= 0 && v
< 256) {
1499 if (!acpi_ec_write(i
, v
))
1508 static int brightness_get(struct backlight_device
*bd
)
1511 if (!acpi_ec_read(brightness_offset
, &level
))
1519 static int brightness_read(char *p
)
1524 if ((level
= brightness_get(NULL
)) < 0) {
1525 len
+= sprintf(p
+ len
, "level:\t\tunreadable\n");
1527 len
+= sprintf(p
+ len
, "level:\t\t%d\n", level
& 0x7);
1528 len
+= sprintf(p
+ len
, "commands:\tup, down\n");
1529 len
+= sprintf(p
+ len
, "commands:\tlevel <level>"
1530 " (<level> is 0-7)\n");
1536 static int brightness_set(int value
)
1538 int cmos_cmd
, inc
, i
;
1539 int current_value
= brightness_get(NULL
);
1543 cmos_cmd
= value
> current_value
?
1544 TP_CMOS_BRIGHTNESS_UP
: TP_CMOS_BRIGHTNESS_DOWN
;
1545 inc
= value
> current_value
? 1 : -1;
1546 for (i
= current_value
; i
!= value
; i
+= inc
) {
1547 if (!cmos_eval(cmos_cmd
))
1549 if (!acpi_ec_write(brightness_offset
, i
+ inc
))
1556 static int brightness_write(char *buf
)
1562 while ((cmd
= next_cmd(&buf
))) {
1563 if ((level
= brightness_get(NULL
)) < 0)
1567 if (strlencmp(cmd
, "up") == 0) {
1568 new_level
= level
== 7 ? 7 : level
+ 1;
1569 } else if (strlencmp(cmd
, "down") == 0) {
1570 new_level
= level
== 0 ? 0 : level
- 1;
1571 } else if (sscanf(cmd
, "level %d", &new_level
) == 1 &&
1572 new_level
>= 0 && new_level
<= 7) {
1577 brightness_set(new_level
);
1583 static int brightness_update_status(struct backlight_device
*bd
)
1585 return brightness_set(
1586 (bd
->props
.fb_blank
== FB_BLANK_UNBLANK
&&
1587 bd
->props
.power
== FB_BLANK_UNBLANK
) ?
1588 bd
->props
.brightness
: 0);
1591 static struct backlight_ops ibm_backlight_data
= {
1592 .get_brightness
= brightness_get
,
1593 .update_status
= brightness_update_status
,
1596 static int brightness_init(void)
1600 b
= brightness_get(NULL
);
1604 ibm_backlight_device
= backlight_device_register("ibm", NULL
, NULL
,
1605 &ibm_backlight_data
);
1606 if (IS_ERR(ibm_backlight_device
)) {
1607 printk(IBM_ERR
"Could not register backlight device\n");
1608 return PTR_ERR(ibm_backlight_device
);
1611 ibm_backlight_device
->props
.max_brightness
= 7;
1612 ibm_backlight_device
->props
.brightness
= b
;
1613 backlight_update_status(ibm_backlight_device
);
1618 static void brightness_exit(void)
1620 if (ibm_backlight_device
) {
1621 backlight_device_unregister(ibm_backlight_device
);
1622 ibm_backlight_device
= NULL
;
1626 static int volume_read(char *p
)
1631 if (!acpi_ec_read(volume_offset
, &level
)) {
1632 len
+= sprintf(p
+ len
, "level:\t\tunreadable\n");
1634 len
+= sprintf(p
+ len
, "level:\t\t%d\n", level
& 0xf);
1635 len
+= sprintf(p
+ len
, "mute:\t\t%s\n", onoff(level
, 6));
1636 len
+= sprintf(p
+ len
, "commands:\tup, down, mute\n");
1637 len
+= sprintf(p
+ len
, "commands:\tlevel <level>"
1638 " (<level> is 0-15)\n");
1644 static int volume_write(char *buf
)
1646 int cmos_cmd
, inc
, i
;
1648 int new_level
, new_mute
;
1651 while ((cmd
= next_cmd(&buf
))) {
1652 if (!acpi_ec_read(volume_offset
, &level
))
1654 new_mute
= mute
= level
& 0x40;
1655 new_level
= level
= level
& 0xf;
1657 if (strlencmp(cmd
, "up") == 0) {
1661 new_level
= level
== 15 ? 15 : level
+ 1;
1662 } else if (strlencmp(cmd
, "down") == 0) {
1666 new_level
= level
== 0 ? 0 : level
- 1;
1667 } else if (sscanf(cmd
, "level %d", &new_level
) == 1 &&
1668 new_level
>= 0 && new_level
<= 15) {
1670 } else if (strlencmp(cmd
, "mute") == 0) {
1675 if (new_level
!= level
) { /* mute doesn't change */
1676 cmos_cmd
= new_level
> level
?
1677 TP_CMOS_VOLUME_UP
: TP_CMOS_VOLUME_DOWN
;
1678 inc
= new_level
> level
? 1 : -1;
1680 if (mute
&& (!cmos_eval(cmos_cmd
) ||
1681 !acpi_ec_write(volume_offset
, level
)))
1684 for (i
= level
; i
!= new_level
; i
+= inc
)
1685 if (!cmos_eval(cmos_cmd
) ||
1686 !acpi_ec_write(volume_offset
, i
+ inc
))
1689 if (mute
&& (!cmos_eval(TP_CMOS_VOLUME_MUTE
) ||
1690 !acpi_ec_write(volume_offset
,
1695 if (new_mute
!= mute
) { /* level doesn't change */
1696 cmos_cmd
= new_mute
?
1697 TP_CMOS_VOLUME_MUTE
: TP_CMOS_VOLUME_UP
;
1699 if (!cmos_eval(cmos_cmd
) ||
1700 !acpi_ec_write(volume_offset
, level
+ new_mute
))
1708 static enum fan_status_access_mode fan_status_access_mode
;
1709 static enum fan_control_access_mode fan_control_access_mode
;
1710 static enum fan_control_commands fan_control_commands
;
1712 static int fan_control_status_known
;
1713 static u8 fan_control_initial_status
;
1715 static void fan_watchdog_fire(struct work_struct
*ignored
);
1716 static int fan_watchdog_maxinterval
;
1717 static DECLARE_DELAYED_WORK(fan_watchdog_task
, fan_watchdog_fire
);
1719 static int fan_init(void)
1721 fan_status_access_mode
= IBMACPI_FAN_NONE
;
1722 fan_control_access_mode
= IBMACPI_FAN_WR_NONE
;
1723 fan_control_commands
= 0;
1724 fan_control_status_known
= 1;
1725 fan_watchdog_maxinterval
= 0;
1728 /* 570, 600e/x, 770e, 770x */
1729 fan_status_access_mode
= IBMACPI_FAN_RD_ACPI_GFAN
;
1731 /* all other ThinkPads: note that even old-style
1732 * ThinkPad ECs supports the fan control register */
1733 if (likely(acpi_ec_read(fan_status_offset
,
1734 &fan_control_initial_status
))) {
1735 fan_status_access_mode
= IBMACPI_FAN_RD_TPEC
;
1737 /* In some ThinkPads, neither the EC nor the ACPI
1738 * DSDT initialize the fan status, and it ends up
1739 * being set to 0x07 when it *could* be either
1742 * Enable for TP-1Y (T43), TP-78 (R51e),
1743 * TP-76 (R52), TP-70 (T43, R52), which are known
1745 if (fan_control_initial_status
== 0x07 &&
1746 ibm_thinkpad_ec_found
&&
1747 ((ibm_thinkpad_ec_found
[0] == '1' &&
1748 ibm_thinkpad_ec_found
[1] == 'Y') ||
1749 (ibm_thinkpad_ec_found
[0] == '7' &&
1750 (ibm_thinkpad_ec_found
[1] == '6' ||
1751 ibm_thinkpad_ec_found
[1] == '8' ||
1752 ibm_thinkpad_ec_found
[1] == '0'))
1755 "fan_init: initial fan status is "
1756 "unknown, assuming it is in auto "
1758 fan_control_status_known
= 0;
1762 "ThinkPad ACPI EC access misbehaving, "
1763 "fan status and control unavailable\n");
1770 fan_control_access_mode
= IBMACPI_FAN_WR_ACPI_SFAN
;
1771 fan_control_commands
|=
1772 IBMACPI_FAN_CMD_LEVEL
| IBMACPI_FAN_CMD_ENABLE
;
1775 /* gfan without sfan means no fan control */
1776 /* all other models implement TP EC 0x2f control */
1780 fan_control_access_mode
=
1781 IBMACPI_FAN_WR_ACPI_FANS
;
1782 fan_control_commands
|=
1783 IBMACPI_FAN_CMD_SPEED
|
1784 IBMACPI_FAN_CMD_LEVEL
|
1785 IBMACPI_FAN_CMD_ENABLE
;
1787 fan_control_access_mode
= IBMACPI_FAN_WR_TPEC
;
1788 fan_control_commands
|=
1789 IBMACPI_FAN_CMD_LEVEL
|
1790 IBMACPI_FAN_CMD_ENABLE
;
1798 static int fan_get_status(u8
*status
)
1803 * Add IBMACPI_FAN_RD_ACPI_FANS ? */
1805 switch (fan_status_access_mode
) {
1806 case IBMACPI_FAN_RD_ACPI_GFAN
:
1807 /* 570, 600e/x, 770e, 770x */
1809 if (unlikely(!acpi_evalf(gfan_handle
, &s
, NULL
, "d")))
1817 case IBMACPI_FAN_RD_TPEC
:
1818 /* all except 570, 600e/x, 770e, 770x */
1819 if (unlikely(!acpi_ec_read(fan_status_offset
, &s
)))
1834 static int fan_get_speed(unsigned int *speed
)
1838 switch (fan_status_access_mode
) {
1839 case IBMACPI_FAN_RD_TPEC
:
1840 /* all except 570, 600e/x, 770e, 770x */
1841 if (unlikely(!acpi_ec_read(fan_rpm_offset
, &lo
) ||
1842 !acpi_ec_read(fan_rpm_offset
+ 1, &hi
)))
1846 *speed
= (hi
<< 8) | lo
;
1857 static void fan_exit(void)
1859 cancel_delayed_work(&fan_watchdog_task
);
1860 flush_scheduled_work();
1863 static void fan_watchdog_reset(void)
1865 static int fan_watchdog_active
= 0;
1867 if (fan_watchdog_active
)
1868 cancel_delayed_work(&fan_watchdog_task
);
1870 if (fan_watchdog_maxinterval
> 0) {
1871 fan_watchdog_active
= 1;
1872 if (!schedule_delayed_work(&fan_watchdog_task
,
1873 msecs_to_jiffies(fan_watchdog_maxinterval
1875 printk(IBM_ERR
"failed to schedule the fan watchdog, "
1876 "watchdog will not trigger\n");
1879 fan_watchdog_active
= 0;
1882 static int fan_read(char *p
)
1887 unsigned int speed
= 0;
1889 switch (fan_status_access_mode
) {
1890 case IBMACPI_FAN_RD_ACPI_GFAN
:
1891 /* 570, 600e/x, 770e, 770x */
1892 if ((rc
= fan_get_status(&status
)) < 0)
1895 len
+= sprintf(p
+ len
, "status:\t\t%s\n"
1897 (status
!= 0) ? "enabled" : "disabled", status
);
1900 case IBMACPI_FAN_RD_TPEC
:
1901 /* all except 570, 600e/x, 770e, 770x */
1902 if ((rc
= fan_get_status(&status
)) < 0)
1905 if (unlikely(!fan_control_status_known
)) {
1906 if (status
!= fan_control_initial_status
)
1907 fan_control_status_known
= 1;
1909 /* Return most likely status. In fact, it
1910 * might be the only possible status */
1911 status
= IBMACPI_FAN_EC_AUTO
;
1914 len
+= sprintf(p
+ len
, "status:\t\t%s\n",
1915 (status
!= 0) ? "enabled" : "disabled");
1917 /* No ThinkPad boots on disengaged mode, we can safely
1918 * assume the tachometer is online if fan control status
1920 if ((rc
= fan_get_speed(&speed
)) < 0)
1923 len
+= sprintf(p
+ len
, "speed:\t\t%d\n", speed
);
1925 if (status
& IBMACPI_FAN_EC_DISENGAGED
)
1926 /* Disengaged mode takes precedence */
1927 len
+= sprintf(p
+ len
, "level:\t\tdisengaged\n");
1928 else if (status
& IBMACPI_FAN_EC_AUTO
)
1929 len
+= sprintf(p
+ len
, "level:\t\tauto\n");
1931 len
+= sprintf(p
+ len
, "level:\t\t%d\n", status
);
1934 case IBMACPI_FAN_NONE
:
1936 len
+= sprintf(p
+ len
, "status:\t\tnot supported\n");
1939 if (fan_control_commands
& IBMACPI_FAN_CMD_LEVEL
) {
1940 len
+= sprintf(p
+ len
, "commands:\tlevel <level>");
1942 switch (fan_control_access_mode
) {
1943 case IBMACPI_FAN_WR_ACPI_SFAN
:
1944 len
+= sprintf(p
+ len
, " (<level> is 0-7)\n");
1948 len
+= sprintf(p
+ len
, " (<level> is 0-7, "
1949 "auto, disengaged)\n");
1954 if (fan_control_commands
& IBMACPI_FAN_CMD_ENABLE
)
1955 len
+= sprintf(p
+ len
, "commands:\tenable, disable\n"
1956 "commands:\twatchdog <timeout> (<timeout> is 0 (off), "
1957 "1-120 (seconds))\n");
1959 if (fan_control_commands
& IBMACPI_FAN_CMD_SPEED
)
1960 len
+= sprintf(p
+ len
, "commands:\tspeed <speed>"
1961 " (<speed> is 0-65535)\n");
1966 static int fan_set_level(int level
)
1968 switch (fan_control_access_mode
) {
1969 case IBMACPI_FAN_WR_ACPI_SFAN
:
1970 if (level
>= 0 && level
<= 7) {
1971 if (!acpi_evalf(sfan_handle
, NULL
, NULL
, "vd", level
))
1977 case IBMACPI_FAN_WR_ACPI_FANS
:
1978 case IBMACPI_FAN_WR_TPEC
:
1979 if ((level
!= IBMACPI_FAN_EC_AUTO
) &&
1980 (level
!= IBMACPI_FAN_EC_DISENGAGED
) &&
1981 ((level
< 0) || (level
> 7)))
1984 if (!acpi_ec_write(fan_status_offset
, level
))
1987 fan_control_status_known
= 1;
1996 static int fan_set_enable(void)
2001 switch (fan_control_access_mode
) {
2002 case IBMACPI_FAN_WR_ACPI_FANS
:
2003 case IBMACPI_FAN_WR_TPEC
:
2004 if ((rc
= fan_get_status(&s
)) < 0)
2007 /* Don't go out of emergency fan mode */
2009 s
= IBMACPI_FAN_EC_AUTO
;
2011 if (!acpi_ec_write(fan_status_offset
, s
))
2014 fan_control_status_known
= 1;
2017 case IBMACPI_FAN_WR_ACPI_SFAN
:
2018 if ((rc
= fan_get_status(&s
)) < 0)
2023 /* Set fan to at least level 4 */
2027 if (!acpi_evalf(sfan_handle
, NULL
, NULL
, "vd", s
))
2037 static int fan_set_disable(void)
2039 switch (fan_control_access_mode
) {
2040 case IBMACPI_FAN_WR_ACPI_FANS
:
2041 case IBMACPI_FAN_WR_TPEC
:
2042 if (!acpi_ec_write(fan_status_offset
, 0x00))
2045 fan_control_status_known
= 1;
2048 case IBMACPI_FAN_WR_ACPI_SFAN
:
2049 if (!acpi_evalf(sfan_handle
, NULL
, NULL
, "vd", 0x00))
2059 static int fan_set_speed(int speed
)
2061 switch (fan_control_access_mode
) {
2062 case IBMACPI_FAN_WR_ACPI_FANS
:
2063 if (speed
>= 0 && speed
<= 65535) {
2064 if (!acpi_evalf(fans_handle
, NULL
, NULL
, "vddd",
2065 speed
, speed
, speed
))
2077 static int fan_write_cmd_level(const char *cmd
, int *rc
)
2081 if (strlencmp(cmd
, "level auto") == 0)
2082 level
= IBMACPI_FAN_EC_AUTO
;
2083 else if (strlencmp(cmd
, "level disengaged") == 0)
2084 level
= IBMACPI_FAN_EC_DISENGAGED
;
2085 else if (sscanf(cmd
, "level %d", &level
) != 1)
2088 if ((*rc
= fan_set_level(level
)) == -ENXIO
)
2089 printk(IBM_ERR
"level command accepted for unsupported "
2090 "access mode %d", fan_control_access_mode
);
2095 static int fan_write_cmd_enable(const char *cmd
, int *rc
)
2097 if (strlencmp(cmd
, "enable") != 0)
2100 if ((*rc
= fan_set_enable()) == -ENXIO
)
2101 printk(IBM_ERR
"enable command accepted for unsupported "
2102 "access mode %d", fan_control_access_mode
);
2107 static int fan_write_cmd_disable(const char *cmd
, int *rc
)
2109 if (strlencmp(cmd
, "disable") != 0)
2112 if ((*rc
= fan_set_disable()) == -ENXIO
)
2113 printk(IBM_ERR
"disable command accepted for unsupported "
2114 "access mode %d", fan_control_access_mode
);
2119 static int fan_write_cmd_speed(const char *cmd
, int *rc
)
2124 * Support speed <low> <medium> <high> ? */
2126 if (sscanf(cmd
, "speed %d", &speed
) != 1)
2129 if ((*rc
= fan_set_speed(speed
)) == -ENXIO
)
2130 printk(IBM_ERR
"speed command accepted for unsupported "
2131 "access mode %d", fan_control_access_mode
);
2136 static int fan_write_cmd_watchdog(const char *cmd
, int *rc
)
2140 if (sscanf(cmd
, "watchdog %d", &interval
) != 1)
2143 if (interval
< 0 || interval
> 120)
2146 fan_watchdog_maxinterval
= interval
;
2151 static int fan_write(char *buf
)
2156 while (!rc
&& (cmd
= next_cmd(&buf
))) {
2157 if (!((fan_control_commands
& IBMACPI_FAN_CMD_LEVEL
) &&
2158 fan_write_cmd_level(cmd
, &rc
)) &&
2159 !((fan_control_commands
& IBMACPI_FAN_CMD_ENABLE
) &&
2160 (fan_write_cmd_enable(cmd
, &rc
) ||
2161 fan_write_cmd_disable(cmd
, &rc
) ||
2162 fan_write_cmd_watchdog(cmd
, &rc
))) &&
2163 !((fan_control_commands
& IBMACPI_FAN_CMD_SPEED
) &&
2164 fan_write_cmd_speed(cmd
, &rc
))
2168 fan_watchdog_reset();
2174 static void fan_watchdog_fire(struct work_struct
*ignored
)
2176 printk(IBM_NOTICE
"fan watchdog: enabling fan\n");
2177 if (fan_set_enable()) {
2178 printk(IBM_ERR
"fan watchdog: error while enabling fan\n");
2179 /* reschedule for later */
2180 fan_watchdog_reset();
2184 static struct ibm_struct ibms
[] = {
2187 .init
= ibm_acpi_driver_init
,
2188 .read
= ibm_acpi_driver_read
,
2192 .hid
= IBM_HKEY_HID
,
2193 .init
= hotkey_init
,
2194 .read
= hotkey_read
,
2195 .write
= hotkey_write
,
2196 .exit
= hotkey_exit
,
2197 .notify
= hotkey_notify
,
2198 .handle
= &hkey_handle
,
2199 .type
= ACPI_DEVICE_NOTIFY
,
2202 .name
= "bluetooth",
2203 .init
= bluetooth_init
,
2204 .read
= bluetooth_read
,
2205 .write
= bluetooth_write
,
2218 .write
= video_write
,
2225 .write
= light_write
,
2227 #ifdef CONFIG_ACPI_IBM_DOCK
2231 .write
= dock_write
,
2232 .notify
= dock_notify
,
2233 .handle
= &dock_handle
,
2234 .type
= ACPI_SYSTEM_NOTIFY
,
2239 .notify
= dock_notify
,
2240 .handle
= &pci_handle
,
2241 .type
= ACPI_SYSTEM_NOTIFY
,
2244 #ifdef CONFIG_ACPI_IBM_BAY
2250 .notify
= bay_notify
,
2251 .handle
= &bay_handle
,
2252 .type
= ACPI_SYSTEM_NOTIFY
,
2254 #endif /* CONFIG_ACPI_IBM_BAY */
2258 .write
= cmos_write
,
2269 .write
= beep_write
,
2273 .init
= thermal_init
,
2274 .read
= thermal_read
,
2278 .read
= ecdump_read
,
2279 .write
= ecdump_write
,
2283 .name
= "brightness",
2284 .read
= brightness_read
,
2285 .write
= brightness_write
,
2286 .init
= brightness_init
,
2287 .exit
= brightness_exit
,
2291 .read
= volume_read
,
2292 .write
= volume_write
,
2304 static int dispatch_read(char *page
, char **start
, off_t off
, int count
,
2305 int *eof
, void *data
)
2307 struct ibm_struct
*ibm
= data
;
2310 if (!ibm
|| !ibm
->read
)
2313 len
= ibm
->read(page
);
2317 if (len
<= off
+ count
)
2319 *start
= page
+ off
;
2329 static int dispatch_write(struct file
*file
, const char __user
* userbuf
,
2330 unsigned long count
, void *data
)
2332 struct ibm_struct
*ibm
= data
;
2336 if (!ibm
|| !ibm
->write
)
2339 kernbuf
= kmalloc(count
+ 2, GFP_KERNEL
);
2343 if (copy_from_user(kernbuf
, userbuf
, count
)) {
2349 strcat(kernbuf
, ",");
2350 ret
= ibm
->write(kernbuf
);
2359 static void dispatch_notify(acpi_handle handle
, u32 event
, void *data
)
2361 struct ibm_struct
*ibm
= data
;
2363 if (!ibm
|| !ibm
->notify
)
2366 ibm
->notify(ibm
, event
);
2369 static int __init
setup_notify(struct ibm_struct
*ibm
)
2377 ret
= acpi_bus_get_device(*ibm
->handle
, &ibm
->device
);
2379 printk(IBM_ERR
"%s device not present\n", ibm
->name
);
2383 acpi_driver_data(ibm
->device
) = ibm
;
2384 sprintf(acpi_device_class(ibm
->device
), "%s/%s", IBM_NAME
, ibm
->name
);
2386 status
= acpi_install_notify_handler(*ibm
->handle
, ibm
->type
,
2387 dispatch_notify
, ibm
);
2388 if (ACPI_FAILURE(status
)) {
2389 if (status
== AE_ALREADY_EXISTS
) {
2390 printk(IBM_NOTICE
"another device driver is already handling %s events\n",
2393 printk(IBM_ERR
"acpi_install_notify_handler(%s) failed: %d\n",
2398 ibm
->notify_installed
= 1;
2402 static int __init
ibm_device_add(struct acpi_device
*device
)
2407 static int __init
register_ibmacpi_subdriver(struct ibm_struct
*ibm
)
2411 ibm
->driver
= kzalloc(sizeof(struct acpi_driver
), GFP_KERNEL
);
2413 printk(IBM_ERR
"kmalloc(ibm->driver) failed\n");
2417 sprintf(ibm
->driver
->name
, "%s_%s", IBM_NAME
, ibm
->name
);
2418 ibm
->driver
->ids
= ibm
->hid
;
2419 ibm
->driver
->ops
.add
= &ibm_device_add
;
2421 ret
= acpi_bus_register_driver(ibm
->driver
);
2423 printk(IBM_ERR
"acpi_bus_register_driver(%s) failed: %d\n",
2431 static int __init
ibm_init(struct ibm_struct
*ibm
)
2434 struct proc_dir_entry
*entry
;
2436 if (ibm
->experimental
&& !experimental
)
2440 ret
= register_ibmacpi_subdriver(ibm
);
2443 ibm
->driver_registered
= 1;
2450 ibm
->init_called
= 1;
2454 entry
= create_proc_entry(ibm
->name
,
2455 S_IFREG
| S_IRUGO
| S_IWUSR
,
2458 printk(IBM_ERR
"unable to create proc entry %s\n",
2462 entry
->owner
= THIS_MODULE
;
2464 entry
->read_proc
= &dispatch_read
;
2466 entry
->write_proc
= &dispatch_write
;
2467 ibm
->proc_created
= 1;
2471 ret
= setup_notify(ibm
);
2472 if (ret
== -ENODEV
) {
2473 printk(IBM_NOTICE
"disabling subdriver %s\n",
2485 static void ibm_exit(struct ibm_struct
*ibm
)
2487 if (ibm
->notify_installed
)
2488 acpi_remove_notify_handler(*ibm
->handle
, ibm
->type
,
2491 if (ibm
->proc_created
)
2492 remove_proc_entry(ibm
->name
, proc_dir
);
2494 if (ibm
->init_called
&& ibm
->exit
)
2497 if (ibm
->driver_registered
) {
2498 acpi_bus_unregister_driver(ibm
->driver
);
2503 static void __init
ibm_handle_init(char *name
,
2504 acpi_handle
* handle
, acpi_handle parent
,
2505 char **paths
, int num_paths
, char **path
)
2510 for (i
= 0; i
< num_paths
; i
++) {
2511 status
= acpi_get_handle(parent
, paths
[i
], handle
);
2512 if (ACPI_SUCCESS(status
)) {
2521 #define IBM_HANDLE_INIT(object) \
2522 ibm_handle_init(#object, &object##_handle, *object##_parent, \
2523 object##_paths, ARRAY_SIZE(object##_paths), &object##_path)
2525 static int __init
set_ibm_param(const char *val
, struct kernel_param
*kp
)
2529 for (i
= 0; i
< ARRAY_SIZE(ibms
); i
++)
2530 if (strcmp(ibms
[i
].name
, kp
->name
) == 0 && ibms
[i
].write
) {
2531 if (strlen(val
) > sizeof(ibms
[i
].param
) - 2)
2533 strcpy(ibms
[i
].param
, val
);
2534 strcat(ibms
[i
].param
, ",");
2541 #define IBM_PARAM(feature) \
2542 module_param_call(feature, set_ibm_param, NULL, NULL, 0)
2545 IBM_PARAM(bluetooth
);
2548 #ifdef CONFIG_ACPI_IBM_DOCK
2551 #ifdef CONFIG_ACPI_IBM_BAY
2553 #endif /* CONFIG_ACPI_IBM_BAY */
2558 IBM_PARAM(brightness
);
2562 static void acpi_ibm_exit(void)
2566 for (i
= ARRAY_SIZE(ibms
) - 1; i
>= 0; i
--)
2570 remove_proc_entry(IBM_DIR
, acpi_root_dir
);
2572 if (ibm_thinkpad_ec_found
)
2573 kfree(ibm_thinkpad_ec_found
);
2576 static char* __init
check_dmi_for_ec(void)
2578 struct dmi_device
*dev
= NULL
;
2579 char ec_fw_string
[18];
2582 * ThinkPad T23 or newer, A31 or newer, R50e or newer,
2583 * X32 or newer, all Z series; Some models must have an
2584 * up-to-date BIOS or they will not be detected.
2586 * See http://thinkwiki.org/wiki/List_of_DMI_IDs
2588 while ((dev
= dmi_find_device(DMI_DEV_TYPE_OEM_STRING
, NULL
, dev
))) {
2589 if (sscanf(dev
->name
,
2590 "IBM ThinkPad Embedded Controller -[%17c",
2591 ec_fw_string
) == 1) {
2592 ec_fw_string
[sizeof(ec_fw_string
) - 1] = 0;
2593 ec_fw_string
[strcspn(ec_fw_string
, " ]")] = 0;
2594 return kstrdup(ec_fw_string
, GFP_KERNEL
);
2600 static int __init
acpi_ibm_init(void)
2607 /* ec is required because many other handles are relative to it */
2608 IBM_HANDLE_INIT(ec
);
2610 printk(IBM_ERR
"ec object not found\n");
2614 /* Models with newer firmware report the EC in DMI */
2615 ibm_thinkpad_ec_found
= check_dmi_for_ec();
2617 /* these handles are not required */
2618 IBM_HANDLE_INIT(vid
);
2619 IBM_HANDLE_INIT(vid2
);
2620 IBM_HANDLE_INIT(ledb
);
2621 IBM_HANDLE_INIT(led
);
2622 IBM_HANDLE_INIT(hkey
);
2623 IBM_HANDLE_INIT(lght
);
2624 IBM_HANDLE_INIT(cmos
);
2625 #ifdef CONFIG_ACPI_IBM_DOCK
2626 IBM_HANDLE_INIT(dock
);
2628 IBM_HANDLE_INIT(pci
);
2629 #ifdef CONFIG_ACPI_IBM_BAY
2630 IBM_HANDLE_INIT(bay
);
2632 IBM_HANDLE_INIT(bay_ej
);
2633 IBM_HANDLE_INIT(bay2
);
2635 IBM_HANDLE_INIT(bay2_ej
);
2636 #endif /* CONFIG_ACPI_IBM_BAY */
2637 IBM_HANDLE_INIT(beep
);
2638 IBM_HANDLE_INIT(ecrd
);
2639 IBM_HANDLE_INIT(ecwr
);
2640 IBM_HANDLE_INIT(fans
);
2641 IBM_HANDLE_INIT(gfan
);
2642 IBM_HANDLE_INIT(sfan
);
2644 proc_dir
= proc_mkdir(IBM_DIR
, acpi_root_dir
);
2646 printk(IBM_ERR
"unable to create proc dir %s", IBM_DIR
);
2650 proc_dir
->owner
= THIS_MODULE
;
2652 for (i
= 0; i
< ARRAY_SIZE(ibms
); i
++) {
2653 ret
= ibm_init(&ibms
[i
]);
2654 if (ret
>= 0 && *ibms
[i
].param
)
2655 ret
= ibms
[i
].write(ibms
[i
].param
);
2665 module_init(acpi_ibm_init
);
2666 module_exit(acpi_ibm_exit
);