x86: OLPC: move s/r-related EC cmds to EC driver

The new EC driver calls platform-specific suspend and resume hooks; run
XO-1-specific EC commands from there, rather than deep in s/r code. If we
attempt to run EC commands after the new EC driver has suspended, it is
refused by the ec->suspended checks.

Signed-off-by: Andres Salomon <dilinger@queued.net>
Acked-by: Paul Fox <pgf@laptop.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

Changed files
+36 -22
arch
x86
platform
-15
arch/x86/platform/olpc/olpc-xo1-pm.c
··· 52 52 static int xo1_power_state_enter(suspend_state_t pm_state) 53 53 { 54 54 unsigned long saved_sci_mask; 55 - int r; 56 55 57 56 /* Only STR is supported */ 58 57 if (pm_state != PM_SUSPEND_MEM) 59 58 return -EINVAL; 60 - 61 - r = olpc_ec_cmd(EC_SET_SCI_INHIBIT, NULL, 0, NULL, 0); 62 - if (r) 63 - return r; 64 59 65 60 /* 66 61 * Save SCI mask (this gets lost since PM1_EN is used as a mask for ··· 71 76 72 77 /* Restore SCI mask (using dword access to CS5536_PM1_EN) */ 73 78 outl(saved_sci_mask, acpi_base + CS5536_PM1_STS); 74 - 75 - /* Tell the EC to stop inhibiting SCIs */ 76 - olpc_ec_cmd(EC_SET_SCI_INHIBIT_RELEASE, NULL, 0, NULL, 0); 77 - 78 - /* 79 - * Tell the wireless module to restart USB communication. 80 - * Must be done twice. 81 - */ 82 - olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0); 83 - olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0); 84 79 85 80 return 0; 86 81 }
+36 -7
arch/x86/platform/olpc/olpc.c
··· 263 263 } 264 264 EXPORT_SYMBOL_GPL(olpc_ec_sci_query); 265 265 266 - static int olpc_ec_suspend(struct platform_device *pdev) 267 - { 268 - return olpc_ec_mask_write(ec_wakeup_mask); 269 - } 270 - 271 266 static bool __init check_ofw_architecture(struct device_node *root) 272 267 { 273 268 const char *olpc_arch; ··· 334 339 335 340 return 0; 336 341 } 342 + static int olpc_xo1_ec_suspend(struct platform_device *pdev) 343 + { 344 + olpc_ec_mask_write(ec_wakeup_mask); 345 + 346 + /* 347 + * Squelch SCIs while suspended. This is a fix for 348 + * <http://dev.laptop.org/ticket/1835>. 349 + */ 350 + return olpc_ec_cmd(EC_SET_SCI_INHIBIT, NULL, 0, NULL, 0); 351 + } 352 + 353 + static int olpc_xo1_ec_resume(struct platform_device *pdev) 354 + { 355 + /* Tell the EC to stop inhibiting SCIs */ 356 + olpc_ec_cmd(EC_SET_SCI_INHIBIT_RELEASE, NULL, 0, NULL, 0); 357 + 358 + /* 359 + * Tell the wireless module to restart USB communication. 360 + * Must be done twice. 361 + */ 362 + olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0); 363 + olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0); 364 + 365 + return 0; 366 + } 337 367 338 368 static struct olpc_ec_driver ec_xo1_driver = { 339 - .suspend = olpc_ec_suspend, 369 + .probe = olpc_xo1_ec_probe, 370 + .suspend = olpc_xo1_ec_suspend, 371 + .resume = olpc_xo1_ec_resume, 372 + .ec_cmd = olpc_xo1_ec_cmd, 373 + }; 374 + 375 + static struct olpc_ec_driver ec_xo1_5_driver = { 340 376 .probe = olpc_xo1_ec_probe, 341 377 .ec_cmd = olpc_xo1_ec_cmd, 342 378 }; ··· 380 354 return 0; 381 355 382 356 /* register the XO-1 and 1.5-specific EC handler */ 383 - olpc_ec_driver_register(&ec_xo1_driver, NULL); 357 + if (olpc_platform_info.boardrev < olpc_board_pre(0xd0)) /* XO-1 */ 358 + olpc_ec_driver_register(&ec_xo1_driver, NULL); 359 + else 360 + olpc_ec_driver_register(&ec_xo1_5_driver, NULL); 384 361 platform_device_register_simple("olpc-ec", -1, NULL, 0); 385 362 386 363 /* assume B1 and above models always have a DCON */