msi-laptop: Support standard ec 66/62 command on MSI notebook and nebook

Suppport standard ec 66/62 command on MSI notebook and nebook. MSI
netbook and notebook already support 66/62 command, so, add new
get_state function, and put the old model to non-standard model, but
driver still support those old model.

Signed-off-by: Lee, Chun-Yi <jlee@novell.com>
Cc: Lennart Poettering <mzxreary@0pointer.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by Lee, Chun-Yi and committed by Greg Kroah-Hartman 46d0e9e0 8e9394ce

+39 -4
+39 -4
drivers/platform/x86/msi-laptop.c
··· 66 66 #define MSI_EC_COMMAND_WIRELESS 0x10 67 67 #define MSI_EC_COMMAND_LCD_LEVEL 0x11 68 68 69 + #define MSI_STANDARD_EC_COMMAND_ADDRESS 0x2e 70 + #define MSI_STANDARD_EC_BLUETOOTH_MASK (1 << 0) 71 + #define MSI_STANDARD_EC_WEBCAM_MASK (1 << 1) 72 + #define MSI_STANDARD_EC_WLAN_MASK (1 << 3) 73 + 69 74 static int force; 70 75 module_param(force, bool, 0); 71 76 MODULE_PARM_DESC(force, "Force driver load, ignore DMI data"); ··· 78 73 static int auto_brightness; 79 74 module_param(auto_brightness, int, 0); 80 75 MODULE_PARM_DESC(auto_brightness, "Enable automatic brightness control (0: disabled; 1: enabled; 2: don't touch)"); 76 + 77 + static bool old_ec_model; 78 + static int wlan_s, bluetooth_s; 81 79 82 80 /* Hardware access */ 83 81 ··· 156 148 return 0; 157 149 } 158 150 151 + static int get_wireless_state_ec_standard(void) 152 + { 153 + u8 rdata; 154 + int result; 155 + 156 + result = ec_read(MSI_STANDARD_EC_COMMAND_ADDRESS, &rdata); 157 + if (result < 0) 158 + return -1; 159 + 160 + wlan_s = !!(rdata & MSI_STANDARD_EC_WLAN_MASK); 161 + 162 + bluetooth_s = !!(rdata & MSI_STANDARD_EC_BLUETOOTH_MASK); 163 + 164 + return 0; 165 + } 166 + 159 167 /* Backlight device stuff */ 160 168 161 169 static int bl_get_brightness(struct backlight_device *b) ··· 200 176 201 177 int ret, enabled; 202 178 203 - ret = get_wireless_state(&enabled, NULL); 179 + if (old_ec_model) { 180 + ret = get_wireless_state(&enabled, NULL); 181 + } else { 182 + ret = get_wireless_state_ec_standard(); 183 + enabled = wlan_s; 184 + } 204 185 if (ret < 0) 205 186 return ret; 206 187 ··· 218 189 219 190 int ret, enabled; 220 191 221 - ret = get_wireless_state(NULL, &enabled); 192 + if (old_ec_model) { 193 + ret = get_wireless_state(NULL, &enabled); 194 + } else { 195 + ret = get_wireless_state_ec_standard(); 196 + enabled = bluetooth_s; 197 + } 222 198 if (ret < 0) 223 199 return ret; 224 200 ··· 373 339 if (acpi_disabled) 374 340 return -ENODEV; 375 341 376 - if (!force && !dmi_check_system(msi_dmi_table)) 377 - return -ENODEV; 342 + if (force || dmi_check_system(msi_dmi_table)) 343 + old_ec_model = 1; 378 344 379 345 if (auto_brightness < 0 || auto_brightness > 2) 380 346 return -EINVAL; ··· 469 435 MODULE_ALIAS("dmi:*:svnMicro-StarInternational:pnMS-1058:pvr0581:rvnMSI:rnMS-1058:*:ct10:*"); 470 436 MODULE_ALIAS("dmi:*:svnMicro-StarInternational:pnMS-1412:*:rvnMSI:rnMS-1412:*:cvnMICRO-STARINT'LCO.,LTD:ct10:*"); 471 437 MODULE_ALIAS("dmi:*:svnNOTEBOOK:pnSAM2000:pvr0131*:cvnMICRO-STARINT'LCO.,LTD:ct10:*"); 438 + MODULE_ALIAS("dmi:*:svnMICRO-STARINTERNATIONAL*:pnMS-N034:*");