#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/delay.h>
-#include <linux/spinlock.h>
 #include <linux/io.h>
 #include <linux/string.h>
 #include <linux/platform_device.h>
 struct olpc_platform_t olpc_platform_info;
 EXPORT_SYMBOL_GPL(olpc_platform_info);
 
-static DEFINE_SPINLOCK(ec_lock);
-
 /* debugfs interface to EC commands */
 #define EC_MAX_CMD_ARGS (5 + 1)        /* cmd byte + 5 args */
 #define EC_MAX_CMD_REPLY (8)
  * <http://wiki.laptop.org/go/Ec_specification>.  Unfortunately, while
  * OpenFirmware's source is available, the EC's is not.
  */
-int olpc_ec_cmd_x86(unsigned char cmd, unsigned char *inbuf, size_t inlen,
-               unsigned char *outbuf,  size_t outlen)
+static int olpc_xo1_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *outbuf,
+               size_t outlen, void *arg)
 {
-       unsigned long flags;
        int ret = -EIO;
        int i;
        int restarts = 0;
 
-       spin_lock_irqsave(&ec_lock, flags);
-
        /* Clear OBF */
        for (i = 0; i < 10 && (obf_status(0x6c) == 1); i++)
                inb(0x68);
 
        ret = 0;
 err:
-       spin_unlock_irqrestore(&ec_lock, flags);
        return ret;
 }
-EXPORT_SYMBOL_GPL(olpc_ec_cmd_x86);
 
 void olpc_ec_wakeup_set(u16 value)
 {
                            &ec_debugfs_genops);
 }
 
-static int olpc_ec_suspend(void)
+static int olpc_ec_suspend(struct platform_device *pdev)
 {
        return olpc_ec_mask_write(ec_wakeup_mask);
 }
        return 0;
 }
 
-static struct syscore_ops olpc_syscore_ops = {
+static int olpc_xo1_ec_probe(struct platform_device *pdev)
+{
+       /* get the EC revision */
+       olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0,
+                       (unsigned char *) &olpc_platform_info.ecver, 1);
+
+       /* EC version 0x5f adds support for wide SCI mask */
+       if (olpc_platform_info.ecver >= 0x5f)
+               olpc_platform_info.flags |= OLPC_F_EC_WIDE_SCI;
+
+       pr_info("OLPC board revision %s%X (EC=%x)\n",
+                       ((olpc_platform_info.boardrev & 0xf) < 8) ? "pre" : "",
+                       olpc_platform_info.boardrev >> 4,
+                       olpc_platform_info.ecver);
+
+       return 0;
+}
+
+static struct olpc_ec_driver ec_xo1_driver = {
        .suspend = olpc_ec_suspend,
+       .probe = olpc_xo1_ec_probe,
+       .ec_cmd = olpc_xo1_ec_cmd,
 };
 
 static int __init olpc_init(void)
        if (!olpc_ofw_present() || !platform_detect())
                return 0;
 
-       spin_lock_init(&ec_lock);
+       /* register the XO-1 and 1.5-specific EC handler */
+       olpc_ec_driver_register(&ec_xo1_driver, NULL);
+       platform_device_register_simple("olpc-ec", -1, NULL, 0);
 
        /* assume B1 and above models always have a DCON */
        if (olpc_board_at_least(olpc_board(0xb1)))
                olpc_platform_info.flags |= OLPC_F_DCON;
 
-       /* get the EC revision */
-       olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0,
-                       (unsigned char *) &olpc_platform_info.ecver, 1);
-
 #ifdef CONFIG_PCI_OLPC
        /* If the VSA exists let it emulate PCI, if not emulate in kernel.
         * XO-1 only. */
                        !cs5535_has_vsa2())
                x86_init.pci.arch_init = pci_olpc_init;
 #endif
-       /* EC version 0x5f adds support for wide SCI mask */
-       if (olpc_platform_info.ecver >= 0x5f)
-               olpc_platform_info.flags |= OLPC_F_EC_WIDE_SCI;
-
-       printk(KERN_INFO "OLPC board revision %s%X (EC=%x)\n",
-                       ((olpc_platform_info.boardrev & 0xf) < 8) ? "pre" : "",
-                       olpc_platform_info.boardrev >> 4,
-                       olpc_platform_info.ecver);
 
        if (olpc_platform_info.boardrev < olpc_board_pre(0xd0)) { /* XO-1 */
                r = add_xo1_platform_devices();
                        return r;
        }
 
-       register_syscore_ops(&olpc_syscore_ops);
        setup_debugfs();
 
        return 0;