Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'platform-drivers-x86-v3.20-1' of git://git.infradead.org/users/dvhart/linux-platform-drivers-x86

Pull platform driver update from Darren Hart:
"This includes a significant update to the toshiba_acpi driver,
bringing it to feature parity with the Windows driver, followed by
some needed cleanups.

The other changes are mostly minor updates, quirks, sparse fixes, or
cleanups.

Details:

- toshiba_acpi:
Add support for missing features from the Windows driver, bump the
sysfs version, and clean up the driver.

- thinkpad_acpi:
BIOS string versions, unhandled hkey events.

- msamsung-laptop:
Add native backlight quirk, enable better lid handling.

- intel_scu_ipc:
Read resources from PCI configuration

- other:
Fix sparse warnings, general cleanups"

* tag 'platform-drivers-x86-v3.20-1' of git://git.infradead.org/users/dvhart/linux-platform-drivers-x86: (34 commits)
toshiba_acpi: Cleanup GPL header
toshiba_acpi: Cleanup comment blocks and capitalization
toshiba_acpi: Make use of DEVICE_ATTR_{RO, RW} macros
toshiba_acpi: Drop the toshiba_ prefix from sysfs function names
toshiba_acpi: Move sysfs function and struct declarations further down
Documentation/ABI: Add file describing the sysfs entries for toshiba_acpi
toshiba_acpi: Clean file according to coding style
toshiba_acpi: Bump version number to 0.21
toshiba_acpi: Add support to enable/disable USB 3
toshiba_acpi: Add support for Panel Power ON
toshiba_acpi: Add support for Keyboard functions mode
toshiba_acpi: Add fan entry to sysfs
toshiba_acpi: Add version entry to sysfs
thinkpad_acpi: support new BIOS version string pattern
thinkpad_acpi: unhandled hkey event
toshiba_acpi: Make toshiba_eco_mode_available more robust
classmate-laptop: Fix sparse warning (0 as NULL)
Sony-laptop: Fix sparse warning (make undeclared var static)
thinkpad_acpi.c: Fix sparse warning (make undeclared var static)
samsung-laptop.c: Prefer kstrtoint over single variable sscanf
...

