2 * Support for rfkill through the OLPC XO-1 laptop embedded controller
4 * Copyright (C) 2010 One Laptop per Child
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
12 #include <linux/module.h>
13 #include <linux/platform_device.h>
14 #include <linux/rfkill.h>
18 static bool card_blocked;
20 static int rfkill_set_block(void *data, bool blocked)
25 if (blocked == card_blocked)
29 cmd = EC_WLAN_ENTER_RESET;
31 cmd = EC_WLAN_LEAVE_RESET;
33 r = olpc_ec_cmd(cmd, NULL, 0, NULL, 0);
35 card_blocked = blocked;
40 static const struct rfkill_ops rfkill_ops = {
41 .set_block = rfkill_set_block,
44 static int __devinit xo1_rfkill_probe(struct platform_device *pdev)
49 rfk = rfkill_alloc(pdev->name, &pdev->dev, RFKILL_TYPE_WLAN,
54 r = rfkill_register(rfk);
60 platform_set_drvdata(pdev, rfk);
64 static int __devexit xo1_rfkill_remove(struct platform_device *pdev)
66 struct rfkill *rfk = platform_get_drvdata(pdev);
67 rfkill_unregister(rfk);
72 static struct platform_driver xo1_rfkill_driver = {
77 .probe = xo1_rfkill_probe,
78 .remove = __devexit_p(xo1_rfkill_remove),
81 module_platform_driver(xo1_rfkill_driver);
83 MODULE_AUTHOR("Daniel Drake <dsd@laptop.org>");
84 MODULE_LICENSE("GPL");
85 MODULE_ALIAS("platform:xo1-rfkill");