aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorDmitry Baryshkov <dbaryshkov@gmail.com>2008-07-05 04:02:48 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-07-07 08:22:10 -0400
commit16b32fd0a35b30cbd67395cfcbd360354db44f39 (patch)
tree1d4ded0a19ea134a8dd29e33fec07b8712b4f6d7 /arch/arm
parent5289fecda021828af85fccc8cc2613a85d0fcf52 (diff)
[ARM] 5150/1: Tosa: support built-in bluetooth power-up
The driver is pretty much generic and will be later shared with a few other devices, like hx4700 ipaq. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-pxa/Kconfig8
-rw-r--r--arch/arm/mach-pxa/Makefile2
-rw-r--r--arch/arm/mach-pxa/tosa-bt.c150
-rw-r--r--arch/arm/mach-pxa/tosa.c17
4 files changed, 176 insertions, 1 deletions
diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig
index 5da7a6820492..6c162f8fdcea 100644
--- a/arch/arm/mach-pxa/Kconfig
+++ b/arch/arm/mach-pxa/Kconfig
@@ -273,4 +273,12 @@ config PXA_SSP
273 tristate 273 tristate
274 help 274 help
275 Enable support for PXA2xx SSP ports 275 Enable support for PXA2xx SSP ports
276
277config TOSA_BT
278 tristate "Control the state of built-in bluetooth chip on Sharp SL-6000"
279 depends on MACH_TOSA
280 select RFKILL
281 help
282 This is a simple driver that is able to control
283 the state of built in bluetooth chip on tosa.
276endif 284endif
diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile
index c9e66fbe622e..18e0b249f7ca 100644
--- a/arch/arm/mach-pxa/Makefile
+++ b/arch/arm/mach-pxa/Makefile
@@ -58,3 +58,5 @@ obj-$(CONFIG_LEDS) += $(led-y)
58ifeq ($(CONFIG_PCI),y) 58ifeq ($(CONFIG_PCI),y)
59obj-$(CONFIG_MACH_ARMCORE) += cm-x270-pci.o 59obj-$(CONFIG_MACH_ARMCORE) += cm-x270-pci.o
60endif 60endif
61
62obj-$(CONFIG_TOSA_BT) += tosa-bt.o
diff --git a/arch/arm/mach-pxa/tosa-bt.c b/arch/arm/mach-pxa/tosa-bt.c
new file mode 100644
index 000000000000..7d8505466e54
--- /dev/null
+++ b/arch/arm/mach-pxa/tosa-bt.c
@@ -0,0 +1,150 @@
1/*
2 * Bluetooth built-in chip control
3 *
4 * Copyright (c) 2008 Dmitry Baryshkov
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 version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/platform_device.h>
15#include <linux/gpio.h>
16#include <linux/delay.h>
17#include <linux/rfkill.h>
18
19#include <asm/arch/tosa_bt.h>
20
21static void tosa_bt_on(struct tosa_bt_data *data)
22{
23 gpio_set_value(data->gpio_reset, 0);
24 gpio_set_value(data->gpio_pwr, 1);
25 gpio_set_value(data->gpio_reset, 1);
26 mdelay(20);
27 gpio_set_value(data->gpio_reset, 0);
28}
29
30static void tosa_bt_off(struct tosa_bt_data *data)
31{
32 gpio_set_value(data->gpio_reset, 1);
33 mdelay(10);
34 gpio_set_value(data->gpio_pwr, 0);
35 gpio_set_value(data->gpio_reset, 0);
36}
37
38static int tosa_bt_toggle_radio(void *data, enum rfkill_state state)
39{
40 pr_info("BT_RADIO going: %s\n",
41 state == RFKILL_STATE_ON ? "on" : "off");
42
43 if (state == RFKILL_STATE_ON) {
44 pr_info("TOSA_BT: going ON\n");
45 tosa_bt_on(data);
46 } else {
47 pr_info("TOSA_BT: going OFF\n");
48 tosa_bt_off(data);
49 }
50 return 0;
51}
52
53static int tosa_bt_probe(struct platform_device *dev)
54{
55 int rc;
56 struct rfkill *rfk;
57
58 struct tosa_bt_data *data = dev->dev.platform_data;
59
60 rc = gpio_request(data->gpio_reset, "Bluetooth reset");
61 if (rc)
62 goto err_reset;
63 rc = gpio_direction_output(data->gpio_reset, 0);
64 if (rc)
65 goto err_reset_dir;
66 rc = gpio_request(data->gpio_pwr, "Bluetooth power");
67 if (rc)
68 goto err_pwr;
69 rc = gpio_direction_output(data->gpio_pwr, 0);
70 if (rc)
71 goto err_pwr_dir;
72
73 rfk = rfkill_allocate(&dev->dev, RFKILL_TYPE_BLUETOOTH);
74 if (!rfk) {
75 rc = -ENOMEM;
76 goto err_rfk_alloc;
77 }
78
79 rfk->name = "tosa-bt";
80 rfk->toggle_radio = tosa_bt_toggle_radio;
81 rfk->data = data;
82#ifdef CONFIG_RFKILL_LEDS
83 rfk->led_trigger.name = "tosa-bt";
84#endif
85
86 rc = rfkill_register(rfk);
87 if (rc)
88 goto err_rfkill;
89
90 platform_set_drvdata(dev, rfk);
91
92 return 0;
93
94err_rfkill:
95 if (rfk)
96 rfkill_free(rfk);
97 rfk = NULL;
98err_rfk_alloc:
99 tosa_bt_off(data);
100err_pwr_dir:
101 gpio_free(data->gpio_pwr);
102err_pwr:
103err_reset_dir:
104 gpio_free(data->gpio_reset);
105err_reset:
106 return rc;
107}
108
109static int __devexit tosa_bt_remove(struct platform_device *dev)
110{
111 struct tosa_bt_data *data = dev->dev.platform_data;
112 struct rfkill *rfk = platform_get_drvdata(dev);
113
114 platform_set_drvdata(dev, NULL);
115
116 if (rfk)
117 rfkill_unregister(rfk);
118 rfk = NULL;
119
120 tosa_bt_off(data);
121
122 gpio_free(data->gpio_pwr);
123 gpio_free(data->gpio_reset);
124
125 return 0;
126}
127
128static struct platform_driver tosa_bt_driver = {
129 .probe = tosa_bt_probe,
130 .remove = __devexit_p(tosa_bt_remove),
131
132 .driver = {
133 .name = "tosa-bt",
134 .owner = THIS_MODULE,
135 },
136};
137
138
139static int __init tosa_bt_init(void)
140{
141 return platform_driver_register(&tosa_bt_driver);
142}
143
144static void __exit tosa_bt_exit(void)
145{
146 platform_driver_unregister(&tosa_bt_driver);
147}
148
149module_init(tosa_bt_init);
150module_exit(tosa_bt_exit);
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
index fa903e7ae624..5a9d329f5045 100644
--- a/arch/arm/mach-pxa/tosa.c
+++ b/arch/arm/mach-pxa/tosa.c
@@ -31,6 +31,7 @@
31#include <linux/input.h> 31#include <linux/input.h>
32#include <linux/gpio.h> 32#include <linux/gpio.h>
33#include <linux/pda_power.h> 33#include <linux/pda_power.h>
34#include <linux/rfkill.h>
34 35
35#include <asm/setup.h> 36#include <asm/setup.h>
36#include <asm/mach-types.h> 37#include <asm/mach-types.h>
@@ -40,6 +41,7 @@
40#include <asm/arch/i2c.h> 41#include <asm/arch/i2c.h>
41#include <asm/arch/mmc.h> 42#include <asm/arch/mmc.h>
42#include <asm/arch/udc.h> 43#include <asm/arch/udc.h>
44#include <asm/arch/tosa_bt.h>
43 45
44#include <asm/mach/arch.h> 46#include <asm/mach/arch.h>
45#include <asm/arch/tosa.h> 47#include <asm/arch/tosa.h>
@@ -562,7 +564,7 @@ static struct gpio_led tosa_gpio_leds[] = {
562 }, 564 },
563 { 565 {
564 .name = "tosa:blue:bluetooth", 566 .name = "tosa:blue:bluetooth",
565 .default_trigger = "none", 567 .default_trigger = "tosa-bt",
566 .gpio = TOSA_GPIO_BT_LED, 568 .gpio = TOSA_GPIO_BT_LED,
567 }, 569 },
568}; 570};
@@ -732,6 +734,18 @@ static struct platform_device tc6393xb_device = {
732 .resource = tc6393xb_resources, 734 .resource = tc6393xb_resources,
733}; 735};
734 736
737static struct tosa_bt_data tosa_bt_data = {
738 .gpio_pwr = TOSA_GPIO_BT_PWR_EN,
739 .gpio_reset = TOSA_GPIO_BT_RESET,
740};
741
742static struct platform_device tosa_bt_device = {
743 .name = "tosa-bt",
744 .id = -1,
745 .dev.platform_data = &tosa_bt_data,
746};
747
748
735static struct platform_device *devices[] __initdata = { 749static struct platform_device *devices[] __initdata = {
736 &tosascoop_device, 750 &tosascoop_device,
737 &tosascoop_jc_device, 751 &tosascoop_jc_device,
@@ -740,6 +754,7 @@ static struct platform_device *devices[] __initdata = {
740 &tosakbd_device, 754 &tosakbd_device,
741 &tosa_gpio_keys_device, 755 &tosa_gpio_keys_device,
742 &tosaled_device, 756 &tosaled_device,
757 &tosa_bt_device,
743}; 758};
744 759
745static void tosa_poweroff(void) 760static void tosa_poweroff(void)