Skip to content

Commit 85f90cf

Browse files
committed
x86: OLPC: switch over to using new EC driver on x86
This uses the new EC driver framework in drivers/platform/olpc. The XO-1 and XO-1.5-specific code is still in arch/x86, but the generic stuff (including a new workqueue; no more running EC commands with IRQs disabled!) can be shared with other architectures. Signed-off-by: Andres Salomon <dilinger@queued.net> Acked-by: Paul Fox <pgf@laptop.org> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
1 parent d278b7a commit 85f90cf

File tree

3 files changed

+27
-36
lines changed

3 files changed

+27
-36
lines changed

arch/x86/include/asm/olpc.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@ extern void olpc_xo1_pm_wakeup_clear(u16 value);
100100

101101
extern int pci_olpc_init(void);
102102

103-
/* EC related functions */
104-
105-
extern int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf,
106-
size_t inlen, unsigned char *outbuf, size_t outlen);
107-
108103
/* SCI source values */
109104

110105
#define EC_SCI_SRC_EMPTY 0x00

arch/x86/platform/olpc/olpc.c

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <linux/init.h>
1515
#include <linux/module.h>
1616
#include <linux/delay.h>
17-
#include <linux/spinlock.h>
1817
#include <linux/io.h>
1918
#include <linux/string.h>
2019
#include <linux/platform_device.h>
@@ -32,8 +31,6 @@
3231
struct olpc_platform_t olpc_platform_info;
3332
EXPORT_SYMBOL_GPL(olpc_platform_info);
3433

35-
static DEFINE_SPINLOCK(ec_lock);
36-
3734
/* debugfs interface to EC commands */
3835
#define EC_MAX_CMD_ARGS (5 + 1) /* cmd byte + 5 args */
3936
#define EC_MAX_CMD_REPLY (8)
@@ -126,16 +123,13 @@ static int __wait_on_obf(unsigned int line, unsigned int port, int desired)
126123
* <http://wiki.laptop.org/go/Ec_specification>. Unfortunately, while
127124
* OpenFirmware's source is available, the EC's is not.
128125
*/
129-
int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf, size_t inlen,
130-
unsigned char *outbuf, size_t outlen)
126+
static int olpc_xo1_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
127+
size_t outlen, void *arg)
131128
{
132-
unsigned long flags;
133129
int ret = -EIO;
134130
int i;
135131
int restarts = 0;
136132

137-
spin_lock_irqsave(&ec_lock, flags);
138-
139133
/* Clear OBF */
140134
for (i = 0; i < 10 && (obf_status(0x6c) == 1); i++)
141135
inb(0x68);
@@ -199,10 +193,8 @@ int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf, size_t inlen,
199193

200194
ret = 0;
201195
err:
202-
spin_unlock_irqrestore(&ec_lock, flags);
203196
return ret;
204197
}
205-
EXPORT_SYMBOL_GPL(olpc_ec_cmd_x86);
206198

207199
void olpc_ec_wakeup_set(u16 value)
208200
{
@@ -366,7 +358,7 @@ static void setup_debugfs(void)
366358
&ec_debugfs_genops);
367359
}
368360

369-
static int olpc_ec_suspend(void)
361+
static int olpc_ec_suspend(struct platform_device *pdev)
370362
{
371363
return olpc_ec_mask_write(ec_wakeup_mask);
372364
}
@@ -425,8 +417,28 @@ static int __init add_xo1_platform_devices(void)
425417
return 0;
426418
}
427419

428-
static struct syscore_ops olpc_syscore_ops = {
420+
static int olpc_xo1_ec_probe(struct platform_device *pdev)
421+
{
422+
/* get the EC revision */
423+
olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0,
424+
(unsigned char *) &olpc_platform_info.ecver, 1);
425+
426+
/* EC version 0x5f adds support for wide SCI mask */
427+
if (olpc_platform_info.ecver >= 0x5f)
428+
olpc_platform_info.flags |= OLPC_F_EC_WIDE_SCI;
429+
430+
pr_info("OLPC board revision %s%X (EC=%x)\n",
431+
((olpc_platform_info.boardrev & 0xf) < 8) ? "pre" : "",
432+
olpc_platform_info.boardrev >> 4,
433+
olpc_platform_info.ecver);
434+
435+
return 0;
436+
}
437+
438+
static struct olpc_ec_driver ec_xo1_driver = {
429439
.suspend = olpc_ec_suspend,
440+
.probe = olpc_xo1_ec_probe,
441+
.ec_cmd = olpc_xo1_ec_cmd,
430442
};
431443

432444
static int __init olpc_init(void)
@@ -436,39 +448,28 @@ static int __init olpc_init(void)
436448
if (!olpc_ofw_present() || !platform_detect())
437449
return 0;
438450

439-
spin_lock_init(&ec_lock);
451+
/* register the XO-1 and 1.5-specific EC handler */
452+
olpc_ec_driver_register(&ec_xo1_driver, NULL);
453+
platform_device_register_simple("olpc-ec", -1, NULL, 0);
440454

441455
/* assume B1 and above models always have a DCON */
442456
if (olpc_board_at_least(olpc_board(0xb1)))
443457
olpc_platform_info.flags |= OLPC_F_DCON;
444458

445-
/* get the EC revision */
446-
olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0,
447-
(unsigned char *) &olpc_platform_info.ecver, 1);
448-
449459
#ifdef CONFIG_PCI_OLPC
450460
/* If the VSA exists let it emulate PCI, if not emulate in kernel.
451461
* XO-1 only. */
452462
if (olpc_platform_info.boardrev < olpc_board_pre(0xd0) &&
453463
!cs5535_has_vsa2())
454464
x86_init.pci.arch_init = pci_olpc_init;
455465
#endif
456-
/* EC version 0x5f adds support for wide SCI mask */
457-
if (olpc_platform_info.ecver >= 0x5f)
458-
olpc_platform_info.flags |= OLPC_F_EC_WIDE_SCI;
459-
460-
printk(KERN_INFO "OLPC board revision %s%X (EC=%x)\n",
461-
((olpc_platform_info.boardrev & 0xf) < 8) ? "pre" : "",
462-
olpc_platform_info.boardrev >> 4,
463-
olpc_platform_info.ecver);
464466

465467
if (olpc_platform_info.boardrev < olpc_board_pre(0xd0)) { /* XO-1 */
466468
r = add_xo1_platform_devices();
467469
if (r)
468470
return r;
469471
}
470472

471-
register_syscore_ops(&olpc_syscore_ops);
472473
setup_debugfs();
473474

474475
return 0;

drivers/platform/olpc/olpc-ec.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,6 @@ int olpc_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf, size_t outlen)
113113
struct olpc_ec_priv *ec = ec_priv;
114114
struct ec_cmd_desc desc;
115115

116-
/* XXX: this will be removed in later patches */
117-
/* Are we using old-style callers? */
118-
if (!ec_driver || !ec_driver->ec_cmd)
119-
return olpc_ec_cmd_x86(cmd, inbuf, inlen, outbuf, outlen);
120-
121116
/* Ensure a driver and ec hook have been registered */
122117
if (WARN_ON(!ec_driver || !ec_driver->ec_cmd))
123118
return -ENODEV;

0 commit comments

Comments
 (0)