1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Support for rfkill through the OLPC XO-1 laptop embedded controller
5 * Copyright (C) 2010 One Laptop per Child
8 #include <linux/module.h>
9 #include <linux/platform_device.h>
10 #include <linux/rfkill.h>
11 #include <linux/olpc-ec.h>
13 static bool card_blocked
;
15 static int rfkill_set_block(void *data
, bool blocked
)
20 if (blocked
== card_blocked
)
24 cmd
= EC_WLAN_ENTER_RESET
;
26 cmd
= EC_WLAN_LEAVE_RESET
;
28 r
= olpc_ec_cmd(cmd
, NULL
, 0, NULL
, 0);
30 card_blocked
= blocked
;
35 static const struct rfkill_ops rfkill_ops
= {
36 .set_block
= rfkill_set_block
,
39 static int xo1_rfkill_probe(struct platform_device
*pdev
)
44 rfk
= rfkill_alloc(pdev
->name
, &pdev
->dev
, RFKILL_TYPE_WLAN
,
49 r
= rfkill_register(rfk
);
55 platform_set_drvdata(pdev
, rfk
);
59 static int xo1_rfkill_remove(struct platform_device
*pdev
)
61 struct rfkill
*rfk
= platform_get_drvdata(pdev
);
62 rfkill_unregister(rfk
);
67 static struct platform_driver xo1_rfkill_driver
= {
71 .probe
= xo1_rfkill_probe
,
72 .remove
= xo1_rfkill_remove
,
75 module_platform_driver(xo1_rfkill_driver
);
77 MODULE_AUTHOR("Daniel Drake <dsd@laptop.org>");
78 MODULE_LICENSE("GPL");
79 MODULE_ALIAS("platform:xo1-rfkill");