diff options
Diffstat (limited to 'drivers/platform/x86/toshiba_acpi.c')
-rw-r--r-- | drivers/platform/x86/toshiba_acpi.c | 1025 |
1 files changed, 893 insertions, 132 deletions
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c index fc34a71866ed..dbcb7a8915b8 100644 --- a/drivers/platform/x86/toshiba_acpi.c +++ b/drivers/platform/x86/toshiba_acpi.c | |||
@@ -1,11 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | * toshiba_acpi.c - Toshiba Laptop ACPI Extras | 2 | * toshiba_acpi.c - Toshiba Laptop ACPI Extras |
3 | * | 3 | * |
4 | * | ||
5 | * Copyright (C) 2002-2004 John Belmonte | 4 | * Copyright (C) 2002-2004 John Belmonte |
6 | * Copyright (C) 2008 Philip Langdale | 5 | * Copyright (C) 2008 Philip Langdale |
7 | * Copyright (C) 2010 Pierre Ducroquet | 6 | * Copyright (C) 2010 Pierre Ducroquet |
8 | * Copyright (C) 2014 Azael Avalos | 7 | * Copyright (C) 2014-2015 Azael Avalos |
9 | * | 8 | * |
10 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -17,10 +16,8 @@ | |||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | * GNU General Public License for more details. | 17 | * GNU General Public License for more details. |
19 | * | 18 | * |
20 | * You should have received a copy of the GNU General Public License | 19 | * The full GNU General Public License is included in this distribution in |
21 | * along with this program; if not, write to the Free Software | 20 | * the file called "COPYING". |
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 | * | ||
24 | * | 21 | * |
25 | * The devolpment page for this driver is located at | 22 | * The devolpment page for this driver is located at |
26 | * http://memebeam.org/toys/ToshibaAcpiDriver. | 23 | * http://memebeam.org/toys/ToshibaAcpiDriver. |
@@ -30,15 +27,11 @@ | |||
30 | * engineering the Windows drivers | 27 | * engineering the Windows drivers |
31 | * Yasushi Nagato - changes for linux kernel 2.4 -> 2.5 | 28 | * Yasushi Nagato - changes for linux kernel 2.4 -> 2.5 |
32 | * Rob Miller - TV out and hotkeys help | 29 | * Rob Miller - TV out and hotkeys help |
33 | * | ||
34 | * | ||
35 | * TODO | ||
36 | * | ||
37 | */ | 30 | */ |
38 | 31 | ||
39 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 32 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
40 | 33 | ||
41 | #define TOSHIBA_ACPI_VERSION "0.20" | 34 | #define TOSHIBA_ACPI_VERSION "0.21" |
42 | #define PROC_INTERFACE_VERSION 1 | 35 | #define PROC_INTERFACE_VERSION 1 |
43 | 36 | ||
44 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
@@ -57,7 +50,7 @@ | |||
57 | #include <linux/i8042.h> | 50 | #include <linux/i8042.h> |
58 | #include <linux/acpi.h> | 51 | #include <linux/acpi.h> |
59 | #include <linux/dmi.h> | 52 | #include <linux/dmi.h> |
60 | #include <asm/uaccess.h> | 53 | #include <linux/uaccess.h> |
61 | 54 | ||
62 | MODULE_AUTHOR("John Belmonte"); | 55 | MODULE_AUTHOR("John Belmonte"); |
63 | MODULE_DESCRIPTION("Toshiba Laptop ACPI Extras Driver"); | 56 | MODULE_DESCRIPTION("Toshiba Laptop ACPI Extras Driver"); |
@@ -71,7 +64,8 @@ MODULE_LICENSE("GPL"); | |||
71 | /* Toshiba ACPI method paths */ | 64 | /* Toshiba ACPI method paths */ |
72 | #define METHOD_VIDEO_OUT "\\_SB_.VALX.DSSX" | 65 | #define METHOD_VIDEO_OUT "\\_SB_.VALX.DSSX" |
73 | 66 | ||
74 | /* The Toshiba configuration interface is composed of the HCI and the SCI, | 67 | /* |
68 | * The Toshiba configuration interface is composed of the HCI and the SCI, | ||
75 | * which are defined as follows: | 69 | * which are defined as follows: |
76 | * | 70 | * |
77 | * HCI is Toshiba's "Hardware Control Interface" which is supposed to | 71 | * HCI is Toshiba's "Hardware Control Interface" which is supposed to |
@@ -108,6 +102,7 @@ MODULE_LICENSE("GPL"); | |||
108 | #define TOS_FIFO_EMPTY 0x8c00 | 102 | #define TOS_FIFO_EMPTY 0x8c00 |
109 | #define TOS_DATA_NOT_AVAILABLE 0x8d20 | 103 | #define TOS_DATA_NOT_AVAILABLE 0x8d20 |
110 | #define TOS_NOT_INITIALIZED 0x8d50 | 104 | #define TOS_NOT_INITIALIZED 0x8d50 |
105 | #define TOS_NOT_INSTALLED 0x8e00 | ||
111 | 106 | ||
112 | /* registers */ | 107 | /* registers */ |
113 | #define HCI_FAN 0x0004 | 108 | #define HCI_FAN 0x0004 |
@@ -121,9 +116,14 @@ MODULE_LICENSE("GPL"); | |||
121 | #define HCI_KBD_ILLUMINATION 0x0095 | 116 | #define HCI_KBD_ILLUMINATION 0x0095 |
122 | #define HCI_ECO_MODE 0x0097 | 117 | #define HCI_ECO_MODE 0x0097 |
123 | #define HCI_ACCELEROMETER2 0x00a6 | 118 | #define HCI_ACCELEROMETER2 0x00a6 |
119 | #define SCI_PANEL_POWER_ON 0x010d | ||
124 | #define SCI_ILLUMINATION 0x014e | 120 | #define SCI_ILLUMINATION 0x014e |
121 | #define SCI_USB_SLEEP_CHARGE 0x0150 | ||
125 | #define SCI_KBD_ILLUM_STATUS 0x015c | 122 | #define SCI_KBD_ILLUM_STATUS 0x015c |
123 | #define SCI_USB_SLEEP_MUSIC 0x015e | ||
124 | #define SCI_USB_THREE 0x0169 | ||
126 | #define SCI_TOUCHPAD 0x050e | 125 | #define SCI_TOUCHPAD 0x050e |
126 | #define SCI_KBD_FUNCTION_KEYS 0x0522 | ||
127 | 127 | ||
128 | /* field definitions */ | 128 | /* field definitions */ |
129 | #define HCI_ACCEL_MASK 0x7fff | 129 | #define HCI_ACCEL_MASK 0x7fff |
@@ -146,6 +146,15 @@ MODULE_LICENSE("GPL"); | |||
146 | #define SCI_KBD_MODE_ON 0x8 | 146 | #define SCI_KBD_MODE_ON 0x8 |
147 | #define SCI_KBD_MODE_OFF 0x10 | 147 | #define SCI_KBD_MODE_OFF 0x10 |
148 | #define SCI_KBD_TIME_MAX 0x3c001a | 148 | #define SCI_KBD_TIME_MAX 0x3c001a |
149 | #define SCI_USB_CHARGE_MODE_MASK 0xff | ||
150 | #define SCI_USB_CHARGE_DISABLED 0x30000 | ||
151 | #define SCI_USB_CHARGE_ALTERNATE 0x30009 | ||
152 | #define SCI_USB_CHARGE_AUTO 0x30021 | ||
153 | #define SCI_USB_CHARGE_BAT_MASK 0x7 | ||
154 | #define SCI_USB_CHARGE_BAT_LVL_OFF 0x1 | ||
155 | #define SCI_USB_CHARGE_BAT_LVL_ON 0x4 | ||
156 | #define SCI_USB_CHARGE_BAT_LVL 0x0200 | ||
157 | #define SCI_USB_CHARGE_RAPID_DSP 0x0300 | ||
149 | 158 | ||
150 | struct toshiba_acpi_dev { | 159 | struct toshiba_acpi_dev { |
151 | struct acpi_device *acpi_dev; | 160 | struct acpi_device *acpi_dev; |
@@ -164,6 +173,7 @@ struct toshiba_acpi_dev { | |||
164 | int kbd_type; | 173 | int kbd_type; |
165 | int kbd_mode; | 174 | int kbd_mode; |
166 | int kbd_time; | 175 | int kbd_time; |
176 | int usbsc_bat_level; | ||
167 | 177 | ||
168 | unsigned int illumination_supported:1; | 178 | unsigned int illumination_supported:1; |
169 | unsigned int video_supported:1; | 179 | unsigned int video_supported:1; |
@@ -177,6 +187,12 @@ struct toshiba_acpi_dev { | |||
177 | unsigned int touchpad_supported:1; | 187 | unsigned int touchpad_supported:1; |
178 | unsigned int eco_supported:1; | 188 | unsigned int eco_supported:1; |
179 | unsigned int accelerometer_supported:1; | 189 | unsigned int accelerometer_supported:1; |
190 | unsigned int usb_sleep_charge_supported:1; | ||
191 | unsigned int usb_rapid_charge_supported:1; | ||
192 | unsigned int usb_sleep_music_supported:1; | ||
193 | unsigned int kbd_function_keys_supported:1; | ||
194 | unsigned int panel_power_on_supported:1; | ||
195 | unsigned int usb_three_supported:1; | ||
180 | unsigned int sysfs_created:1; | 196 | unsigned int sysfs_created:1; |
181 | 197 | ||
182 | struct mutex mutex; | 198 | struct mutex mutex; |
@@ -264,15 +280,17 @@ static const struct key_entry toshiba_acpi_alt_keymap[] = { | |||
264 | { KE_END, 0 }, | 280 | { KE_END, 0 }, |
265 | }; | 281 | }; |
266 | 282 | ||
267 | /* utility | 283 | /* |
284 | * Utility | ||
268 | */ | 285 | */ |
269 | 286 | ||
270 | static __inline__ void _set_bit(u32 * word, u32 mask, int value) | 287 | static inline void _set_bit(u32 *word, u32 mask, int value) |
271 | { | 288 | { |
272 | *word = (*word & ~mask) | (mask * value); | 289 | *word = (*word & ~mask) | (mask * value); |
273 | } | 290 | } |
274 | 291 | ||
275 | /* acpi interface wrappers | 292 | /* |
293 | * ACPI interface wrappers | ||
276 | */ | 294 | */ |
277 | 295 | ||
278 | static int write_acpi_int(const char *methodName, int val) | 296 | static int write_acpi_int(const char *methodName, int val) |
@@ -283,7 +301,8 @@ static int write_acpi_int(const char *methodName, int val) | |||
283 | return (status == AE_OK) ? 0 : -EIO; | 301 | return (status == AE_OK) ? 0 : -EIO; |
284 | } | 302 | } |
285 | 303 | ||
286 | /* Perform a raw configuration call. Here we don't care about input or output | 304 | /* |
305 | * Perform a raw configuration call. Here we don't care about input or output | ||
287 | * buffer format. | 306 | * buffer format. |
288 | */ | 307 | */ |
289 | static acpi_status tci_raw(struct toshiba_acpi_dev *dev, | 308 | static acpi_status tci_raw(struct toshiba_acpi_dev *dev, |
@@ -310,15 +329,15 @@ static acpi_status tci_raw(struct toshiba_acpi_dev *dev, | |||
310 | (char *)dev->method_hci, ¶ms, | 329 | (char *)dev->method_hci, ¶ms, |
311 | &results); | 330 | &results); |
312 | if ((status == AE_OK) && (out_objs->package.count <= TCI_WORDS)) { | 331 | if ((status == AE_OK) && (out_objs->package.count <= TCI_WORDS)) { |
313 | for (i = 0; i < out_objs->package.count; ++i) { | 332 | for (i = 0; i < out_objs->package.count; ++i) |
314 | out[i] = out_objs->package.elements[i].integer.value; | 333 | out[i] = out_objs->package.elements[i].integer.value; |
315 | } | ||
316 | } | 334 | } |
317 | 335 | ||
318 | return status; | 336 | return status; |
319 | } | 337 | } |
320 | 338 | ||
321 | /* common hci tasks (get or set one or two value) | 339 | /* |
340 | * Common hci tasks (get or set one or two value) | ||
322 | * | 341 | * |
323 | * In addition to the ACPI status, the HCI system returns a result which | 342 | * In addition to the ACPI status, the HCI system returns a result which |
324 | * may be useful (such as "not supported"). | 343 | * may be useful (such as "not supported"). |
@@ -338,6 +357,7 @@ static u32 hci_read1(struct toshiba_acpi_dev *dev, u32 reg, u32 *out1) | |||
338 | u32 in[TCI_WORDS] = { HCI_GET, reg, 0, 0, 0, 0 }; | 357 | u32 in[TCI_WORDS] = { HCI_GET, reg, 0, 0, 0, 0 }; |
339 | u32 out[TCI_WORDS]; | 358 | u32 out[TCI_WORDS]; |
340 | acpi_status status = tci_raw(dev, in, out); | 359 | acpi_status status = tci_raw(dev, in, out); |
360 | |||
341 | if (ACPI_FAILURE(status)) | 361 | if (ACPI_FAILURE(status)) |
342 | return TOS_FAILURE; | 362 | return TOS_FAILURE; |
343 | 363 | ||
@@ -355,11 +375,13 @@ static u32 hci_write2(struct toshiba_acpi_dev *dev, u32 reg, u32 in1, u32 in2) | |||
355 | return ACPI_SUCCESS(status) ? out[0] : TOS_FAILURE; | 375 | return ACPI_SUCCESS(status) ? out[0] : TOS_FAILURE; |
356 | } | 376 | } |
357 | 377 | ||
358 | static u32 hci_read2(struct toshiba_acpi_dev *dev, u32 reg, u32 *out1, u32 *out2) | 378 | static u32 hci_read2(struct toshiba_acpi_dev *dev, |
379 | u32 reg, u32 *out1, u32 *out2) | ||
359 | { | 380 | { |
360 | u32 in[TCI_WORDS] = { HCI_GET, reg, *out1, *out2, 0, 0 }; | 381 | u32 in[TCI_WORDS] = { HCI_GET, reg, *out1, *out2, 0, 0 }; |
361 | u32 out[TCI_WORDS]; | 382 | u32 out[TCI_WORDS]; |
362 | acpi_status status = tci_raw(dev, in, out); | 383 | acpi_status status = tci_raw(dev, in, out); |
384 | |||
363 | if (ACPI_FAILURE(status)) | 385 | if (ACPI_FAILURE(status)) |
364 | return TOS_FAILURE; | 386 | return TOS_FAILURE; |
365 | 387 | ||
@@ -369,7 +391,8 @@ static u32 hci_read2(struct toshiba_acpi_dev *dev, u32 reg, u32 *out1, u32 *out2 | |||
369 | return out[0]; | 391 | return out[0]; |
370 | } | 392 | } |
371 | 393 | ||
372 | /* common sci tasks | 394 | /* |
395 | * Common sci tasks | ||
373 | */ | 396 | */ |
374 | 397 | ||
375 | static int sci_open(struct toshiba_acpi_dev *dev) | 398 | static int sci_open(struct toshiba_acpi_dev *dev) |
@@ -389,6 +412,20 @@ static int sci_open(struct toshiba_acpi_dev *dev) | |||
389 | } else if (out[0] == TOS_ALREADY_OPEN) { | 412 | } else if (out[0] == TOS_ALREADY_OPEN) { |
390 | pr_info("Toshiba SCI already opened\n"); | 413 | pr_info("Toshiba SCI already opened\n"); |
391 | return 1; | 414 | return 1; |
415 | } else if (out[0] == TOS_NOT_SUPPORTED) { | ||
416 | /* | ||
417 | * Some BIOSes do not have the SCI open/close functions | ||
418 | * implemented and return 0x8000 (Not Supported), failing to | ||
419 | * register some supported features. | ||
420 | * | ||
421 | * Simply return 1 if we hit those affected laptops to make the | ||
422 | * supported features work. | ||
423 | * | ||
424 | * In the case that some laptops really do not support the SCI, | ||
425 | * all the SCI dependent functions check for TOS_NOT_SUPPORTED, | ||
426 | * and thus, not registering support for the queried feature. | ||
427 | */ | ||
428 | return 1; | ||
392 | } else if (out[0] == TOS_NOT_PRESENT) { | 429 | } else if (out[0] == TOS_NOT_PRESENT) { |
393 | pr_info("Toshiba SCI is not present\n"); | 430 | pr_info("Toshiba SCI is not present\n"); |
394 | } | 431 | } |
@@ -421,6 +458,7 @@ static u32 sci_read(struct toshiba_acpi_dev *dev, u32 reg, u32 *out1) | |||
421 | u32 in[TCI_WORDS] = { SCI_GET, reg, 0, 0, 0, 0 }; | 458 | u32 in[TCI_WORDS] = { SCI_GET, reg, 0, 0, 0, 0 }; |
422 | u32 out[TCI_WORDS]; | 459 | u32 out[TCI_WORDS]; |
423 | acpi_status status = tci_raw(dev, in, out); | 460 | acpi_status status = tci_raw(dev, in, out); |
461 | |||
424 | if (ACPI_FAILURE(status)) | 462 | if (ACPI_FAILURE(status)) |
425 | return TOS_FAILURE; | 463 | return TOS_FAILURE; |
426 | 464 | ||
@@ -529,10 +567,11 @@ static int toshiba_kbd_illum_available(struct toshiba_acpi_dev *dev) | |||
529 | return 0; | 567 | return 0; |
530 | } | 568 | } |
531 | 569 | ||
532 | /* Check for keyboard backlight timeout max value, | 570 | /* |
571 | * Check for keyboard backlight timeout max value, | ||
533 | * previous kbd backlight implementation set this to | 572 | * previous kbd backlight implementation set this to |
534 | * 0x3c0003, and now the new implementation set this | 573 | * 0x3c0003, and now the new implementation set this |
535 | * to 0x3c001a, use this to distinguish between them | 574 | * to 0x3c001a, use this to distinguish between them. |
536 | */ | 575 | */ |
537 | if (out[3] == SCI_KBD_TIME_MAX) | 576 | if (out[3] == SCI_KBD_TIME_MAX) |
538 | dev->kbd_type = 2; | 577 | dev->kbd_type = 2; |
@@ -667,19 +706,37 @@ static int toshiba_touchpad_get(struct toshiba_acpi_dev *dev, u32 *state) | |||
667 | static int toshiba_eco_mode_available(struct toshiba_acpi_dev *dev) | 706 | static int toshiba_eco_mode_available(struct toshiba_acpi_dev *dev) |
668 | { | 707 | { |
669 | acpi_status status; | 708 | acpi_status status; |
670 | u32 in[TCI_WORDS] = { HCI_GET, HCI_ECO_MODE, 0, 1, 0, 0 }; | 709 | u32 in[TCI_WORDS] = { HCI_GET, HCI_ECO_MODE, 0, 0, 0, 0 }; |
671 | u32 out[TCI_WORDS]; | 710 | u32 out[TCI_WORDS]; |
672 | 711 | ||
673 | status = tci_raw(dev, in, out); | 712 | status = tci_raw(dev, in, out); |
674 | if (ACPI_FAILURE(status) || out[0] == TOS_INPUT_DATA_ERROR) { | 713 | if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) { |
675 | pr_info("ACPI call to get ECO led failed\n"); | 714 | pr_err("ACPI call to get ECO led failed\n"); |
676 | return 0; | 715 | } else if (out[0] == TOS_NOT_INSTALLED) { |
716 | pr_info("ECO led not installed"); | ||
717 | } else if (out[0] == TOS_INPUT_DATA_ERROR) { | ||
718 | /* | ||
719 | * If we receive 0x8300 (Input Data Error), it means that the | ||
720 | * LED device is present, but that we just screwed the input | ||
721 | * parameters. | ||
722 | * | ||
723 | * Let's query the status of the LED to see if we really have a | ||
724 | * success response, indicating the actual presense of the LED, | ||
725 | * bail out otherwise. | ||
726 | */ | ||
727 | in[3] = 1; | ||
728 | status = tci_raw(dev, in, out); | ||
729 | if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) | ||
730 | pr_err("ACPI call to get ECO led failed\n"); | ||
731 | else if (out[0] == TOS_SUCCESS) | ||
732 | return 1; | ||
677 | } | 733 | } |
678 | 734 | ||
679 | return 1; | 735 | return 0; |
680 | } | 736 | } |
681 | 737 | ||
682 | static enum led_brightness toshiba_eco_mode_get_status(struct led_classdev *cdev) | 738 | static enum led_brightness |
739 | toshiba_eco_mode_get_status(struct led_classdev *cdev) | ||
683 | { | 740 | { |
684 | struct toshiba_acpi_dev *dev = container_of(cdev, | 741 | struct toshiba_acpi_dev *dev = container_of(cdev, |
685 | struct toshiba_acpi_dev, eco_led); | 742 | struct toshiba_acpi_dev, eco_led); |
@@ -721,7 +778,8 @@ static int toshiba_accelerometer_supported(struct toshiba_acpi_dev *dev) | |||
721 | u32 out[TCI_WORDS]; | 778 | u32 out[TCI_WORDS]; |
722 | acpi_status status; | 779 | acpi_status status; |
723 | 780 | ||
724 | /* Check if the accelerometer call exists, | 781 | /* |
782 | * Check if the accelerometer call exists, | ||
725 | * this call also serves as initialization | 783 | * this call also serves as initialization |
726 | */ | 784 | */ |
727 | status = tci_raw(dev, in, out); | 785 | status = tci_raw(dev, in, out); |
@@ -760,6 +818,337 @@ static int toshiba_accelerometer_get(struct toshiba_acpi_dev *dev, | |||
760 | return 0; | 818 | return 0; |
761 | } | 819 | } |
762 | 820 | ||
821 | /* Sleep (Charge and Music) utilities support */ | ||
822 | static int toshiba_usb_sleep_charge_get(struct toshiba_acpi_dev *dev, | ||
823 | u32 *mode) | ||
824 | { | ||
825 | u32 result; | ||
826 | |||
827 | if (!sci_open(dev)) | ||
828 | return -EIO; | ||
829 | |||
830 | result = sci_read(dev, SCI_USB_SLEEP_CHARGE, mode); | ||
831 | sci_close(dev); | ||
832 | if (result == TOS_FAILURE) { | ||
833 | pr_err("ACPI call to set USB S&C mode failed\n"); | ||
834 | return -EIO; | ||
835 | } else if (result == TOS_NOT_SUPPORTED) { | ||
836 | pr_info("USB Sleep and Charge not supported\n"); | ||
837 | return -ENODEV; | ||
838 | } else if (result == TOS_INPUT_DATA_ERROR) { | ||
839 | return -EIO; | ||
840 | } | ||
841 | |||
842 | return 0; | ||
843 | } | ||
844 | |||
845 | static int toshiba_usb_sleep_charge_set(struct toshiba_acpi_dev *dev, | ||
846 | u32 mode) | ||
847 | { | ||
848 | u32 result; | ||
849 | |||
850 | if (!sci_open(dev)) | ||
851 | return -EIO; | ||
852 | |||
853 | result = sci_write(dev, SCI_USB_SLEEP_CHARGE, mode); | ||
854 | sci_close(dev); | ||
855 | if (result == TOS_FAILURE) { | ||
856 | pr_err("ACPI call to set USB S&C mode failed\n"); | ||
857 | return -EIO; | ||
858 | } else if (result == TOS_NOT_SUPPORTED) { | ||
859 | pr_info("USB Sleep and Charge not supported\n"); | ||
860 | return -ENODEV; | ||
861 | } else if (result == TOS_INPUT_DATA_ERROR) { | ||
862 | return -EIO; | ||
863 | } | ||
864 | |||
865 | return 0; | ||
866 | } | ||
867 | |||
868 | static int toshiba_sleep_functions_status_get(struct toshiba_acpi_dev *dev, | ||
869 | u32 *mode) | ||
870 | { | ||
871 | u32 in[TCI_WORDS] = { SCI_GET, SCI_USB_SLEEP_CHARGE, 0, 0, 0, 0 }; | ||
872 | u32 out[TCI_WORDS]; | ||
873 | acpi_status status; | ||
874 | |||
875 | if (!sci_open(dev)) | ||
876 | return -EIO; | ||
877 | |||
878 | in[5] = SCI_USB_CHARGE_BAT_LVL; | ||
879 | status = tci_raw(dev, in, out); | ||
880 | sci_close(dev); | ||
881 | if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) { | ||
882 | pr_err("ACPI call to get USB S&C battery level failed\n"); | ||
883 | return -EIO; | ||
884 | } else if (out[0] == TOS_NOT_SUPPORTED) { | ||
885 | pr_info("USB Sleep and Charge not supported\n"); | ||
886 | return -ENODEV; | ||
887 | } else if (out[0] == TOS_INPUT_DATA_ERROR) { | ||
888 | return -EIO; | ||
889 | } | ||
890 | |||
891 | *mode = out[2]; | ||
892 | |||
893 | return 0; | ||
894 | } | ||
895 | |||
896 | static int toshiba_sleep_functions_status_set(struct toshiba_acpi_dev *dev, | ||
897 | u32 mode) | ||
898 | { | ||
899 | u32 in[TCI_WORDS] = { SCI_SET, SCI_USB_SLEEP_CHARGE, 0, 0, 0, 0 }; | ||
900 | u32 out[TCI_WORDS]; | ||
901 | acpi_status status; | ||
902 | |||
903 | if (!sci_open(dev)) | ||
904 | return -EIO; | ||
905 | |||
906 | in[2] = mode; | ||
907 | in[5] = SCI_USB_CHARGE_BAT_LVL; | ||
908 | status = tci_raw(dev, in, out); | ||
909 | sci_close(dev); | ||
910 | if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) { | ||
911 | pr_err("ACPI call to set USB S&C battery level failed\n"); | ||
912 | return -EIO; | ||
913 | } else if (out[0] == TOS_NOT_SUPPORTED) { | ||
914 | pr_info("USB Sleep and Charge not supported\n"); | ||
915 | return -ENODEV; | ||
916 | } else if (out[0] == TOS_INPUT_DATA_ERROR) { | ||
917 | return -EIO; | ||
918 | } | ||
919 | |||
920 | return 0; | ||
921 | } | ||
922 | |||
923 | static int toshiba_usb_rapid_charge_get(struct toshiba_acpi_dev *dev, | ||
924 | u32 *state) | ||
925 | { | ||
926 | u32 in[TCI_WORDS] = { SCI_GET, SCI_USB_SLEEP_CHARGE, 0, 0, 0, 0 }; | ||
927 | u32 out[TCI_WORDS]; | ||
928 | acpi_status status; | ||
929 | |||
930 | if (!sci_open(dev)) | ||
931 | return -EIO; | ||
932 | |||
933 | in[5] = SCI_USB_CHARGE_RAPID_DSP; | ||
934 | status = tci_raw(dev, in, out); | ||
935 | sci_close(dev); | ||
936 | if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) { | ||
937 | pr_err("ACPI call to get USB S&C battery level failed\n"); | ||
938 | return -EIO; | ||
939 | } else if (out[0] == TOS_NOT_SUPPORTED || | ||
940 | out[0] == TOS_INPUT_DATA_ERROR) { | ||
941 | pr_info("USB Sleep and Charge not supported\n"); | ||
942 | return -ENODEV; | ||
943 | } | ||
944 | |||
945 | *state = out[2]; | ||
946 | |||
947 | return 0; | ||
948 | } | ||
949 | |||
950 | static int toshiba_usb_rapid_charge_set(struct toshiba_acpi_dev *dev, | ||
951 | u32 state) | ||
952 | { | ||
953 | u32 in[TCI_WORDS] = { SCI_SET, SCI_USB_SLEEP_CHARGE, 0, 0, 0, 0 }; | ||
954 | u32 out[TCI_WORDS]; | ||
955 | acpi_status status; | ||
956 | |||
957 | if (!sci_open(dev)) | ||
958 | return -EIO; | ||
959 | |||
960 | in[2] = state; | ||
961 | in[5] = SCI_USB_CHARGE_RAPID_DSP; | ||
962 | status = tci_raw(dev, in, out); | ||
963 | sci_close(dev); | ||
964 | if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) { | ||
965 | pr_err("ACPI call to set USB S&C battery level failed\n"); | ||
966 | return -EIO; | ||
967 | } else if (out[0] == TOS_NOT_SUPPORTED) { | ||
968 | pr_info("USB Sleep and Charge not supported\n"); | ||
969 | return -ENODEV; | ||
970 | } else if (out[0] == TOS_INPUT_DATA_ERROR) { | ||
971 | return -EIO; | ||
972 | } | ||
973 | |||
974 | return 0; | ||
975 | } | ||
976 | |||
977 | static int toshiba_usb_sleep_music_get(struct toshiba_acpi_dev *dev, u32 *state) | ||
978 | { | ||
979 | u32 result; | ||
980 | |||
981 | if (!sci_open(dev)) | ||
982 | return -EIO; | ||
983 | |||
984 | result = sci_read(dev, SCI_USB_SLEEP_MUSIC, state); | ||
985 | sci_close(dev); | ||
986 | if (result == TOS_FAILURE) { | ||
987 | pr_err("ACPI call to set USB S&C mode failed\n"); | ||
988 | return -EIO; | ||
989 | } else if (result == TOS_NOT_SUPPORTED) { | ||
990 | pr_info("USB Sleep and Charge not supported\n"); | ||
991 | return -ENODEV; | ||
992 | } else if (result == TOS_INPUT_DATA_ERROR) { | ||
993 | return -EIO; | ||
994 | } | ||
995 | |||
996 | return 0; | ||
997 | } | ||
998 | |||
999 | static int toshiba_usb_sleep_music_set(struct toshiba_acpi_dev *dev, u32 state) | ||
1000 | { | ||
1001 | u32 result; | ||
1002 | |||
1003 | if (!sci_open(dev)) | ||
1004 | return -EIO; | ||
1005 | |||
1006 | result = sci_write(dev, SCI_USB_SLEEP_MUSIC, state); | ||
1007 | sci_close(dev); | ||
1008 | if (result == TOS_FAILURE) { | ||
1009 | pr_err("ACPI call to set USB S&C mode failed\n"); | ||
1010 | return -EIO; | ||
1011 | } else if (result == TOS_NOT_SUPPORTED) { | ||
1012 | pr_info("USB Sleep and Charge not supported\n"); | ||
1013 | return -ENODEV; | ||
1014 | } else if (result == TOS_INPUT_DATA_ERROR) { | ||
1015 | return -EIO; | ||
1016 | } | ||
1017 | |||
1018 | return 0; | ||
1019 | } | ||
1020 | |||
1021 | /* Keyboard function keys */ | ||
1022 | static int toshiba_function_keys_get(struct toshiba_acpi_dev *dev, u32 *mode) | ||
1023 | { | ||
1024 | u32 result; | ||
1025 | |||
1026 | if (!sci_open(dev)) | ||
1027 | return -EIO; | ||
1028 | |||
1029 | result = sci_read(dev, SCI_KBD_FUNCTION_KEYS, mode); | ||
1030 | sci_close(dev); | ||
1031 | if (result == TOS_FAILURE || result == TOS_INPUT_DATA_ERROR) { | ||
1032 | pr_err("ACPI call to get KBD function keys failed\n"); | ||
1033 | return -EIO; | ||
1034 | } else if (result == TOS_NOT_SUPPORTED) { | ||
1035 | pr_info("KBD function keys not supported\n"); | ||
1036 | return -ENODEV; | ||
1037 | } | ||
1038 | |||
1039 | return 0; | ||
1040 | } | ||
1041 | |||
1042 | static int toshiba_function_keys_set(struct toshiba_acpi_dev *dev, u32 mode) | ||
1043 | { | ||
1044 | u32 result; | ||
1045 | |||
1046 | if (!sci_open(dev)) | ||
1047 | return -EIO; | ||
1048 | |||
1049 | result = sci_write(dev, SCI_KBD_FUNCTION_KEYS, mode); | ||
1050 | sci_close(dev); | ||
1051 | if (result == TOS_FAILURE || result == TOS_INPUT_DATA_ERROR) { | ||
1052 | pr_err("ACPI call to set KBD function keys failed\n"); | ||
1053 | return -EIO; | ||
1054 | } else if (result == TOS_NOT_SUPPORTED) { | ||
1055 | pr_info("KBD function keys not supported\n"); | ||
1056 | return -ENODEV; | ||
1057 | } | ||
1058 | |||
1059 | return 0; | ||
1060 | } | ||
1061 | |||
1062 | /* Panel Power ON */ | ||
1063 | static int toshiba_panel_power_on_get(struct toshiba_acpi_dev *dev, u32 *state) | ||
1064 | { | ||
1065 | u32 result; | ||
1066 | |||
1067 | if (!sci_open(dev)) | ||
1068 | return -EIO; | ||
1069 | |||
1070 | result = sci_read(dev, SCI_PANEL_POWER_ON, state); | ||
1071 | sci_close(dev); | ||
1072 | if (result == TOS_FAILURE) { | ||
1073 | pr_err("ACPI call to get Panel Power ON failed\n"); | ||
1074 | return -EIO; | ||
1075 | } else if (result == TOS_NOT_SUPPORTED) { | ||
1076 | pr_info("Panel Power on not supported\n"); | ||
1077 | return -ENODEV; | ||
1078 | } else if (result == TOS_INPUT_DATA_ERROR) { | ||
1079 | return -EIO; | ||
1080 | } | ||
1081 | |||
1082 | return 0; | ||
1083 | } | ||
1084 | |||
1085 | static int toshiba_panel_power_on_set(struct toshiba_acpi_dev *dev, u32 state) | ||
1086 | { | ||
1087 | u32 result; | ||
1088 | |||
1089 | if (!sci_open(dev)) | ||
1090 | return -EIO; | ||
1091 | |||
1092 | result = sci_write(dev, SCI_PANEL_POWER_ON, state); | ||
1093 | sci_close(dev); | ||
1094 | if (result == TOS_FAILURE) { | ||
1095 | pr_err("ACPI call to set Panel Power ON failed\n"); | ||
1096 | return -EIO; | ||
1097 | } else if (result == TOS_NOT_SUPPORTED) { | ||
1098 | pr_info("Panel Power ON not supported\n"); | ||
1099 | return -ENODEV; | ||
1100 | } else if (result == TOS_INPUT_DATA_ERROR) { | ||
1101 | return -EIO; | ||
1102 | } | ||
1103 | |||
1104 | return 0; | ||
1105 | } | ||
1106 | |||
1107 | /* USB Three */ | ||
1108 | static int toshiba_usb_three_get(struct toshiba_acpi_dev *dev, u32 *state) | ||
1109 | { | ||
1110 | u32 result; | ||
1111 | |||
1112 | if (!sci_open(dev)) | ||
1113 | return -EIO; | ||
1114 | |||
1115 | result = sci_read(dev, SCI_USB_THREE, state); | ||
1116 | sci_close(dev); | ||
1117 | if (result == TOS_FAILURE) { | ||
1118 | pr_err("ACPI call to get USB 3 failed\n"); | ||
1119 | return -EIO; | ||
1120 | } else if (result == TOS_NOT_SUPPORTED) { | ||
1121 | pr_info("USB 3 not supported\n"); | ||
1122 | return -ENODEV; | ||
1123 | } else if (result == TOS_INPUT_DATA_ERROR) { | ||
1124 | return -EIO; | ||
1125 | } | ||
1126 | |||
1127 | return 0; | ||
1128 | } | ||
1129 | |||
1130 | static int toshiba_usb_three_set(struct toshiba_acpi_dev *dev, u32 state) | ||
1131 | { | ||
1132 | u32 result; | ||
1133 | |||
1134 | if (!sci_open(dev)) | ||
1135 | return -EIO; | ||
1136 | |||
1137 | result = sci_write(dev, SCI_USB_THREE, state); | ||
1138 | sci_close(dev); | ||
1139 | if (result == TOS_FAILURE) { | ||
1140 | pr_err("ACPI call to set USB 3 failed\n"); | ||
1141 | return -EIO; | ||
1142 | } else if (result == TOS_NOT_SUPPORTED) { | ||
1143 | pr_info("USB 3 not supported\n"); | ||
1144 | return -ENODEV; | ||
1145 | } else if (result == TOS_INPUT_DATA_ERROR) { | ||
1146 | return -EIO; | ||
1147 | } | ||
1148 | |||
1149 | return 0; | ||
1150 | } | ||
1151 | |||
763 | /* Bluetooth rfkill handlers */ | 1152 | /* Bluetooth rfkill handlers */ |
764 | 1153 | ||
765 | static u32 hci_get_bt_present(struct toshiba_acpi_dev *dev, bool *present) | 1154 | static u32 hci_get_bt_present(struct toshiba_acpi_dev *dev, bool *present) |
@@ -870,7 +1259,7 @@ static int set_tr_backlight_status(struct toshiba_acpi_dev *dev, bool enable) | |||
870 | return hci_result == TOS_SUCCESS ? 0 : -EIO; | 1259 | return hci_result == TOS_SUCCESS ? 0 : -EIO; |
871 | } | 1260 | } |
872 | 1261 | ||
873 | static struct proc_dir_entry *toshiba_proc_dir /*= 0*/ ; | 1262 | static struct proc_dir_entry *toshiba_proc_dir /*= 0*/; |
874 | 1263 | ||
875 | static int __get_lcd_brightness(struct toshiba_acpi_dev *dev) | 1264 | static int __get_lcd_brightness(struct toshiba_acpi_dev *dev) |
876 | { | 1265 | { |
@@ -881,6 +1270,7 @@ static int __get_lcd_brightness(struct toshiba_acpi_dev *dev) | |||
881 | if (dev->tr_backlight_supported) { | 1270 | if (dev->tr_backlight_supported) { |
882 | bool enabled; | 1271 | bool enabled; |
883 | int ret = get_tr_backlight_status(dev, &enabled); | 1272 | int ret = get_tr_backlight_status(dev, &enabled); |
1273 | |||
884 | if (ret) | 1274 | if (ret) |
885 | return ret; | 1275 | return ret; |
886 | if (enabled) | 1276 | if (enabled) |
@@ -898,6 +1288,7 @@ static int __get_lcd_brightness(struct toshiba_acpi_dev *dev) | |||
898 | static int get_lcd_brightness(struct backlight_device *bd) | 1288 | static int get_lcd_brightness(struct backlight_device *bd) |
899 | { | 1289 | { |
900 | struct toshiba_acpi_dev *dev = bl_get_data(bd); | 1290 | struct toshiba_acpi_dev *dev = bl_get_data(bd); |
1291 | |||
901 | return __get_lcd_brightness(dev); | 1292 | return __get_lcd_brightness(dev); |
902 | } | 1293 | } |
903 | 1294 | ||
@@ -934,6 +1325,7 @@ static int set_lcd_brightness(struct toshiba_acpi_dev *dev, int value) | |||
934 | if (dev->tr_backlight_supported) { | 1325 | if (dev->tr_backlight_supported) { |
935 | bool enable = !value; | 1326 | bool enable = !value; |
936 | int ret = set_tr_backlight_status(dev, enable); | 1327 | int ret = set_tr_backlight_status(dev, enable); |
1328 | |||
937 | if (ret) | 1329 | if (ret) |
938 | return ret; | 1330 | return ret; |
939 | if (value) | 1331 | if (value) |
@@ -948,6 +1340,7 @@ static int set_lcd_brightness(struct toshiba_acpi_dev *dev, int value) | |||
948 | static int set_lcd_status(struct backlight_device *bd) | 1340 | static int set_lcd_status(struct backlight_device *bd) |
949 | { | 1341 | { |
950 | struct toshiba_acpi_dev *dev = bl_get_data(bd); | 1342 | struct toshiba_acpi_dev *dev = bl_get_data(bd); |
1343 | |||
951 | return set_lcd_brightness(dev, bd->props.brightness); | 1344 | return set_lcd_brightness(dev, bd->props.brightness); |
952 | } | 1345 | } |
953 | 1346 | ||
@@ -1005,6 +1398,7 @@ static int video_proc_show(struct seq_file *m, void *v) | |||
1005 | int is_lcd = (value & HCI_VIDEO_OUT_LCD) ? 1 : 0; | 1398 | int is_lcd = (value & HCI_VIDEO_OUT_LCD) ? 1 : 0; |
1006 | int is_crt = (value & HCI_VIDEO_OUT_CRT) ? 1 : 0; | 1399 | int is_crt = (value & HCI_VIDEO_OUT_CRT) ? 1 : 0; |
1007 | int is_tv = (value & HCI_VIDEO_OUT_TV) ? 1 : 0; | 1400 | int is_tv = (value & HCI_VIDEO_OUT_TV) ? 1 : 0; |
1401 | |||
1008 | seq_printf(m, "lcd_out: %d\n", is_lcd); | 1402 | seq_printf(m, "lcd_out: %d\n", is_lcd); |
1009 | seq_printf(m, "crt_out: %d\n", is_crt); | 1403 | seq_printf(m, "crt_out: %d\n", is_crt); |
1010 | seq_printf(m, "tv_out: %d\n", is_tv); | 1404 | seq_printf(m, "tv_out: %d\n", is_tv); |
@@ -1042,9 +1436,9 @@ static ssize_t video_proc_write(struct file *file, const char __user *buf, | |||
1042 | 1436 | ||
1043 | buffer = cmd; | 1437 | buffer = cmd; |
1044 | 1438 | ||
1045 | /* scan expression. Multiple expressions may be delimited with ; | 1439 | /* |
1046 | * | 1440 | * Scan expression. Multiple expressions may be delimited with ; |
1047 | * NOTE: to keep scanning simple, invalid fields are ignored | 1441 | * NOTE: To keep scanning simple, invalid fields are ignored. |
1048 | */ | 1442 | */ |
1049 | while (remain) { | 1443 | while (remain) { |
1050 | if (sscanf(buffer, " lcd_out : %i", &value) == 1) | 1444 | if (sscanf(buffer, " lcd_out : %i", &value) == 1) |
@@ -1053,12 +1447,11 @@ static ssize_t video_proc_write(struct file *file, const char __user *buf, | |||
1053 | crt_out = value & 1; | 1447 | crt_out = value & 1; |
1054 | else if (sscanf(buffer, " tv_out : %i", &value) == 1) | 1448 | else if (sscanf(buffer, " tv_out : %i", &value) == 1) |
1055 | tv_out = value & 1; | 1449 | tv_out = value & 1; |
1056 | /* advance to one character past the next ; */ | 1450 | /* Advance to one character past the next ; */ |
1057 | do { | 1451 | do { |
1058 | ++buffer; | 1452 | ++buffer; |
1059 | --remain; | 1453 | --remain; |
1060 | } | 1454 | } while (remain && *(buffer - 1) != ';'); |
1061 | while (remain && *(buffer - 1) != ';'); | ||
1062 | } | 1455 | } |
1063 | 1456 | ||
1064 | kfree(cmd); | 1457 | kfree(cmd); |
@@ -1066,13 +1459,15 @@ static ssize_t video_proc_write(struct file *file, const char __user *buf, | |||
1066 | ret = get_video_status(dev, &video_out); | 1459 | ret = get_video_status(dev, &video_out); |
1067 | if (!ret) { | 1460 | if (!ret) { |
1068 | unsigned int new_video_out = video_out; | 1461 | unsigned int new_video_out = video_out; |
1462 | |||
1069 | if (lcd_out != -1) | 1463 | if (lcd_out != -1) |
1070 | _set_bit(&new_video_out, HCI_VIDEO_OUT_LCD, lcd_out); | 1464 | _set_bit(&new_video_out, HCI_VIDEO_OUT_LCD, lcd_out); |
1071 | if (crt_out != -1) | 1465 | if (crt_out != -1) |
1072 | _set_bit(&new_video_out, HCI_VIDEO_OUT_CRT, crt_out); | 1466 | _set_bit(&new_video_out, HCI_VIDEO_OUT_CRT, crt_out); |
1073 | if (tv_out != -1) | 1467 | if (tv_out != -1) |
1074 | _set_bit(&new_video_out, HCI_VIDEO_OUT_TV, tv_out); | 1468 | _set_bit(&new_video_out, HCI_VIDEO_OUT_TV, tv_out); |
1075 | /* To avoid unnecessary video disruption, only write the new | 1469 | /* |
1470 | * To avoid unnecessary video disruption, only write the new | ||
1076 | * video setting if something changed. */ | 1471 | * video setting if something changed. */ |
1077 | if (new_video_out != video_out) | 1472 | if (new_video_out != video_out) |
1078 | ret = write_acpi_int(METHOD_VIDEO_OUT, new_video_out); | 1473 | ret = write_acpi_int(METHOD_VIDEO_OUT, new_video_out); |
@@ -1135,10 +1530,10 @@ static ssize_t fan_proc_write(struct file *file, const char __user *buf, | |||
1135 | if (sscanf(cmd, " force_on : %i", &value) == 1 && | 1530 | if (sscanf(cmd, " force_on : %i", &value) == 1 && |
1136 | value >= 0 && value <= 1) { | 1531 | value >= 0 && value <= 1) { |
1137 | hci_result = hci_write1(dev, HCI_FAN, value); | 1532 | hci_result = hci_write1(dev, HCI_FAN, value); |
1138 | if (hci_result != TOS_SUCCESS) | 1533 | if (hci_result == TOS_SUCCESS) |
1139 | return -EIO; | ||
1140 | else | ||
1141 | dev->force_fan = value; | 1534 | dev->force_fan = value; |
1535 | else | ||
1536 | return -EIO; | ||
1142 | } else { | 1537 | } else { |
1143 | return -EINVAL; | 1538 | return -EINVAL; |
1144 | } | 1539 | } |
@@ -1167,11 +1562,13 @@ static int keys_proc_show(struct seq_file *m, void *v) | |||
1167 | dev->key_event_valid = 1; | 1562 | dev->key_event_valid = 1; |
1168 | dev->last_key_event = value; | 1563 | dev->last_key_event = value; |
1169 | } else if (hci_result == TOS_FIFO_EMPTY) { | 1564 | } else if (hci_result == TOS_FIFO_EMPTY) { |
1170 | /* better luck next time */ | 1565 | /* Better luck next time */ |
1171 | } else if (hci_result == TOS_NOT_SUPPORTED) { | 1566 | } else if (hci_result == TOS_NOT_SUPPORTED) { |
1172 | /* This is a workaround for an unresolved issue on | 1567 | /* |
1568 | * This is a workaround for an unresolved issue on | ||
1173 | * some machines where system events sporadically | 1569 | * some machines where system events sporadically |
1174 | * become disabled. */ | 1570 | * become disabled. |
1571 | */ | ||
1175 | hci_result = hci_write1(dev, HCI_SYSTEM_EVENT, 1); | 1572 | hci_result = hci_write1(dev, HCI_SYSTEM_EVENT, 1); |
1176 | pr_notice("Re-enabled hotkeys\n"); | 1573 | pr_notice("Re-enabled hotkeys\n"); |
1177 | } else { | 1574 | } else { |
@@ -1203,11 +1600,10 @@ static ssize_t keys_proc_write(struct file *file, const char __user *buf, | |||
1203 | return -EFAULT; | 1600 | return -EFAULT; |
1204 | cmd[len] = '\0'; | 1601 | cmd[len] = '\0'; |
1205 | 1602 | ||
1206 | if (sscanf(cmd, " hotkey_ready : %i", &value) == 1 && value == 0) { | 1603 | if (sscanf(cmd, " hotkey_ready : %i", &value) == 1 && value == 0) |
1207 | dev->key_event_valid = 0; | 1604 | dev->key_event_valid = 0; |
1208 | } else { | 1605 | else |
1209 | return -EINVAL; | 1606 | return -EINVAL; |
1210 | } | ||
1211 | 1607 | ||
1212 | return count; | 1608 | return count; |
1213 | } | 1609 | } |
@@ -1241,7 +1637,8 @@ static const struct file_operations version_proc_fops = { | |||
1241 | .release = single_release, | 1637 | .release = single_release, |
1242 | }; | 1638 | }; |
1243 | 1639 | ||
1244 | /* proc and module init | 1640 | /* |
1641 | * Proc and module init | ||
1245 | */ | 1642 | */ |
1246 | 1643 | ||
1247 | #define PROC_TOSHIBA "toshiba" | 1644 | #define PROC_TOSHIBA "toshiba" |
@@ -1286,66 +1683,56 @@ static const struct backlight_ops toshiba_backlight_data = { | |||
1286 | /* | 1683 | /* |
1287 | * Sysfs files | 1684 | * Sysfs files |
1288 | */ | 1685 | */ |
1289 | static ssize_t toshiba_kbd_bl_mode_store(struct device *dev, | 1686 | static ssize_t version_show(struct device *dev, |
1290 | struct device_attribute *attr, | 1687 | struct device_attribute *attr, char *buf) |
1291 | const char *buf, size_t count); | 1688 | { |
1292 | static ssize_t toshiba_kbd_bl_mode_show(struct device *dev, | 1689 | return sprintf(buf, "%s\n", TOSHIBA_ACPI_VERSION); |
1293 | struct device_attribute *attr, | 1690 | } |
1294 | char *buf); | 1691 | static DEVICE_ATTR_RO(version); |
1295 | static ssize_t toshiba_kbd_type_show(struct device *dev, | ||
1296 | struct device_attribute *attr, | ||
1297 | char *buf); | ||
1298 | static ssize_t toshiba_available_kbd_modes_show(struct device *dev, | ||
1299 | struct device_attribute *attr, | ||
1300 | char *buf); | ||
1301 | static ssize_t toshiba_kbd_bl_timeout_store(struct device *dev, | ||
1302 | struct device_attribute *attr, | ||
1303 | const char *buf, size_t count); | ||
1304 | static ssize_t toshiba_kbd_bl_timeout_show(struct device *dev, | ||
1305 | struct device_attribute *attr, | ||
1306 | char *buf); | ||
1307 | static ssize_t toshiba_touchpad_store(struct device *dev, | ||
1308 | struct device_attribute *attr, | ||
1309 | const char *buf, size_t count); | ||
1310 | static ssize_t toshiba_touchpad_show(struct device *dev, | ||
1311 | struct device_attribute *attr, | ||
1312 | char *buf); | ||
1313 | static ssize_t toshiba_position_show(struct device *dev, | ||
1314 | struct device_attribute *attr, | ||
1315 | char *buf); | ||
1316 | |||
1317 | static DEVICE_ATTR(kbd_backlight_mode, S_IRUGO | S_IWUSR, | ||
1318 | toshiba_kbd_bl_mode_show, toshiba_kbd_bl_mode_store); | ||
1319 | static DEVICE_ATTR(kbd_type, S_IRUGO, toshiba_kbd_type_show, NULL); | ||
1320 | static DEVICE_ATTR(available_kbd_modes, S_IRUGO, | ||
1321 | toshiba_available_kbd_modes_show, NULL); | ||
1322 | static DEVICE_ATTR(kbd_backlight_timeout, S_IRUGO | S_IWUSR, | ||
1323 | toshiba_kbd_bl_timeout_show, toshiba_kbd_bl_timeout_store); | ||
1324 | static DEVICE_ATTR(touchpad, S_IRUGO | S_IWUSR, | ||
1325 | toshiba_touchpad_show, toshiba_touchpad_store); | ||
1326 | static DEVICE_ATTR(position, S_IRUGO, toshiba_position_show, NULL); | ||
1327 | 1692 | ||
1328 | static struct attribute *toshiba_attributes[] = { | 1693 | static ssize_t fan_store(struct device *dev, |
1329 | &dev_attr_kbd_backlight_mode.attr, | 1694 | struct device_attribute *attr, |
1330 | &dev_attr_kbd_type.attr, | 1695 | const char *buf, size_t count) |
1331 | &dev_attr_available_kbd_modes.attr, | 1696 | { |
1332 | &dev_attr_kbd_backlight_timeout.attr, | 1697 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); |
1333 | &dev_attr_touchpad.attr, | 1698 | u32 result; |
1334 | &dev_attr_position.attr, | 1699 | int state; |
1335 | NULL, | 1700 | int ret; |
1336 | }; | ||
1337 | 1701 | ||
1338 | static umode_t toshiba_sysfs_is_visible(struct kobject *, | 1702 | ret = kstrtoint(buf, 0, &state); |
1339 | struct attribute *, int); | 1703 | if (ret) |
1704 | return ret; | ||
1340 | 1705 | ||
1341 | static struct attribute_group toshiba_attr_group = { | 1706 | if (state != 0 && state != 1) |
1342 | .is_visible = toshiba_sysfs_is_visible, | 1707 | return -EINVAL; |
1343 | .attrs = toshiba_attributes, | ||
1344 | }; | ||
1345 | 1708 | ||
1346 | static ssize_t toshiba_kbd_bl_mode_store(struct device *dev, | 1709 | result = hci_write1(toshiba, HCI_FAN, state); |
1347 | struct device_attribute *attr, | 1710 | if (result == TOS_FAILURE) |
1348 | const char *buf, size_t count) | 1711 | return -EIO; |
1712 | else if (result == TOS_NOT_SUPPORTED) | ||
1713 | return -ENODEV; | ||
1714 | |||
1715 | return count; | ||
1716 | } | ||
1717 | |||
1718 | static ssize_t fan_show(struct device *dev, | ||
1719 | struct device_attribute *attr, char *buf) | ||
1720 | { | ||
1721 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | ||
1722 | u32 value; | ||
1723 | int ret; | ||
1724 | |||
1725 | ret = get_fan_status(toshiba, &value); | ||
1726 | if (ret) | ||
1727 | return ret; | ||
1728 | |||
1729 | return sprintf(buf, "%d\n", value); | ||
1730 | } | ||
1731 | static DEVICE_ATTR_RW(fan); | ||
1732 | |||
1733 | static ssize_t kbd_backlight_mode_store(struct device *dev, | ||
1734 | struct device_attribute *attr, | ||
1735 | const char *buf, size_t count) | ||
1349 | { | 1736 | { |
1350 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | 1737 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); |
1351 | int mode; | 1738 | int mode; |
@@ -1369,7 +1756,8 @@ static ssize_t toshiba_kbd_bl_mode_store(struct device *dev, | |||
1369 | return -EINVAL; | 1756 | return -EINVAL; |
1370 | } | 1757 | } |
1371 | 1758 | ||
1372 | /* Set the Keyboard Backlight Mode where: | 1759 | /* |
1760 | * Set the Keyboard Backlight Mode where: | ||
1373 | * Auto - KBD backlight turns off automatically in given time | 1761 | * Auto - KBD backlight turns off automatically in given time |
1374 | * FN-Z - KBD backlight "toggles" when hotkey pressed | 1762 | * FN-Z - KBD backlight "toggles" when hotkey pressed |
1375 | * ON - KBD backlight is always on | 1763 | * ON - KBD backlight is always on |
@@ -1400,9 +1788,9 @@ static ssize_t toshiba_kbd_bl_mode_store(struct device *dev, | |||
1400 | return count; | 1788 | return count; |
1401 | } | 1789 | } |
1402 | 1790 | ||
1403 | static ssize_t toshiba_kbd_bl_mode_show(struct device *dev, | 1791 | static ssize_t kbd_backlight_mode_show(struct device *dev, |
1404 | struct device_attribute *attr, | 1792 | struct device_attribute *attr, |
1405 | char *buf) | 1793 | char *buf) |
1406 | { | 1794 | { |
1407 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | 1795 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); |
1408 | u32 time; | 1796 | u32 time; |
@@ -1412,19 +1800,20 @@ static ssize_t toshiba_kbd_bl_mode_show(struct device *dev, | |||
1412 | 1800 | ||
1413 | return sprintf(buf, "%i\n", time & SCI_KBD_MODE_MASK); | 1801 | return sprintf(buf, "%i\n", time & SCI_KBD_MODE_MASK); |
1414 | } | 1802 | } |
1803 | static DEVICE_ATTR_RW(kbd_backlight_mode); | ||
1415 | 1804 | ||
1416 | static ssize_t toshiba_kbd_type_show(struct device *dev, | 1805 | static ssize_t kbd_type_show(struct device *dev, |
1417 | struct device_attribute *attr, | 1806 | struct device_attribute *attr, char *buf) |
1418 | char *buf) | ||
1419 | { | 1807 | { |
1420 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | 1808 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); |
1421 | 1809 | ||
1422 | return sprintf(buf, "%d\n", toshiba->kbd_type); | 1810 | return sprintf(buf, "%d\n", toshiba->kbd_type); |
1423 | } | 1811 | } |
1812 | static DEVICE_ATTR_RO(kbd_type); | ||
1424 | 1813 | ||
1425 | static ssize_t toshiba_available_kbd_modes_show(struct device *dev, | 1814 | static ssize_t available_kbd_modes_show(struct device *dev, |
1426 | struct device_attribute *attr, | 1815 | struct device_attribute *attr, |
1427 | char *buf) | 1816 | char *buf) |
1428 | { | 1817 | { |
1429 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | 1818 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); |
1430 | 1819 | ||
@@ -1435,10 +1824,11 @@ static ssize_t toshiba_available_kbd_modes_show(struct device *dev, | |||
1435 | return sprintf(buf, "%x %x %x\n", | 1824 | return sprintf(buf, "%x %x %x\n", |
1436 | SCI_KBD_MODE_AUTO, SCI_KBD_MODE_ON, SCI_KBD_MODE_OFF); | 1825 | SCI_KBD_MODE_AUTO, SCI_KBD_MODE_ON, SCI_KBD_MODE_OFF); |
1437 | } | 1826 | } |
1827 | static DEVICE_ATTR_RO(available_kbd_modes); | ||
1438 | 1828 | ||
1439 | static ssize_t toshiba_kbd_bl_timeout_store(struct device *dev, | 1829 | static ssize_t kbd_backlight_timeout_store(struct device *dev, |
1440 | struct device_attribute *attr, | 1830 | struct device_attribute *attr, |
1441 | const char *buf, size_t count) | 1831 | const char *buf, size_t count) |
1442 | { | 1832 | { |
1443 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | 1833 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); |
1444 | int time; | 1834 | int time; |
@@ -1479,9 +1869,9 @@ static ssize_t toshiba_kbd_bl_timeout_store(struct device *dev, | |||
1479 | return count; | 1869 | return count; |
1480 | } | 1870 | } |
1481 | 1871 | ||
1482 | static ssize_t toshiba_kbd_bl_timeout_show(struct device *dev, | 1872 | static ssize_t kbd_backlight_timeout_show(struct device *dev, |
1483 | struct device_attribute *attr, | 1873 | struct device_attribute *attr, |
1484 | char *buf) | 1874 | char *buf) |
1485 | { | 1875 | { |
1486 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | 1876 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); |
1487 | u32 time; | 1877 | u32 time; |
@@ -1491,10 +1881,11 @@ static ssize_t toshiba_kbd_bl_timeout_show(struct device *dev, | |||
1491 | 1881 | ||
1492 | return sprintf(buf, "%i\n", time >> HCI_MISC_SHIFT); | 1882 | return sprintf(buf, "%i\n", time >> HCI_MISC_SHIFT); |
1493 | } | 1883 | } |
1884 | static DEVICE_ATTR_RW(kbd_backlight_timeout); | ||
1494 | 1885 | ||
1495 | static ssize_t toshiba_touchpad_store(struct device *dev, | 1886 | static ssize_t touchpad_store(struct device *dev, |
1496 | struct device_attribute *attr, | 1887 | struct device_attribute *attr, |
1497 | const char *buf, size_t count) | 1888 | const char *buf, size_t count) |
1498 | { | 1889 | { |
1499 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | 1890 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); |
1500 | int state; | 1891 | int state; |
@@ -1514,8 +1905,8 @@ static ssize_t toshiba_touchpad_store(struct device *dev, | |||
1514 | return count; | 1905 | return count; |
1515 | } | 1906 | } |
1516 | 1907 | ||
1517 | static ssize_t toshiba_touchpad_show(struct device *dev, | 1908 | static ssize_t touchpad_show(struct device *dev, |
1518 | struct device_attribute *attr, char *buf) | 1909 | struct device_attribute *attr, char *buf) |
1519 | { | 1910 | { |
1520 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | 1911 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); |
1521 | u32 state; | 1912 | u32 state; |
@@ -1527,9 +1918,10 @@ static ssize_t toshiba_touchpad_show(struct device *dev, | |||
1527 | 1918 | ||
1528 | return sprintf(buf, "%i\n", state); | 1919 | return sprintf(buf, "%i\n", state); |
1529 | } | 1920 | } |
1921 | static DEVICE_ATTR_RW(touchpad); | ||
1530 | 1922 | ||
1531 | static ssize_t toshiba_position_show(struct device *dev, | 1923 | static ssize_t position_show(struct device *dev, |
1532 | struct device_attribute *attr, char *buf) | 1924 | struct device_attribute *attr, char *buf) |
1533 | { | 1925 | { |
1534 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | 1926 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); |
1535 | u32 xyval, zval, tmp; | 1927 | u32 xyval, zval, tmp; |
@@ -1548,6 +1940,336 @@ static ssize_t toshiba_position_show(struct device *dev, | |||
1548 | 1940 | ||
1549 | return sprintf(buf, "%d %d %d\n", x, y, z); | 1941 | return sprintf(buf, "%d %d %d\n", x, y, z); |
1550 | } | 1942 | } |
1943 | static DEVICE_ATTR_RO(position); | ||
1944 | |||
1945 | static ssize_t usb_sleep_charge_show(struct device *dev, | ||
1946 | struct device_attribute *attr, char *buf) | ||
1947 | { | ||
1948 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | ||
1949 | u32 mode; | ||
1950 | int ret; | ||
1951 | |||
1952 | ret = toshiba_usb_sleep_charge_get(toshiba, &mode); | ||
1953 | if (ret < 0) | ||
1954 | return ret; | ||
1955 | |||
1956 | return sprintf(buf, "%x\n", mode & SCI_USB_CHARGE_MODE_MASK); | ||
1957 | } | ||
1958 | |||
1959 | static ssize_t usb_sleep_charge_store(struct device *dev, | ||
1960 | struct device_attribute *attr, | ||
1961 | const char *buf, size_t count) | ||
1962 | { | ||
1963 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | ||
1964 | u32 mode; | ||
1965 | int state; | ||
1966 | int ret; | ||
1967 | |||
1968 | ret = kstrtoint(buf, 0, &state); | ||
1969 | if (ret) | ||
1970 | return ret; | ||
1971 | /* | ||
1972 | * Check for supported values, where: | ||
1973 | * 0 - Disabled | ||
1974 | * 1 - Alternate (Non USB conformant devices that require more power) | ||
1975 | * 2 - Auto (USB conformant devices) | ||
1976 | */ | ||
1977 | if (state != 0 && state != 1 && state != 2) | ||
1978 | return -EINVAL; | ||
1979 | |||
1980 | /* Set the USB charging mode to internal value */ | ||
1981 | if (state == 0) | ||
1982 | mode = SCI_USB_CHARGE_DISABLED; | ||
1983 | else if (state == 1) | ||
1984 | mode = SCI_USB_CHARGE_ALTERNATE; | ||
1985 | else if (state == 2) | ||
1986 | mode = SCI_USB_CHARGE_AUTO; | ||
1987 | |||
1988 | ret = toshiba_usb_sleep_charge_set(toshiba, mode); | ||
1989 | if (ret) | ||
1990 | return ret; | ||
1991 | |||
1992 | return count; | ||
1993 | } | ||
1994 | static DEVICE_ATTR_RW(usb_sleep_charge); | ||
1995 | |||
1996 | static ssize_t sleep_functions_on_battery_show(struct device *dev, | ||
1997 | struct device_attribute *attr, | ||
1998 | char *buf) | ||
1999 | { | ||
2000 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | ||
2001 | u32 state; | ||
2002 | int bat_lvl; | ||
2003 | int status; | ||
2004 | int ret; | ||
2005 | int tmp; | ||
2006 | |||
2007 | ret = toshiba_sleep_functions_status_get(toshiba, &state); | ||
2008 | if (ret < 0) | ||
2009 | return ret; | ||
2010 | |||
2011 | /* Determine the status: 0x4 - Enabled | 0x1 - Disabled */ | ||
2012 | tmp = state & SCI_USB_CHARGE_BAT_MASK; | ||
2013 | status = (tmp == 0x4) ? 1 : 0; | ||
2014 | /* Determine the battery level set */ | ||
2015 | bat_lvl = state >> HCI_MISC_SHIFT; | ||
2016 | |||
2017 | return sprintf(buf, "%d %d\n", status, bat_lvl); | ||
2018 | } | ||
2019 | |||
2020 | static ssize_t sleep_functions_on_battery_store(struct device *dev, | ||
2021 | struct device_attribute *attr, | ||
2022 | const char *buf, size_t count) | ||
2023 | { | ||
2024 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | ||
2025 | u32 status; | ||
2026 | int value; | ||
2027 | int ret; | ||
2028 | int tmp; | ||
2029 | |||
2030 | ret = kstrtoint(buf, 0, &value); | ||
2031 | if (ret) | ||
2032 | return ret; | ||
2033 | |||
2034 | /* | ||
2035 | * Set the status of the function: | ||
2036 | * 0 - Disabled | ||
2037 | * 1-100 - Enabled | ||
2038 | */ | ||
2039 | if (value < 0 || value > 100) | ||
2040 | return -EINVAL; | ||
2041 | |||
2042 | if (value == 0) { | ||
2043 | tmp = toshiba->usbsc_bat_level << HCI_MISC_SHIFT; | ||
2044 | status = tmp | SCI_USB_CHARGE_BAT_LVL_OFF; | ||
2045 | } else { | ||
2046 | tmp = value << HCI_MISC_SHIFT; | ||
2047 | status = tmp | SCI_USB_CHARGE_BAT_LVL_ON; | ||
2048 | } | ||
2049 | ret = toshiba_sleep_functions_status_set(toshiba, status); | ||
2050 | if (ret < 0) | ||
2051 | return ret; | ||
2052 | |||
2053 | toshiba->usbsc_bat_level = status >> HCI_MISC_SHIFT; | ||
2054 | |||
2055 | return count; | ||
2056 | } | ||
2057 | static DEVICE_ATTR_RW(sleep_functions_on_battery); | ||
2058 | |||
2059 | static ssize_t usb_rapid_charge_show(struct device *dev, | ||
2060 | struct device_attribute *attr, char *buf) | ||
2061 | { | ||
2062 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | ||
2063 | u32 state; | ||
2064 | int ret; | ||
2065 | |||
2066 | ret = toshiba_usb_rapid_charge_get(toshiba, &state); | ||
2067 | if (ret < 0) | ||
2068 | return ret; | ||
2069 | |||
2070 | return sprintf(buf, "%d\n", state); | ||
2071 | } | ||
2072 | |||
2073 | static ssize_t usb_rapid_charge_store(struct device *dev, | ||
2074 | struct device_attribute *attr, | ||
2075 | const char *buf, size_t count) | ||
2076 | { | ||
2077 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | ||
2078 | int state; | ||
2079 | int ret; | ||
2080 | |||
2081 | ret = kstrtoint(buf, 0, &state); | ||
2082 | if (ret) | ||
2083 | return ret; | ||
2084 | if (state != 0 && state != 1) | ||
2085 | return -EINVAL; | ||
2086 | |||
2087 | ret = toshiba_usb_rapid_charge_set(toshiba, state); | ||
2088 | if (ret) | ||
2089 | return ret; | ||
2090 | |||
2091 | return count; | ||
2092 | } | ||
2093 | static DEVICE_ATTR_RW(usb_rapid_charge); | ||
2094 | |||
2095 | static ssize_t usb_sleep_music_show(struct device *dev, | ||
2096 | struct device_attribute *attr, char *buf) | ||
2097 | { | ||
2098 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | ||
2099 | u32 state; | ||
2100 | int ret; | ||
2101 | |||
2102 | ret = toshiba_usb_sleep_music_get(toshiba, &state); | ||
2103 | if (ret < 0) | ||
2104 | return ret; | ||
2105 | |||
2106 | return sprintf(buf, "%d\n", state); | ||
2107 | } | ||
2108 | |||
2109 | static ssize_t usb_sleep_music_store(struct device *dev, | ||
2110 | struct device_attribute *attr, | ||
2111 | const char *buf, size_t count) | ||
2112 | { | ||
2113 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | ||
2114 | int state; | ||
2115 | int ret; | ||
2116 | |||
2117 | ret = kstrtoint(buf, 0, &state); | ||
2118 | if (ret) | ||
2119 | return ret; | ||
2120 | if (state != 0 && state != 1) | ||
2121 | return -EINVAL; | ||
2122 | |||
2123 | ret = toshiba_usb_sleep_music_set(toshiba, state); | ||
2124 | if (ret) | ||
2125 | return ret; | ||
2126 | |||
2127 | return count; | ||
2128 | } | ||
2129 | static DEVICE_ATTR_RW(usb_sleep_music); | ||
2130 | |||
2131 | static ssize_t kbd_function_keys_show(struct device *dev, | ||
2132 | struct device_attribute *attr, char *buf) | ||
2133 | { | ||
2134 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | ||
2135 | int mode; | ||
2136 | int ret; | ||
2137 | |||
2138 | ret = toshiba_function_keys_get(toshiba, &mode); | ||
2139 | if (ret < 0) | ||
2140 | return ret; | ||
2141 | |||
2142 | return sprintf(buf, "%d\n", mode); | ||
2143 | } | ||
2144 | |||
2145 | static ssize_t kbd_function_keys_store(struct device *dev, | ||
2146 | struct device_attribute *attr, | ||
2147 | const char *buf, size_t count) | ||
2148 | { | ||
2149 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | ||
2150 | int mode; | ||
2151 | int ret; | ||
2152 | |||
2153 | ret = kstrtoint(buf, 0, &mode); | ||
2154 | if (ret) | ||
2155 | return ret; | ||
2156 | /* | ||
2157 | * Check for the function keys mode where: | ||
2158 | * 0 - Normal operation (F{1-12} as usual and hotkeys via FN-F{1-12}) | ||
2159 | * 1 - Special functions (Opposite of the above setting) | ||
2160 | */ | ||
2161 | if (mode != 0 && mode != 1) | ||
2162 | return -EINVAL; | ||
2163 | |||
2164 | ret = toshiba_function_keys_set(toshiba, mode); | ||
2165 | if (ret) | ||
2166 | return ret; | ||
2167 | |||
2168 | pr_info("Reboot for changes to KBD Function Keys to take effect"); | ||
2169 | |||
2170 | return count; | ||
2171 | } | ||
2172 | static DEVICE_ATTR_RW(kbd_function_keys); | ||
2173 | |||
2174 | static ssize_t panel_power_on_show(struct device *dev, | ||
2175 | struct device_attribute *attr, char *buf) | ||
2176 | { | ||
2177 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | ||
2178 | u32 state; | ||
2179 | int ret; | ||
2180 | |||
2181 | ret = toshiba_panel_power_on_get(toshiba, &state); | ||
2182 | if (ret < 0) | ||
2183 | return ret; | ||
2184 | |||
2185 | return sprintf(buf, "%d\n", state); | ||
2186 | } | ||
2187 | |||
2188 | static ssize_t panel_power_on_store(struct device *dev, | ||
2189 | struct device_attribute *attr, | ||
2190 | const char *buf, size_t count) | ||
2191 | { | ||
2192 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | ||
2193 | int state; | ||
2194 | int ret; | ||
2195 | |||
2196 | ret = kstrtoint(buf, 0, &state); | ||
2197 | if (ret) | ||
2198 | return ret; | ||
2199 | if (state != 0 && state != 1) | ||
2200 | return -EINVAL; | ||
2201 | |||
2202 | ret = toshiba_panel_power_on_set(toshiba, state); | ||
2203 | if (ret) | ||
2204 | return ret; | ||
2205 | |||
2206 | pr_info("Reboot for changes to Panel Power ON to take effect"); | ||
2207 | |||
2208 | return count; | ||
2209 | } | ||
2210 | static DEVICE_ATTR_RW(panel_power_on); | ||
2211 | |||
2212 | static ssize_t usb_three_show(struct device *dev, | ||
2213 | struct device_attribute *attr, char *buf) | ||
2214 | { | ||
2215 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | ||
2216 | u32 state; | ||
2217 | int ret; | ||
2218 | |||
2219 | ret = toshiba_usb_three_get(toshiba, &state); | ||
2220 | if (ret < 0) | ||
2221 | return ret; | ||
2222 | |||
2223 | return sprintf(buf, "%d\n", state); | ||
2224 | } | ||
2225 | |||
2226 | static ssize_t usb_three_store(struct device *dev, | ||
2227 | struct device_attribute *attr, | ||
2228 | const char *buf, size_t count) | ||
2229 | { | ||
2230 | struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); | ||
2231 | int state; | ||
2232 | int ret; | ||
2233 | |||
2234 | ret = kstrtoint(buf, 0, &state); | ||
2235 | if (ret) | ||
2236 | return ret; | ||
2237 | /* | ||
2238 | * Check for USB 3 mode where: | ||
2239 | * 0 - Disabled (Acts like a USB 2 port, saving power) | ||
2240 | * 1 - Enabled | ||
2241 | */ | ||
2242 | if (state != 0 && state != 1) | ||
2243 | return -EINVAL; | ||
2244 | |||
2245 | ret = toshiba_usb_three_set(toshiba, state); | ||
2246 | if (ret) | ||
2247 | return ret; | ||
2248 | |||
2249 | pr_info("Reboot for changes to USB 3 to take effect"); | ||
2250 | |||
2251 | return count; | ||
2252 | } | ||
2253 | static DEVICE_ATTR_RW(usb_three); | ||
2254 | |||
2255 | static struct attribute *toshiba_attributes[] = { | ||
2256 | &dev_attr_version.attr, | ||
2257 | &dev_attr_fan.attr, | ||
2258 | &dev_attr_kbd_backlight_mode.attr, | ||
2259 | &dev_attr_kbd_type.attr, | ||
2260 | &dev_attr_available_kbd_modes.attr, | ||
2261 | &dev_attr_kbd_backlight_timeout.attr, | ||
2262 | &dev_attr_touchpad.attr, | ||
2263 | &dev_attr_position.attr, | ||
2264 | &dev_attr_usb_sleep_charge.attr, | ||
2265 | &dev_attr_sleep_functions_on_battery.attr, | ||
2266 | &dev_attr_usb_rapid_charge.attr, | ||
2267 | &dev_attr_usb_sleep_music.attr, | ||
2268 | &dev_attr_kbd_function_keys.attr, | ||
2269 | &dev_attr_panel_power_on.attr, | ||
2270 | &dev_attr_usb_three.attr, | ||
2271 | NULL, | ||
2272 | }; | ||
1551 | 2273 | ||
1552 | static umode_t toshiba_sysfs_is_visible(struct kobject *kobj, | 2274 | static umode_t toshiba_sysfs_is_visible(struct kobject *kobj, |
1553 | struct attribute *attr, int idx) | 2275 | struct attribute *attr, int idx) |
@@ -1556,7 +2278,9 @@ static umode_t toshiba_sysfs_is_visible(struct kobject *kobj, | |||
1556 | struct toshiba_acpi_dev *drv = dev_get_drvdata(dev); | 2278 | struct toshiba_acpi_dev *drv = dev_get_drvdata(dev); |
1557 | bool exists = true; | 2279 | bool exists = true; |
1558 | 2280 | ||
1559 | if (attr == &dev_attr_kbd_backlight_mode.attr) | 2281 | if (attr == &dev_attr_fan.attr) |
2282 | exists = (drv->fan_supported) ? true : false; | ||
2283 | else if (attr == &dev_attr_kbd_backlight_mode.attr) | ||
1560 | exists = (drv->kbd_illum_supported) ? true : false; | 2284 | exists = (drv->kbd_illum_supported) ? true : false; |
1561 | else if (attr == &dev_attr_kbd_backlight_timeout.attr) | 2285 | else if (attr == &dev_attr_kbd_backlight_timeout.attr) |
1562 | exists = (drv->kbd_mode == SCI_KBD_MODE_AUTO) ? true : false; | 2286 | exists = (drv->kbd_mode == SCI_KBD_MODE_AUTO) ? true : false; |
@@ -1564,10 +2288,29 @@ static umode_t toshiba_sysfs_is_visible(struct kobject *kobj, | |||
1564 | exists = (drv->touchpad_supported) ? true : false; | 2288 | exists = (drv->touchpad_supported) ? true : false; |
1565 | else if (attr == &dev_attr_position.attr) | 2289 | else if (attr == &dev_attr_position.attr) |
1566 | exists = (drv->accelerometer_supported) ? true : false; | 2290 | exists = (drv->accelerometer_supported) ? true : false; |
2291 | else if (attr == &dev_attr_usb_sleep_charge.attr) | ||
2292 | exists = (drv->usb_sleep_charge_supported) ? true : false; | ||
2293 | else if (attr == &dev_attr_sleep_functions_on_battery.attr) | ||
2294 | exists = (drv->usb_sleep_charge_supported) ? true : false; | ||
2295 | else if (attr == &dev_attr_usb_rapid_charge.attr) | ||
2296 | exists = (drv->usb_rapid_charge_supported) ? true : false; | ||
2297 | else if (attr == &dev_attr_usb_sleep_music.attr) | ||
2298 | exists = (drv->usb_sleep_music_supported) ? true : false; | ||
2299 | else if (attr == &dev_attr_kbd_function_keys.attr) | ||
2300 | exists = (drv->kbd_function_keys_supported) ? true : false; | ||
2301 | else if (attr == &dev_attr_panel_power_on.attr) | ||
2302 | exists = (drv->panel_power_on_supported) ? true : false; | ||
2303 | else if (attr == &dev_attr_usb_three.attr) | ||
2304 | exists = (drv->usb_three_supported) ? true : false; | ||
1567 | 2305 | ||
1568 | return exists ? attr->mode : 0; | 2306 | return exists ? attr->mode : 0; |
1569 | } | 2307 | } |
1570 | 2308 | ||
2309 | static struct attribute_group toshiba_attr_group = { | ||
2310 | .is_visible = toshiba_sysfs_is_visible, | ||
2311 | .attrs = toshiba_attributes, | ||
2312 | }; | ||
2313 | |||
1571 | /* | 2314 | /* |
1572 | * Hotkeys | 2315 | * Hotkeys |
1573 | */ | 2316 | */ |
@@ -1644,7 +2387,7 @@ static void toshiba_acpi_report_hotkey(struct toshiba_acpi_dev *dev, | |||
1644 | if (scancode == 0x100) | 2387 | if (scancode == 0x100) |
1645 | return; | 2388 | return; |
1646 | 2389 | ||
1647 | /* act on key press; ignore key release */ | 2390 | /* Act on key press; ignore key release */ |
1648 | if (scancode & 0x80) | 2391 | if (scancode & 0x80) |
1649 | return; | 2392 | return; |
1650 | 2393 | ||
@@ -1680,7 +2423,7 @@ static void toshiba_acpi_process_hotkeys(struct toshiba_acpi_dev *dev) | |||
1680 | hci_result = | 2423 | hci_result = |
1681 | hci_write1(dev, HCI_SYSTEM_EVENT, 1); | 2424 | hci_write1(dev, HCI_SYSTEM_EVENT, 1); |
1682 | pr_notice("Re-enabled hotkeys\n"); | 2425 | pr_notice("Re-enabled hotkeys\n"); |
1683 | /* fall through */ | 2426 | /* Fall through */ |
1684 | default: | 2427 | default: |
1685 | retries--; | 2428 | retries--; |
1686 | break; | 2429 | break; |
@@ -1802,7 +2545,7 @@ static int toshiba_acpi_setup_backlight(struct toshiba_acpi_dev *dev) | |||
1802 | props.type = BACKLIGHT_PLATFORM; | 2545 | props.type = BACKLIGHT_PLATFORM; |
1803 | props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1; | 2546 | props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1; |
1804 | 2547 | ||
1805 | /* adding an extra level and having 0 change to transflective mode */ | 2548 | /* Adding an extra level and having 0 change to transflective mode */ |
1806 | if (dev->tr_backlight_supported) | 2549 | if (dev->tr_backlight_supported) |
1807 | props.max_brightness++; | 2550 | props.max_brightness++; |
1808 | 2551 | ||
@@ -1973,6 +2716,24 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev) | |||
1973 | ret = toshiba_accelerometer_supported(dev); | 2716 | ret = toshiba_accelerometer_supported(dev); |
1974 | dev->accelerometer_supported = !ret; | 2717 | dev->accelerometer_supported = !ret; |
1975 | 2718 | ||
2719 | ret = toshiba_usb_sleep_charge_get(dev, &dummy); | ||
2720 | dev->usb_sleep_charge_supported = !ret; | ||
2721 | |||
2722 | ret = toshiba_usb_rapid_charge_get(dev, &dummy); | ||
2723 | dev->usb_rapid_charge_supported = !ret; | ||
2724 | |||
2725 | ret = toshiba_usb_sleep_music_get(dev, &dummy); | ||
2726 | dev->usb_sleep_music_supported = !ret; | ||
2727 | |||
2728 | ret = toshiba_function_keys_get(dev, &dummy); | ||
2729 | dev->kbd_function_keys_supported = !ret; | ||
2730 | |||
2731 | ret = toshiba_panel_power_on_get(dev, &dummy); | ||
2732 | dev->panel_power_on_supported = !ret; | ||
2733 | |||
2734 | ret = toshiba_usb_three_get(dev, &dummy); | ||
2735 | dev->usb_three_supported = !ret; | ||
2736 | |||
1976 | /* Determine whether or not BIOS supports fan and video interfaces */ | 2737 | /* Determine whether or not BIOS supports fan and video interfaces */ |
1977 | 2738 | ||
1978 | ret = get_video_status(dev, &dummy); | 2739 | ret = get_video_status(dev, &dummy); |