2 * toshiba_acpi.c - Toshiba Laptop ACPI Extras
4 * Copyright (C) 2002-2004 John Belmonte
5 * Copyright (C) 2008 Philip Langdale
6 * Copyright (C) 2010 Pierre Ducroquet
7 * Copyright (C) 2014-2015 Azael Avalos
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * The full GNU General Public License is included in this distribution in
20 * the file called "COPYING".
22 * The devolpment page for this driver is located at
23 * http://memebeam.org/toys/ToshibaAcpiDriver.
26 * Jonathan A. Buzzard - Toshiba HCI info, and critical tips on reverse
27 * engineering the Windows drivers
28 * Yasushi Nagato - changes for linux kernel 2.4 -> 2.5
29 * Rob Miller - TV out and hotkeys help
32 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
34 #define TOSHIBA_ACPI_VERSION "0.23"
35 #define PROC_INTERFACE_VERSION 1
37 #include <linux/kernel.h>
38 #include <linux/module.h>
39 #include <linux/init.h>
40 #include <linux/types.h>
41 #include <linux/proc_fs.h>
42 #include <linux/seq_file.h>
43 #include <linux/backlight.h>
44 #include <linux/input.h>
45 #include <linux/input/sparse-keymap.h>
46 #include <linux/leds.h>
47 #include <linux/slab.h>
48 #include <linux/workqueue.h>
49 #include <linux/i8042.h>
50 #include <linux/acpi.h>
51 #include <linux/dmi.h>
52 #include <linux/uaccess.h>
53 #include <linux/miscdevice.h>
54 #include <linux/rfkill.h>
55 #include <linux/toshiba.h>
56 #include <acpi/video.h>
58 MODULE_AUTHOR("John Belmonte");
59 MODULE_DESCRIPTION("Toshiba Laptop ACPI Extras Driver");
60 MODULE_LICENSE("GPL");
62 #define TOSHIBA_WMI_EVENT_GUID "59142400-C6A3-40FA-BADB-8A2652834100"
64 /* Scan code for Fn key on TOS1900 models */
65 #define TOS1900_FN_SCAN 0x6e
67 /* Toshiba ACPI method paths */
68 #define METHOD_VIDEO_OUT "\\_SB_.VALX.DSSX"
71 * The Toshiba configuration interface is composed of the HCI and the SCI,
72 * which are defined as follows:
74 * HCI is Toshiba's "Hardware Control Interface" which is supposed to
75 * be uniform across all their models. Ideally we would just call
76 * dedicated ACPI methods instead of using this primitive interface.
77 * However the ACPI methods seem to be incomplete in some areas (for
78 * example they allow setting, but not reading, the LCD brightness value),
79 * so this is still useful.
81 * SCI stands for "System Configuration Interface" which aim is to
82 * conceal differences in hardware between different models.
88 #define HCI_SET 0xff00
89 #define HCI_GET 0xfe00
90 #define SCI_OPEN 0xf100
91 #define SCI_CLOSE 0xf200
92 #define SCI_GET 0xf300
93 #define SCI_SET 0xf400
96 #define TOS_SUCCESS 0x0000
97 #define TOS_SUCCESS2 0x0001
98 #define TOS_OPEN_CLOSE_OK 0x0044
99 #define TOS_FAILURE 0x1000
100 #define TOS_NOT_SUPPORTED 0x8000
101 #define TOS_ALREADY_OPEN 0x8100
102 #define TOS_NOT_OPENED 0x8200
103 #define TOS_INPUT_DATA_ERROR 0x8300
104 #define TOS_WRITE_PROTECTED 0x8400
105 #define TOS_NOT_PRESENT 0x8600
106 #define TOS_FIFO_EMPTY 0x8c00
107 #define TOS_DATA_NOT_AVAILABLE 0x8d20
108 #define TOS_NOT_INITIALIZED 0x8d50
109 #define TOS_NOT_INSTALLED 0x8e00
112 #define HCI_FAN 0x0004
113 #define HCI_TR_BACKLIGHT 0x0005
114 #define HCI_SYSTEM_EVENT 0x0016
115 #define HCI_VIDEO_OUT 0x001c
116 #define HCI_HOTKEY_EVENT 0x001e
117 #define HCI_LCD_BRIGHTNESS 0x002a
118 #define HCI_WIRELESS 0x0056
119 #define HCI_ACCELEROMETER 0x006d
120 #define HCI_KBD_ILLUMINATION 0x0095
121 #define HCI_ECO_MODE 0x0097
122 #define HCI_ACCELEROMETER2 0x00a6
123 #define HCI_SYSTEM_INFO 0xc000
124 #define SCI_PANEL_POWER_ON 0x010d
125 #define SCI_ILLUMINATION 0x014e
126 #define SCI_USB_SLEEP_CHARGE 0x0150
127 #define SCI_KBD_ILLUM_STATUS 0x015c
128 #define SCI_USB_SLEEP_MUSIC 0x015e
129 #define SCI_USB_THREE 0x0169
130 #define SCI_TOUCHPAD 0x050e
131 #define SCI_KBD_FUNCTION_KEYS 0x0522
133 /* Field definitions */
134 #define HCI_ACCEL_MASK 0x7fff
135 #define HCI_HOTKEY_DISABLE 0x0b
136 #define HCI_HOTKEY_ENABLE 0x01
137 #define HCI_HOTKEY_SPECIAL_FUNCTIONS 0x10
138 #define HCI_LCD_BRIGHTNESS_BITS 3
139 #define HCI_LCD_BRIGHTNESS_SHIFT (16-HCI_LCD_BRIGHTNESS_BITS)
140 #define HCI_LCD_BRIGHTNESS_LEVELS (1 << HCI_LCD_BRIGHTNESS_BITS)
141 #define HCI_MISC_SHIFT 0x10
142 #define HCI_SYSTEM_TYPE1 0x10
143 #define HCI_SYSTEM_TYPE2 0x11
144 #define HCI_VIDEO_OUT_LCD 0x1
145 #define HCI_VIDEO_OUT_CRT 0x2
146 #define HCI_VIDEO_OUT_TV 0x4
147 #define SCI_KBD_MODE_MASK 0x1f
148 #define SCI_KBD_MODE_FNZ 0x1
149 #define SCI_KBD_MODE_AUTO 0x2
150 #define SCI_KBD_MODE_ON 0x8
151 #define SCI_KBD_MODE_OFF 0x10
152 #define SCI_KBD_TIME_MAX 0x3c001a
153 #define HCI_WIRELESS_STATUS 0x1
154 #define HCI_WIRELESS_WWAN 0x3
155 #define HCI_WIRELESS_WWAN_STATUS 0x2000
156 #define HCI_WIRELESS_WWAN_POWER 0x4000
157 #define SCI_USB_CHARGE_MODE_MASK 0xff
158 #define SCI_USB_CHARGE_DISABLED 0x00
159 #define SCI_USB_CHARGE_ALTERNATE 0x09
160 #define SCI_USB_CHARGE_TYPICAL 0x11
161 #define SCI_USB_CHARGE_AUTO 0x21
162 #define SCI_USB_CHARGE_BAT_MASK 0x7
163 #define SCI_USB_CHARGE_BAT_LVL_OFF 0x1
164 #define SCI_USB_CHARGE_BAT_LVL_ON 0x4
165 #define SCI_USB_CHARGE_BAT_LVL 0x0200
166 #define SCI_USB_CHARGE_RAPID_DSP 0x0300
168 struct toshiba_acpi_dev
{
169 struct acpi_device
*acpi_dev
;
170 const char *method_hci
;
171 struct input_dev
*hotkey_dev
;
172 struct work_struct hotkey_work
;
173 struct backlight_device
*backlight_dev
;
174 struct led_classdev led_dev
;
175 struct led_classdev kbd_led
;
176 struct led_classdev eco_led
;
177 struct miscdevice miscdev
;
178 struct rfkill
*wwan_rfk
;
188 int hotkey_event_type
;
190 unsigned int illumination_supported
:1;
191 unsigned int video_supported
:1;
192 unsigned int fan_supported
:1;
193 unsigned int system_event_supported
:1;
194 unsigned int ntfy_supported
:1;
195 unsigned int info_supported
:1;
196 unsigned int tr_backlight_supported
:1;
197 unsigned int kbd_illum_supported
:1;
198 unsigned int touchpad_supported
:1;
199 unsigned int eco_supported
:1;
200 unsigned int accelerometer_supported
:1;
201 unsigned int usb_sleep_charge_supported
:1;
202 unsigned int usb_rapid_charge_supported
:1;
203 unsigned int usb_sleep_music_supported
:1;
204 unsigned int kbd_function_keys_supported
:1;
205 unsigned int panel_power_on_supported
:1;
206 unsigned int usb_three_supported
:1;
207 unsigned int wwan_supported
:1;
208 unsigned int sysfs_created
:1;
209 unsigned int special_functions
;
211 bool kbd_event_generated
;
212 bool kbd_led_registered
;
213 bool illumination_led_registered
;
214 bool eco_led_registered
;
218 static struct toshiba_acpi_dev
*toshiba_acpi
;
220 static const struct acpi_device_id toshiba_device_ids
[] = {
227 MODULE_DEVICE_TABLE(acpi
, toshiba_device_ids
);
229 static const struct key_entry toshiba_acpi_keymap
[] = {
230 { KE_KEY
, 0x9e, { KEY_RFKILL
} },
231 { KE_KEY
, 0x101, { KEY_MUTE
} },
232 { KE_KEY
, 0x102, { KEY_ZOOMOUT
} },
233 { KE_KEY
, 0x103, { KEY_ZOOMIN
} },
234 { KE_KEY
, 0x10f, { KEY_TAB
} },
235 { KE_KEY
, 0x12c, { KEY_KBDILLUMTOGGLE
} },
236 { KE_KEY
, 0x139, { KEY_ZOOMRESET
} },
237 { KE_KEY
, 0x13b, { KEY_COFFEE
} },
238 { KE_KEY
, 0x13c, { KEY_BATTERY
} },
239 { KE_KEY
, 0x13d, { KEY_SLEEP
} },
240 { KE_KEY
, 0x13e, { KEY_SUSPEND
} },
241 { KE_KEY
, 0x13f, { KEY_SWITCHVIDEOMODE
} },
242 { KE_KEY
, 0x140, { KEY_BRIGHTNESSDOWN
} },
243 { KE_KEY
, 0x141, { KEY_BRIGHTNESSUP
} },
244 { KE_KEY
, 0x142, { KEY_WLAN
} },
245 { KE_KEY
, 0x143, { KEY_TOUCHPAD_TOGGLE
} },
246 { KE_KEY
, 0x17f, { KEY_FN
} },
247 { KE_KEY
, 0xb05, { KEY_PROG2
} },
248 { KE_KEY
, 0xb06, { KEY_WWW
} },
249 { KE_KEY
, 0xb07, { KEY_MAIL
} },
250 { KE_KEY
, 0xb30, { KEY_STOP
} },
251 { KE_KEY
, 0xb31, { KEY_PREVIOUSSONG
} },
252 { KE_KEY
, 0xb32, { KEY_NEXTSONG
} },
253 { KE_KEY
, 0xb33, { KEY_PLAYPAUSE
} },
254 { KE_KEY
, 0xb5a, { KEY_MEDIA
} },
255 { KE_IGNORE
, 0x1430, { KEY_RESERVED
} }, /* Wake from sleep */
256 { KE_IGNORE
, 0x1501, { KEY_RESERVED
} }, /* Output changed */
257 { KE_IGNORE
, 0x1502, { KEY_RESERVED
} }, /* HDMI plugged/unplugged */
258 { KE_IGNORE
, 0x1ABE, { KEY_RESERVED
} }, /* Protection level set */
259 { KE_IGNORE
, 0x1ABF, { KEY_RESERVED
} }, /* Protection level off */
263 static const struct key_entry toshiba_acpi_alt_keymap
[] = {
264 { KE_KEY
, 0x102, { KEY_ZOOMOUT
} },
265 { KE_KEY
, 0x103, { KEY_ZOOMIN
} },
266 { KE_KEY
, 0x12c, { KEY_KBDILLUMTOGGLE
} },
267 { KE_KEY
, 0x139, { KEY_ZOOMRESET
} },
268 { KE_KEY
, 0x13c, { KEY_BRIGHTNESSDOWN
} },
269 { KE_KEY
, 0x13d, { KEY_BRIGHTNESSUP
} },
270 { KE_KEY
, 0x13e, { KEY_SWITCHVIDEOMODE
} },
271 { KE_KEY
, 0x13f, { KEY_TOUCHPAD_TOGGLE
} },
272 { KE_KEY
, 0x157, { KEY_MUTE
} },
273 { KE_KEY
, 0x158, { KEY_WLAN
} },
278 * List of models which have a broken acpi-video backlight interface and thus
279 * need to use the toshiba (vendor) interface instead.
281 static const struct dmi_system_id toshiba_vendor_backlight_dmi
[] = {
289 static inline void _set_bit(u32
*word
, u32 mask
, int value
)
291 *word
= (*word
& ~mask
) | (mask
* value
);
295 * ACPI interface wrappers
298 static int write_acpi_int(const char *methodName
, int val
)
302 status
= acpi_execute_simple_method(NULL
, (char *)methodName
, val
);
303 return (status
== AE_OK
) ? 0 : -EIO
;
307 * Perform a raw configuration call. Here we don't care about input or output
310 static acpi_status
tci_raw(struct toshiba_acpi_dev
*dev
,
311 const u32 in
[TCI_WORDS
], u32 out
[TCI_WORDS
])
313 struct acpi_object_list params
;
314 union acpi_object in_objs
[TCI_WORDS
];
315 struct acpi_buffer results
;
316 union acpi_object out_objs
[TCI_WORDS
+ 1];
320 params
.count
= TCI_WORDS
;
321 params
.pointer
= in_objs
;
322 for (i
= 0; i
< TCI_WORDS
; ++i
) {
323 in_objs
[i
].type
= ACPI_TYPE_INTEGER
;
324 in_objs
[i
].integer
.value
= in
[i
];
327 results
.length
= sizeof(out_objs
);
328 results
.pointer
= out_objs
;
330 status
= acpi_evaluate_object(dev
->acpi_dev
->handle
,
331 (char *)dev
->method_hci
, ¶ms
,
333 if ((status
== AE_OK
) && (out_objs
->package
.count
<= TCI_WORDS
)) {
334 for (i
= 0; i
< out_objs
->package
.count
; ++i
)
335 out
[i
] = out_objs
->package
.elements
[i
].integer
.value
;
344 * In addition to the ACPI status, the HCI system returns a result which
345 * may be useful (such as "not supported").
348 static u32
hci_write(struct toshiba_acpi_dev
*dev
, u32 reg
, u32 in1
)
350 u32 in
[TCI_WORDS
] = { HCI_SET
, reg
, in1
, 0, 0, 0 };
352 acpi_status status
= tci_raw(dev
, in
, out
);
354 return ACPI_SUCCESS(status
) ? out
[0] : TOS_FAILURE
;
357 static u32
hci_read(struct toshiba_acpi_dev
*dev
, u32 reg
, u32
*out1
)
359 u32 in
[TCI_WORDS
] = { HCI_GET
, reg
, 0, 0, 0, 0 };
361 acpi_status status
= tci_raw(dev
, in
, out
);
363 if (ACPI_FAILURE(status
))
375 static int sci_open(struct toshiba_acpi_dev
*dev
)
377 u32 in
[TCI_WORDS
] = { SCI_OPEN
, 0, 0, 0, 0, 0 };
381 status
= tci_raw(dev
, in
, out
);
382 if (ACPI_FAILURE(status
)) {
383 pr_err("ACPI call to open SCI failed\n");
387 if (out
[0] == TOS_OPEN_CLOSE_OK
) {
389 } else if (out
[0] == TOS_ALREADY_OPEN
) {
390 pr_info("Toshiba SCI already opened\n");
392 } else if (out
[0] == TOS_NOT_SUPPORTED
) {
394 * Some BIOSes do not have the SCI open/close functions
395 * implemented and return 0x8000 (Not Supported), failing to
396 * register some supported features.
398 * Simply return 1 if we hit those affected laptops to make the
399 * supported features work.
401 * In the case that some laptops really do not support the SCI,
402 * all the SCI dependent functions check for TOS_NOT_SUPPORTED,
403 * and thus, not registering support for the queried feature.
406 } else if (out
[0] == TOS_NOT_PRESENT
) {
407 pr_info("Toshiba SCI is not present\n");
413 static void sci_close(struct toshiba_acpi_dev
*dev
)
415 u32 in
[TCI_WORDS
] = { SCI_CLOSE
, 0, 0, 0, 0, 0 };
419 status
= tci_raw(dev
, in
, out
);
420 if (ACPI_FAILURE(status
)) {
421 pr_err("ACPI call to close SCI failed\n");
425 if (out
[0] == TOS_OPEN_CLOSE_OK
)
427 else if (out
[0] == TOS_NOT_OPENED
)
428 pr_info("Toshiba SCI not opened\n");
429 else if (out
[0] == TOS_NOT_PRESENT
)
430 pr_info("Toshiba SCI is not present\n");
433 static u32
sci_read(struct toshiba_acpi_dev
*dev
, u32 reg
, u32
*out1
)
435 u32 in
[TCI_WORDS
] = { SCI_GET
, reg
, 0, 0, 0, 0 };
437 acpi_status status
= tci_raw(dev
, in
, out
);
439 if (ACPI_FAILURE(status
))
447 static u32
sci_write(struct toshiba_acpi_dev
*dev
, u32 reg
, u32 in1
)
449 u32 in
[TCI_WORDS
] = { SCI_SET
, reg
, in1
, 0, 0, 0 };
451 acpi_status status
= tci_raw(dev
, in
, out
);
453 return ACPI_SUCCESS(status
) ? out
[0] : TOS_FAILURE
;
456 /* Illumination support */
457 static void toshiba_illumination_available(struct toshiba_acpi_dev
*dev
)
459 u32 in
[TCI_WORDS
] = { SCI_GET
, SCI_ILLUMINATION
, 0, 0, 0, 0 };
463 dev
->illumination_supported
= 0;
464 dev
->illumination_led_registered
= false;
469 status
= tci_raw(dev
, in
, out
);
471 if (ACPI_FAILURE(status
))
472 pr_err("ACPI call to query Illumination support failed\n");
473 else if (out
[0] == TOS_SUCCESS
)
474 dev
->illumination_supported
= 1;
477 static void toshiba_illumination_set(struct led_classdev
*cdev
,
478 enum led_brightness brightness
)
480 struct toshiba_acpi_dev
*dev
= container_of(cdev
,
481 struct toshiba_acpi_dev
, led_dev
);
485 /* First request : initialize communication. */
489 /* Switch the illumination on/off */
490 state
= brightness
? 1 : 0;
491 result
= sci_write(dev
, SCI_ILLUMINATION
, state
);
493 if (result
== TOS_FAILURE
)
494 pr_err("ACPI call for illumination failed\n");
497 static enum led_brightness
toshiba_illumination_get(struct led_classdev
*cdev
)
499 struct toshiba_acpi_dev
*dev
= container_of(cdev
,
500 struct toshiba_acpi_dev
, led_dev
);
503 /* First request : initialize communication. */
507 /* Check the illumination */
508 result
= sci_read(dev
, SCI_ILLUMINATION
, &state
);
510 if (result
== TOS_FAILURE
) {
511 pr_err("ACPI call for illumination failed\n");
513 } else if (result
!= TOS_SUCCESS
) {
517 return state
? LED_FULL
: LED_OFF
;
520 /* KBD Illumination */
521 static void toshiba_kbd_illum_available(struct toshiba_acpi_dev
*dev
)
523 u32 in
[TCI_WORDS
] = { SCI_GET
, SCI_KBD_ILLUM_STATUS
, 0, 0, 0, 0 };
527 dev
->kbd_illum_supported
= 0;
528 dev
->kbd_led_registered
= false;
529 dev
->kbd_event_generated
= false;
534 status
= tci_raw(dev
, in
, out
);
536 if (ACPI_FAILURE(status
)) {
537 pr_err("ACPI call to query kbd illumination support failed\n");
538 } else if (out
[0] == TOS_SUCCESS
) {
540 * Check for keyboard backlight timeout max value,
541 * previous kbd backlight implementation set this to
542 * 0x3c0003, and now the new implementation set this
543 * to 0x3c001a, use this to distinguish between them.
545 if (out
[3] == SCI_KBD_TIME_MAX
)
549 /* Get the current keyboard backlight mode */
550 dev
->kbd_mode
= out
[2] & SCI_KBD_MODE_MASK
;
551 /* Get the current time (1-60 seconds) */
552 dev
->kbd_time
= out
[2] >> HCI_MISC_SHIFT
;
553 /* Flag as supported */
554 dev
->kbd_illum_supported
= 1;
558 static int toshiba_kbd_illum_status_set(struct toshiba_acpi_dev
*dev
, u32 time
)
565 result
= sci_write(dev
, SCI_KBD_ILLUM_STATUS
, time
);
567 if (result
== TOS_FAILURE
)
568 pr_err("ACPI call to set KBD backlight status failed\n");
569 else if (result
== TOS_NOT_SUPPORTED
)
572 return result
== TOS_SUCCESS
? 0 : -EIO
;
575 static int toshiba_kbd_illum_status_get(struct toshiba_acpi_dev
*dev
, u32
*time
)
582 result
= sci_read(dev
, SCI_KBD_ILLUM_STATUS
, time
);
584 if (result
== TOS_FAILURE
)
585 pr_err("ACPI call to get KBD backlight status failed\n");
586 else if (result
== TOS_NOT_SUPPORTED
)
589 return result
== TOS_SUCCESS
? 0 : -EIO
;
592 static enum led_brightness
toshiba_kbd_backlight_get(struct led_classdev
*cdev
)
594 struct toshiba_acpi_dev
*dev
= container_of(cdev
,
595 struct toshiba_acpi_dev
, kbd_led
);
599 /* Check the keyboard backlight state */
600 result
= hci_read(dev
, HCI_KBD_ILLUMINATION
, &state
);
601 if (result
== TOS_FAILURE
) {
602 pr_err("ACPI call to get the keyboard backlight failed\n");
604 } else if (result
!= TOS_SUCCESS
) {
608 return state
? LED_FULL
: LED_OFF
;
611 static void toshiba_kbd_backlight_set(struct led_classdev
*cdev
,
612 enum led_brightness brightness
)
614 struct toshiba_acpi_dev
*dev
= container_of(cdev
,
615 struct toshiba_acpi_dev
, kbd_led
);
619 /* Set the keyboard backlight state */
620 state
= brightness
? 1 : 0;
621 result
= hci_write(dev
, HCI_KBD_ILLUMINATION
, state
);
622 if (result
== TOS_FAILURE
)
623 pr_err("ACPI call to set KBD Illumination mode failed\n");
626 /* TouchPad support */
627 static int toshiba_touchpad_set(struct toshiba_acpi_dev
*dev
, u32 state
)
634 result
= sci_write(dev
, SCI_TOUCHPAD
, state
);
636 if (result
== TOS_FAILURE
)
637 pr_err("ACPI call to set the touchpad failed\n");
638 else if (result
== TOS_NOT_SUPPORTED
)
641 return result
== TOS_SUCCESS
? 0 : -EIO
;
644 static int toshiba_touchpad_get(struct toshiba_acpi_dev
*dev
, u32
*state
)
651 result
= sci_read(dev
, SCI_TOUCHPAD
, state
);
653 if (result
== TOS_FAILURE
)
654 pr_err("ACPI call to query the touchpad failed\n");
655 else if (result
== TOS_NOT_SUPPORTED
)
658 return result
== TOS_SUCCESS
? 0 : -EIO
;
661 /* Eco Mode support */
662 static void toshiba_eco_mode_available(struct toshiba_acpi_dev
*dev
)
665 u32 in
[TCI_WORDS
] = { HCI_GET
, HCI_ECO_MODE
, 0, 0, 0, 0 };
668 dev
->eco_supported
= 0;
669 dev
->eco_led_registered
= false;
671 status
= tci_raw(dev
, in
, out
);
672 if (ACPI_FAILURE(status
)) {
673 pr_err("ACPI call to get ECO led failed\n");
674 } else if (out
[0] == TOS_INPUT_DATA_ERROR
) {
676 * If we receive 0x8300 (Input Data Error), it means that the
677 * LED device is present, but that we just screwed the input
680 * Let's query the status of the LED to see if we really have a
681 * success response, indicating the actual presense of the LED,
682 * bail out otherwise.
685 status
= tci_raw(dev
, in
, out
);
686 if (ACPI_FAILURE(status
))
687 pr_err("ACPI call to get ECO led failed\n");
688 else if (out
[0] == TOS_SUCCESS
)
689 dev
->eco_supported
= 1;
693 static enum led_brightness
694 toshiba_eco_mode_get_status(struct led_classdev
*cdev
)
696 struct toshiba_acpi_dev
*dev
= container_of(cdev
,
697 struct toshiba_acpi_dev
, eco_led
);
698 u32 in
[TCI_WORDS
] = { HCI_GET
, HCI_ECO_MODE
, 0, 1, 0, 0 };
702 status
= tci_raw(dev
, in
, out
);
703 if (ACPI_FAILURE(status
)) {
704 pr_err("ACPI call to get ECO led failed\n");
706 } else if (out
[0] != TOS_SUCCESS
) {
710 return out
[2] ? LED_FULL
: LED_OFF
;
713 static void toshiba_eco_mode_set_status(struct led_classdev
*cdev
,
714 enum led_brightness brightness
)
716 struct toshiba_acpi_dev
*dev
= container_of(cdev
,
717 struct toshiba_acpi_dev
, eco_led
);
718 u32 in
[TCI_WORDS
] = { HCI_SET
, HCI_ECO_MODE
, 0, 1, 0, 0 };
722 /* Switch the Eco Mode led on/off */
723 in
[2] = (brightness
) ? 1 : 0;
724 status
= tci_raw(dev
, in
, out
);
725 if (ACPI_FAILURE(status
))
726 pr_err("ACPI call to set ECO led failed\n");
729 /* Accelerometer support */
730 static void toshiba_accelerometer_available(struct toshiba_acpi_dev
*dev
)
732 u32 in
[TCI_WORDS
] = { HCI_GET
, HCI_ACCELEROMETER2
, 0, 0, 0, 0 };
736 dev
->accelerometer_supported
= 0;
739 * Check if the accelerometer call exists,
740 * this call also serves as initialization
742 status
= tci_raw(dev
, in
, out
);
743 if (ACPI_FAILURE(status
))
744 pr_err("ACPI call to query the accelerometer failed\n");
745 else if (out
[0] == TOS_SUCCESS
)
746 dev
->accelerometer_supported
= 1;
749 static int toshiba_accelerometer_get(struct toshiba_acpi_dev
*dev
,
752 u32 in
[TCI_WORDS
] = { HCI_GET
, HCI_ACCELEROMETER
, 0, 1, 0, 0 };
756 /* Check the Accelerometer status */
757 status
= tci_raw(dev
, in
, out
);
758 if (ACPI_FAILURE(status
)) {
759 pr_err("ACPI call to query the accelerometer failed\n");
761 } else if (out
[0] == TOS_NOT_SUPPORTED
) {
763 } else if (out
[0] == TOS_SUCCESS
) {
772 /* Sleep (Charge and Music) utilities support */
773 static void toshiba_usb_sleep_charge_available(struct toshiba_acpi_dev
*dev
)
775 u32 in
[TCI_WORDS
] = { SCI_GET
, SCI_USB_SLEEP_CHARGE
, 0, 0, 0, 0 };
779 dev
->usb_sleep_charge_supported
= 0;
784 status
= tci_raw(dev
, in
, out
);
785 if (ACPI_FAILURE(status
)) {
786 pr_err("ACPI call to get USB Sleep and Charge mode failed\n");
789 } else if (out
[0] == TOS_NOT_SUPPORTED
) {
792 } else if (out
[0] == TOS_SUCCESS
) {
793 dev
->usbsc_mode_base
= out
[4];
796 in
[5] = SCI_USB_CHARGE_BAT_LVL
;
797 status
= tci_raw(dev
, in
, out
);
799 if (ACPI_FAILURE(status
)) {
800 pr_err("ACPI call to get USB Sleep and Charge mode failed\n");
801 } else if (out
[0] == TOS_SUCCESS
) {
802 dev
->usbsc_bat_level
= out
[2];
803 /* Flag as supported */
804 dev
->usb_sleep_charge_supported
= 1;
809 static int toshiba_usb_sleep_charge_get(struct toshiba_acpi_dev
*dev
,
817 result
= sci_read(dev
, SCI_USB_SLEEP_CHARGE
, mode
);
819 if (result
== TOS_FAILURE
)
820 pr_err("ACPI call to set USB S&C mode failed\n");
821 else if (result
== TOS_NOT_SUPPORTED
)
824 return result
== TOS_SUCCESS
? 0 : -EIO
;
827 static int toshiba_usb_sleep_charge_set(struct toshiba_acpi_dev
*dev
,
835 result
= sci_write(dev
, SCI_USB_SLEEP_CHARGE
, mode
);
837 if (result
== TOS_FAILURE
)
838 pr_err("ACPI call to set USB S&C mode failed\n");
839 else if (result
== TOS_NOT_SUPPORTED
)
842 return result
== TOS_SUCCESS
? 0 : -EIO
;
845 static int toshiba_sleep_functions_status_get(struct toshiba_acpi_dev
*dev
,
848 u32 in
[TCI_WORDS
] = { SCI_GET
, SCI_USB_SLEEP_CHARGE
, 0, 0, 0, 0 };
855 in
[5] = SCI_USB_CHARGE_BAT_LVL
;
856 status
= tci_raw(dev
, in
, out
);
858 if (ACPI_FAILURE(status
)) {
859 pr_err("ACPI call to get USB S&C battery level failed\n");
860 } else if (out
[0] == TOS_NOT_SUPPORTED
) {
862 } else if (out
[0] == TOS_SUCCESS
) {
870 static int toshiba_sleep_functions_status_set(struct toshiba_acpi_dev
*dev
,
873 u32 in
[TCI_WORDS
] = { SCI_SET
, SCI_USB_SLEEP_CHARGE
, 0, 0, 0, 0 };
881 in
[5] = SCI_USB_CHARGE_BAT_LVL
;
882 status
= tci_raw(dev
, in
, out
);
884 if (ACPI_FAILURE(status
))
885 pr_err("ACPI call to set USB S&C battery level failed\n");
886 else if (out
[0] == TOS_NOT_SUPPORTED
)
889 return out
[0] == TOS_SUCCESS
? 0 : -EIO
;
892 static int toshiba_usb_rapid_charge_get(struct toshiba_acpi_dev
*dev
,
895 u32 in
[TCI_WORDS
] = { SCI_GET
, SCI_USB_SLEEP_CHARGE
, 0, 0, 0, 0 };
902 in
[5] = SCI_USB_CHARGE_RAPID_DSP
;
903 status
= tci_raw(dev
, in
, out
);
905 if (ACPI_FAILURE(status
)) {
906 pr_err("ACPI call to get USB Rapid Charge failed\n");
907 } else if (out
[0] == TOS_NOT_SUPPORTED
) {
909 } else if (out
[0] == TOS_SUCCESS
|| out
[0] == TOS_SUCCESS2
) {
917 static int toshiba_usb_rapid_charge_set(struct toshiba_acpi_dev
*dev
,
920 u32 in
[TCI_WORDS
] = { SCI_SET
, SCI_USB_SLEEP_CHARGE
, 0, 0, 0, 0 };
928 in
[5] = SCI_USB_CHARGE_RAPID_DSP
;
929 status
= tci_raw(dev
, in
, out
);
931 if (ACPI_FAILURE(status
))
932 pr_err("ACPI call to set USB Rapid Charge failed\n");
933 else if (out
[0] == TOS_NOT_SUPPORTED
)
936 return (out
[0] == TOS_SUCCESS
|| out
[0] == TOS_SUCCESS2
) ? 0 : -EIO
;
939 static int toshiba_usb_sleep_music_get(struct toshiba_acpi_dev
*dev
, u32
*state
)
946 result
= sci_read(dev
, SCI_USB_SLEEP_MUSIC
, state
);
948 if (result
== TOS_FAILURE
)
949 pr_err("ACPI call to get Sleep and Music failed\n");
950 else if (result
== TOS_NOT_SUPPORTED
)
953 return result
== TOS_SUCCESS
? 0 : -EIO
;
956 static int toshiba_usb_sleep_music_set(struct toshiba_acpi_dev
*dev
, u32 state
)
963 result
= sci_write(dev
, SCI_USB_SLEEP_MUSIC
, state
);
965 if (result
== TOS_FAILURE
)
966 pr_err("ACPI call to set Sleep and Music failed\n");
967 else if (result
== TOS_NOT_SUPPORTED
)
970 return result
== TOS_SUCCESS
? 0 : -EIO
;
973 /* Keyboard function keys */
974 static int toshiba_function_keys_get(struct toshiba_acpi_dev
*dev
, u32
*mode
)
981 result
= sci_read(dev
, SCI_KBD_FUNCTION_KEYS
, mode
);
983 if (result
== TOS_FAILURE
)
984 pr_err("ACPI call to get KBD function keys failed\n");
985 else if (result
== TOS_NOT_SUPPORTED
)
988 return (result
== TOS_SUCCESS
|| result
== TOS_SUCCESS2
) ? 0 : -EIO
;
991 static int toshiba_function_keys_set(struct toshiba_acpi_dev
*dev
, u32 mode
)
998 result
= sci_write(dev
, SCI_KBD_FUNCTION_KEYS
, mode
);
1000 if (result
== TOS_FAILURE
)
1001 pr_err("ACPI call to set KBD function keys failed\n");
1002 else if (result
== TOS_NOT_SUPPORTED
)
1005 return (result
== TOS_SUCCESS
|| result
== TOS_SUCCESS2
) ? 0 : -EIO
;
1008 /* Panel Power ON */
1009 static int toshiba_panel_power_on_get(struct toshiba_acpi_dev
*dev
, u32
*state
)
1016 result
= sci_read(dev
, SCI_PANEL_POWER_ON
, state
);
1018 if (result
== TOS_FAILURE
)
1019 pr_err("ACPI call to get Panel Power ON failed\n");
1020 else if (result
== TOS_NOT_SUPPORTED
)
1023 return result
== TOS_SUCCESS
? 0 : -EIO
;
1026 static int toshiba_panel_power_on_set(struct toshiba_acpi_dev
*dev
, u32 state
)
1033 result
= sci_write(dev
, SCI_PANEL_POWER_ON
, state
);
1035 if (result
== TOS_FAILURE
)
1036 pr_err("ACPI call to set Panel Power ON failed\n");
1037 else if (result
== TOS_NOT_SUPPORTED
)
1040 return result
== TOS_SUCCESS
? 0 : -EIO
;
1044 static int toshiba_usb_three_get(struct toshiba_acpi_dev
*dev
, u32
*state
)
1051 result
= sci_read(dev
, SCI_USB_THREE
, state
);
1053 if (result
== TOS_FAILURE
)
1054 pr_err("ACPI call to get USB 3 failed\n");
1055 else if (result
== TOS_NOT_SUPPORTED
)
1058 return (result
== TOS_SUCCESS
|| result
== TOS_SUCCESS2
) ? 0 : -EIO
;
1061 static int toshiba_usb_three_set(struct toshiba_acpi_dev
*dev
, u32 state
)
1068 result
= sci_write(dev
, SCI_USB_THREE
, state
);
1070 if (result
== TOS_FAILURE
)
1071 pr_err("ACPI call to set USB 3 failed\n");
1072 else if (result
== TOS_NOT_SUPPORTED
)
1075 return (result
== TOS_SUCCESS
|| result
== TOS_SUCCESS2
) ? 0 : -EIO
;
1078 /* Hotkey Event type */
1079 static int toshiba_hotkey_event_type_get(struct toshiba_acpi_dev
*dev
,
1082 u32 in
[TCI_WORDS
] = { HCI_GET
, HCI_SYSTEM_INFO
, 0x03, 0, 0, 0 };
1086 status
= tci_raw(dev
, in
, out
);
1087 if (ACPI_FAILURE(status
)) {
1088 pr_err("ACPI call to get System type failed\n");
1089 } else if (out
[0] == TOS_NOT_SUPPORTED
) {
1091 } else if (out
[0] == TOS_SUCCESS
) {
1099 /* Wireless status (RFKill, WLAN, BT, WWAN) */
1100 static int toshiba_wireless_status(struct toshiba_acpi_dev
*dev
)
1102 u32 in
[TCI_WORDS
] = { HCI_GET
, HCI_WIRELESS
, 0, 0, 0, 0 };
1106 in
[3] = HCI_WIRELESS_STATUS
;
1107 status
= tci_raw(dev
, in
, out
);
1109 if (ACPI_FAILURE(status
)) {
1110 pr_err("ACPI call to get Wireless status failed\n");
1114 if (out
[0] == TOS_NOT_SUPPORTED
)
1117 if (out
[0] != TOS_SUCCESS
)
1120 dev
->killswitch
= !!(out
[2] & HCI_WIRELESS_STATUS
);
1126 static void toshiba_wwan_available(struct toshiba_acpi_dev
*dev
)
1128 u32 in
[TCI_WORDS
] = { HCI_GET
, HCI_WIRELESS
, 0, 0, 0, 0 };
1132 dev
->wwan_supported
= 0;
1135 * WWAN support can be queried by setting the in[3] value to
1136 * HCI_WIRELESS_WWAN (0x03).
1138 * If supported, out[0] contains TOS_SUCCESS and out[2] contains
1139 * HCI_WIRELESS_WWAN_STATUS (0x2000).
1141 * If not supported, out[0] contains TOS_INPUT_DATA_ERROR (0x8300)
1142 * or TOS_NOT_SUPPORTED (0x8000).
1144 in
[3] = HCI_WIRELESS_WWAN
;
1145 status
= tci_raw(dev
, in
, out
);
1147 if (ACPI_FAILURE(status
)) {
1148 pr_err("ACPI call to get WWAN status failed\n");
1152 if (out
[0] != TOS_SUCCESS
)
1155 dev
->wwan_supported
= (out
[2] == HCI_WIRELESS_WWAN_STATUS
);
1158 static int toshiba_wwan_set(struct toshiba_acpi_dev
*dev
, u32 state
)
1160 u32 in
[TCI_WORDS
] = { HCI_SET
, HCI_WIRELESS
, state
, 0, 0, 0 };
1164 in
[3] = HCI_WIRELESS_WWAN_STATUS
;
1165 status
= tci_raw(dev
, in
, out
);
1167 if (ACPI_FAILURE(status
)) {
1168 pr_err("ACPI call to set WWAN status failed\n");
1172 if (out
[0] == TOS_NOT_SUPPORTED
)
1175 if (out
[0] != TOS_SUCCESS
)
1179 * Some devices only need to call HCI_WIRELESS_WWAN_STATUS to
1180 * (de)activate the device, but some others need the
1181 * HCI_WIRELESS_WWAN_POWER call as well.
1183 in
[3] = HCI_WIRELESS_WWAN_POWER
;
1184 status
= tci_raw(dev
, in
, out
);
1186 if (ACPI_FAILURE(status
)) {
1187 pr_err("ACPI call to set WWAN power failed\n");
1191 if (out
[0] == TOS_NOT_SUPPORTED
)
1194 return out
[0] == TOS_SUCCESS
? 0 : -EIO
;
1197 /* Transflective Backlight */
1198 static int get_tr_backlight_status(struct toshiba_acpi_dev
*dev
, u32
*status
)
1200 u32 result
= hci_read(dev
, HCI_TR_BACKLIGHT
, status
);
1202 if (result
== TOS_FAILURE
)
1203 pr_err("ACPI call to get Transflective Backlight failed\n");
1204 else if (result
== TOS_NOT_SUPPORTED
)
1207 return result
== TOS_SUCCESS
? 0 : -EIO
;
1210 static int set_tr_backlight_status(struct toshiba_acpi_dev
*dev
, u32 status
)
1212 u32 result
= hci_write(dev
, HCI_TR_BACKLIGHT
, !status
);
1214 if (result
== TOS_FAILURE
)
1215 pr_err("ACPI call to set Transflective Backlight failed\n");
1216 else if (result
== TOS_NOT_SUPPORTED
)
1219 return result
== TOS_SUCCESS
? 0 : -EIO
;
1222 static struct proc_dir_entry
*toshiba_proc_dir
;
1224 /* LCD Brightness */
1225 static int __get_lcd_brightness(struct toshiba_acpi_dev
*dev
)
1231 if (dev
->tr_backlight_supported
) {
1232 int ret
= get_tr_backlight_status(dev
, &value
);
1241 result
= hci_read(dev
, HCI_LCD_BRIGHTNESS
, &value
);
1242 if (result
== TOS_FAILURE
)
1243 pr_err("ACPI call to get LCD Brightness failed\n");
1244 else if (result
== TOS_NOT_SUPPORTED
)
1246 if (result
== TOS_SUCCESS
)
1247 return brightness
+ (value
>> HCI_LCD_BRIGHTNESS_SHIFT
);
1252 static int get_lcd_brightness(struct backlight_device
*bd
)
1254 struct toshiba_acpi_dev
*dev
= bl_get_data(bd
);
1256 return __get_lcd_brightness(dev
);
1259 static int lcd_proc_show(struct seq_file
*m
, void *v
)
1261 struct toshiba_acpi_dev
*dev
= m
->private;
1265 if (!dev
->backlight_dev
)
1268 levels
= dev
->backlight_dev
->props
.max_brightness
+ 1;
1269 value
= get_lcd_brightness(dev
->backlight_dev
);
1271 seq_printf(m
, "brightness: %d\n", value
);
1272 seq_printf(m
, "brightness_levels: %d\n", levels
);
1276 pr_err("Error reading LCD brightness\n");
1281 static int lcd_proc_open(struct inode
*inode
, struct file
*file
)
1283 return single_open(file
, lcd_proc_show
, PDE_DATA(inode
));
1286 static int set_lcd_brightness(struct toshiba_acpi_dev
*dev
, int value
)
1290 if (dev
->tr_backlight_supported
) {
1291 int ret
= set_tr_backlight_status(dev
, !value
);
1299 value
= value
<< HCI_LCD_BRIGHTNESS_SHIFT
;
1300 result
= hci_write(dev
, HCI_LCD_BRIGHTNESS
, value
);
1301 if (result
== TOS_FAILURE
)
1302 pr_err("ACPI call to set LCD Brightness failed\n");
1303 else if (result
== TOS_NOT_SUPPORTED
)
1306 return result
== TOS_SUCCESS
? 0 : -EIO
;
1309 static int set_lcd_status(struct backlight_device
*bd
)
1311 struct toshiba_acpi_dev
*dev
= bl_get_data(bd
);
1313 return set_lcd_brightness(dev
, bd
->props
.brightness
);
1316 static ssize_t
lcd_proc_write(struct file
*file
, const char __user
*buf
,
1317 size_t count
, loff_t
*pos
)
1319 struct toshiba_acpi_dev
*dev
= PDE_DATA(file_inode(file
));
1322 int levels
= dev
->backlight_dev
->props
.max_brightness
+ 1;
1325 len
= min(count
, sizeof(cmd
) - 1);
1326 if (copy_from_user(cmd
, buf
, len
))
1330 if (sscanf(cmd
, " brightness : %i", &value
) != 1 &&
1331 value
< 0 && value
> levels
)
1334 if (set_lcd_brightness(dev
, value
))
1340 static const struct file_operations lcd_proc_fops
= {
1341 .owner
= THIS_MODULE
,
1342 .open
= lcd_proc_open
,
1344 .llseek
= seq_lseek
,
1345 .release
= single_release
,
1346 .write
= lcd_proc_write
,
1350 static int get_video_status(struct toshiba_acpi_dev
*dev
, u32
*status
)
1352 u32 result
= hci_read(dev
, HCI_VIDEO_OUT
, status
);
1354 if (result
== TOS_FAILURE
)
1355 pr_err("ACPI call to get Video-Out failed\n");
1356 else if (result
== TOS_NOT_SUPPORTED
)
1359 return result
== TOS_SUCCESS
? 0 : -EIO
;
1362 static int video_proc_show(struct seq_file
*m
, void *v
)
1364 struct toshiba_acpi_dev
*dev
= m
->private;
1367 if (!get_video_status(dev
, &value
)) {
1368 int is_lcd
= (value
& HCI_VIDEO_OUT_LCD
) ? 1 : 0;
1369 int is_crt
= (value
& HCI_VIDEO_OUT_CRT
) ? 1 : 0;
1370 int is_tv
= (value
& HCI_VIDEO_OUT_TV
) ? 1 : 0;
1372 seq_printf(m
, "lcd_out: %d\n", is_lcd
);
1373 seq_printf(m
, "crt_out: %d\n", is_crt
);
1374 seq_printf(m
, "tv_out: %d\n", is_tv
);
1381 static int video_proc_open(struct inode
*inode
, struct file
*file
)
1383 return single_open(file
, video_proc_show
, PDE_DATA(inode
));
1386 static ssize_t
video_proc_write(struct file
*file
, const char __user
*buf
,
1387 size_t count
, loff_t
*pos
)
1389 struct toshiba_acpi_dev
*dev
= PDE_DATA(file_inode(file
));
1400 cmd
= kmalloc(count
+ 1, GFP_KERNEL
);
1403 if (copy_from_user(cmd
, buf
, count
)) {
1412 * Scan expression. Multiple expressions may be delimited with ;
1413 * NOTE: To keep scanning simple, invalid fields are ignored.
1416 if (sscanf(buffer
, " lcd_out : %i", &value
) == 1)
1417 lcd_out
= value
& 1;
1418 else if (sscanf(buffer
, " crt_out : %i", &value
) == 1)
1419 crt_out
= value
& 1;
1420 else if (sscanf(buffer
, " tv_out : %i", &value
) == 1)
1422 /* Advance to one character past the next ; */
1426 } while (remain
&& *(buffer
- 1) != ';');
1431 ret
= get_video_status(dev
, &video_out
);
1433 unsigned int new_video_out
= video_out
;
1436 _set_bit(&new_video_out
, HCI_VIDEO_OUT_LCD
, lcd_out
);
1438 _set_bit(&new_video_out
, HCI_VIDEO_OUT_CRT
, crt_out
);
1440 _set_bit(&new_video_out
, HCI_VIDEO_OUT_TV
, tv_out
);
1442 * To avoid unnecessary video disruption, only write the new
1443 * video setting if something changed.
1445 if (new_video_out
!= video_out
)
1446 ret
= write_acpi_int(METHOD_VIDEO_OUT
, new_video_out
);
1449 return ret
? -EIO
: count
;
1452 static const struct file_operations video_proc_fops
= {
1453 .owner
= THIS_MODULE
,
1454 .open
= video_proc_open
,
1456 .llseek
= seq_lseek
,
1457 .release
= single_release
,
1458 .write
= video_proc_write
,
1462 static int get_fan_status(struct toshiba_acpi_dev
*dev
, u32
*status
)
1464 u32 result
= hci_read(dev
, HCI_FAN
, status
);
1466 if (result
== TOS_FAILURE
)
1467 pr_err("ACPI call to get Fan status failed\n");
1468 else if (result
== TOS_NOT_SUPPORTED
)
1471 return result
== TOS_SUCCESS
? 0 : -EIO
;
1474 static int set_fan_status(struct toshiba_acpi_dev
*dev
, u32 status
)
1476 u32 result
= hci_write(dev
, HCI_FAN
, status
);
1478 if (result
== TOS_FAILURE
)
1479 pr_err("ACPI call to set Fan status failed\n");
1480 else if (result
== TOS_NOT_SUPPORTED
)
1483 return result
== TOS_SUCCESS
? 0 : -EIO
;
1486 static int fan_proc_show(struct seq_file
*m
, void *v
)
1488 struct toshiba_acpi_dev
*dev
= m
->private;
1491 if (get_fan_status(dev
, &value
))
1494 seq_printf(m
, "running: %d\n", (value
> 0));
1495 seq_printf(m
, "force_on: %d\n", dev
->force_fan
);
1500 static int fan_proc_open(struct inode
*inode
, struct file
*file
)
1502 return single_open(file
, fan_proc_show
, PDE_DATA(inode
));
1505 static ssize_t
fan_proc_write(struct file
*file
, const char __user
*buf
,
1506 size_t count
, loff_t
*pos
)
1508 struct toshiba_acpi_dev
*dev
= PDE_DATA(file_inode(file
));
1513 len
= min(count
, sizeof(cmd
) - 1);
1514 if (copy_from_user(cmd
, buf
, len
))
1518 if (sscanf(cmd
, " force_on : %i", &value
) != 1 &&
1519 value
!= 0 && value
!= 1)
1522 if (set_fan_status(dev
, value
))
1525 dev
->force_fan
= value
;
1530 static const struct file_operations fan_proc_fops
= {
1531 .owner
= THIS_MODULE
,
1532 .open
= fan_proc_open
,
1534 .llseek
= seq_lseek
,
1535 .release
= single_release
,
1536 .write
= fan_proc_write
,
1539 static int keys_proc_show(struct seq_file
*m
, void *v
)
1541 struct toshiba_acpi_dev
*dev
= m
->private;
1543 seq_printf(m
, "hotkey_ready: %d\n", dev
->key_event_valid
);
1544 seq_printf(m
, "hotkey: 0x%04x\n", dev
->last_key_event
);
1549 static int keys_proc_open(struct inode
*inode
, struct file
*file
)
1551 return single_open(file
, keys_proc_show
, PDE_DATA(inode
));
1554 static ssize_t
keys_proc_write(struct file
*file
, const char __user
*buf
,
1555 size_t count
, loff_t
*pos
)
1557 struct toshiba_acpi_dev
*dev
= PDE_DATA(file_inode(file
));
1562 len
= min(count
, sizeof(cmd
) - 1);
1563 if (copy_from_user(cmd
, buf
, len
))
1567 if (sscanf(cmd
, " hotkey_ready : %i", &value
) == 1 && value
== 0)
1568 dev
->key_event_valid
= 0;
1575 static const struct file_operations keys_proc_fops
= {
1576 .owner
= THIS_MODULE
,
1577 .open
= keys_proc_open
,
1579 .llseek
= seq_lseek
,
1580 .release
= single_release
,
1581 .write
= keys_proc_write
,
1584 static int version_proc_show(struct seq_file
*m
, void *v
)
1586 seq_printf(m
, "driver: %s\n", TOSHIBA_ACPI_VERSION
);
1587 seq_printf(m
, "proc_interface: %d\n", PROC_INTERFACE_VERSION
);
1591 static int version_proc_open(struct inode
*inode
, struct file
*file
)
1593 return single_open(file
, version_proc_show
, PDE_DATA(inode
));
1596 static const struct file_operations version_proc_fops
= {
1597 .owner
= THIS_MODULE
,
1598 .open
= version_proc_open
,
1600 .llseek
= seq_lseek
,
1601 .release
= single_release
,
1605 * Proc and module init
1608 #define PROC_TOSHIBA "toshiba"
1610 static void create_toshiba_proc_entries(struct toshiba_acpi_dev
*dev
)
1612 if (dev
->backlight_dev
)
1613 proc_create_data("lcd", S_IRUGO
| S_IWUSR
, toshiba_proc_dir
,
1614 &lcd_proc_fops
, dev
);
1615 if (dev
->video_supported
)
1616 proc_create_data("video", S_IRUGO
| S_IWUSR
, toshiba_proc_dir
,
1617 &video_proc_fops
, dev
);
1618 if (dev
->fan_supported
)
1619 proc_create_data("fan", S_IRUGO
| S_IWUSR
, toshiba_proc_dir
,
1620 &fan_proc_fops
, dev
);
1621 if (dev
->hotkey_dev
)
1622 proc_create_data("keys", S_IRUGO
| S_IWUSR
, toshiba_proc_dir
,
1623 &keys_proc_fops
, dev
);
1624 proc_create_data("version", S_IRUGO
, toshiba_proc_dir
,
1625 &version_proc_fops
, dev
);
1628 static void remove_toshiba_proc_entries(struct toshiba_acpi_dev
*dev
)
1630 if (dev
->backlight_dev
)
1631 remove_proc_entry("lcd", toshiba_proc_dir
);
1632 if (dev
->video_supported
)
1633 remove_proc_entry("video", toshiba_proc_dir
);
1634 if (dev
->fan_supported
)
1635 remove_proc_entry("fan", toshiba_proc_dir
);
1636 if (dev
->hotkey_dev
)
1637 remove_proc_entry("keys", toshiba_proc_dir
);
1638 remove_proc_entry("version", toshiba_proc_dir
);
1641 static const struct backlight_ops toshiba_backlight_data
= {
1642 .options
= BL_CORE_SUSPENDRESUME
,
1643 .get_brightness
= get_lcd_brightness
,
1644 .update_status
= set_lcd_status
,
1647 /* Keyboard backlight work */
1648 static void toshiba_acpi_kbd_bl_work(struct work_struct
*work
);
1650 static DECLARE_WORK(kbd_bl_work
, toshiba_acpi_kbd_bl_work
);
1655 static ssize_t
version_show(struct device
*dev
,
1656 struct device_attribute
*attr
, char *buf
)
1658 return sprintf(buf
, "%s\n", TOSHIBA_ACPI_VERSION
);
1660 static DEVICE_ATTR_RO(version
);
1662 static ssize_t
fan_store(struct device
*dev
,
1663 struct device_attribute
*attr
,
1664 const char *buf
, size_t count
)
1666 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
1670 ret
= kstrtoint(buf
, 0, &state
);
1674 if (state
!= 0 && state
!= 1)
1677 ret
= set_fan_status(toshiba
, state
);
1684 static ssize_t
fan_show(struct device
*dev
,
1685 struct device_attribute
*attr
, char *buf
)
1687 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
1691 ret
= get_fan_status(toshiba
, &value
);
1695 return sprintf(buf
, "%d\n", value
);
1697 static DEVICE_ATTR_RW(fan
);
1699 static ssize_t
kbd_backlight_mode_store(struct device
*dev
,
1700 struct device_attribute
*attr
,
1701 const char *buf
, size_t count
)
1703 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
1708 ret
= kstrtoint(buf
, 0, &mode
);
1712 /* Check for supported modes depending on keyboard backlight type */
1713 if (toshiba
->kbd_type
== 1) {
1714 /* Type 1 supports SCI_KBD_MODE_FNZ and SCI_KBD_MODE_AUTO */
1715 if (mode
!= SCI_KBD_MODE_FNZ
&& mode
!= SCI_KBD_MODE_AUTO
)
1717 } else if (toshiba
->kbd_type
== 2) {
1718 /* Type 2 doesn't support SCI_KBD_MODE_FNZ */
1719 if (mode
!= SCI_KBD_MODE_AUTO
&& mode
!= SCI_KBD_MODE_ON
&&
1720 mode
!= SCI_KBD_MODE_OFF
)
1725 * Set the Keyboard Backlight Mode where:
1726 * Auto - KBD backlight turns off automatically in given time
1727 * FN-Z - KBD backlight "toggles" when hotkey pressed
1728 * ON - KBD backlight is always on
1729 * OFF - KBD backlight is always off
1732 /* Only make a change if the actual mode has changed */
1733 if (toshiba
->kbd_mode
!= mode
) {
1734 /* Shift the time to "base time" (0x3c0000 == 60 seconds) */
1735 int time
= toshiba
->kbd_time
<< HCI_MISC_SHIFT
;
1737 /* OR the "base time" to the actual method format */
1738 if (toshiba
->kbd_type
== 1) {
1739 /* Type 1 requires the current mode */
1740 time
|= toshiba
->kbd_mode
;
1741 } else if (toshiba
->kbd_type
== 2) {
1742 /* Type 2 requires the desired mode */
1746 ret
= toshiba_kbd_illum_status_set(toshiba
, time
);
1750 toshiba
->kbd_mode
= mode
;
1753 * Some laptop models with the second generation backlit
1754 * keyboard (type 2) do not generate the keyboard backlight
1755 * changed event (0x92), and thus, the driver will never update
1756 * the sysfs entries.
1758 * The event is generated right when changing the keyboard
1759 * backlight mode and the *notify function will set the
1760 * kbd_event_generated to true.
1762 * In case the event is not generated, schedule the keyboard
1763 * backlight work to update the sysfs entries and emulate the
1764 * event via genetlink.
1766 if (toshiba
->kbd_type
== 2 &&
1767 !toshiba_acpi
->kbd_event_generated
)
1768 schedule_work(&kbd_bl_work
);
1774 static ssize_t
kbd_backlight_mode_show(struct device
*dev
,
1775 struct device_attribute
*attr
,
1778 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
1781 if (toshiba_kbd_illum_status_get(toshiba
, &time
) < 0)
1784 return sprintf(buf
, "%i\n", time
& SCI_KBD_MODE_MASK
);
1786 static DEVICE_ATTR_RW(kbd_backlight_mode
);
1788 static ssize_t
kbd_type_show(struct device
*dev
,
1789 struct device_attribute
*attr
, char *buf
)
1791 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
1793 return sprintf(buf
, "%d\n", toshiba
->kbd_type
);
1795 static DEVICE_ATTR_RO(kbd_type
);
1797 static ssize_t
available_kbd_modes_show(struct device
*dev
,
1798 struct device_attribute
*attr
,
1801 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
1803 if (toshiba
->kbd_type
== 1)
1804 return sprintf(buf
, "0x%x 0x%x\n",
1805 SCI_KBD_MODE_FNZ
, SCI_KBD_MODE_AUTO
);
1807 return sprintf(buf
, "0x%x 0x%x 0x%x\n",
1808 SCI_KBD_MODE_AUTO
, SCI_KBD_MODE_ON
, SCI_KBD_MODE_OFF
);
1810 static DEVICE_ATTR_RO(available_kbd_modes
);
1812 static ssize_t
kbd_backlight_timeout_store(struct device
*dev
,
1813 struct device_attribute
*attr
,
1814 const char *buf
, size_t count
)
1816 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
1820 ret
= kstrtoint(buf
, 0, &time
);
1824 /* Check for supported values depending on kbd_type */
1825 if (toshiba
->kbd_type
== 1) {
1826 if (time
< 0 || time
> 60)
1828 } else if (toshiba
->kbd_type
== 2) {
1829 if (time
< 1 || time
> 60)
1833 /* Set the Keyboard Backlight Timeout */
1835 /* Only make a change if the actual timeout has changed */
1836 if (toshiba
->kbd_time
!= time
) {
1837 /* Shift the time to "base time" (0x3c0000 == 60 seconds) */
1838 time
= time
<< HCI_MISC_SHIFT
;
1839 /* OR the "base time" to the actual method format */
1840 if (toshiba
->kbd_type
== 1)
1841 time
|= SCI_KBD_MODE_FNZ
;
1842 else if (toshiba
->kbd_type
== 2)
1843 time
|= SCI_KBD_MODE_AUTO
;
1845 ret
= toshiba_kbd_illum_status_set(toshiba
, time
);
1849 toshiba
->kbd_time
= time
>> HCI_MISC_SHIFT
;
1855 static ssize_t
kbd_backlight_timeout_show(struct device
*dev
,
1856 struct device_attribute
*attr
,
1859 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
1862 if (toshiba_kbd_illum_status_get(toshiba
, &time
) < 0)
1865 return sprintf(buf
, "%i\n", time
>> HCI_MISC_SHIFT
);
1867 static DEVICE_ATTR_RW(kbd_backlight_timeout
);
1869 static ssize_t
touchpad_store(struct device
*dev
,
1870 struct device_attribute
*attr
,
1871 const char *buf
, size_t count
)
1873 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
1877 /* Set the TouchPad on/off, 0 - Disable | 1 - Enable */
1878 ret
= kstrtoint(buf
, 0, &state
);
1881 if (state
!= 0 && state
!= 1)
1884 ret
= toshiba_touchpad_set(toshiba
, state
);
1891 static ssize_t
touchpad_show(struct device
*dev
,
1892 struct device_attribute
*attr
, char *buf
)
1894 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
1898 ret
= toshiba_touchpad_get(toshiba
, &state
);
1902 return sprintf(buf
, "%i\n", state
);
1904 static DEVICE_ATTR_RW(touchpad
);
1906 static ssize_t
position_show(struct device
*dev
,
1907 struct device_attribute
*attr
, char *buf
)
1909 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
1910 u32 xyval
, zval
, tmp
;
1915 ret
= toshiba_accelerometer_get(toshiba
, &xyval
, &zval
);
1919 x
= xyval
& HCI_ACCEL_MASK
;
1920 tmp
= xyval
>> HCI_MISC_SHIFT
;
1921 y
= tmp
& HCI_ACCEL_MASK
;
1922 z
= zval
& HCI_ACCEL_MASK
;
1924 return sprintf(buf
, "%d %d %d\n", x
, y
, z
);
1926 static DEVICE_ATTR_RO(position
);
1928 static ssize_t
usb_sleep_charge_show(struct device
*dev
,
1929 struct device_attribute
*attr
, char *buf
)
1931 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
1935 ret
= toshiba_usb_sleep_charge_get(toshiba
, &mode
);
1939 return sprintf(buf
, "%x\n", mode
& SCI_USB_CHARGE_MODE_MASK
);
1942 static ssize_t
usb_sleep_charge_store(struct device
*dev
,
1943 struct device_attribute
*attr
,
1944 const char *buf
, size_t count
)
1946 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
1951 ret
= kstrtoint(buf
, 0, &state
);
1955 * Check for supported values, where:
1957 * 1 - Alternate (Non USB conformant devices that require more power)
1958 * 2 - Auto (USB conformant devices)
1961 if (state
!= 0 && state
!= 1 && state
!= 2 && state
!= 3)
1964 /* Set the USB charging mode to internal value */
1965 mode
= toshiba
->usbsc_mode_base
;
1967 mode
|= SCI_USB_CHARGE_DISABLED
;
1968 else if (state
== 1)
1969 mode
|= SCI_USB_CHARGE_ALTERNATE
;
1970 else if (state
== 2)
1971 mode
|= SCI_USB_CHARGE_AUTO
;
1972 else if (state
== 3)
1973 mode
|= SCI_USB_CHARGE_TYPICAL
;
1975 ret
= toshiba_usb_sleep_charge_set(toshiba
, mode
);
1981 static DEVICE_ATTR_RW(usb_sleep_charge
);
1983 static ssize_t
sleep_functions_on_battery_show(struct device
*dev
,
1984 struct device_attribute
*attr
,
1987 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
1994 ret
= toshiba_sleep_functions_status_get(toshiba
, &state
);
1998 /* Determine the status: 0x4 - Enabled | 0x1 - Disabled */
1999 tmp
= state
& SCI_USB_CHARGE_BAT_MASK
;
2000 status
= (tmp
== 0x4) ? 1 : 0;
2001 /* Determine the battery level set */
2002 bat_lvl
= state
>> HCI_MISC_SHIFT
;
2004 return sprintf(buf
, "%d %d\n", status
, bat_lvl
);
2007 static ssize_t
sleep_functions_on_battery_store(struct device
*dev
,
2008 struct device_attribute
*attr
,
2009 const char *buf
, size_t count
)
2011 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
2017 ret
= kstrtoint(buf
, 0, &value
);
2022 * Set the status of the function:
2026 if (value
< 0 || value
> 100)
2030 tmp
= toshiba
->usbsc_bat_level
<< HCI_MISC_SHIFT
;
2031 status
= tmp
| SCI_USB_CHARGE_BAT_LVL_OFF
;
2033 tmp
= value
<< HCI_MISC_SHIFT
;
2034 status
= tmp
| SCI_USB_CHARGE_BAT_LVL_ON
;
2036 ret
= toshiba_sleep_functions_status_set(toshiba
, status
);
2040 toshiba
->usbsc_bat_level
= status
>> HCI_MISC_SHIFT
;
2044 static DEVICE_ATTR_RW(sleep_functions_on_battery
);
2046 static ssize_t
usb_rapid_charge_show(struct device
*dev
,
2047 struct device_attribute
*attr
, char *buf
)
2049 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
2053 ret
= toshiba_usb_rapid_charge_get(toshiba
, &state
);
2057 return sprintf(buf
, "%d\n", state
);
2060 static ssize_t
usb_rapid_charge_store(struct device
*dev
,
2061 struct device_attribute
*attr
,
2062 const char *buf
, size_t count
)
2064 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
2068 ret
= kstrtoint(buf
, 0, &state
);
2071 if (state
!= 0 && state
!= 1)
2074 ret
= toshiba_usb_rapid_charge_set(toshiba
, state
);
2080 static DEVICE_ATTR_RW(usb_rapid_charge
);
2082 static ssize_t
usb_sleep_music_show(struct device
*dev
,
2083 struct device_attribute
*attr
, char *buf
)
2085 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
2089 ret
= toshiba_usb_sleep_music_get(toshiba
, &state
);
2093 return sprintf(buf
, "%d\n", state
);
2096 static ssize_t
usb_sleep_music_store(struct device
*dev
,
2097 struct device_attribute
*attr
,
2098 const char *buf
, size_t count
)
2100 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
2104 ret
= kstrtoint(buf
, 0, &state
);
2107 if (state
!= 0 && state
!= 1)
2110 ret
= toshiba_usb_sleep_music_set(toshiba
, state
);
2116 static DEVICE_ATTR_RW(usb_sleep_music
);
2118 static ssize_t
kbd_function_keys_show(struct device
*dev
,
2119 struct device_attribute
*attr
, char *buf
)
2121 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
2125 ret
= toshiba_function_keys_get(toshiba
, &mode
);
2129 return sprintf(buf
, "%d\n", mode
);
2132 static ssize_t
kbd_function_keys_store(struct device
*dev
,
2133 struct device_attribute
*attr
,
2134 const char *buf
, size_t count
)
2136 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
2140 ret
= kstrtoint(buf
, 0, &mode
);
2144 * Check for the function keys mode where:
2145 * 0 - Normal operation (F{1-12} as usual and hotkeys via FN-F{1-12})
2146 * 1 - Special functions (Opposite of the above setting)
2148 if (mode
!= 0 && mode
!= 1)
2151 ret
= toshiba_function_keys_set(toshiba
, mode
);
2155 pr_info("Reboot for changes to KBD Function Keys to take effect");
2159 static DEVICE_ATTR_RW(kbd_function_keys
);
2161 static ssize_t
panel_power_on_show(struct device
*dev
,
2162 struct device_attribute
*attr
, char *buf
)
2164 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
2168 ret
= toshiba_panel_power_on_get(toshiba
, &state
);
2172 return sprintf(buf
, "%d\n", state
);
2175 static ssize_t
panel_power_on_store(struct device
*dev
,
2176 struct device_attribute
*attr
,
2177 const char *buf
, size_t count
)
2179 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
2183 ret
= kstrtoint(buf
, 0, &state
);
2186 if (state
!= 0 && state
!= 1)
2189 ret
= toshiba_panel_power_on_set(toshiba
, state
);
2193 pr_info("Reboot for changes to Panel Power ON to take effect");
2197 static DEVICE_ATTR_RW(panel_power_on
);
2199 static ssize_t
usb_three_show(struct device
*dev
,
2200 struct device_attribute
*attr
, char *buf
)
2202 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
2206 ret
= toshiba_usb_three_get(toshiba
, &state
);
2210 return sprintf(buf
, "%d\n", state
);
2213 static ssize_t
usb_three_store(struct device
*dev
,
2214 struct device_attribute
*attr
,
2215 const char *buf
, size_t count
)
2217 struct toshiba_acpi_dev
*toshiba
= dev_get_drvdata(dev
);
2221 ret
= kstrtoint(buf
, 0, &state
);
2225 * Check for USB 3 mode where:
2226 * 0 - Disabled (Acts like a USB 2 port, saving power)
2229 if (state
!= 0 && state
!= 1)
2232 ret
= toshiba_usb_three_set(toshiba
, state
);
2236 pr_info("Reboot for changes to USB 3 to take effect");
2240 static DEVICE_ATTR_RW(usb_three
);
2242 static struct attribute
*toshiba_attributes
[] = {
2243 &dev_attr_version
.attr
,
2245 &dev_attr_kbd_backlight_mode
.attr
,
2246 &dev_attr_kbd_type
.attr
,
2247 &dev_attr_available_kbd_modes
.attr
,
2248 &dev_attr_kbd_backlight_timeout
.attr
,
2249 &dev_attr_touchpad
.attr
,
2250 &dev_attr_position
.attr
,
2251 &dev_attr_usb_sleep_charge
.attr
,
2252 &dev_attr_sleep_functions_on_battery
.attr
,
2253 &dev_attr_usb_rapid_charge
.attr
,
2254 &dev_attr_usb_sleep_music
.attr
,
2255 &dev_attr_kbd_function_keys
.attr
,
2256 &dev_attr_panel_power_on
.attr
,
2257 &dev_attr_usb_three
.attr
,
2261 static umode_t
toshiba_sysfs_is_visible(struct kobject
*kobj
,
2262 struct attribute
*attr
, int idx
)
2264 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
2265 struct toshiba_acpi_dev
*drv
= dev_get_drvdata(dev
);
2268 if (attr
== &dev_attr_fan
.attr
)
2269 exists
= (drv
->fan_supported
) ? true : false;
2270 else if (attr
== &dev_attr_kbd_backlight_mode
.attr
)
2271 exists
= (drv
->kbd_illum_supported
) ? true : false;
2272 else if (attr
== &dev_attr_kbd_backlight_timeout
.attr
)
2273 exists
= (drv
->kbd_mode
== SCI_KBD_MODE_AUTO
) ? true : false;
2274 else if (attr
== &dev_attr_touchpad
.attr
)
2275 exists
= (drv
->touchpad_supported
) ? true : false;
2276 else if (attr
== &dev_attr_position
.attr
)
2277 exists
= (drv
->accelerometer_supported
) ? true : false;
2278 else if (attr
== &dev_attr_usb_sleep_charge
.attr
)
2279 exists
= (drv
->usb_sleep_charge_supported
) ? true : false;
2280 else if (attr
== &dev_attr_sleep_functions_on_battery
.attr
)
2281 exists
= (drv
->usb_sleep_charge_supported
) ? true : false;
2282 else if (attr
== &dev_attr_usb_rapid_charge
.attr
)
2283 exists
= (drv
->usb_rapid_charge_supported
) ? true : false;
2284 else if (attr
== &dev_attr_usb_sleep_music
.attr
)
2285 exists
= (drv
->usb_sleep_music_supported
) ? true : false;
2286 else if (attr
== &dev_attr_kbd_function_keys
.attr
)
2287 exists
= (drv
->kbd_function_keys_supported
) ? true : false;
2288 else if (attr
== &dev_attr_panel_power_on
.attr
)
2289 exists
= (drv
->panel_power_on_supported
) ? true : false;
2290 else if (attr
== &dev_attr_usb_three
.attr
)
2291 exists
= (drv
->usb_three_supported
) ? true : false;
2293 return exists
? attr
->mode
: 0;
2296 static struct attribute_group toshiba_attr_group
= {
2297 .is_visible
= toshiba_sysfs_is_visible
,
2298 .attrs
= toshiba_attributes
,
2301 static void toshiba_acpi_kbd_bl_work(struct work_struct
*work
)
2303 struct acpi_device
*acpi_dev
= toshiba_acpi
->acpi_dev
;
2305 /* Update the sysfs entries */
2306 if (sysfs_update_group(&acpi_dev
->dev
.kobj
,
2307 &toshiba_attr_group
))
2308 pr_err("Unable to update sysfs entries\n");
2310 /* Emulate the keyboard backlight event */
2311 acpi_bus_generate_netlink_event(acpi_dev
->pnp
.device_class
,
2312 dev_name(&acpi_dev
->dev
),
2319 static int toshiba_acpi_smm_bridge(SMMRegisters
*regs
)
2321 u32 in
[TCI_WORDS
] = { regs
->eax
, regs
->ebx
, regs
->ecx
,
2322 regs
->edx
, regs
->esi
, regs
->edi
};
2326 status
= tci_raw(toshiba_acpi
, in
, out
);
2327 if (ACPI_FAILURE(status
)) {
2328 pr_err("ACPI call to query SMM registers failed\n");
2332 /* Fillout the SMM struct with the TCI call results */
2343 static long toshiba_acpi_ioctl(struct file
*fp
, unsigned int cmd
,
2346 SMMRegisters __user
*argp
= (SMMRegisters __user
*)arg
;
2355 if (copy_from_user(®s
, argp
, sizeof(SMMRegisters
)))
2357 ret
= toshiba_acpi_smm_bridge(®s
);
2360 if (copy_to_user(argp
, ®s
, sizeof(SMMRegisters
)))
2363 case TOSHIBA_ACPI_SCI
:
2364 if (copy_from_user(®s
, argp
, sizeof(SMMRegisters
)))
2366 /* Ensure we are being called with a SCI_{GET, SET} register */
2367 if (regs
.eax
!= SCI_GET
&& regs
.eax
!= SCI_SET
)
2369 if (!sci_open(toshiba_acpi
))
2371 ret
= toshiba_acpi_smm_bridge(®s
);
2372 sci_close(toshiba_acpi
);
2375 if (copy_to_user(argp
, ®s
, sizeof(SMMRegisters
)))
2385 static const struct file_operations toshiba_acpi_fops
= {
2386 .owner
= THIS_MODULE
,
2387 .unlocked_ioctl
= toshiba_acpi_ioctl
,
2388 .llseek
= noop_llseek
,
2392 * WWAN RFKill handlers
2394 static int toshiba_acpi_wwan_set_block(void *data
, bool blocked
)
2396 struct toshiba_acpi_dev
*dev
= data
;
2399 ret
= toshiba_wireless_status(dev
);
2403 if (!dev
->killswitch
)
2406 return toshiba_wwan_set(dev
, !blocked
);
2409 static void toshiba_acpi_wwan_poll(struct rfkill
*rfkill
, void *data
)
2411 struct toshiba_acpi_dev
*dev
= data
;
2413 if (toshiba_wireless_status(dev
))
2416 rfkill_set_hw_state(dev
->wwan_rfk
, !dev
->killswitch
);
2419 static const struct rfkill_ops wwan_rfk_ops
= {
2420 .set_block
= toshiba_acpi_wwan_set_block
,
2421 .poll
= toshiba_acpi_wwan_poll
,
2424 static int toshiba_acpi_setup_wwan_rfkill(struct toshiba_acpi_dev
*dev
)
2426 int ret
= toshiba_wireless_status(dev
);
2431 dev
->wwan_rfk
= rfkill_alloc("Toshiba WWAN",
2432 &dev
->acpi_dev
->dev
,
2436 if (!dev
->wwan_rfk
) {
2437 pr_err("Unable to allocate WWAN rfkill device\n");
2441 rfkill_set_hw_state(dev
->wwan_rfk
, !dev
->killswitch
);
2443 ret
= rfkill_register(dev
->wwan_rfk
);
2445 pr_err("Unable to register WWAN rfkill device\n");
2446 rfkill_destroy(dev
->wwan_rfk
);
2455 static int toshiba_acpi_enable_hotkeys(struct toshiba_acpi_dev
*dev
)
2460 status
= acpi_evaluate_object(dev
->acpi_dev
->handle
,
2461 "ENAB", NULL
, NULL
);
2462 if (ACPI_FAILURE(status
))
2466 * Enable the "Special Functions" mode only if they are
2467 * supported and if they are activated.
2469 if (dev
->kbd_function_keys_supported
&& dev
->special_functions
)
2470 result
= hci_write(dev
, HCI_HOTKEY_EVENT
,
2471 HCI_HOTKEY_SPECIAL_FUNCTIONS
);
2473 result
= hci_write(dev
, HCI_HOTKEY_EVENT
, HCI_HOTKEY_ENABLE
);
2475 if (result
== TOS_FAILURE
)
2477 else if (result
== TOS_NOT_SUPPORTED
)
2483 static bool toshiba_acpi_i8042_filter(unsigned char data
, unsigned char str
,
2486 if (str
& I8042_STR_AUXDATA
)
2489 if (unlikely(data
== 0xe0))
2492 if ((data
& 0x7f) == TOS1900_FN_SCAN
) {
2493 schedule_work(&toshiba_acpi
->hotkey_work
);
2500 static void toshiba_acpi_hotkey_work(struct work_struct
*work
)
2502 acpi_handle ec_handle
= ec_get_handle();
2508 status
= acpi_evaluate_object(ec_handle
, "NTFY", NULL
, NULL
);
2509 if (ACPI_FAILURE(status
))
2510 pr_err("ACPI NTFY method execution failed\n");
2514 * Returns hotkey scancode, or < 0 on failure.
2516 static int toshiba_acpi_query_hotkey(struct toshiba_acpi_dev
*dev
)
2518 unsigned long long value
;
2521 status
= acpi_evaluate_integer(dev
->acpi_dev
->handle
, "INFO",
2523 if (ACPI_FAILURE(status
)) {
2524 pr_err("ACPI INFO method execution failed\n");
2531 static void toshiba_acpi_report_hotkey(struct toshiba_acpi_dev
*dev
,
2534 if (scancode
== 0x100)
2537 /* Act on key press; ignore key release */
2538 if (scancode
& 0x80)
2541 if (!sparse_keymap_report_event(dev
->hotkey_dev
, scancode
, 1, true))
2542 pr_info("Unknown key %x\n", scancode
);
2545 static void toshiba_acpi_process_hotkeys(struct toshiba_acpi_dev
*dev
)
2547 if (dev
->info_supported
) {
2548 int scancode
= toshiba_acpi_query_hotkey(dev
);
2551 pr_err("Failed to query hotkey event\n");
2552 } else if (scancode
!= 0) {
2553 toshiba_acpi_report_hotkey(dev
, scancode
);
2554 dev
->key_event_valid
= 1;
2555 dev
->last_key_event
= scancode
;
2557 } else if (dev
->system_event_supported
) {
2563 result
= hci_read(dev
, HCI_SYSTEM_EVENT
, &value
);
2566 toshiba_acpi_report_hotkey(dev
, (int)value
);
2567 dev
->key_event_valid
= 1;
2568 dev
->last_key_event
= value
;
2570 case TOS_NOT_SUPPORTED
:
2572 * This is a workaround for an unresolved
2573 * issue on some machines where system events
2574 * sporadically become disabled.
2576 result
= hci_write(dev
, HCI_SYSTEM_EVENT
, 1);
2577 if (result
== TOS_SUCCESS
)
2578 pr_notice("Re-enabled hotkeys\n");
2584 } while (retries
&& result
!= TOS_FIFO_EMPTY
);
2588 static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev
*dev
)
2590 const struct key_entry
*keymap
= toshiba_acpi_keymap
;
2591 acpi_handle ec_handle
;
2594 if (wmi_has_guid(TOSHIBA_WMI_EVENT_GUID
)) {
2595 pr_info("WMI event detected, hotkeys will not be monitored\n");
2599 error
= toshiba_acpi_enable_hotkeys(dev
);
2603 if (toshiba_hotkey_event_type_get(dev
, &dev
->hotkey_event_type
))
2604 pr_notice("Unable to query Hotkey Event Type\n");
2606 dev
->hotkey_dev
= input_allocate_device();
2607 if (!dev
->hotkey_dev
)
2610 dev
->hotkey_dev
->name
= "Toshiba input device";
2611 dev
->hotkey_dev
->phys
= "toshiba_acpi/input0";
2612 dev
->hotkey_dev
->id
.bustype
= BUS_HOST
;
2614 if (dev
->hotkey_event_type
== HCI_SYSTEM_TYPE1
||
2615 !dev
->kbd_function_keys_supported
)
2616 keymap
= toshiba_acpi_keymap
;
2617 else if (dev
->hotkey_event_type
== HCI_SYSTEM_TYPE2
||
2618 dev
->kbd_function_keys_supported
)
2619 keymap
= toshiba_acpi_alt_keymap
;
2621 pr_info("Unknown event type received %x\n",
2622 dev
->hotkey_event_type
);
2623 error
= sparse_keymap_setup(dev
->hotkey_dev
, keymap
, NULL
);
2628 * For some machines the SCI responsible for providing hotkey
2629 * notification doesn't fire. We can trigger the notification
2630 * whenever the Fn key is pressed using the NTFY method, if
2631 * supported, so if it's present set up an i8042 key filter
2634 ec_handle
= ec_get_handle();
2635 if (ec_handle
&& acpi_has_method(ec_handle
, "NTFY")) {
2636 INIT_WORK(&dev
->hotkey_work
, toshiba_acpi_hotkey_work
);
2638 error
= i8042_install_filter(toshiba_acpi_i8042_filter
);
2640 pr_err("Error installing key filter\n");
2641 goto err_free_keymap
;
2644 dev
->ntfy_supported
= 1;
2648 * Determine hotkey query interface. Prefer using the INFO
2649 * method when it is available.
2651 if (acpi_has_method(dev
->acpi_dev
->handle
, "INFO"))
2652 dev
->info_supported
= 1;
2653 else if (hci_write(dev
, HCI_SYSTEM_EVENT
, 1) == TOS_SUCCESS
)
2654 dev
->system_event_supported
= 1;
2656 if (!dev
->info_supported
&& !dev
->system_event_supported
) {
2657 pr_warn("No hotkey query interface found\n");
2658 goto err_remove_filter
;
2661 error
= input_register_device(dev
->hotkey_dev
);
2663 pr_info("Unable to register input device\n");
2664 goto err_remove_filter
;
2670 if (dev
->ntfy_supported
)
2671 i8042_remove_filter(toshiba_acpi_i8042_filter
);
2673 sparse_keymap_free(dev
->hotkey_dev
);
2675 input_free_device(dev
->hotkey_dev
);
2676 dev
->hotkey_dev
= NULL
;
2680 static int toshiba_acpi_setup_backlight(struct toshiba_acpi_dev
*dev
)
2682 struct backlight_properties props
;
2687 * Some machines don't support the backlight methods at all, and
2688 * others support it read-only. Either of these is pretty useless,
2689 * so only register the backlight device if the backlight method
2690 * supports both reads and writes.
2692 brightness
= __get_lcd_brightness(dev
);
2696 * If transflective backlight is supported and the brightness is zero
2697 * (lowest brightness level), the set_lcd_brightness function will
2698 * activate the transflective backlight, making the LCD appear to be
2699 * turned off, simply increment the brightness level to avoid that.
2701 if (dev
->tr_backlight_supported
&& brightness
== 0)
2703 ret
= set_lcd_brightness(dev
, brightness
);
2705 pr_debug("Backlight method is read-only, disabling backlight support\n");
2710 * Tell acpi-video-detect code to prefer vendor backlight on all
2711 * systems with transflective backlight and on dmi matched systems.
2713 if (dev
->tr_backlight_supported
||
2714 dmi_check_system(toshiba_vendor_backlight_dmi
))
2715 acpi_video_set_dmi_backlight_type(acpi_backlight_vendor
);
2717 if (acpi_video_get_backlight_type() != acpi_backlight_vendor
)
2720 memset(&props
, 0, sizeof(props
));
2721 props
.type
= BACKLIGHT_PLATFORM
;
2722 props
.max_brightness
= HCI_LCD_BRIGHTNESS_LEVELS
- 1;
2724 /* Adding an extra level and having 0 change to transflective mode */
2725 if (dev
->tr_backlight_supported
)
2726 props
.max_brightness
++;
2728 dev
->backlight_dev
= backlight_device_register("toshiba",
2729 &dev
->acpi_dev
->dev
,
2731 &toshiba_backlight_data
,
2733 if (IS_ERR(dev
->backlight_dev
)) {
2734 ret
= PTR_ERR(dev
->backlight_dev
);
2735 pr_err("Could not register toshiba backlight device\n");
2736 dev
->backlight_dev
= NULL
;
2740 dev
->backlight_dev
->props
.brightness
= brightness
;
2744 static void print_supported_features(struct toshiba_acpi_dev
*dev
)
2746 pr_info("Supported laptop features:");
2748 if (dev
->hotkey_dev
)
2749 pr_cont(" hotkeys");
2750 if (dev
->backlight_dev
)
2751 pr_cont(" backlight");
2752 if (dev
->video_supported
)
2753 pr_cont(" video-out");
2754 if (dev
->fan_supported
)
2756 if (dev
->tr_backlight_supported
)
2757 pr_cont(" transflective-backlight");
2758 if (dev
->illumination_supported
)
2759 pr_cont(" illumination");
2760 if (dev
->kbd_illum_supported
)
2761 pr_cont(" keyboard-backlight");
2762 if (dev
->touchpad_supported
)
2763 pr_cont(" touchpad");
2764 if (dev
->eco_supported
)
2765 pr_cont(" eco-led");
2766 if (dev
->accelerometer_supported
)
2767 pr_cont(" accelerometer-axes");
2768 if (dev
->usb_sleep_charge_supported
)
2769 pr_cont(" usb-sleep-charge");
2770 if (dev
->usb_rapid_charge_supported
)
2771 pr_cont(" usb-rapid-charge");
2772 if (dev
->usb_sleep_music_supported
)
2773 pr_cont(" usb-sleep-music");
2774 if (dev
->kbd_function_keys_supported
)
2775 pr_cont(" special-function-keys");
2776 if (dev
->panel_power_on_supported
)
2777 pr_cont(" panel-power-on");
2778 if (dev
->usb_three_supported
)
2780 if (dev
->wwan_supported
)
2786 static int toshiba_acpi_remove(struct acpi_device
*acpi_dev
)
2788 struct toshiba_acpi_dev
*dev
= acpi_driver_data(acpi_dev
);
2790 misc_deregister(&dev
->miscdev
);
2792 remove_toshiba_proc_entries(dev
);
2794 if (dev
->sysfs_created
)
2795 sysfs_remove_group(&dev
->acpi_dev
->dev
.kobj
,
2796 &toshiba_attr_group
);
2798 if (dev
->ntfy_supported
) {
2799 i8042_remove_filter(toshiba_acpi_i8042_filter
);
2800 cancel_work_sync(&dev
->hotkey_work
);
2803 if (dev
->hotkey_dev
) {
2804 input_unregister_device(dev
->hotkey_dev
);
2805 sparse_keymap_free(dev
->hotkey_dev
);
2808 backlight_device_unregister(dev
->backlight_dev
);
2810 if (dev
->illumination_led_registered
)
2811 led_classdev_unregister(&dev
->led_dev
);
2813 if (dev
->kbd_led_registered
)
2814 led_classdev_unregister(&dev
->kbd_led
);
2816 if (dev
->eco_led_registered
)
2817 led_classdev_unregister(&dev
->eco_led
);
2819 if (dev
->wwan_rfk
) {
2820 rfkill_unregister(dev
->wwan_rfk
);
2821 rfkill_destroy(dev
->wwan_rfk
);
2825 toshiba_acpi
= NULL
;
2832 static const char *find_hci_method(acpi_handle handle
)
2834 if (acpi_has_method(handle
, "GHCI"))
2837 if (acpi_has_method(handle
, "SPFC"))
2843 static int toshiba_acpi_add(struct acpi_device
*acpi_dev
)
2845 struct toshiba_acpi_dev
*dev
;
2846 const char *hci_method
;
2853 pr_info("Toshiba Laptop ACPI Extras version %s\n",
2854 TOSHIBA_ACPI_VERSION
);
2856 hci_method
= find_hci_method(acpi_dev
->handle
);
2858 pr_err("HCI interface not found\n");
2862 dev
= kzalloc(sizeof(*dev
), GFP_KERNEL
);
2865 dev
->acpi_dev
= acpi_dev
;
2866 dev
->method_hci
= hci_method
;
2867 dev
->miscdev
.minor
= MISC_DYNAMIC_MINOR
;
2868 dev
->miscdev
.name
= "toshiba_acpi";
2869 dev
->miscdev
.fops
= &toshiba_acpi_fops
;
2871 ret
= misc_register(&dev
->miscdev
);
2873 pr_err("Failed to register miscdevice\n");
2878 acpi_dev
->driver_data
= dev
;
2879 dev_set_drvdata(&acpi_dev
->dev
, dev
);
2881 /* Query the BIOS for supported features */
2884 * The "Special Functions" are always supported by the laptops
2885 * with the new keyboard layout, query for its presence to help
2886 * determine the keymap layout to use.
2888 ret
= toshiba_function_keys_get(dev
, &dev
->special_functions
);
2889 dev
->kbd_function_keys_supported
= !ret
;
2891 dev
->hotkey_event_type
= 0;
2892 if (toshiba_acpi_setup_keyboard(dev
))
2893 pr_info("Unable to activate hotkeys\n");
2895 /* Determine whether or not BIOS supports transflective backlight */
2896 ret
= get_tr_backlight_status(dev
, &dummy
);
2897 dev
->tr_backlight_supported
= !ret
;
2899 ret
= toshiba_acpi_setup_backlight(dev
);
2903 toshiba_illumination_available(dev
);
2904 if (dev
->illumination_supported
) {
2905 dev
->led_dev
.name
= "toshiba::illumination";
2906 dev
->led_dev
.max_brightness
= 1;
2907 dev
->led_dev
.brightness_set
= toshiba_illumination_set
;
2908 dev
->led_dev
.brightness_get
= toshiba_illumination_get
;
2909 if (!led_classdev_register(&acpi_dev
->dev
, &dev
->led_dev
))
2910 dev
->illumination_led_registered
= true;
2913 toshiba_eco_mode_available(dev
);
2914 if (dev
->eco_supported
) {
2915 dev
->eco_led
.name
= "toshiba::eco_mode";
2916 dev
->eco_led
.max_brightness
= 1;
2917 dev
->eco_led
.brightness_set
= toshiba_eco_mode_set_status
;
2918 dev
->eco_led
.brightness_get
= toshiba_eco_mode_get_status
;
2919 if (!led_classdev_register(&dev
->acpi_dev
->dev
, &dev
->eco_led
))
2920 dev
->eco_led_registered
= true;
2923 toshiba_kbd_illum_available(dev
);
2925 * Only register the LED if KBD illumination is supported
2926 * and the keyboard backlight operation mode is set to FN-Z
2928 if (dev
->kbd_illum_supported
&& dev
->kbd_mode
== SCI_KBD_MODE_FNZ
) {
2929 dev
->kbd_led
.name
= "toshiba::kbd_backlight";
2930 dev
->kbd_led
.max_brightness
= 1;
2931 dev
->kbd_led
.brightness_set
= toshiba_kbd_backlight_set
;
2932 dev
->kbd_led
.brightness_get
= toshiba_kbd_backlight_get
;
2933 if (!led_classdev_register(&dev
->acpi_dev
->dev
, &dev
->kbd_led
))
2934 dev
->kbd_led_registered
= true;
2937 ret
= toshiba_touchpad_get(dev
, &dummy
);
2938 dev
->touchpad_supported
= !ret
;
2940 toshiba_accelerometer_available(dev
);
2942 toshiba_usb_sleep_charge_available(dev
);
2944 ret
= toshiba_usb_rapid_charge_get(dev
, &dummy
);
2945 dev
->usb_rapid_charge_supported
= !ret
;
2947 ret
= toshiba_usb_sleep_music_get(dev
, &dummy
);
2948 dev
->usb_sleep_music_supported
= !ret
;
2950 ret
= toshiba_panel_power_on_get(dev
, &dummy
);
2951 dev
->panel_power_on_supported
= !ret
;
2953 ret
= toshiba_usb_three_get(dev
, &dummy
);
2954 dev
->usb_three_supported
= !ret
;
2956 ret
= get_video_status(dev
, &dummy
);
2957 dev
->video_supported
= !ret
;
2959 ret
= get_fan_status(dev
, &dummy
);
2960 dev
->fan_supported
= !ret
;
2962 toshiba_wwan_available(dev
);
2963 if (dev
->wwan_supported
)
2964 toshiba_acpi_setup_wwan_rfkill(dev
);
2966 print_supported_features(dev
);
2968 ret
= sysfs_create_group(&dev
->acpi_dev
->dev
.kobj
,
2969 &toshiba_attr_group
);
2971 dev
->sysfs_created
= 0;
2974 dev
->sysfs_created
= !ret
;
2976 create_toshiba_proc_entries(dev
);
2983 toshiba_acpi_remove(acpi_dev
);
2987 static void toshiba_acpi_notify(struct acpi_device
*acpi_dev
, u32 event
)
2989 struct toshiba_acpi_dev
*dev
= acpi_driver_data(acpi_dev
);
2992 case 0x80: /* Hotkeys and some system events */
2994 * Machines with this WMI GUID aren't supported due to bugs in
2997 * Return silently to avoid triggering a netlink event.
2999 if (wmi_has_guid(TOSHIBA_WMI_EVENT_GUID
))
3001 toshiba_acpi_process_hotkeys(dev
);
3003 case 0x81: /* Dock events */
3006 pr_info("Dock event received %x\n", event
);
3008 case 0x88: /* Thermal events */
3009 pr_info("Thermal event received\n");
3011 case 0x8f: /* LID closed */
3012 case 0x90: /* LID is closed and Dock has been ejected */
3014 case 0x8c: /* SATA power events */
3016 pr_info("SATA power event received %x\n", event
);
3018 case 0x92: /* Keyboard backlight mode changed */
3019 toshiba_acpi
->kbd_event_generated
= true;
3020 /* Update sysfs entries */
3021 if (sysfs_update_group(&acpi_dev
->dev
.kobj
,
3022 &toshiba_attr_group
))
3023 pr_err("Unable to update sysfs entries\n");
3025 case 0x85: /* Unknown */
3026 case 0x8d: /* Unknown */
3027 case 0x8e: /* Unknown */
3028 case 0x94: /* Unknown */
3029 case 0x95: /* Unknown */
3031 pr_info("Unknown event received %x\n", event
);
3035 acpi_bus_generate_netlink_event(acpi_dev
->pnp
.device_class
,
3036 dev_name(&acpi_dev
->dev
),
3037 event
, (event
== 0x80) ?
3038 dev
->last_key_event
: 0);
3041 #ifdef CONFIG_PM_SLEEP
3042 static int toshiba_acpi_suspend(struct device
*device
)
3044 struct toshiba_acpi_dev
*dev
= acpi_driver_data(to_acpi_device(device
));
3046 if (dev
->hotkey_dev
) {
3049 result
= hci_write(dev
, HCI_HOTKEY_EVENT
, HCI_HOTKEY_DISABLE
);
3050 if (result
!= TOS_SUCCESS
)
3051 pr_info("Unable to disable hotkeys\n");
3057 static int toshiba_acpi_resume(struct device
*device
)
3059 struct toshiba_acpi_dev
*dev
= acpi_driver_data(to_acpi_device(device
));
3061 if (dev
->hotkey_dev
) {
3062 if (toshiba_acpi_enable_hotkeys(dev
))
3063 pr_info("Unable to re-enable hotkeys\n");
3066 if (dev
->wwan_rfk
) {
3067 if (!toshiba_wireless_status(dev
))
3068 rfkill_set_hw_state(dev
->wwan_rfk
, !dev
->killswitch
);
3075 static SIMPLE_DEV_PM_OPS(toshiba_acpi_pm
,
3076 toshiba_acpi_suspend
, toshiba_acpi_resume
);
3078 static struct acpi_driver toshiba_acpi_driver
= {
3079 .name
= "Toshiba ACPI driver",
3080 .owner
= THIS_MODULE
,
3081 .ids
= toshiba_device_ids
,
3082 .flags
= ACPI_DRIVER_ALL_NOTIFY_EVENTS
,
3084 .add
= toshiba_acpi_add
,
3085 .remove
= toshiba_acpi_remove
,
3086 .notify
= toshiba_acpi_notify
,
3088 .drv
.pm
= &toshiba_acpi_pm
,
3091 static int __init
toshiba_acpi_init(void)
3095 toshiba_proc_dir
= proc_mkdir(PROC_TOSHIBA
, acpi_root_dir
);
3096 if (!toshiba_proc_dir
) {
3097 pr_err("Unable to create proc dir " PROC_TOSHIBA
"\n");
3101 ret
= acpi_bus_register_driver(&toshiba_acpi_driver
);
3103 pr_err("Failed to register ACPI driver: %d\n", ret
);
3104 remove_proc_entry(PROC_TOSHIBA
, acpi_root_dir
);
3110 static void __exit
toshiba_acpi_exit(void)
3112 acpi_bus_unregister_driver(&toshiba_acpi_driver
);
3113 if (toshiba_proc_dir
)
3114 remove_proc_entry(PROC_TOSHIBA
, acpi_root_dir
);
3117 module_init(toshiba_acpi_init
);
3118 module_exit(toshiba_acpi_exit
);