diff options
author | Daniel Drake <dsd@laptop.org> | 2010-10-05 10:55:21 -0400 |
---|---|---|
committer | Matthew Garrett <mjg@redhat.com> | 2010-10-21 10:10:44 -0400 |
commit | 260586d2b444909380137de6c6423e5b44edf4db (patch) | |
tree | 612411c307af79ff2bc1f1545b76c1ad5a8c9dc8 /drivers/platform/x86 | |
parent | bd9fc3a72345807683a009c1e19dc0d517f0f4e7 (diff) |
Add OLPC XO-1 rfkill driver
Add a software rfkill switch for the WLAN interface in the OLPC XO-1
laptop. It uses the OLPC embedded controller to cut/restore power to
the Marvell WLAN chip on the motherboard.
Signed-off-by: Daniel Drake <dsd@laptop.org>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers/platform/x86')
-rw-r--r-- | drivers/platform/x86/Kconfig | 8 | ||||
-rw-r--r-- | drivers/platform/x86/Makefile | 1 | ||||
-rw-r--r-- | drivers/platform/x86/xo1-rfkill.c | 85 |
3 files changed, 94 insertions, 0 deletions
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index d2d15108ce4b..91e431b6f20f 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig | |||
@@ -615,4 +615,12 @@ config INTEL_IPS | |||
615 | functionality. If in doubt, say Y here; it will only load on | 615 | functionality. If in doubt, say Y here; it will only load on |
616 | supported platforms. | 616 | supported platforms. |
617 | 617 | ||
618 | config XO1_RFKILL | ||
619 | tristate "OLPC XO-1 software RF kill switch" | ||
620 | depends on OLPC | ||
621 | depends on RFKILL | ||
622 | ---help--- | ||
623 | Support for enabling/disabling the WLAN interface on the OLPC XO-1 | ||
624 | laptop. | ||
625 | |||
618 | endif # X86_PLATFORM_DEVICES | 626 | endif # X86_PLATFORM_DEVICES |
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index c97ac2a9dab7..c15e96336e65 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile | |||
@@ -31,4 +31,5 @@ obj-$(CONFIG_INTEL_SCU_IPC) += intel_scu_ipc.o | |||
31 | obj-$(CONFIG_RAR_REGISTER) += intel_rar_register.o | 31 | obj-$(CONFIG_RAR_REGISTER) += intel_rar_register.o |
32 | obj-$(CONFIG_INTEL_IPS) += intel_ips.o | 32 | obj-$(CONFIG_INTEL_IPS) += intel_ips.o |
33 | obj-$(CONFIG_GPIO_INTEL_PMIC) += intel_pmic_gpio.o | 33 | obj-$(CONFIG_GPIO_INTEL_PMIC) += intel_pmic_gpio.o |
34 | obj-$(CONFIG_XO1_RFKILL) += xo1-rfkill.o | ||
34 | 35 | ||
diff --git a/drivers/platform/x86/xo1-rfkill.c b/drivers/platform/x86/xo1-rfkill.c new file mode 100644 index 000000000000..e549eeeda121 --- /dev/null +++ b/drivers/platform/x86/xo1-rfkill.c | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | * Support for rfkill through the OLPC XO-1 laptop embedded controller | ||
3 | * | ||
4 | * Copyright (C) 2010 One Laptop per Child | ||
5 | * | ||
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. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/rfkill.h> | ||
15 | |||
16 | #include <asm/olpc.h> | ||
17 | |||
18 | static int rfkill_set_block(void *data, bool blocked) | ||
19 | { | ||
20 | unsigned char cmd; | ||
21 | if (blocked) | ||
22 | cmd = EC_WLAN_ENTER_RESET; | ||
23 | else | ||
24 | cmd = EC_WLAN_LEAVE_RESET; | ||
25 | |||
26 | return olpc_ec_cmd(cmd, NULL, 0, NULL, 0); | ||
27 | } | ||
28 | |||
29 | static const struct rfkill_ops rfkill_ops = { | ||
30 | .set_block = rfkill_set_block, | ||
31 | }; | ||
32 | |||
33 | static int __devinit xo1_rfkill_probe(struct platform_device *pdev) | ||
34 | { | ||
35 | struct rfkill *rfk; | ||
36 | int r; | ||
37 | |||
38 | rfk = rfkill_alloc(pdev->name, &pdev->dev, RFKILL_TYPE_WLAN, | ||
39 | &rfkill_ops, NULL); | ||
40 | if (!rfk) | ||
41 | return -ENOMEM; | ||
42 | |||
43 | r = rfkill_register(rfk); | ||
44 | if (r) { | ||
45 | rfkill_destroy(rfk); | ||
46 | return r; | ||
47 | } | ||
48 | |||
49 | platform_set_drvdata(pdev, rfk); | ||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | static int __devexit xo1_rfkill_remove(struct platform_device *pdev) | ||
54 | { | ||
55 | struct rfkill *rfk = platform_get_drvdata(pdev); | ||
56 | rfkill_unregister(rfk); | ||
57 | rfkill_destroy(rfk); | ||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | static struct platform_driver xo1_rfkill_driver = { | ||
62 | .driver = { | ||
63 | .name = "xo1-rfkill", | ||
64 | .owner = THIS_MODULE, | ||
65 | }, | ||
66 | .probe = xo1_rfkill_probe, | ||
67 | .remove = __devexit_p(xo1_rfkill_remove), | ||
68 | }; | ||
69 | |||
70 | static int __init xo1_rfkill_init(void) | ||
71 | { | ||
72 | return platform_driver_register(&xo1_rfkill_driver); | ||
73 | } | ||
74 | |||
75 | static void __exit xo1_rfkill_exit(void) | ||
76 | { | ||
77 | platform_driver_unregister(&xo1_rfkill_driver); | ||
78 | } | ||
79 | |||
80 | MODULE_AUTHOR("Daniel Drake <dsd@laptop.org>"); | ||
81 | MODULE_LICENSE("GPL"); | ||
82 | MODULE_ALIAS("platform:xo1-rfkill"); | ||
83 | |||
84 | module_init(xo1_rfkill_init); | ||
85 | module_exit(xo1_rfkill_exit); | ||