+1262 -246
+8
Documentation/ABI/testing/sysfs-driver-samsung-laptop
··· 35 35 Description: Use your USB ports to charge devices, even 36 36 when your laptop is powered off. 37 37 1 means enabled, 0 means disabled. 38 + 39 + What: /sys/devices/platform/samsung/lid_handling 40 + Date: December 11, 2014 41 + KernelVersion: 3.19 42 + Contact: Julijonas Kikutis <julijonas.kikutis@gmail.com> 43 + Description: Some Samsung laptops handle lid closing quicker and 44 + only handle lid opening with this mode enabled. 45 + 1 means enabled, 0 means disabled.
+114
Documentation/ABI/testing/sysfs-driver-toshiba_acpi
··· 1 + What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/kbd_backlight_mode 2 + Date: June 8, 2014 3 + KernelVersion: 3.15 4 + Contact: Azael Avalos <coproscefalo@gmail.com> 5 + Description: This file controls the keyboard backlight operation mode, valid 6 + values are: 7 + * 0x1 -> FN-Z 8 + * 0x2 -> AUTO (also called TIMER) 9 + * 0x8 -> ON 10 + * 0x10 -> OFF 11 + Note that the kernel 3.16 onwards this file accepts all listed 12 + parameters, kernel 3.15 only accepts the first two (FN-Z and 13 + AUTO). 14 + Users: KToshiba 15 + 16 + What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/kbd_backlight_timeout 17 + Date: June 8, 2014 18 + KernelVersion: 3.15 19 + Contact: Azael Avalos <coproscefalo@gmail.com> 20 + Description: This file controls the timeout of the keyboard backlight 21 + whenever the operation mode is set to AUTO (or TIMER), 22 + valid values range from 0-60. 23 + Note that the kernel 3.15 only had support for the first 24 + keyboard type, the kernel 3.16 added support for the second 25 + type and the range accepted for type 2 is 1-60. 26 + See the entry named "kbd_type" 27 + Users: KToshiba 28 + 29 + What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/position 30 + Date: June 8, 2014 31 + KernelVersion: 3.15 32 + Contact: Azael Avalos <coproscefalo@gmail.com> 33 + Description: This file shows the absolute position of the built-in 34 + accelereometer. 35 + 36 + What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/touchpad 37 + Date: June 8, 2014 38 + KernelVersion: 3.15 39 + Contact: Azael Avalos <coproscefalo@gmail.com> 40 + Description: This files controls the status of the touchpad and pointing 41 + stick (if available), valid values are: 42 + * 0 -> OFF 43 + * 1 -> ON 44 + Users: KToshiba 45 + 46 + What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/available_kbd_modes 47 + Date: August 3, 2014 48 + KernelVersion: 3.16 49 + Contact: Azael Avalos <coproscefalo@gmail.com> 50 + Description: This file shows the supported keyboard backlight modes 51 + the system supports, which can be: 52 + * 0x1 -> FN-Z 53 + * 0x2 -> AUTO (also called TIMER) 54 + * 0x8 -> ON 55 + * 0x10 -> OFF 56 + Note that not all keyboard types support the listed modes. 57 + See the entry named "available_kbd_modes" 58 + Users: KToshiba 59 + 60 + What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/kbd_type 61 + Date: August 3, 2014 62 + KernelVersion: 3.16 63 + Contact: Azael Avalos <coproscefalo@gmail.com> 64 + Description: This file shows the current keyboard backlight type, 65 + which can be: 66 + * 1 -> Type 1, supporting modes FN-Z and AUTO 67 + * 2 -> Type 2, supporting modes TIMER, ON and OFF 68 + Users: KToshiba 69 + 70 + What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/version 71 + Date: February, 2015 72 + KernelVersion: 3.20 73 + Contact: Azael Avalos <coproscefalo@gmail.com> 74 + Description: This file shows the current version of the driver 75 + 76 + What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/fan 77 + Date: February, 2015 78 + KernelVersion: 3.20 79 + Contact: Azael Avalos <coproscefalo@gmail.com> 80 + Description: This file controls the state of the internal fan, valid 81 + values are: 82 + * 0 -> OFF 83 + * 1 -> ON 84 + 85 + What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/kbd_function_keys 86 + Date: February, 2015 87 + KernelVersion: 3.20 88 + Contact: Azael Avalos <coproscefalo@gmail.com> 89 + Description: This file controls the Special Functions (hotkeys) operation 90 + mode, valid values are: 91 + * 0 -> Normal Operation 92 + * 1 -> Special Functions 93 + In the "Normal Operation" mode, the F{1-12} keys are as usual 94 + and the hotkeys are accessed via FN-F{1-12}. 95 + In the "Special Functions" mode, the F{1-12} keys trigger the 96 + hotkey and the F{1-12} keys are accessed via FN-F{1-12}. 97 + 98 + What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/panel_power_on 99 + Date: February, 2015 100 + KernelVersion: 3.20 101 + Contact: Azael Avalos <coproscefalo@gmail.com> 102 + Description: This file controls whether the laptop should turn ON whenever 103 + the LID is opened, valid values are: 104 + * 0 -> Disabled 105 + * 1 -> Enabled 106 + 107 + What: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/usb_three 108 + Date: February, 2015 109 + KernelVersion: 3.20 110 + Contact: Azael Avalos <coproscefalo@gmail.com> 111 + Description: This file controls whether the USB 3 functionality, valid 112 + values are: 113 + * 0 -> Disabled (Acts as a regular USB 2) 114 + * 1 -> Enabled (Full USB 3 functionality)
+47 -50
drivers/platform/x86/asus-laptop.c
··· 856 856 * than count bytes. We set eof to 1 if we handle those 2 values. We return the 857 857 * number of bytes written in page 858 858 */ 859 - static ssize_t show_infos(struct device *dev, 860 - struct device_attribute *attr, char *page) 859 + static ssize_t infos_show(struct device *dev, struct device_attribute *attr, 860 + char *page) 861 861 { 862 862 struct asus_laptop *asus = dev_get_drvdata(dev); 863 863 int len = 0; ··· 926 926 927 927 return len; 928 928 } 929 + static DEVICE_ATTR_RO(infos); 929 930 930 931 static int parse_arg(const char *buf, unsigned long count, int *val) 931 932 { ··· 958 957 /* 959 958 * LEDD display 960 959 */ 961 - static ssize_t show_ledd(struct device *dev, 962 - struct device_attribute *attr, char *buf) 960 + static ssize_t ledd_show(struct device *dev, struct device_attribute *attr, 961 + char *buf) 963 962 { 964 963 struct asus_laptop *asus = dev_get_drvdata(dev); 965 964 966 965 return sprintf(buf, "0x%08x\n", asus->ledd_status); 967 966 } 968 967 969 - static ssize_t store_ledd(struct device *dev, struct device_attribute *attr, 968 + static ssize_t ledd_store(struct device *dev, struct device_attribute *attr, 970 969 const char *buf, size_t count) 971 970 { 972 971 struct asus_laptop *asus = dev_get_drvdata(dev); ··· 982 981 } 983 982 return rv; 984 983 } 984 + static DEVICE_ATTR_RW(ledd); 985 985 986 986 /* 987 987 * Wireless ··· 1016 1014 return 0; 1017 1015 } 1018 1016 1019 - static ssize_t show_wlan(struct device *dev, 1020 - struct device_attribute *attr, char *buf) 1017 + static ssize_t wlan_show(struct device *dev, struct device_attribute *attr, 1018 + char *buf) 1021 1019 { 1022 1020 struct asus_laptop *asus = dev_get_drvdata(dev); 1023 1021 1024 1022 return sprintf(buf, "%d\n", asus_wireless_status(asus, WL_RSTS)); 1025 1023 } 1026 1024 1027 - static ssize_t store_wlan(struct device *dev, struct device_attribute *attr, 1025 + static ssize_t wlan_store(struct device *dev, struct device_attribute *attr, 1028 1026 const char *buf, size_t count) 1029 1027 { 1030 1028 struct asus_laptop *asus = dev_get_drvdata(dev); 1031 1029 1032 1030 return sysfs_acpi_set(asus, buf, count, METHOD_WLAN); 1033 1031 } 1032 + static DEVICE_ATTR_RW(wlan); 1034 1033 1035 1034 /*e 1036 1035 * Bluetooth ··· 1045 1042 return 0; 1046 1043 } 1047 1044 1048 - static ssize_t show_bluetooth(struct device *dev, 1049 - struct device_attribute *attr, char *buf) 1045 + static ssize_t bluetooth_show(struct device *dev, struct device_attribute *attr, 1046 + char *buf) 1050 1047 { 1051 1048 struct asus_laptop *asus = dev_get_drvdata(dev); 1052 1049 1053 1050 return sprintf(buf, "%d\n", asus_wireless_status(asus, BT_RSTS)); 1054 1051 } 1055 1052 1056 - static ssize_t store_bluetooth(struct device *dev, 1053 + static ssize_t bluetooth_store(struct device *dev, 1057 1054 struct device_attribute *attr, const char *buf, 1058 1055 size_t count) 1059 1056 { ··· 1061 1058 1062 1059 return sysfs_acpi_set(asus, buf, count, METHOD_BLUETOOTH); 1063 1060 } 1061 + static DEVICE_ATTR_RW(bluetooth); 1064 1062 1065 1063 /* 1066 1064 * Wimax ··· 1075 1071 return 0; 1076 1072 } 1077 1073 1078 - static ssize_t show_wimax(struct device *dev, 1079 - struct device_attribute *attr, char *buf) 1074 + static ssize_t wimax_show(struct device *dev, struct device_attribute *attr, 1075 + char *buf) 1080 1076 { 1081 1077 struct asus_laptop *asus = dev_get_drvdata(dev); 1082 1078 1083 1079 return sprintf(buf, "%d\n", asus_wireless_status(asus, WM_RSTS)); 1084 1080 } 1085 1081 1086 - static ssize_t store_wimax(struct device *dev, 1087 - struct device_attribute *attr, const char *buf, 1088 - size_t count) 1082 + static ssize_t wimax_store(struct device *dev, struct device_attribute *attr, 1083 + const char *buf, size_t count) 1089 1084 { 1090 1085 struct asus_laptop *asus = dev_get_drvdata(dev); 1091 1086 1092 1087 return sysfs_acpi_set(asus, buf, count, METHOD_WIMAX); 1093 1088 } 1089 + static DEVICE_ATTR_RW(wimax); 1094 1090 1095 1091 /* 1096 1092 * Wwan ··· 1104 1100 return 0; 1105 1101 } 1106 1102 1107 - static ssize_t show_wwan(struct device *dev, 1108 - struct device_attribute *attr, char *buf) 1103 + static ssize_t wwan_show(struct device *dev, struct device_attribute *attr, 1104 + char *buf) 1109 1105 { 1110 1106 struct asus_laptop *asus = dev_get_drvdata(dev); 1111 1107 1112 1108 return sprintf(buf, "%d\n", asus_wireless_status(asus, WW_RSTS)); 1113 1109 } 1114 1110 1115 - static ssize_t store_wwan(struct device *dev, 1116 - struct device_attribute *attr, const char *buf, 1117 - size_t count) 1111 + static ssize_t wwan_store(struct device *dev, struct device_attribute *attr, 1112 + const char *buf, size_t count) 1118 1113 { 1119 1114 struct asus_laptop *asus = dev_get_drvdata(dev); 1120 1115 1121 1116 return sysfs_acpi_set(asus, buf, count, METHOD_WWAN); 1122 1117 } 1118 + static DEVICE_ATTR_RW(wwan); 1123 1119 1124 1120 /* 1125 1121 * Display ··· 1139 1135 * displays hooked up simultaneously, so be warned. See the acpi4asus README 1140 1136 * for more info. 1141 1137 */ 1142 - static ssize_t store_disp(struct device *dev, struct device_attribute *attr, 1143 - const char *buf, size_t count) 1138 + static ssize_t display_store(struct device *dev, struct device_attribute *attr, 1139 + const char *buf, size_t count) 1144 1140 { 1145 1141 struct asus_laptop *asus = dev_get_drvdata(dev); 1146 1142 int rv, value; ··· 1150 1146 asus_set_display(asus, value); 1151 1147 return rv; 1152 1148 } 1149 + static DEVICE_ATTR_WO(display); 1153 1150 1154 1151 /* 1155 1152 * Light Sens ··· 1172 1167 asus->light_switch = value; 1173 1168 } 1174 1169 1175 - static ssize_t show_lssw(struct device *dev, 1176 - struct device_attribute *attr, char *buf) 1170 + static ssize_t ls_switch_show(struct device *dev, struct device_attribute *attr, 1171 + char *buf) 1177 1172 { 1178 1173 struct asus_laptop *asus = dev_get_drvdata(dev); 1179 1174 1180 1175 return sprintf(buf, "%d\n", asus->light_switch); 1181 1176 } 1182 1177 1183 - static ssize_t store_lssw(struct device *dev, struct device_attribute *attr, 1184 - const char *buf, size_t count) 1178 + static ssize_t ls_switch_store(struct device *dev, 1179 + struct device_attribute *attr, const char *buf, 1180 + size_t count) 1185 1181 { 1186 1182 struct asus_laptop *asus = dev_get_drvdata(dev); 1187 1183 int rv, value; ··· 1193 1187 1194 1188 return rv; 1195 1189 } 1190 + static DEVICE_ATTR_RW(ls_switch); 1196 1191 1197 1192 static void asus_als_level(struct asus_laptop *asus, int value) 1198 1193 { ··· 1202 1195 asus->light_level = value; 1203 1196 } 1204 1197 1205 - static ssize_t show_lslvl(struct device *dev, 1206 - struct device_attribute *attr, char *buf) 1198 + static ssize_t ls_level_show(struct device *dev, struct device_attribute *attr, 1199 + char *buf) 1207 1200 { 1208 1201 struct asus_laptop *asus = dev_get_drvdata(dev); 1209 1202 1210 1203 return sprintf(buf, "%d\n", asus->light_level); 1211 1204 } 1212 1205 1213 - static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr, 1214 - const char *buf, size_t count) 1206 + static ssize_t ls_level_store(struct device *dev, struct device_attribute *attr, 1207 + const char *buf, size_t count) 1215 1208 { 1216 1209 struct asus_laptop *asus = dev_get_drvdata(dev); 1217 1210 int rv, value; ··· 1225 1218 1226 1219 return rv; 1227 1220 } 1221 + static DEVICE_ATTR_RW(ls_level); 1228 1222 1229 1223 static int pega_int_read(struct asus_laptop *asus, int arg, int *result) 1230 1224 { ··· 1242 1234 return err; 1243 1235 } 1244 1236 1245 - static ssize_t show_lsvalue(struct device *dev, 1246 - struct device_attribute *attr, char *buf) 1237 + static ssize_t ls_value_show(struct device *dev, struct device_attribute *attr, 1238 + char *buf) 1247 1239 { 1248 1240 struct asus_laptop *asus = dev_get_drvdata(dev); 1249 1241 int err, hi, lo; ··· 1255 1247 return sprintf(buf, "%d\n", 10 * hi + lo); 1256 1248 return err; 1257 1249 } 1250 + static DEVICE_ATTR_RO(ls_value); 1258 1251 1259 1252 /* 1260 1253 * GPS ··· 1283 1274 return 0; 1284 1275 } 1285 1276 1286 - static ssize_t show_gps(struct device *dev, 1287 - struct device_attribute *attr, char *buf) 1277 + static ssize_t gps_show(struct device *dev, struct device_attribute *attr, 1278 + char *buf) 1288 1279 { 1289 1280 struct asus_laptop *asus = dev_get_drvdata(dev); 1290 1281 1291 1282 return sprintf(buf, "%d\n", asus_gps_status(asus)); 1292 1283 } 1293 1284 1294 - static ssize_t store_gps(struct device *dev, struct device_attribute *attr, 1285 + static ssize_t gps_store(struct device *dev, struct device_attribute *attr, 1295 1286 const char *buf, size_t count) 1296 1287 { 1297 1288 struct asus_laptop *asus = dev_get_drvdata(dev); ··· 1307 1298 rfkill_set_sw_state(asus->gps.rfkill, !value); 1308 1299 return rv; 1309 1300 } 1301 + static DEVICE_ATTR_RW(gps); 1310 1302 1311 1303 /* 1312 1304 * rfkill ··· 1579 1569 asus_input_notify(asus, event); 1580 1570 } 1581 1571 1582 - static DEVICE_ATTR(infos, S_IRUGO, show_infos, NULL); 1583 - static DEVICE_ATTR(wlan, S_IRUGO | S_IWUSR, show_wlan, store_wlan); 1584 - static DEVICE_ATTR(bluetooth, S_IRUGO | S_IWUSR, 1585 - show_bluetooth, store_bluetooth); 1586 - static DEVICE_ATTR(wimax, S_IRUGO | S_IWUSR, show_wimax, store_wimax); 1587 - static DEVICE_ATTR(wwan, S_IRUGO | S_IWUSR, show_wwan, store_wwan); 1588 - static DEVICE_ATTR(display, S_IWUSR, NULL, store_disp); 1589 - static DEVICE_ATTR(ledd, S_IRUGO | S_IWUSR, show_ledd, store_ledd); 1590 - static DEVICE_ATTR(ls_value, S_IRUGO, show_lsvalue, NULL); 1591 - static DEVICE_ATTR(ls_level, S_IRUGO | S_IWUSR, show_lslvl, store_lslvl); 1592 - static DEVICE_ATTR(ls_switch, S_IRUGO | S_IWUSR, show_lssw, store_lssw); 1593 - static DEVICE_ATTR(gps, S_IRUGO | S_IWUSR, show_gps, store_gps); 1594 - 1595 1572 static struct attribute *asus_attributes[] = { 1596 1573 &dev_attr_infos.attr, 1597 1574 &dev_attr_wlan.attr, ··· 1613 1616 else 1614 1617 goto normal; 1615 1618 1616 - return supported; 1619 + return supported ? attr->mode : 0; 1617 1620 } 1618 1621 1619 1622 normal:
+1 -1
drivers/platform/x86/classmate-laptop.c
··· 520 520 { 521 521 union acpi_object param[2]; 522 522 struct acpi_object_list input; 523 - struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, 0 }; 523 + struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; 524 524 unsigned char *locs; 525 525 acpi_status status; 526 526
+4 -3
drivers/platform/x86/fujitsu-laptop.c
··· 64 64 #include <linux/acpi.h> 65 65 #include <linux/dmi.h> 66 66 #include <linux/backlight.h> 67 + #include <linux/fb.h> 67 68 #include <linux/input.h> 68 69 #include <linux/kfifo.h> 69 70 #include <linux/platform_device.h> ··· 399 398 static int bl_update_status(struct backlight_device *b) 400 399 { 401 400 int ret; 402 - if (b->props.power == 4) 401 + if (b->props.power == FB_BLANK_POWERDOWN) 403 402 ret = call_fext_func(FUNC_BACKLIGHT, 0x1, 0x4, 0x3); 404 403 else 405 404 ret = call_fext_func(FUNC_BACKLIGHT, 0x1, 0x4, 0x0); ··· 1140 1139 1141 1140 if (!acpi_video_backlight_support()) { 1142 1141 if (call_fext_func(FUNC_BACKLIGHT, 0x2, 0x4, 0x0) == 3) 1143 - fujitsu->bl_device->props.power = 4; 1142 + fujitsu->bl_device->props.power = FB_BLANK_POWERDOWN; 1144 1143 else 1145 - fujitsu->bl_device->props.power = 0; 1144 + fujitsu->bl_device->props.power = FB_BLANK_UNBLANK; 1146 1145 } 1147 1146 1148 1147 pr_info("driver " FUJITSU_DRIVER_VERSION " successfully loaded\n");
+32 -45
drivers/platform/x86/intel_scu_ipc.c
··· 1 1 /* 2 2 * intel_scu_ipc.c: Driver for the Intel SCU IPC mechanism 3 3 * 4 - * (C) Copyright 2008-2010 Intel Corporation 4 + * (C) Copyright 2008-2010,2015 Intel Corporation 5 5 * Author: Sreedhara DS (sreedhara.ds@intel.com) 6 6 * 7 7 * This program is free software; you can redistribute it and/or ··· 43 43 /* 44 44 * IPC register summary 45 45 * 46 - * IPC register blocks are memory mapped at fixed address of 0xFF11C000 46 + * IPC register blocks are memory mapped at fixed address of PCI BAR 0. 47 47 * To read or write information to the SCU, driver writes to IPC-1 memory 48 - * mapped registers (base address 0xFF11C000). The following is the IPC 49 - * mechanism 48 + * mapped registers. The following is the IPC mechanism 50 49 * 51 50 * 1. IA core cDMI interface claims this transaction and converts it to a 52 51 * Transaction Layer Packet (TLP) message which is sent across the cDMI. ··· 66 67 #define PCI_DEVICE_ID_CLOVERVIEW 0x08ea 67 68 #define PCI_DEVICE_ID_TANGIER 0x11a0 68 69 69 - /* intel scu ipc driver data*/ 70 + /* intel scu ipc driver data */ 70 71 struct intel_scu_ipc_pdata_t { 71 - u32 ipc_base; 72 72 u32 i2c_base; 73 - u32 ipc_len; 74 73 u32 i2c_len; 75 74 u8 irq_mode; 76 75 }; 77 76 78 77 static struct intel_scu_ipc_pdata_t intel_scu_ipc_lincroft_pdata = { 79 - .ipc_base = 0xff11c000, 80 78 .i2c_base = 0xff12b000, 81 - .ipc_len = 0x100, 82 79 .i2c_len = 0x10, 83 80 .irq_mode = 0, 84 81 }; 85 82 86 83 /* Penwell and Cloverview */ 87 84 static struct intel_scu_ipc_pdata_t intel_scu_ipc_penwell_pdata = { 88 - .ipc_base = 0xff11c000, 89 85 .i2c_base = 0xff12b000, 90 - .ipc_len = 0x100, 91 86 .i2c_len = 0x10, 92 87 .irq_mode = 1, 93 88 }; 94 89 95 90 static struct intel_scu_ipc_pdata_t intel_scu_ipc_tangier_pdata = { 96 - .ipc_base = 0xff009000, 97 91 .i2c_base = 0xff00d000, 98 - .ipc_len = 0x100, 99 92 .i2c_len = 0x10, 100 93 .irq_mode = 0, 101 94 }; ··· 104 113 }; 105 114 106 115 static struct intel_scu_ipc_dev ipcdev; /* Only one for now */ 107 - 108 - static int platform; /* Platform type */ 109 116 110 117 /* 111 118 * IPC Read Buffer (Read Only): ··· 149 160 * Format: 150 161 * |rfu3(8)|error code(8)|initiator id(8)|cmd id(4)|rfu1(2)|error(1)|busy(1)| 151 162 */ 152 - 153 163 static inline u8 ipc_read_status(void) 154 164 { 155 165 return __raw_readl(ipcdev.ipc_base + 0x04); ··· 164 176 return readl(ipcdev.ipc_base + IPC_READ_BUFFER + offset); 165 177 } 166 178 167 - static inline int busy_loop(void) /* Wait till scu status is busy */ 179 + /* Wait till scu status is busy */ 180 + static inline int busy_loop(void) 168 181 { 169 - u32 status = 0; 170 - u32 loop_count = 0; 182 + u32 status = ipc_read_status(); 183 + u32 loop_count = 100000; 171 184 172 - status = ipc_read_status(); 173 - while (status & 1) { 185 + /* break if scu doesn't reset busy bit after huge retry */ 186 + while ((status & BIT(0)) && --loop_count) { 174 187 udelay(1); /* scu processing time is in few u secods */ 175 188 status = ipc_read_status(); 176 - loop_count++; 177 - /* break if scu doesn't reset busy bit after huge retry */ 178 - if (loop_count > 100000) { 179 - dev_err(&ipcdev.pdev->dev, "IPC timed out"); 180 - return -ETIMEDOUT; 181 - } 182 189 } 183 - if ((status >> 1) & 1) 190 + 191 + if (status & BIT(0)) { 192 + dev_err(&ipcdev.pdev->dev, "IPC timed out"); 193 + return -ETIMEDOUT; 194 + } 195 + 196 + if (status & BIT(1)) 184 197 return -EIO; 185 198 186 199 return 0; ··· 199 210 } 200 211 201 212 status = ipc_read_status(); 202 - 203 - if ((status >> 1) & 1) 213 + if (status & BIT(1)) 204 214 return -EIO; 205 215 206 216 return 0; 207 217 } 208 218 209 - int intel_scu_ipc_check_status(void) 219 + static int intel_scu_ipc_check_status(void) 210 220 { 211 221 return ipcdev.irq_mode ? ipc_wait_for_interrupt() : busy_loop(); 212 222 } ··· 236 248 if (id == IPC_CMD_PCNTRL_R) { 237 249 for (nc = 0, offset = 0; nc < count; nc++, offset += 4) 238 250 ipc_data_writel(wbuf[nc], offset); 239 - ipc_command((count*2) << 16 | id << 12 | 0 << 8 | op); 251 + ipc_command((count * 2) << 16 | id << 12 | 0 << 8 | op); 240 252 } else if (id == IPC_CMD_PCNTRL_W) { 241 253 for (nc = 0; nc < count; nc++, offset += 1) 242 254 cbuf[offset] = data[nc]; 243 255 for (nc = 0, offset = 0; nc < count; nc++, offset += 4) 244 256 ipc_data_writel(wbuf[nc], offset); 245 - ipc_command((count*3) << 16 | id << 12 | 0 << 8 | op); 257 + ipc_command((count * 3) << 16 | id << 12 | 0 << 8 | op); 246 258 } else if (id == IPC_CMD_PCNTRL_M) { 247 259 cbuf[offset] = data[0]; 248 260 cbuf[offset + 1] = data[1]; 249 261 ipc_data_writel(wbuf[0], 0); /* Write wbuff */ 250 - ipc_command(4 << 16 | id << 12 | 0 << 8 | op); 262 + ipc_command(4 << 16 | id << 12 | 0 << 8 | op); 251 263 } 252 264 253 265 err = intel_scu_ipc_check_status(); ··· 289 301 */ 290 302 int intel_scu_ipc_ioread16(u16 addr, u16 *data) 291 303 { 292 - u16 x[2] = {addr, addr + 1 }; 304 + u16 x[2] = {addr, addr + 1}; 293 305 return pwr_reg_rdwr(x, (u8 *)data, 2, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_R); 294 306 } 295 307 EXPORT_SYMBOL(intel_scu_ipc_ioread16); ··· 339 351 */ 340 352 int intel_scu_ipc_iowrite16(u16 addr, u16 data) 341 353 { 342 - u16 x[2] = {addr, addr + 1 }; 354 + u16 x[2] = {addr, addr + 1}; 343 355 return pwr_reg_rdwr(x, (u8 *)&data, 2, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_W); 344 356 } 345 357 EXPORT_SYMBOL(intel_scu_ipc_iowrite16); ··· 399 411 return pwr_reg_rdwr(addr, data, len, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_W); 400 412 } 401 413 EXPORT_SYMBOL(intel_scu_ipc_writev); 402 - 403 414 404 415 /** 405 416 * intel_scu_ipc_update_register - r/m/w a register ··· 462 475 * Issue a command to the SCU which involves data transfers. Do the 463 476 * data copies under the lock but leave it for the caller to interpret 464 477 */ 465 - 466 478 int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen, 467 - u32 *out, int outlen) 479 + u32 *out, int outlen) 468 480 { 469 481 int i, err; 470 482 ··· 489 503 } 490 504 EXPORT_SYMBOL(intel_scu_ipc_command); 491 505 492 - /*I2C commands */ 506 + /* I2C commands */ 493 507 #define IPC_I2C_WRITE 1 /* I2C Write command */ 494 508 #define IPC_I2C_READ 2 /* I2C Read command */ 495 509 ··· 563 577 { 564 578 int err; 565 579 struct intel_scu_ipc_pdata_t *pdata; 566 - resource_size_t pci_resource; 580 + resource_size_t base; 567 581 568 582 if (ipcdev.pdev) /* We support only one SCU */ 569 583 return -EBUSY; ··· 581 595 if (err) 582 596 return err; 583 597 584 - pci_resource = pci_resource_start(dev, 0); 585 - if (!pci_resource) 598 + base = pci_resource_start(dev, 0); 599 + if (!base) 586 600 return -ENOMEM; 587 601 588 602 init_completion(&ipcdev.cmd_complete); ··· 590 604 if (request_irq(dev->irq, ioc, 0, "intel_scu_ipc", &ipcdev)) 591 605 return -EBUSY; 592 606 593 - ipcdev.ipc_base = ioremap_nocache(pdata->ipc_base, pdata->ipc_len); 607 + ipcdev.ipc_base = ioremap_nocache(base, pci_resource_len(dev, 0)); 594 608 if (!ipcdev.ipc_base) 595 609 return -ENOMEM; 596 610 ··· 652 666 .remove = ipc_remove, 653 667 }; 654 668 655 - 656 669 static int __init intel_scu_ipc_init(void) 657 670 { 671 + int platform; /* Platform type */ 672 + 658 673 platform = intel_mid_identify_cpu(); 659 674 if (platform == 0) 660 675 return -ENODEV;
+139 -7
drivers/platform/x86/samsung-laptop.c
··· 124 124 u16 get_wireless_status; 125 125 u16 set_wireless_status; 126 126 127 + /* 0x80 is off, 0x81 is on */ 128 + u16 get_lid_handling; 129 + u16 set_lid_handling; 130 + 127 131 /* 0x81 to read, (0x82 | level << 8) to set, 0xaabb to enable */ 128 132 u16 kbd_backlight; 129 133 ··· 198 194 .get_wireless_status = 0xFFFF, 199 195 .set_wireless_status = 0xFFFF, 200 196 197 + .get_lid_handling = 0xFFFF, 198 + .set_lid_handling = 0xFFFF, 199 + 201 200 .kbd_backlight = 0xFFFF, 202 201 203 202 .set_linux = 0x0a, ··· 260 253 261 254 .get_wireless_status = 0x69, 262 255 .set_wireless_status = 0x6a, 256 + 257 + .get_lid_handling = 0x6d, 258 + .set_lid_handling = 0x6e, 263 259 264 260 .kbd_backlight = 0x78, 265 261 ··· 363 353 bool broken_acpi_video; 364 354 bool four_kbd_backlight_levels; 365 355 bool enable_kbd_backlight; 356 + bool use_native_backlight; 357 + bool lid_handling; 366 358 }; 367 359 368 360 static struct samsung_quirks samsung_unknown = {}; ··· 373 361 .broken_acpi_video = true, 374 362 }; 375 363 364 + static struct samsung_quirks samsung_use_native_backlight = { 365 + .use_native_backlight = true, 366 + }; 367 + 376 368 static struct samsung_quirks samsung_np740u3e = { 377 369 .four_kbd_backlight_levels = true, 378 370 .enable_kbd_backlight = true, 371 + }; 372 + 373 + static struct samsung_quirks samsung_lid_handling = { 374 + .lid_handling = true, 379 375 }; 380 376 381 377 static bool force; ··· 768 748 struct samsung_laptop *samsung = dev_get_drvdata(dev); 769 749 int ret, value; 770 750 771 - if (!count || sscanf(buf, "%i", &value) != 1) 751 + if (!count || kstrtoint(buf, 0, &value) != 0) 772 752 return -EINVAL; 773 753 774 754 ret = write_battery_life_extender(samsung, !!value); ··· 837 817 struct samsung_laptop *samsung = dev_get_drvdata(dev); 838 818 int ret, value; 839 819 840 - if (!count || sscanf(buf, "%i", &value) != 1) 820 + if (!count || kstrtoint(buf, 0, &value) != 0) 841 821 return -EINVAL; 842 822 843 823 ret = write_usb_charge(samsung, !!value); ··· 850 830 static DEVICE_ATTR(usb_charge, S_IWUSR | S_IRUGO, 851 831 get_usb_charge, set_usb_charge); 852 832 833 + static int read_lid_handling(struct samsung_laptop *samsung) 834 + { 835 + const struct sabi_commands *commands = &samsung->config->commands; 836 + struct sabi_data data; 837 + int retval; 838 + 839 + if (commands->get_lid_handling == 0xFFFF) 840 + return -ENODEV; 841 + 842 + memset(&data, 0, sizeof(data)); 843 + retval = sabi_command(samsung, commands->get_lid_handling, 844 + &data, &data); 845 + 846 + if (retval) 847 + return retval; 848 + 849 + return data.data[0] & 0x1; 850 + } 851 + 852 + static int write_lid_handling(struct samsung_laptop *samsung, 853 + int enabled) 854 + { 855 + const struct sabi_commands *commands = &samsung->config->commands; 856 + struct sabi_data data; 857 + 858 + memset(&data, 0, sizeof(data)); 859 + data.data[0] = 0x80 | enabled; 860 + return sabi_command(samsung, commands->set_lid_handling, 861 + &data, NULL); 862 + } 863 + 864 + static ssize_t get_lid_handling(struct device *dev, 865 + struct device_attribute *attr, 866 + char *buf) 867 + { 868 + struct samsung_laptop *samsung = dev_get_drvdata(dev); 869 + int ret; 870 + 871 + ret = read_lid_handling(samsung); 872 + if (ret < 0) 873 + return ret; 874 + 875 + return sprintf(buf, "%d\n", ret); 876 + } 877 + 878 + static ssize_t set_lid_handling(struct device *dev, 879 + struct device_attribute *attr, 880 + const char *buf, size_t count) 881 + { 882 + struct samsung_laptop *samsung = dev_get_drvdata(dev); 883 + int ret, value; 884 + 885 + if (!count || kstrtoint(buf, 0, &value) != 0) 886 + return -EINVAL; 887 + 888 + ret = write_lid_handling(samsung, !!value); 889 + if (ret < 0) 890 + return ret; 891 + 892 + return count; 893 + } 894 + 895 + static DEVICE_ATTR(lid_handling, S_IWUSR | S_IRUGO, 896 + get_lid_handling, set_lid_handling); 897 + 853 898 static struct attribute *platform_attributes[] = { 854 899 &dev_attr_performance_level.attr, 855 900 &dev_attr_battery_life_extender.attr, 856 901 &dev_attr_usb_charge.attr, 902 + &dev_attr_lid_handling.attr, 857 903 NULL 858 904 }; 859 905 ··· 1040 954 if (samsung->config->sabi_version == 3) 1041 955 return samsung_rfkill_init_swsmi(samsung); 1042 956 return 0; 957 + } 958 + 959 + static void samsung_lid_handling_exit(struct samsung_laptop *samsung) 960 + { 961 + if (samsung->quirks->lid_handling) 962 + write_lid_handling(samsung, 0); 963 + } 964 + 965 + static int __init samsung_lid_handling_init(struct samsung_laptop *samsung) 966 + { 967 + int retval = 0; 968 + 969 + if (samsung->quirks->lid_handling) 970 + retval = write_lid_handling(samsung, 1); 971 + 972 + return retval; 1043 973 } 1044 974 1045 975 static int kbd_backlight_enable(struct samsung_laptop *samsung) ··· 1213 1111 } 1214 1112 1215 1113 static umode_t samsung_sysfs_is_visible(struct kobject *kobj, 1216 - struct attribute *attr, int idx) 1114 + struct attribute *attr, int idx) 1217 1115 { 1218 1116 struct device *dev = container_of(kobj, struct device, kobj); 1219 1117 struct platform_device *pdev = to_platform_device(dev); ··· 1226 1124 ok = !!(read_battery_life_extender(samsung) >= 0); 1227 1125 if (attr == &dev_attr_usb_charge.attr) 1228 1126 ok = !!(read_usb_charge(samsung) >= 0); 1127 + if (attr == &dev_attr_lid_handling.attr) 1128 + ok = !!(read_lid_handling(samsung) >= 0); 1229 1129 1230 1130 return ok ? attr->mode : 0; 1231 1131 } ··· 1461 1357 samsung_sabi_diag(samsung); 1462 1358 1463 1359 /* Try to find one of the signatures in memory to find the header */ 1464 - for (i = 0; sabi_configs[i].test_string != 0; ++i) { 1360 + for (i = 0; sabi_configs[i].test_string != NULL; ++i) { 1465 1361 samsung->config = &sabi_configs[i]; 1466 1362 loca = find_signature(samsung->f0000_segment, 1467 1363 samsung->config->test_string); ··· 1540 1436 samsung->quirks->enable_kbd_backlight) 1541 1437 kbd_backlight_enable(samsung); 1542 1438 1439 + if (val == PM_POST_HIBERNATION && samsung->quirks->lid_handling) 1440 + write_lid_handling(samsung, 1); 1441 + 1543 1442 return 0; 1544 1443 } 1545 1444 ··· 1614 1507 DMI_MATCH(DMI_PRODUCT_NAME, "N150P"), 1615 1508 DMI_MATCH(DMI_BOARD_NAME, "N150P"), 1616 1509 }, 1617 - .driver_data = &samsung_broken_acpi_video, 1510 + .driver_data = &samsung_use_native_backlight, 1618 1511 }, 1619 1512 { 1620 1513 .callback = samsung_dmi_matched, ··· 1624 1517 DMI_MATCH(DMI_PRODUCT_NAME, "N145P/N250P/N260P"), 1625 1518 DMI_MATCH(DMI_BOARD_NAME, "N145P/N250P/N260P"), 1626 1519 }, 1627 - .driver_data = &samsung_broken_acpi_video, 1520 + .driver_data = &samsung_use_native_backlight, 1628 1521 }, 1629 1522 { 1630 1523 .callback = samsung_dmi_matched, ··· 1664 1557 DMI_MATCH(DMI_PRODUCT_NAME, "N250P"), 1665 1558 DMI_MATCH(DMI_BOARD_NAME, "N250P"), 1666 1559 }, 1667 - .driver_data = &samsung_broken_acpi_video, 1560 + .driver_data = &samsung_use_native_backlight, 1668 1561 }, 1669 1562 { 1670 1563 .callback = samsung_dmi_matched, ··· 1684 1577 DMI_MATCH(DMI_PRODUCT_NAME, "730U3E/740U3E"), 1685 1578 }, 1686 1579 .driver_data = &samsung_np740u3e, 1580 + }, 1581 + { 1582 + .callback = samsung_dmi_matched, 1583 + .ident = "300V3Z/300V4Z/300V5Z", 1584 + .matches = { 1585 + DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), 1586 + DMI_MATCH(DMI_PRODUCT_NAME, "300V3Z/300V4Z/300V5Z"), 1587 + }, 1588 + .driver_data = &samsung_lid_handling, 1687 1589 }, 1688 1590 { }, 1689 1591 }; ··· 1732 1616 pr_info("Disabling ACPI video driver\n"); 1733 1617 acpi_video_unregister(); 1734 1618 } 1619 + 1620 + if (samsung->quirks->use_native_backlight) { 1621 + pr_info("Using native backlight driver\n"); 1622 + /* Tell acpi-video to not handle the backlight */ 1623 + acpi_video_dmi_promote_vendor(); 1624 + acpi_video_unregister(); 1625 + /* And also do not handle it ourselves */ 1626 + samsung->handle_backlight = false; 1627 + } 1735 1628 #endif 1736 1629 1737 1630 ret = samsung_platform_init(samsung); ··· 1773 1648 if (ret) 1774 1649 goto error_leds; 1775 1650 1651 + ret = samsung_lid_handling_init(samsung); 1652 + if (ret) 1653 + goto error_lid_handling; 1654 + 1776 1655 ret = samsung_debugfs_init(samsung); 1777 1656 if (ret) 1778 1657 goto error_debugfs; ··· 1788 1659 return ret; 1789 1660 1790 1661 error_debugfs: 1662 + samsung_lid_handling_exit(samsung); 1663 + error_lid_handling: 1791 1664 samsung_leds_exit(samsung); 1792 1665 error_leds: 1793 1666 samsung_rfkill_exit(samsung); ··· 1814 1683 unregister_pm_notifier(&samsung->pm_nb); 1815 1684 1816 1685 samsung_debugfs_exit(samsung); 1686 + samsung_lid_handling_exit(samsung); 1817 1687 samsung_leds_exit(samsung); 1818 1688 samsung_rfkill_exit(samsung); 1819 1689 samsung_backlight_exit(samsung);
+1 -1
drivers/platform/x86/sony-laptop.c
··· 1032 1032 u8 offset; 1033 1033 u8 maxlvl; 1034 1034 }; 1035 - struct sony_backlight_props sony_bl_props; 1035 + static struct sony_backlight_props sony_bl_props; 1036 1036 1037 1037 static int sony_backlight_update_status(struct backlight_device *bd) 1038 1038 {
+20 -4
drivers/platform/x86/thinkpad_acpi.c
··· 196 196 /* Key-related user-interface events */ 197 197 TP_HKEY_EV_KEY_NUMLOCK = 0x6000, /* NumLock key pressed */ 198 198 TP_HKEY_EV_KEY_FN = 0x6005, /* Fn key pressed? E420 */ 199 + TP_HKEY_EV_KEY_FN_ESC = 0x6060, /* Fn+Esc key pressed X240 */ 199 200 200 201 /* Thermal events */ 201 202 TP_HKEY_EV_ALARM_BAT_HOT = 0x6011, /* battery too hot */ ··· 3457 3456 LAYFLAT_MODE 3458 3457 }; 3459 3458 3460 - const int adaptive_keyboard_modes[] = { 3459 + static const int adaptive_keyboard_modes[] = { 3461 3460 HOME_MODE, 3462 3461 /* WEB_BROWSER_MODE = 2, 3463 3462 WEB_CONFERENCE_MODE = 3, */ ··· 3713 3712 3714 3713 case TP_HKEY_EV_KEY_NUMLOCK: 3715 3714 case TP_HKEY_EV_KEY_FN: 3715 + case TP_HKEY_EV_KEY_FN_ESC: 3716 3716 /* key press events, we just ignore them as long as the EC 3717 3717 * is still reporting them in the normal keyboard stream */ 3718 3718 *send_acpi_ev = false; ··· 8885 8883 return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z'); 8886 8884 } 8887 8885 8888 - /* Most models: xxyTkkWW (#.##c); Ancient 570/600 and -SL lacks (#.##c) */ 8889 8886 static bool __pure __init tpacpi_is_valid_fw_id(const char * const s, 8890 8887 const char t) 8891 8888 { 8892 - return s && strlen(s) >= 8 && 8889 + /* 8890 + * Most models: xxyTkkWW (#.##c) 8891 + * Ancient 570/600 and -SL lacks (#.##c) 8892 + */ 8893 + if (s && strlen(s) >= 8 && 8893 8894 tpacpi_is_fw_digit(s[0]) && 8894 8895 tpacpi_is_fw_digit(s[1]) && 8895 8896 s[2] == t && 8896 8897 (s[3] == 'T' || s[3] == 'N') && 8897 8898 tpacpi_is_fw_digit(s[4]) && 8898 - tpacpi_is_fw_digit(s[5]); 8899 + tpacpi_is_fw_digit(s[5])) 8900 + return true; 8901 + 8902 + /* New models: xxxyTkkW (#.##c); T550 and some others */ 8903 + return s && strlen(s) >= 8 && 8904 + tpacpi_is_fw_digit(s[0]) && 8905 + tpacpi_is_fw_digit(s[1]) && 8906 + tpacpi_is_fw_digit(s[2]) && 8907 + s[3] == t && 8908 + (s[4] == 'T' || s[4] == 'N') && 8909 + tpacpi_is_fw_digit(s[5]) && 8910 + tpacpi_is_fw_digit(s[6]); 8899 8911 } 8900 8912 8901 8913 /* returns 0 - probe ok, or < 0 - probe error.
+896 -135
drivers/platform/x86/toshiba_acpi.c
··· 1 1 /* 2 2 * toshiba_acpi.c - Toshiba Laptop ACPI Extras 3 3 * 4 - * 5 4 * Copyright (C) 2002-2004 John Belmonte 6 5 * Copyright (C) 2008 Philip Langdale 7 6 * Copyright (C) 2010 Pierre Ducroquet 8 - * Copyright (C) 2014 Azael Avalos 7 + * Copyright (C) 2014-2015 Azael Avalos 9 8 * 10 9 * This program is free software; you can redistribute it and/or modify 11 10 * it under the terms of the GNU General Public License as published by ··· 16 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 18 * GNU General Public License for more details. 18 19 * 19 - * You should have received a copy of the GNU General Public License 20 - * along with this program; if not, write to the Free Software 21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 - * 20 + * The full GNU General Public License is included in this distribution in 21 + * the file called "COPYING". 23 22 * 24 23 * The devolpment page for this driver is located at 25 24 * http://memebeam.org/toys/ToshibaAcpiDriver. ··· 27 30 * engineering the Windows drivers 28 31 * Yasushi Nagato - changes for linux kernel 2.4 -> 2.5 29 32 * Rob Miller - TV out and hotkeys help 30 - * 31 - * 32 - * TODO 33 - * 34 33 */ 35 34 36 35 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 37 36 38 - #define TOSHIBA_ACPI_VERSION "0.20" 37 + #define TOSHIBA_ACPI_VERSION "0.21" 39 38 #define PROC_INTERFACE_VERSION 1 40 39 41 40 #include <linux/kernel.h> ··· 50 57 #include <linux/i8042.h> 51 58 #include <linux/acpi.h> 52 59 #include <linux/dmi.h> 53 - #include <asm/uaccess.h> 60 + #include <linux/uaccess.h> 54 61 55 62 MODULE_AUTHOR("John Belmonte"); 56 63 MODULE_DESCRIPTION("Toshiba Laptop ACPI Extras Driver"); ··· 64 71 /* Toshiba ACPI method paths */ 65 72 #define METHOD_VIDEO_OUT "\\_SB_.VALX.DSSX" 66 73 67 - /* The Toshiba configuration interface is composed of the HCI and the SCI, 74 + /* 75 + * The Toshiba configuration interface is composed of the HCI and the SCI, 68 76 * which are defined as follows: 69 77 * 70 78 * HCI is Toshiba's "Hardware Control Interface" which is supposed to ··· 102 108 #define TOS_FIFO_EMPTY 0x8c00 103 109 #define TOS_DATA_NOT_AVAILABLE 0x8d20 104 110 #define TOS_NOT_INITIALIZED 0x8d50 111 + #define TOS_NOT_INSTALLED 0x8e00 105 112 106 113 /* registers */ 107 114 #define HCI_FAN 0x0004 ··· 116 121 #define HCI_KBD_ILLUMINATION 0x0095 117 122 #define HCI_ECO_MODE 0x0097 118 123 #define HCI_ACCELEROMETER2 0x00a6 124 + #define SCI_PANEL_POWER_ON 0x010d 119 125 #define SCI_ILLUMINATION 0x014e 126 + #define SCI_USB_SLEEP_CHARGE 0x0150 120 127 #define SCI_KBD_ILLUM_STATUS 0x015c 128 + #define SCI_USB_SLEEP_MUSIC 0x015e 129 + #define SCI_USB_THREE 0x0169 121 130 #define SCI_TOUCHPAD 0x050e 131 + #define SCI_KBD_FUNCTION_KEYS 0x0522 122 132 123 133 /* field definitions */ 124 134 #define HCI_ACCEL_MASK 0x7fff ··· 146 146 #define SCI_KBD_MODE_ON 0x8 147 147 #define SCI_KBD_MODE_OFF 0x10 148 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 159 struct toshiba_acpi_dev { 151 160 struct acpi_device *acpi_dev; ··· 173 164 int kbd_type; 174 165 int kbd_mode; 175 166 int kbd_time; 167 + int usbsc_bat_level; 176 168 177 169 unsigned int illumination_supported:1; 178 170 unsigned int video_supported:1; ··· 187 177 unsigned int touchpad_supported:1; 188 178 unsigned int eco_supported:1; 189 179 unsigned int accelerometer_supported:1; 180 + unsigned int usb_sleep_charge_supported:1; 181 + unsigned int usb_rapid_charge_supported:1; 182 + unsigned int usb_sleep_music_supported:1; 183 + unsigned int kbd_function_keys_supported:1; 184 + unsigned int panel_power_on_supported:1; 185 + unsigned int usb_three_supported:1; 190 186 unsigned int sysfs_created:1; 191 187 192 188 struct mutex mutex; ··· 280 264 { KE_END, 0 }, 281 265 }; 282 266 283 - /* utility 267 + /* 268 + * Utility 284 269 */ 285 270 286 - static __inline__ void _set_bit(u32 * word, u32 mask, int value) 271 + static inline void _set_bit(u32 *word, u32 mask, int value) 287 272 { 288 273 *word = (*word & ~mask) | (mask * value); 289 274 } 290 275 291 - /* acpi interface wrappers 276 + /* 277 + * ACPI interface wrappers 292 278 */ 293 279 294 280 static int write_acpi_int(const char *methodName, int val) ··· 301 283 return (status == AE_OK) ? 0 : -EIO; 302 284 } 303 285 304 - /* Perform a raw configuration call. Here we don't care about input or output 286 + /* 287 + * Perform a raw configuration call. Here we don't care about input or output 305 288 * buffer format. 306 289 */ 307 290 static acpi_status tci_raw(struct toshiba_acpi_dev *dev, ··· 329 310 (char *)dev->method_hci, &params, 330 311 &results); 331 312 if ((status == AE_OK) && (out_objs->package.count <= TCI_WORDS)) { 332 - for (i = 0; i < out_objs->package.count; ++i) { 313 + for (i = 0; i < out_objs->package.count; ++i) 333 314 out[i] = out_objs->package.elements[i].integer.value; 334 - } 335 315 } 336 316 337 317 return status; 338 318 } 339 319 340 - /* common hci tasks (get or set one or two value) 320 + /* 321 + * Common hci tasks (get or set one or two value) 341 322 * 342 323 * In addition to the ACPI status, the HCI system returns a result which 343 324 * may be useful (such as "not supported"). ··· 357 338 u32 in[TCI_WORDS] = { HCI_GET, reg, 0, 0, 0, 0 }; 358 339 u32 out[TCI_WORDS]; 359 340 acpi_status status = tci_raw(dev, in, out); 341 + 360 342 if (ACPI_FAILURE(status)) 361 343 return TOS_FAILURE; 362 344 ··· 375 355 return ACPI_SUCCESS(status) ? out[0] : TOS_FAILURE; 376 356 } 377 357 378 - static u32 hci_read2(struct toshiba_acpi_dev *dev, u32 reg, u32 *out1, u32 *out2) 358 + static u32 hci_read2(struct toshiba_acpi_dev *dev, 359 + u32 reg, u32 *out1, u32 *out2) 379 360 { 380 361 u32 in[TCI_WORDS] = { HCI_GET, reg, *out1, *out2, 0, 0 }; 381 362 u32 out[TCI_WORDS]; 382 363 acpi_status status = tci_raw(dev, in, out); 364 + 383 365 if (ACPI_FAILURE(status)) 384 366 return TOS_FAILURE; 385 367 ··· 391 369 return out[0]; 392 370 } 393 371 394 - /* common sci tasks 372 + /* 373 + * Common sci tasks 395 374 */ 396 375 397 376 static int sci_open(struct toshiba_acpi_dev *dev) ··· 411 388 return 1; 412 389 } else if (out[0] == TOS_ALREADY_OPEN) { 413 390 pr_info("Toshiba SCI already opened\n"); 391 + return 1; 392 + } else if (out[0] == TOS_NOT_SUPPORTED) { 393 + /* 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. 397 + * 398 + * Simply return 1 if we hit those affected laptops to make the 399 + * supported features work. 400 + * 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. 404 + */ 414 405 return 1; 415 406 } else if (out[0] == TOS_NOT_PRESENT) { 416 407 pr_info("Toshiba SCI is not present\n"); ··· 458 421 u32 in[TCI_WORDS] = { SCI_GET, reg, 0, 0, 0, 0 }; 459 422 u32 out[TCI_WORDS]; 460 423 acpi_status status = tci_raw(dev, in, out); 424 + 461 425 if (ACPI_FAILURE(status)) 462 426 return TOS_FAILURE; 463 427 ··· 567 529 return 0; 568 530 } 569 531 570 - /* Check for keyboard backlight timeout max value, 532 + /* 533 + * Check for keyboard backlight timeout max value, 571 534 * previous kbd backlight implementation set this to 572 535 * 0x3c0003, and now the new implementation set this 573 - * to 0x3c001a, use this to distinguish between them 536 + * to 0x3c001a, use this to distinguish between them. 574 537 */ 575 538 if (out[3] == SCI_KBD_TIME_MAX) 576 539 dev->kbd_type = 2; ··· 706 667 static int toshiba_eco_mode_available(struct toshiba_acpi_dev *dev) 707 668 { 708 669 acpi_status status; 709 - u32 in[TCI_WORDS] = { HCI_GET, HCI_ECO_MODE, 0, 1, 0, 0 }; 670 + u32 in[TCI_WORDS] = { HCI_GET, HCI_ECO_MODE, 0, 0, 0, 0 }; 710 671 u32 out[TCI_WORDS]; 711 672 712 673 status = tci_raw(dev, in, out); 713 - if (ACPI_FAILURE(status) || out[0] == TOS_INPUT_DATA_ERROR) { 714 - pr_info("ACPI call to get ECO led failed\n"); 715 - return 0; 674 + if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) { 675 + pr_err("ACPI call to get ECO led failed\n"); 676 + } else if (out[0] == TOS_NOT_INSTALLED) { 677 + pr_info("ECO led not installed"); 678 + } else if (out[0] == TOS_INPUT_DATA_ERROR) { 679 + /* 680 + * If we receive 0x8300 (Input Data Error), it means that the 681 + * LED device is present, but that we just screwed the input 682 + * parameters. 683 + * 684 + * Let's query the status of the LED to see if we really have a 685 + * success response, indicating the actual presense of the LED, 686 + * bail out otherwise. 687 + */ 688 + in[3] = 1; 689 + status = tci_raw(dev, in, out); 690 + if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) 691 + pr_err("ACPI call to get ECO led failed\n"); 692 + else if (out[0] == TOS_SUCCESS) 693 + return 1; 716 694 } 717 695 718 - return 1; 696 + return 0; 719 697 } 720 698 721 - static enum led_brightness toshiba_eco_mode_get_status(struct led_classdev *cdev) 699 + static enum led_brightness 700 + toshiba_eco_mode_get_status(struct led_classdev *cdev) 722 701 { 723 702 struct toshiba_acpi_dev *dev = container_of(cdev, 724 703 struct toshiba_acpi_dev, eco_led); ··· 778 721 u32 out[TCI_WORDS]; 779 722 acpi_status status; 780 723 781 - /* Check if the accelerometer call exists, 724 + /* 725 + * Check if the accelerometer call exists, 782 726 * this call also serves as initialization 783 727 */ 784 728 status = tci_raw(dev, in, out); ··· 814 756 815 757 *xy = out[2]; 816 758 *z = out[4]; 759 + 760 + return 0; 761 + } 762 + 763 + /* Sleep (Charge and Music) utilities support */ 764 + static int toshiba_usb_sleep_charge_get(struct toshiba_acpi_dev *dev, 765 + u32 *mode) 766 + { 767 + u32 result; 768 + 769 + if (!sci_open(dev)) 770 + return -EIO; 771 + 772 + result = sci_read(dev, SCI_USB_SLEEP_CHARGE, mode); 773 + sci_close(dev); 774 + if (result == TOS_FAILURE) { 775 + pr_err("ACPI call to set USB S&C mode failed\n"); 776 + return -EIO; 777 + } else if (result == TOS_NOT_SUPPORTED) { 778 + pr_info("USB Sleep and Charge not supported\n"); 779 + return -ENODEV; 780 + } else if (result == TOS_INPUT_DATA_ERROR) { 781 + return -EIO; 782 + } 783 + 784 + return 0; 785 + } 786 + 787 + static int toshiba_usb_sleep_charge_set(struct toshiba_acpi_dev *dev, 788 + u32 mode) 789 + { 790 + u32 result; 791 + 792 + if (!sci_open(dev)) 793 + return -EIO; 794 + 795 + result = sci_write(dev, SCI_USB_SLEEP_CHARGE, mode); 796 + sci_close(dev); 797 + if (result == TOS_FAILURE) { 798 + pr_err("ACPI call to set USB S&C mode failed\n"); 799 + return -EIO; 800 + } else if (result == TOS_NOT_SUPPORTED) { 801 + pr_info("USB Sleep and Charge not supported\n"); 802 + return -ENODEV; 803 + } else if (result == TOS_INPUT_DATA_ERROR) { 804 + return -EIO; 805 + } 806 + 807 + return 0; 808 + } 809 + 810 + static int toshiba_sleep_functions_status_get(struct toshiba_acpi_dev *dev, 811 + u32 *mode) 812 + { 813 + u32 in[TCI_WORDS] = { SCI_GET, SCI_USB_SLEEP_CHARGE, 0, 0, 0, 0 }; 814 + u32 out[TCI_WORDS]; 815 + acpi_status status; 816 + 817 + if (!sci_open(dev)) 818 + return -EIO; 819 + 820 + in[5] = SCI_USB_CHARGE_BAT_LVL; 821 + status = tci_raw(dev, in, out); 822 + sci_close(dev); 823 + if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) { 824 + pr_err("ACPI call to get USB S&C battery level failed\n"); 825 + return -EIO; 826 + } else if (out[0] == TOS_NOT_SUPPORTED) { 827 + pr_info("USB Sleep and Charge not supported\n"); 828 + return -ENODEV; 829 + } else if (out[0] == TOS_INPUT_DATA_ERROR) { 830 + return -EIO; 831 + } 832 + 833 + *mode = out[2]; 834 + 835 + return 0; 836 + } 837 + 838 + static int toshiba_sleep_functions_status_set(struct toshiba_acpi_dev *dev, 839 + u32 mode) 840 + { 841 + u32 in[TCI_WORDS] = { SCI_SET, SCI_USB_SLEEP_CHARGE, 0, 0, 0, 0 }; 842 + u32 out[TCI_WORDS]; 843 + acpi_status status; 844 + 845 + if (!sci_open(dev)) 846 + return -EIO; 847 + 848 + in[2] = mode; 849 + in[5] = SCI_USB_CHARGE_BAT_LVL; 850 + status = tci_raw(dev, in, out); 851 + sci_close(dev); 852 + if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) { 853 + pr_err("ACPI call to set USB S&C battery level failed\n"); 854 + return -EIO; 855 + } else if (out[0] == TOS_NOT_SUPPORTED) { 856 + pr_info("USB Sleep and Charge not supported\n"); 857 + return -ENODEV; 858 + } else if (out[0] == TOS_INPUT_DATA_ERROR) { 859 + return -EIO; 860 + } 861 + 862 + return 0; 863 + } 864 + 865 + static int toshiba_usb_rapid_charge_get(struct toshiba_acpi_dev *dev, 866 + u32 *state) 867 + { 868 + u32 in[TCI_WORDS] = { SCI_GET, SCI_USB_SLEEP_CHARGE, 0, 0, 0, 0 }; 869 + u32 out[TCI_WORDS]; 870 + acpi_status status; 871 + 872 + if (!sci_open(dev)) 873 + return -EIO; 874 + 875 + in[5] = SCI_USB_CHARGE_RAPID_DSP; 876 + status = tci_raw(dev, in, out); 877 + sci_close(dev); 878 + if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) { 879 + pr_err("ACPI call to get USB S&C battery level failed\n"); 880 + return -EIO; 881 + } else if (out[0] == TOS_NOT_SUPPORTED || 882 + out[0] == TOS_INPUT_DATA_ERROR) { 883 + pr_info("USB Sleep and Charge not supported\n"); 884 + return -ENODEV; 885 + } 886 + 887 + *state = out[2]; 888 + 889 + return 0; 890 + } 891 + 892 + static int toshiba_usb_rapid_charge_set(struct toshiba_acpi_dev *dev, 893 + u32 state) 894 + { 895 + u32 in[TCI_WORDS] = { SCI_SET, SCI_USB_SLEEP_CHARGE, 0, 0, 0, 0 }; 896 + u32 out[TCI_WORDS]; 897 + acpi_status status; 898 + 899 + if (!sci_open(dev)) 900 + return -EIO; 901 + 902 + in[2] = state; 903 + in[5] = SCI_USB_CHARGE_RAPID_DSP; 904 + status = tci_raw(dev, in, out); 905 + sci_close(dev); 906 + if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) { 907 + pr_err("ACPI call to set USB S&C battery level failed\n"); 908 + return -EIO; 909 + } else if (out[0] == TOS_NOT_SUPPORTED) { 910 + pr_info("USB Sleep and Charge not supported\n"); 911 + return -ENODEV; 912 + } else if (out[0] == TOS_INPUT_DATA_ERROR) { 913 + return -EIO; 914 + } 915 + 916 + return 0; 917 + } 918 + 919 + static int toshiba_usb_sleep_music_get(struct toshiba_acpi_dev *dev, u32 *state) 920 + { 921 + u32 result; 922 + 923 + if (!sci_open(dev)) 924 + return -EIO; 925 + 926 + result = sci_read(dev, SCI_USB_SLEEP_MUSIC, state); 927 + sci_close(dev); 928 + if (result == TOS_FAILURE) { 929 + pr_err("ACPI call to set USB S&C mode failed\n"); 930 + return -EIO; 931 + } else if (result == TOS_NOT_SUPPORTED) { 932 + pr_info("USB Sleep and Charge not supported\n"); 933 + return -ENODEV; 934 + } else if (result == TOS_INPUT_DATA_ERROR) { 935 + return -EIO; 936 + } 937 + 938 + return 0; 939 + } 940 + 941 + static int toshiba_usb_sleep_music_set(struct toshiba_acpi_dev *dev, u32 state) 942 + { 943 + u32 result; 944 + 945 + if (!sci_open(dev)) 946 + return -EIO; 947 + 948 + result = sci_write(dev, SCI_USB_SLEEP_MUSIC, state); 949 + sci_close(dev); 950 + if (result == TOS_FAILURE) { 951 + pr_err("ACPI call to set USB S&C mode failed\n"); 952 + return -EIO; 953 + } else if (result == TOS_NOT_SUPPORTED) { 954 + pr_info("USB Sleep and Charge not supported\n"); 955 + return -ENODEV; 956 + } else if (result == TOS_INPUT_DATA_ERROR) { 957 + return -EIO; 958 + } 959 + 960 + return 0; 961 + } 962 + 963 + /* Keyboard function keys */ 964 + static int toshiba_function_keys_get(struct toshiba_acpi_dev *dev, u32 *mode) 965 + { 966 + u32 result; 967 + 968 + if (!sci_open(dev)) 969 + return -EIO; 970 + 971 + result = sci_read(dev, SCI_KBD_FUNCTION_KEYS, mode); 972 + sci_close(dev); 973 + if (result == TOS_FAILURE || result == TOS_INPUT_DATA_ERROR) { 974 + pr_err("ACPI call to get KBD function keys failed\n"); 975 + return -EIO; 976 + } else if (result == TOS_NOT_SUPPORTED) { 977 + pr_info("KBD function keys not supported\n"); 978 + return -ENODEV; 979 + } 980 + 981 + return 0; 982 + } 983 + 984 + static int toshiba_function_keys_set(struct toshiba_acpi_dev *dev, u32 mode) 985 + { 986 + u32 result; 987 + 988 + if (!sci_open(dev)) 989 + return -EIO; 990 + 991 + result = sci_write(dev, SCI_KBD_FUNCTION_KEYS, mode); 992 + sci_close(dev); 993 + if (result == TOS_FAILURE || result == TOS_INPUT_DATA_ERROR) { 994 + pr_err("ACPI call to set KBD function keys failed\n"); 995 + return -EIO; 996 + } else if (result == TOS_NOT_SUPPORTED) { 997 + pr_info("KBD function keys not supported\n"); 998 + return -ENODEV; 999 + } 1000 + 1001 + return 0; 1002 + } 1003 + 1004 + /* Panel Power ON */ 1005 + static int toshiba_panel_power_on_get(struct toshiba_acpi_dev *dev, u32 *state) 1006 + { 1007 + u32 result; 1008 + 1009 + if (!sci_open(dev)) 1010 + return -EIO; 1011 + 1012 + result = sci_read(dev, SCI_PANEL_POWER_ON, state); 1013 + sci_close(dev); 1014 + if (result == TOS_FAILURE) { 1015 + pr_err("ACPI call to get Panel Power ON failed\n"); 1016 + return -EIO; 1017 + } else if (result == TOS_NOT_SUPPORTED) { 1018 + pr_info("Panel Power on not supported\n"); 1019 + return -ENODEV; 1020 + } else if (result == TOS_INPUT_DATA_ERROR) { 1021 + return -EIO; 1022 + } 1023 + 1024 + return 0; 1025 + } 1026 + 1027 + static int toshiba_panel_power_on_set(struct toshiba_acpi_dev *dev, u32 state) 1028 + { 1029 + u32 result; 1030 + 1031 + if (!sci_open(dev)) 1032 + return -EIO; 1033 + 1034 + result = sci_write(dev, SCI_PANEL_POWER_ON, state); 1035 + sci_close(dev); 1036 + if (result == TOS_FAILURE) { 1037 + pr_err("ACPI call to set Panel Power ON failed\n"); 1038 + return -EIO; 1039 + } else if (result == TOS_NOT_SUPPORTED) { 1040 + pr_info("Panel Power ON not supported\n"); 1041 + return -ENODEV; 1042 + } else if (result == TOS_INPUT_DATA_ERROR) { 1043 + return -EIO; 1044 + } 1045 + 1046 + return 0; 1047 + } 1048 + 1049 + /* USB Three */ 1050 + static int toshiba_usb_three_get(struct toshiba_acpi_dev *dev, u32 *state) 1051 + { 1052 + u32 result; 1053 + 1054 + if (!sci_open(dev)) 1055 + return -EIO; 1056 + 1057 + result = sci_read(dev, SCI_USB_THREE, state); 1058 + sci_close(dev); 1059 + if (result == TOS_FAILURE) { 1060 + pr_err("ACPI call to get USB 3 failed\n"); 1061 + return -EIO; 1062 + } else if (result == TOS_NOT_SUPPORTED) { 1063 + pr_info("USB 3 not supported\n"); 1064 + return -ENODEV; 1065 + } else if (result == TOS_INPUT_DATA_ERROR) { 1066 + return -EIO; 1067 + } 1068 + 1069 + return 0; 1070 + } 1071 + 1072 + static int toshiba_usb_three_set(struct toshiba_acpi_dev *dev, u32 state) 1073 + { 1074 + u32 result; 1075 + 1076 + if (!sci_open(dev)) 1077 + return -EIO; 1078 + 1079 + result = sci_write(dev, SCI_USB_THREE, state); 1080 + sci_close(dev); 1081 + if (result == TOS_FAILURE) { 1082 + pr_err("ACPI call to set USB 3 failed\n"); 1083 + return -EIO; 1084 + } else if (result == TOS_NOT_SUPPORTED) { 1085 + pr_info("USB 3 not supported\n"); 1086 + return -ENODEV; 1087 + } else if (result == TOS_INPUT_DATA_ERROR) { 1088 + return -EIO; 1089 + } 817 1090 818 1091 return 0; 819 1092 } ··· 1259 870 return hci_result == TOS_SUCCESS ? 0 : -EIO; 1260 871 } 1261 872 1262 - static struct proc_dir_entry *toshiba_proc_dir /*= 0*/ ; 873 + static struct proc_dir_entry *toshiba_proc_dir /*= 0*/; 1263 874 1264 875 static int __get_lcd_brightness(struct toshiba_acpi_dev *dev) 1265 876 { ··· 1270 881 if (dev->tr_backlight_supported) { 1271 882 bool enabled; 1272 883 int ret = get_tr_backlight_status(dev, &enabled); 884 + 1273 885 if (ret) 1274 886 return ret; 1275 887 if (enabled) ··· 1288 898 static int get_lcd_brightness(struct backlight_device *bd) 1289 899 { 1290 900 struct toshiba_acpi_dev *dev = bl_get_data(bd); 901 + 1291 902 return __get_lcd_brightness(dev); 1292 903 } 1293 904 ··· 1325 934 if (dev->tr_backlight_supported) { 1326 935 bool enable = !value; 1327 936 int ret = set_tr_backlight_status(dev, enable); 937 + 1328 938 if (ret) 1329 939 return ret; 1330 940 if (value) ··· 1340 948 static int set_lcd_status(struct backlight_device *bd) 1341 949 { 1342 950 struct toshiba_acpi_dev *dev = bl_get_data(bd); 951 + 1343 952 return set_lcd_brightness(dev, bd->props.brightness); 1344 953 } 1345 954 ··· 1398 1005 int is_lcd = (value & HCI_VIDEO_OUT_LCD) ? 1 : 0; 1399 1006 int is_crt = (value & HCI_VIDEO_OUT_CRT) ? 1 : 0; 1400 1007 int is_tv = (value & HCI_VIDEO_OUT_TV) ? 1 : 0; 1008 + 1401 1009 seq_printf(m, "lcd_out: %d\n", is_lcd); 1402 1010 seq_printf(m, "crt_out: %d\n", is_crt); 1403 1011 seq_printf(m, "tv_out: %d\n", is_tv); ··· 1436 1042 1437 1043 buffer = cmd; 1438 1044 1439 - /* scan expression. Multiple expressions may be delimited with ; 1440 - * 1441 - * NOTE: to keep scanning simple, invalid fields are ignored 1045 + /* 1046 + * Scan expression. Multiple expressions may be delimited with ; 1047 + * NOTE: To keep scanning simple, invalid fields are ignored. 1442 1048 */ 1443 1049 while (remain) { 1444 1050 if (sscanf(buffer, " lcd_out : %i", &value) == 1) ··· 1447 1053 crt_out = value & 1; 1448 1054 else if (sscanf(buffer, " tv_out : %i", &value) == 1) 1449 1055 tv_out = value & 1; 1450 - /* advance to one character past the next ; */ 1056 + /* Advance to one character past the next ; */ 1451 1057 do { 1452 1058 ++buffer; 1453 1059 --remain; 1454 - } 1455 - while (remain && *(buffer - 1) != ';'); 1060 + } while (remain && *(buffer - 1) != ';'); 1456 1061 } 1457 1062 1458 1063 kfree(cmd); ··· 1459 1066 ret = get_video_status(dev, &video_out); 1460 1067 if (!ret) { 1461 1068 unsigned int new_video_out = video_out; 1069 + 1462 1070 if (lcd_out != -1) 1463 1071 _set_bit(&new_video_out, HCI_VIDEO_OUT_LCD, lcd_out); 1464 1072 if (crt_out != -1) 1465 1073 _set_bit(&new_video_out, HCI_VIDEO_OUT_CRT, crt_out); 1466 1074 if (tv_out != -1) 1467 1075 _set_bit(&new_video_out, HCI_VIDEO_OUT_TV, tv_out); 1468 - /* To avoid unnecessary video disruption, only write the new 1076 + /* 1077 + * To avoid unnecessary video disruption, only write the new 1469 1078 * video setting if something changed. */ 1470 1079 if (new_video_out != video_out) 1471 1080 ret = write_acpi_int(METHOD_VIDEO_OUT, new_video_out); ··· 1530 1135 if (sscanf(cmd, " force_on : %i", &value) == 1 && 1531 1136 value >= 0 && value <= 1) { 1532 1137 hci_result = hci_write1(dev, HCI_FAN, value); 1533 - if (hci_result != TOS_SUCCESS) 1534 - return -EIO; 1535 - else 1138 + if (hci_result == TOS_SUCCESS) 1536 1139 dev->force_fan = value; 1140 + else 1141 + return -EIO; 1537 1142 } else { 1538 1143 return -EINVAL; 1539 1144 } ··· 1562 1167 dev->key_event_valid = 1; 1563 1168 dev->last_key_event = value; 1564 1169 } else if (hci_result == TOS_FIFO_EMPTY) { 1565 - /* better luck next time */ 1170 + /* Better luck next time */ 1566 1171 } else if (hci_result == TOS_NOT_SUPPORTED) { 1567 - /* This is a workaround for an unresolved issue on 1172 + /* 1173 + * This is a workaround for an unresolved issue on 1568 1174 * some machines where system events sporadically 1569 - * become disabled. */ 1175 + * become disabled. 1176 + */ 1570 1177 hci_result = hci_write1(dev, HCI_SYSTEM_EVENT, 1); 1571 1178 pr_notice("Re-enabled hotkeys\n"); 1572 1179 } else { ··· 1600 1203 return -EFAULT; 1601 1204 cmd[len] = '\0'; 1602 1205 1603 - if (sscanf(cmd, " hotkey_ready : %i", &value) == 1 && value == 0) { 1206 + if (sscanf(cmd, " hotkey_ready : %i", &value) == 1 && value == 0) 1604 1207 dev->key_event_valid = 0; 1605 - } else { 1208 + else 1606 1209 return -EINVAL; 1607 - } 1608 1210 1609 1211 return count; 1610 1212 } ··· 1637 1241 .release = single_release, 1638 1242 }; 1639 1243 1640 - /* proc and module init 1244 + /* 1245 + * Proc and module init 1641 1246 */ 1642 1247 1643 1248 #define PROC_TOSHIBA "toshiba" ··· 1683 1286 /* 1684 1287 * Sysfs files 1685 1288 */ 1686 - static ssize_t toshiba_kbd_bl_mode_store(struct device *dev, 1687 - struct device_attribute *attr, 1688 - const char *buf, size_t count); 1689 - static ssize_t toshiba_kbd_bl_mode_show(struct device *dev, 1289 + static ssize_t version_show(struct device *dev, 1290 + struct device_attribute *attr, char *buf) 1291 + { 1292 + return sprintf(buf, "%s\n", TOSHIBA_ACPI_VERSION); 1293 + } 1294 + static DEVICE_ATTR_RO(version); 1295 + 1296 + static ssize_t fan_store(struct device *dev, 1297 + struct device_attribute *attr, 1298 + const char *buf, size_t count) 1299 + { 1300 + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1301 + u32 result; 1302 + int state; 1303 + int ret; 1304 + 1305 + ret = kstrtoint(buf, 0, &state); 1306 + if (ret) 1307 + return ret; 1308 + 1309 + if (state != 0 && state != 1) 1310 + return -EINVAL; 1311 + 1312 + result = hci_write1(toshiba, HCI_FAN, state); 1313 + if (result == TOS_FAILURE) 1314 + return -EIO; 1315 + else if (result == TOS_NOT_SUPPORTED) 1316 + return -ENODEV; 1317 + 1318 + return count; 1319 + } 1320 + 1321 + static ssize_t fan_show(struct device *dev, 1322 + struct device_attribute *attr, char *buf) 1323 + { 1324 + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1325 + u32 value; 1326 + int ret; 1327 + 1328 + ret = get_fan_status(toshiba, &value); 1329 + if (ret) 1330 + return ret; 1331 + 1332 + return sprintf(buf, "%d\n", value); 1333 + } 1334 + static DEVICE_ATTR_RW(fan); 1335 + 1336 + static ssize_t kbd_backlight_mode_store(struct device *dev, 1690 1337 struct device_attribute *attr, 1691 - char *buf); 1692 - static ssize_t toshiba_kbd_type_show(struct device *dev, 1693 - struct device_attribute *attr, 1694 - char *buf); 1695 - static ssize_t toshiba_available_kbd_modes_show(struct device *dev, 1696 - struct device_attribute *attr, 1697 - char *buf); 1698 - static ssize_t toshiba_kbd_bl_timeout_store(struct device *dev, 1699 - struct device_attribute *attr, 1700 - const char *buf, size_t count); 1701 - static ssize_t toshiba_kbd_bl_timeout_show(struct device *dev, 1702 - struct device_attribute *attr, 1703 - char *buf); 1704 - static ssize_t toshiba_touchpad_store(struct device *dev, 1705 - struct device_attribute *attr, 1706 - const char *buf, size_t count); 1707 - static ssize_t toshiba_touchpad_show(struct device *dev, 1708 - struct device_attribute *attr, 1709 - char *buf); 1710 - static ssize_t toshiba_position_show(struct device *dev, 1711 - struct device_attribute *attr, 1712 - char *buf); 1713 - 1714 - static DEVICE_ATTR(kbd_backlight_mode, S_IRUGO | S_IWUSR, 1715 - toshiba_kbd_bl_mode_show, toshiba_kbd_bl_mode_store); 1716 - static DEVICE_ATTR(kbd_type, S_IRUGO, toshiba_kbd_type_show, NULL); 1717 - static DEVICE_ATTR(available_kbd_modes, S_IRUGO, 1718 - toshiba_available_kbd_modes_show, NULL); 1719 - static DEVICE_ATTR(kbd_backlight_timeout, S_IRUGO | S_IWUSR, 1720 - toshiba_kbd_bl_timeout_show, toshiba_kbd_bl_timeout_store); 1721 - static DEVICE_ATTR(touchpad, S_IRUGO | S_IWUSR, 1722 - toshiba_touchpad_show, toshiba_touchpad_store); 1723 - static DEVICE_ATTR(position, S_IRUGO, toshiba_position_show, NULL); 1724 - 1725 - static struct attribute *toshiba_attributes[] = { 1726 - &dev_attr_kbd_backlight_mode.attr, 1727 - &dev_attr_kbd_type.attr, 1728 - &dev_attr_available_kbd_modes.attr, 1729 - &dev_attr_kbd_backlight_timeout.attr, 1730 - &dev_attr_touchpad.attr, 1731 - &dev_attr_position.attr, 1732 - NULL, 1733 - }; 1734 - 1735 - static umode_t toshiba_sysfs_is_visible(struct kobject *, 1736 - struct attribute *, int); 1737 - 1738 - static struct attribute_group toshiba_attr_group = { 1739 - .is_visible = toshiba_sysfs_is_visible, 1740 - .attrs = toshiba_attributes, 1741 - }; 1742 - 1743 - static ssize_t toshiba_kbd_bl_mode_store(struct device *dev, 1744 - struct device_attribute *attr, 1745 - const char *buf, size_t count) 1338 + const char *buf, size_t count) 1746 1339 { 1747 1340 struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1748 1341 int mode; ··· 1756 1369 return -EINVAL; 1757 1370 } 1758 1371 1759 - /* Set the Keyboard Backlight Mode where: 1372 + /* 1373 + * Set the Keyboard Backlight Mode where: 1760 1374 * Auto - KBD backlight turns off automatically in given time 1761 1375 * FN-Z - KBD backlight "toggles" when hotkey pressed 1762 1376 * ON - KBD backlight is always on ··· 1788 1400 return count; 1789 1401 } 1790 1402 1791 - static ssize_t toshiba_kbd_bl_mode_show(struct device *dev, 1792 - struct device_attribute *attr, 1793 - char *buf) 1403 + static ssize_t kbd_backlight_mode_show(struct device *dev, 1404 + struct device_attribute *attr, 1405 + char *buf) 1794 1406 { 1795 1407 struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1796 1408 u32 time; ··· 1800 1412 1801 1413 return sprintf(buf, "%i\n", time & SCI_KBD_MODE_MASK); 1802 1414 } 1415 + static DEVICE_ATTR_RW(kbd_backlight_mode); 1803 1416 1804 - static ssize_t toshiba_kbd_type_show(struct device *dev, 1805 - struct device_attribute *attr, 1806 - char *buf) 1417 + static ssize_t kbd_type_show(struct device *dev, 1418 + struct device_attribute *attr, char *buf) 1807 1419 { 1808 1420 struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1809 1421 1810 1422 return sprintf(buf, "%d\n", toshiba->kbd_type); 1811 1423 } 1424 + static DEVICE_ATTR_RO(kbd_type); 1812 1425 1813 - static ssize_t toshiba_available_kbd_modes_show(struct device *dev, 1814 - struct device_attribute *attr, 1815 - char *buf) 1426 + static ssize_t available_kbd_modes_show(struct device *dev, 1427 + struct device_attribute *attr, 1428 + char *buf) 1816 1429 { 1817 1430 struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1818 1431 ··· 1824 1435 return sprintf(buf, "%x %x %x\n", 1825 1436 SCI_KBD_MODE_AUTO, SCI_KBD_MODE_ON, SCI_KBD_MODE_OFF); 1826 1437 } 1438 + static DEVICE_ATTR_RO(available_kbd_modes); 1827 1439 1828 - static ssize_t toshiba_kbd_bl_timeout_store(struct device *dev, 1829 - struct device_attribute *attr, 1830 - const char *buf, size_t count) 1440 + static ssize_t kbd_backlight_timeout_store(struct device *dev, 1441 + struct device_attribute *attr, 1442 + const char *buf, size_t count) 1831 1443 { 1832 1444 struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1833 1445 int time; ··· 1869 1479 return count; 1870 1480 } 1871 1481 1872 - static ssize_t toshiba_kbd_bl_timeout_show(struct device *dev, 1873 - struct device_attribute *attr, 1874 - char *buf) 1482 + static ssize_t kbd_backlight_timeout_show(struct device *dev, 1483 + struct device_attribute *attr, 1484 + char *buf) 1875 1485 { 1876 1486 struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1877 1487 u32 time; ··· 1881 1491 1882 1492 return sprintf(buf, "%i\n", time >> HCI_MISC_SHIFT); 1883 1493 } 1494 + static DEVICE_ATTR_RW(kbd_backlight_timeout); 1884 1495 1885 - static ssize_t toshiba_touchpad_store(struct device *dev, 1886 - struct device_attribute *attr, 1887 - const char *buf, size_t count) 1496 + static ssize_t touchpad_store(struct device *dev, 1497 + struct device_attribute *attr, 1498 + const char *buf, size_t count) 1888 1499 { 1889 1500 struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1890 1501 int state; ··· 1905 1514 return count; 1906 1515 } 1907 1516 1908 - static ssize_t toshiba_touchpad_show(struct device *dev, 1909 - struct device_attribute *attr, char *buf) 1517 + static ssize_t touchpad_show(struct device *dev, 1518 + struct device_attribute *attr, char *buf) 1910 1519 { 1911 1520 struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1912 1521 u32 state; ··· 1918 1527 1919 1528 return sprintf(buf, "%i\n", state); 1920 1529 } 1530 + static DEVICE_ATTR_RW(touchpad); 1921 1531 1922 - static ssize_t toshiba_position_show(struct device *dev, 1923 - struct device_attribute *attr, char *buf) 1532 + static ssize_t position_show(struct device *dev, 1533 + struct device_attribute *attr, char *buf) 1924 1534 { 1925 1535 struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1926 1536 u32 xyval, zval, tmp; ··· 1940 1548 1941 1549 return sprintf(buf, "%d %d %d\n", x, y, z); 1942 1550 } 1551 + static DEVICE_ATTR_RO(position); 1552 + 1553 + static ssize_t usb_sleep_charge_show(struct device *dev, 1554 + struct device_attribute *attr, char *buf) 1555 + { 1556 + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1557 + u32 mode; 1558 + int ret; 1559 + 1560 + ret = toshiba_usb_sleep_charge_get(toshiba, &mode); 1561 + if (ret < 0) 1562 + return ret; 1563 + 1564 + return sprintf(buf, "%x\n", mode & SCI_USB_CHARGE_MODE_MASK); 1565 + } 1566 + 1567 + static ssize_t usb_sleep_charge_store(struct device *dev, 1568 + struct device_attribute *attr, 1569 + const char *buf, size_t count) 1570 + { 1571 + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1572 + u32 mode; 1573 + int state; 1574 + int ret; 1575 + 1576 + ret = kstrtoint(buf, 0, &state); 1577 + if (ret) 1578 + return ret; 1579 + /* 1580 + * Check for supported values, where: 1581 + * 0 - Disabled 1582 + * 1 - Alternate (Non USB conformant devices that require more power) 1583 + * 2 - Auto (USB conformant devices) 1584 + */ 1585 + if (state != 0 && state != 1 && state != 2) 1586 + return -EINVAL; 1587 + 1588 + /* Set the USB charging mode to internal value */ 1589 + if (state == 0) 1590 + mode = SCI_USB_CHARGE_DISABLED; 1591 + else if (state == 1) 1592 + mode = SCI_USB_CHARGE_ALTERNATE; 1593 + else if (state == 2) 1594 + mode = SCI_USB_CHARGE_AUTO; 1595 + 1596 + ret = toshiba_usb_sleep_charge_set(toshiba, mode); 1597 + if (ret) 1598 + return ret; 1599 + 1600 + return count; 1601 + } 1602 + static DEVICE_ATTR_RW(usb_sleep_charge); 1603 + 1604 + static ssize_t sleep_functions_on_battery_show(struct device *dev, 1605 + struct device_attribute *attr, 1606 + char *buf) 1607 + { 1608 + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1609 + u32 state; 1610 + int bat_lvl; 1611 + int status; 1612 + int ret; 1613 + int tmp; 1614 + 1615 + ret = toshiba_sleep_functions_status_get(toshiba, &state); 1616 + if (ret < 0) 1617 + return ret; 1618 + 1619 + /* Determine the status: 0x4 - Enabled | 0x1 - Disabled */ 1620 + tmp = state & SCI_USB_CHARGE_BAT_MASK; 1621 + status = (tmp == 0x4) ? 1 : 0; 1622 + /* Determine the battery level set */ 1623 + bat_lvl = state >> HCI_MISC_SHIFT; 1624 + 1625 + return sprintf(buf, "%d %d\n", status, bat_lvl); 1626 + } 1627 + 1628 + static ssize_t sleep_functions_on_battery_store(struct device *dev, 1629 + struct device_attribute *attr, 1630 + const char *buf, size_t count) 1631 + { 1632 + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1633 + u32 status; 1634 + int value; 1635 + int ret; 1636 + int tmp; 1637 + 1638 + ret = kstrtoint(buf, 0, &value); 1639 + if (ret) 1640 + return ret; 1641 + 1642 + /* 1643 + * Set the status of the function: 1644 + * 0 - Disabled 1645 + * 1-100 - Enabled 1646 + */ 1647 + if (value < 0 || value > 100) 1648 + return -EINVAL; 1649 + 1650 + if (value == 0) { 1651 + tmp = toshiba->usbsc_bat_level << HCI_MISC_SHIFT; 1652 + status = tmp | SCI_USB_CHARGE_BAT_LVL_OFF; 1653 + } else { 1654 + tmp = value << HCI_MISC_SHIFT; 1655 + status = tmp | SCI_USB_CHARGE_BAT_LVL_ON; 1656 + } 1657 + ret = toshiba_sleep_functions_status_set(toshiba, status); 1658 + if (ret < 0) 1659 + return ret; 1660 + 1661 + toshiba->usbsc_bat_level = status >> HCI_MISC_SHIFT; 1662 + 1663 + return count; 1664 + } 1665 + static DEVICE_ATTR_RW(sleep_functions_on_battery); 1666 + 1667 + static ssize_t usb_rapid_charge_show(struct device *dev, 1668 + struct device_attribute *attr, char *buf) 1669 + { 1670 + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1671 + u32 state; 1672 + int ret; 1673 + 1674 + ret = toshiba_usb_rapid_charge_get(toshiba, &state); 1675 + if (ret < 0) 1676 + return ret; 1677 + 1678 + return sprintf(buf, "%d\n", state); 1679 + } 1680 + 1681 + static ssize_t usb_rapid_charge_store(struct device *dev, 1682 + struct device_attribute *attr, 1683 + const char *buf, size_t count) 1684 + { 1685 + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1686 + int state; 1687 + int ret; 1688 + 1689 + ret = kstrtoint(buf, 0, &state); 1690 + if (ret) 1691 + return ret; 1692 + if (state != 0 && state != 1) 1693 + return -EINVAL; 1694 + 1695 + ret = toshiba_usb_rapid_charge_set(toshiba, state); 1696 + if (ret) 1697 + return ret; 1698 + 1699 + return count; 1700 + } 1701 + static DEVICE_ATTR_RW(usb_rapid_charge); 1702 + 1703 + static ssize_t usb_sleep_music_show(struct device *dev, 1704 + struct device_attribute *attr, char *buf) 1705 + { 1706 + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1707 + u32 state; 1708 + int ret; 1709 + 1710 + ret = toshiba_usb_sleep_music_get(toshiba, &state); 1711 + if (ret < 0) 1712 + return ret; 1713 + 1714 + return sprintf(buf, "%d\n", state); 1715 + } 1716 + 1717 + static ssize_t usb_sleep_music_store(struct device *dev, 1718 + struct device_attribute *attr, 1719 + const char *buf, size_t count) 1720 + { 1721 + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1722 + int state; 1723 + int ret; 1724 + 1725 + ret = kstrtoint(buf, 0, &state); 1726 + if (ret) 1727 + return ret; 1728 + if (state != 0 && state != 1) 1729 + return -EINVAL; 1730 + 1731 + ret = toshiba_usb_sleep_music_set(toshiba, state); 1732 + if (ret) 1733 + return ret; 1734 + 1735 + return count; 1736 + } 1737 + static DEVICE_ATTR_RW(usb_sleep_music); 1738 + 1739 + static ssize_t kbd_function_keys_show(struct device *dev, 1740 + struct device_attribute *attr, char *buf) 1741 + { 1742 + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1743 + int mode; 1744 + int ret; 1745 + 1746 + ret = toshiba_function_keys_get(toshiba, &mode); 1747 + if (ret < 0) 1748 + return ret; 1749 + 1750 + return sprintf(buf, "%d\n", mode); 1751 + } 1752 + 1753 + static ssize_t kbd_function_keys_store(struct device *dev, 1754 + struct device_attribute *attr, 1755 + const char *buf, size_t count) 1756 + { 1757 + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1758 + int mode; 1759 + int ret; 1760 + 1761 + ret = kstrtoint(buf, 0, &mode); 1762 + if (ret) 1763 + return ret; 1764 + /* 1765 + * Check for the function keys mode where: 1766 + * 0 - Normal operation (F{1-12} as usual and hotkeys via FN-F{1-12}) 1767 + * 1 - Special functions (Opposite of the above setting) 1768 + */ 1769 + if (mode != 0 && mode != 1) 1770 + return -EINVAL; 1771 + 1772 + ret = toshiba_function_keys_set(toshiba, mode); 1773 + if (ret) 1774 + return ret; 1775 + 1776 + pr_info("Reboot for changes to KBD Function Keys to take effect"); 1777 + 1778 + return count; 1779 + } 1780 + static DEVICE_ATTR_RW(kbd_function_keys); 1781 + 1782 + static ssize_t panel_power_on_show(struct device *dev, 1783 + struct device_attribute *attr, char *buf) 1784 + { 1785 + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1786 + u32 state; 1787 + int ret; 1788 + 1789 + ret = toshiba_panel_power_on_get(toshiba, &state); 1790 + if (ret < 0) 1791 + return ret; 1792 + 1793 + return sprintf(buf, "%d\n", state); 1794 + } 1795 + 1796 + static ssize_t panel_power_on_store(struct device *dev, 1797 + struct device_attribute *attr, 1798 + const char *buf, size_t count) 1799 + { 1800 + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1801 + int state; 1802 + int ret; 1803 + 1804 + ret = kstrtoint(buf, 0, &state); 1805 + if (ret) 1806 + return ret; 1807 + if (state != 0 && state != 1) 1808 + return -EINVAL; 1809 + 1810 + ret = toshiba_panel_power_on_set(toshiba, state); 1811 + if (ret) 1812 + return ret; 1813 + 1814 + pr_info("Reboot for changes to Panel Power ON to take effect"); 1815 + 1816 + return count; 1817 + } 1818 + static DEVICE_ATTR_RW(panel_power_on); 1819 + 1820 + static ssize_t usb_three_show(struct device *dev, 1821 + struct device_attribute *attr, char *buf) 1822 + { 1823 + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1824 + u32 state; 1825 + int ret; 1826 + 1827 + ret = toshiba_usb_three_get(toshiba, &state); 1828 + if (ret < 0) 1829 + return ret; 1830 + 1831 + return sprintf(buf, "%d\n", state); 1832 + } 1833 + 1834 + static ssize_t usb_three_store(struct device *dev, 1835 + struct device_attribute *attr, 1836 + const char *buf, size_t count) 1837 + { 1838 + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev); 1839 + int state; 1840 + int ret; 1841 + 1842 + ret = kstrtoint(buf, 0, &state); 1843 + if (ret) 1844 + return ret; 1845 + /* 1846 + * Check for USB 3 mode where: 1847 + * 0 - Disabled (Acts like a USB 2 port, saving power) 1848 + * 1 - Enabled 1849 + */ 1850 + if (state != 0 && state != 1) 1851 + return -EINVAL; 1852 + 1853 + ret = toshiba_usb_three_set(toshiba, state); 1854 + if (ret) 1855 + return ret; 1856 + 1857 + pr_info("Reboot for changes to USB 3 to take effect"); 1858 + 1859 + return count; 1860 + } 1861 + static DEVICE_ATTR_RW(usb_three); 1862 + 1863 + static struct attribute *toshiba_attributes[] = { 1864 + &dev_attr_version.attr, 1865 + &dev_attr_fan.attr, 1866 + &dev_attr_kbd_backlight_mode.attr, 1867 + &dev_attr_kbd_type.attr, 1868 + &dev_attr_available_kbd_modes.attr, 1869 + &dev_attr_kbd_backlight_timeout.attr, 1870 + &dev_attr_touchpad.attr, 1871 + &dev_attr_position.attr, 1872 + &dev_attr_usb_sleep_charge.attr, 1873 + &dev_attr_sleep_functions_on_battery.attr, 1874 + &dev_attr_usb_rapid_charge.attr, 1875 + &dev_attr_usb_sleep_music.attr, 1876 + &dev_attr_kbd_function_keys.attr, 1877 + &dev_attr_panel_power_on.attr, 1878 + &dev_attr_usb_three.attr, 1879 + NULL, 1880 + }; 1943 1881 1944 1882 static umode_t toshiba_sysfs_is_visible(struct kobject *kobj, 1945 1883 struct attribute *attr, int idx) ··· 2278 1556 struct toshiba_acpi_dev *drv = dev_get_drvdata(dev); 2279 1557 bool exists = true; 2280 1558 2281 - if (attr == &dev_attr_kbd_backlight_mode.attr) 1559 + if (attr == &dev_attr_fan.attr) 1560 + exists = (drv->fan_supported) ? true : false; 1561 + else if (attr == &dev_attr_kbd_backlight_mode.attr) 2282 1562 exists = (drv->kbd_illum_supported) ? true : false; 2283 1563 else if (attr == &dev_attr_kbd_backlight_timeout.attr) 2284 1564 exists = (drv->kbd_mode == SCI_KBD_MODE_AUTO) ? true : false; ··· 2288 1564 exists = (drv->touchpad_supported) ? true : false; 2289 1565 else if (attr == &dev_attr_position.attr) 2290 1566 exists = (drv->accelerometer_supported) ? true : false; 1567 + else if (attr == &dev_attr_usb_sleep_charge.attr) 1568 + exists = (drv->usb_sleep_charge_supported) ? true : false; 1569 + else if (attr == &dev_attr_sleep_functions_on_battery.attr) 1570 + exists = (drv->usb_sleep_charge_supported) ? true : false; 1571 + else if (attr == &dev_attr_usb_rapid_charge.attr) 1572 + exists = (drv->usb_rapid_charge_supported) ? true : false; 1573 + else if (attr == &dev_attr_usb_sleep_music.attr) 1574 + exists = (drv->usb_sleep_music_supported) ? true : false; 1575 + else if (attr == &dev_attr_kbd_function_keys.attr) 1576 + exists = (drv->kbd_function_keys_supported) ? true : false; 1577 + else if (attr == &dev_attr_panel_power_on.attr) 1578 + exists = (drv->panel_power_on_supported) ? true : false; 1579 + else if (attr == &dev_attr_usb_three.attr) 1580 + exists = (drv->usb_three_supported) ? true : false; 2291 1581 2292 1582 return exists ? attr->mode : 0; 2293 1583 } 1584 + 1585 + static struct attribute_group toshiba_attr_group = { 1586 + .is_visible = toshiba_sysfs_is_visible, 1587 + .attrs = toshiba_attributes, 1588 + }; 2294 1589 2295 1590 /* 2296 1591 * Hotkeys ··· 2387 1644 if (scancode == 0x100) 2388 1645 return; 2389 1646 2390 - /* act on key press; ignore key release */ 1647 + /* Act on key press; ignore key release */ 2391 1648 if (scancode & 0x80) 2392 1649 return; 2393 1650 ··· 2423 1680 hci_result = 2424 1681 hci_write1(dev, HCI_SYSTEM_EVENT, 1); 2425 1682 pr_notice("Re-enabled hotkeys\n"); 2426 - /* fall through */ 1683 + /* Fall through */ 2427 1684 default: 2428 1685 retries--; 2429 1686 break; ··· 2545 1802 props.type = BACKLIGHT_PLATFORM; 2546 1803 props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1; 2547 1804 2548 - /* adding an extra level and having 0 change to transflective mode */ 1805 + /* Adding an extra level and having 0 change to transflective mode */ 2549 1806 if (dev->tr_backlight_supported) 2550 1807 props.max_brightness++; 2551 1808 ··· 2715 1972 2716 1973 ret = toshiba_accelerometer_supported(dev); 2717 1974 dev->accelerometer_supported = !ret; 1975 + 1976 + ret = toshiba_usb_sleep_charge_get(dev, &dummy); 1977 + dev->usb_sleep_charge_supported = !ret; 1978 + 1979 + ret = toshiba_usb_rapid_charge_get(dev, &dummy); 1980 + dev->usb_rapid_charge_supported = !ret; 1981 + 1982 + ret = toshiba_usb_sleep_music_get(dev, &dummy); 1983 + dev->usb_sleep_music_supported = !ret; 1984 + 1985 + ret = toshiba_function_keys_get(dev, &dummy); 1986 + dev->kbd_function_keys_supported = !ret; 1987 + 1988 + ret = toshiba_panel_power_on_get(dev, &dummy); 1989 + dev->panel_power_on_supported = !ret; 1990 + 1991 + ret = toshiba_usb_three_get(dev, &dummy); 1992 + dev->usb_three_supported = !ret; 2718 1993 2719 1994 /* Determine whether or not BIOS supports fan and video interfaces */ 2720 1995