Skip to content

Commit 1fcfd08

Browse files
committed
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>
1 parent 99ecb01 commit 1fcfd08

File tree

2 files changed

+36
-22
lines changed

2 files changed

+36
-22
lines changed

arch/x86/platform/olpc/olpc-xo1-pm.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,11 @@ EXPORT_SYMBOL_GPL(olpc_xo1_pm_wakeup_clear);
5252
static int xo1_power_state_enter(suspend_state_t pm_state)
5353
{
5454
unsigned long saved_sci_mask;
55-
int r;
5655

5756
/* Only STR is supported */
5857
if (pm_state != PM_SUSPEND_MEM)
5958
return -EINVAL;
6059

61-
r = olpc_ec_cmd(EC_SET_SCI_INHIBIT, NULL, 0, NULL, 0);
62-
if (r)
63-
return r;
64-
6560
/*
6661
* Save SCI mask (this gets lost since PM1_EN is used as a mask for
6762
* wakeup events, which is not necessarily the same event set)
@@ -77,16 +72,6 @@ static int xo1_power_state_enter(suspend_state_t pm_state)
7772
/* Restore SCI mask (using dword access to CS5536_PM1_EN) */
7873
outl(saved_sci_mask, acpi_base + CS5536_PM1_STS);
7974

80-
/* Tell the EC to stop inhibiting SCIs */
81-
olpc_ec_cmd(EC_SET_SCI_INHIBIT_RELEASE, NULL, 0, NULL, 0);
82-
83-
/*
84-
* Tell the wireless module to restart USB communication.
85-
* Must be done twice.
86-
*/
87-
olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0);
88-
olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0);
89-
9075
return 0;
9176
}
9277

arch/x86/platform/olpc/olpc.c

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,6 @@ int olpc_ec_sci_query(u16 *sci_value)
263263
}
264264
EXPORT_SYMBOL_GPL(olpc_ec_sci_query);
265265

266-
static int olpc_ec_suspend(struct platform_device *pdev)
267-
{
268-
return olpc_ec_mask_write(ec_wakeup_mask);
269-
}
270-
271266
static bool __init check_ofw_architecture(struct device_node *root)
272267
{
273268
const char *olpc_arch;
@@ -339,9 +334,40 @@ static int olpc_xo1_ec_probe(struct platform_device *pdev)
339334

340335
return 0;
341336
}
337+
static int olpc_xo1_ec_suspend(struct platform_device *pdev)
338+
{
339+
olpc_ec_mask_write(ec_wakeup_mask);
340+
341+
/*
342+
* Squelch SCIs while suspended. This is a fix for
343+
* <http://dev.laptop.org/ticket/1835>.
344+
*/
345+
return olpc_ec_cmd(EC_SET_SCI_INHIBIT, NULL, 0, NULL, 0);
346+
}
347+
348+
static int olpc_xo1_ec_resume(struct platform_device *pdev)
349+
{
350+
/* Tell the EC to stop inhibiting SCIs */
351+
olpc_ec_cmd(EC_SET_SCI_INHIBIT_RELEASE, NULL, 0, NULL, 0);
352+
353+
/*
354+
* Tell the wireless module to restart USB communication.
355+
* Must be done twice.
356+
*/
357+
olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0);
358+
olpc_ec_cmd(EC_WAKE_UP_WLAN, NULL, 0, NULL, 0);
359+
360+
return 0;
361+
}
342362

343363
static struct olpc_ec_driver ec_xo1_driver = {
344-
.suspend = olpc_ec_suspend,
364+
.probe = olpc_xo1_ec_probe,
365+
.suspend = olpc_xo1_ec_suspend,
366+
.resume = olpc_xo1_ec_resume,
367+
.ec_cmd = olpc_xo1_ec_cmd,
368+
};
369+
370+
static struct olpc_ec_driver ec_xo1_5_driver = {
345371
.probe = olpc_xo1_ec_probe,
346372
.ec_cmd = olpc_xo1_ec_cmd,
347373
};
@@ -354,7 +380,10 @@ static int __init olpc_init(void)
354380
return 0;
355381

356382
/* register the XO-1 and 1.5-specific EC handler */
357-
olpc_ec_driver_register(&ec_xo1_driver, NULL);
383+
if (olpc_platform_info.boardrev < olpc_board_pre(0xd0)) /* XO-1 */
384+
olpc_ec_driver_register(&ec_xo1_driver, NULL);
385+
else
386+
olpc_ec_driver_register(&ec_xo1_5_driver, NULL);
358387
platform_device_register_simple("olpc-ec", -1, NULL, 0);
359388

360389
/* assume B1 and above models always have a DCON */

0 commit comments

Comments
 (0)