aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/platform/x86/toshiba_acpi.c71
1 files changed, 62 insertions, 9 deletions
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 17a259eb3eed..37f5f64976f1 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -150,9 +150,10 @@ MODULE_LICENSE("GPL");
150#define SCI_KBD_MODE_OFF 0x10 150#define SCI_KBD_MODE_OFF 0x10
151#define SCI_KBD_TIME_MAX 0x3c001a 151#define SCI_KBD_TIME_MAX 0x3c001a
152#define SCI_USB_CHARGE_MODE_MASK 0xff 152#define SCI_USB_CHARGE_MODE_MASK 0xff
153#define SCI_USB_CHARGE_DISABLED 0x30000 153#define SCI_USB_CHARGE_DISABLED 0x00
154#define SCI_USB_CHARGE_ALTERNATE 0x30009 154#define SCI_USB_CHARGE_ALTERNATE 0x09
155#define SCI_USB_CHARGE_AUTO 0x30021 155#define SCI_USB_CHARGE_TYPICAL 0x11
156#define SCI_USB_CHARGE_AUTO 0x21
156#define SCI_USB_CHARGE_BAT_MASK 0x7 157#define SCI_USB_CHARGE_BAT_MASK 0x7
157#define SCI_USB_CHARGE_BAT_LVL_OFF 0x1 158#define SCI_USB_CHARGE_BAT_LVL_OFF 0x1
158#define SCI_USB_CHARGE_BAT_LVL_ON 0x4 159#define SCI_USB_CHARGE_BAT_LVL_ON 0x4
@@ -177,6 +178,7 @@ struct toshiba_acpi_dev {
177 int kbd_mode; 178 int kbd_mode;
178 int kbd_time; 179 int kbd_time;
179 int usbsc_bat_level; 180 int usbsc_bat_level;
181 int usbsc_mode_base;
180 int hotkey_event_type; 182 int hotkey_event_type;
181 183
182 unsigned int illumination_supported:1; 184 unsigned int illumination_supported:1;
@@ -800,6 +802,54 @@ static int toshiba_accelerometer_get(struct toshiba_acpi_dev *dev,
800} 802}
801 803
802/* Sleep (Charge and Music) utilities support */ 804/* Sleep (Charge and Music) utilities support */
805static void toshiba_usb_sleep_charge_available(struct toshiba_acpi_dev *dev)
806{
807 u32 in[TCI_WORDS] = { SCI_GET, SCI_USB_SLEEP_CHARGE, 0, 0, 0, 0 };
808 u32 out[TCI_WORDS];
809 acpi_status status;
810
811 /* Set the feature to "not supported" in case of error */
812 dev->usb_sleep_charge_supported = 0;
813
814 if (!sci_open(dev))
815 return;
816
817 status = tci_raw(dev, in, out);
818 if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) {
819 pr_err("ACPI call to get USB Sleep and Charge mode failed\n");
820 sci_close(dev);
821 return;
822 } else if (out[0] == TOS_NOT_SUPPORTED) {
823 pr_info("USB Sleep and Charge not supported\n");
824 sci_close(dev);
825 return;
826 } else if (out[0] == TOS_SUCCESS) {
827 dev->usbsc_mode_base = out[4];
828 }
829
830 in[5] = SCI_USB_CHARGE_BAT_LVL;
831 status = tci_raw(dev, in, out);
832 if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) {
833 pr_err("ACPI call to get USB Sleep and Charge mode failed\n");
834 sci_close(dev);
835 return;
836 } else if (out[0] == TOS_NOT_SUPPORTED) {
837 pr_info("USB Sleep and Charge not supported\n");
838 sci_close(dev);
839 return;
840 } else if (out[0] == TOS_SUCCESS) {
841 dev->usbsc_bat_level = out[2];
842 /*
843 * If we reach this point, it means that the laptop has support
844 * for this feature and all values are initialized.
845 * Set it as supported.
846 */
847 dev->usb_sleep_charge_supported = 1;
848 }
849
850 sci_close(dev);
851}
852
803static int toshiba_usb_sleep_charge_get(struct toshiba_acpi_dev *dev, 853static int toshiba_usb_sleep_charge_get(struct toshiba_acpi_dev *dev,
804 u32 *mode) 854 u32 *mode)
805{ 855{
@@ -1976,17 +2026,21 @@ static ssize_t usb_sleep_charge_store(struct device *dev,
1976 * 0 - Disabled 2026 * 0 - Disabled
1977 * 1 - Alternate (Non USB conformant devices that require more power) 2027 * 1 - Alternate (Non USB conformant devices that require more power)
1978 * 2 - Auto (USB conformant devices) 2028 * 2 - Auto (USB conformant devices)
2029 * 3 - Typical
1979 */ 2030 */
1980 if (state != 0 && state != 1 && state != 2) 2031 if (state != 0 && state != 1 && state != 2 && state != 3)
1981 return -EINVAL; 2032 return -EINVAL;
1982 2033
1983 /* Set the USB charging mode to internal value */ 2034 /* Set the USB charging mode to internal value */
2035 mode = toshiba->usbsc_mode_base;
1984 if (state == 0) 2036 if (state == 0)
1985 mode = SCI_USB_CHARGE_DISABLED; 2037 mode |= SCI_USB_CHARGE_DISABLED;
1986 else if (state == 1) 2038 else if (state == 1)
1987 mode = SCI_USB_CHARGE_ALTERNATE; 2039 mode |= SCI_USB_CHARGE_ALTERNATE;
1988 else if (state == 2) 2040 else if (state == 2)
1989 mode = SCI_USB_CHARGE_AUTO; 2041 mode |= SCI_USB_CHARGE_AUTO;
2042 else if (state == 3)
2043 mode |= SCI_USB_CHARGE_TYPICAL;
1990 2044
1991 ret = toshiba_usb_sleep_charge_set(toshiba, mode); 2045 ret = toshiba_usb_sleep_charge_set(toshiba, mode);
1992 if (ret) 2046 if (ret)
@@ -2756,8 +2810,7 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
2756 ret = toshiba_accelerometer_supported(dev); 2810 ret = toshiba_accelerometer_supported(dev);
2757 dev->accelerometer_supported = !ret; 2811 dev->accelerometer_supported = !ret;
2758 2812
2759 ret = toshiba_usb_sleep_charge_get(dev, &dummy); 2813 toshiba_usb_sleep_charge_available(dev);
2760 dev->usb_sleep_charge_supported = !ret;
2761 2814
2762 ret = toshiba_usb_rapid_charge_get(dev, &dummy); 2815 ret = toshiba_usb_rapid_charge_get(dev, &dummy);
2763 dev->usb_rapid_charge_supported = !ret; 2816 dev->usb_rapid_charge_supported = !ret;