aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorArnaud Patard <arnaud.patard@rtp-net.org>2007-05-09 16:41:03 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2007-05-11 12:19:37 -0400
commit7fdc7849d2f9f926cbaec224bbcbacb164b07b23 (patch)
treeb7fea8c279e225517324f3714c24999916a0dfe7 /arch/arm
parentb8b6970b4fe08397554295b0c5169bec7575f7c9 (diff)
[ARM] 4359/3: H1940: Add bluetooth support
This patch adds a small driver responsible for configuring the UART used for the bluetooth chip and for enabling the bluetooth chipset. Additionnaly, can trigger a led if the H1940 led driver is enabled. Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org> Signed-off-by: Ben Dooks <ben-linux@fluff.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-s3c2410/Makefile2
-rw-r--r--arch/arm/mach-s3c2410/h1940-bluetooth.c142
-rw-r--r--arch/arm/mach-s3c2410/mach-h1940.c6
3 files changed, 149 insertions, 1 deletions
diff --git a/arch/arm/mach-s3c2410/Makefile b/arch/arm/mach-s3c2410/Makefile
index 9a3d3d24c084..3e7a85594d9c 100644
--- a/arch/arm/mach-s3c2410/Makefile
+++ b/arch/arm/mach-s3c2410/Makefile
@@ -20,7 +20,7 @@ obj-$(CONFIG_S3C2410_CLOCK) += clock.o
20# Machine support 20# Machine support
21 21
22obj-$(CONFIG_ARCH_SMDK2410) += mach-smdk2410.o 22obj-$(CONFIG_ARCH_SMDK2410) += mach-smdk2410.o
23obj-$(CONFIG_ARCH_H1940) += mach-h1940.o 23obj-$(CONFIG_ARCH_H1940) += mach-h1940.o h1940-bluetooth.o
24obj-$(CONFIG_PM_H1940) += pm-h1940.o 24obj-$(CONFIG_PM_H1940) += pm-h1940.o
25obj-$(CONFIG_MACH_N30) += mach-n30.o 25obj-$(CONFIG_MACH_N30) += mach-n30.o
26obj-$(CONFIG_ARCH_BAST) += mach-bast.o usb-simtec.o 26obj-$(CONFIG_ARCH_BAST) += mach-bast.o usb-simtec.o
diff --git a/arch/arm/mach-s3c2410/h1940-bluetooth.c b/arch/arm/mach-s3c2410/h1940-bluetooth.c
new file mode 100644
index 000000000000..3c48886521e7
--- /dev/null
+++ b/arch/arm/mach-s3c2410/h1940-bluetooth.c
@@ -0,0 +1,142 @@
1/*
2 * arch/arm/mach-s3c2410/h1940-bluetooth.c
3 * Copyright (c) Arnaud Patard <arnaud.patard@rtp-net.org>
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file COPYING in the main directory of this archive for
7 * more details.
8 *
9 * S3C2410 bluetooth "driver"
10 *
11 */
12
13#include <linux/module.h>
14#include <linux/platform_device.h>
15#include <linux/delay.h>
16#include <linux/string.h>
17#include <linux/ctype.h>
18#include <linux/leds.h>
19#include <asm/arch/regs-gpio.h>
20#include <asm/hardware.h>
21#include <asm/arch/h1940-latch.h>
22
23#define DRV_NAME "h1940-bt"
24
25#ifdef CONFIG_LEDS_H1940
26DEFINE_LED_TRIGGER(bt_led_trigger);
27#endif
28
29static int state;
30
31/* Bluetooth control */
32static void h1940bt_enable(int on)
33{
34 if (on) {
35#ifdef CONFIG_LEDS_H1940
36 /* flashing Blue */
37 led_trigger_event(bt_led_trigger, LED_HALF);
38#endif
39
40 /* Power on the chip */
41 h1940_latch_control(0, H1940_LATCH_BLUETOOTH_POWER);
42 /* Reset the chip */
43 mdelay(10);
44 s3c2410_gpio_setpin(S3C2410_GPH1, 1);
45 mdelay(10);
46 s3c2410_gpio_setpin(S3C2410_GPH1, 0);
47
48 state = 1;
49 }
50 else {
51#ifdef CONFIG_LEDS_H1940
52 led_trigger_event(bt_led_trigger, 0);
53#endif
54
55 s3c2410_gpio_setpin(S3C2410_GPH1, 1);
56 mdelay(10);
57 s3c2410_gpio_setpin(S3C2410_GPH1, 0);
58 mdelay(10);
59 h1940_latch_control(H1940_LATCH_BLUETOOTH_POWER, 0);
60
61 state = 0;
62 }
63}
64
65static ssize_t h1940bt_show(struct device *dev, struct device_attribute *attr, char *buf)
66{
67 return snprintf(buf, PAGE_SIZE, "%d\n", state);
68}
69
70static ssize_t h1940bt_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
71{
72 int new_state;
73 char *endp;
74
75 new_state = simple_strtoul(buf, &endp, 0);
76 if (*endp && !isspace(*endp))
77 return -EINVAL;
78
79 h1940bt_enable(new_state);
80
81 return count;
82}
83static DEVICE_ATTR(enable, 0644,
84 h1940bt_show,
85 h1940bt_store);
86
87static int __init h1940bt_probe(struct platform_device *pdev)
88{
89 /* Configures BT serial port GPIOs */
90 s3c2410_gpio_cfgpin(S3C2410_GPH0, S3C2410_GPH0_nCTS0);
91 s3c2410_gpio_pullup(S3C2410_GPH0, 1);
92 s3c2410_gpio_cfgpin(S3C2410_GPH1, S3C2410_GPH1_OUTP);
93 s3c2410_gpio_pullup(S3C2410_GPH1, 1);
94 s3c2410_gpio_cfgpin(S3C2410_GPH2, S3C2410_GPH2_TXD0);
95 s3c2410_gpio_pullup(S3C2410_GPH2, 1);
96 s3c2410_gpio_cfgpin(S3C2410_GPH3, S3C2410_GPH3_RXD0);
97 s3c2410_gpio_pullup(S3C2410_GPH3, 1);
98
99#ifdef CONFIG_LEDS_H1940
100 led_trigger_register_simple("h1940-bluetooth", &bt_led_trigger);
101#endif
102
103 /* disable BT by default */
104 h1940bt_enable(0);
105
106 return device_create_file(&pdev->dev, &dev_attr_enable);
107}
108
109static int h1940bt_remove(struct platform_device *pdev)
110{
111#ifdef CONFIG_LEDS_H1940
112 led_trigger_unregister_simple(bt_led_trigger);
113#endif
114 return 0;
115}
116
117
118static struct platform_driver h1940bt_driver = {
119 .driver = {
120 .name = DRV_NAME,
121 },
122 .probe = h1940bt_probe,
123 .remove = h1940bt_remove,
124};
125
126
127static int __init h1940bt_init(void)
128{
129 return platform_driver_register(&h1940bt_driver);
130}
131
132static void __exit h1940bt_exit(void)
133{
134 platform_driver_unregister(&h1940bt_driver);
135}
136
137module_init(h1940bt_init);
138module_exit(h1940bt_exit);
139
140MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
141MODULE_DESCRIPTION("Driver for the iPAQ H1940 bluetooth chip");
142MODULE_LICENSE("GPL");
diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c
index 5d5f00e9c462..5ccd0be23a33 100644
--- a/arch/arm/mach-s3c2410/mach-h1940.c
+++ b/arch/arm/mach-s3c2410/mach-h1940.c
@@ -177,6 +177,11 @@ static struct platform_device s3c_device_leds = {
177 .id = -1, 177 .id = -1,
178}; 178};
179 179
180static struct platform_device s3c_device_bluetooth = {
181 .name = "h1940-bt",
182 .id = -1,
183};
184
180static struct platform_device *h1940_devices[] __initdata = { 185static struct platform_device *h1940_devices[] __initdata = {
181 &s3c_device_usb, 186 &s3c_device_usb,
182 &s3c_device_lcd, 187 &s3c_device_lcd,
@@ -185,6 +190,7 @@ static struct platform_device *h1940_devices[] __initdata = {
185 &s3c_device_iis, 190 &s3c_device_iis,
186 &s3c_device_usbgadget, 191 &s3c_device_usbgadget,
187 &s3c_device_leds, 192 &s3c_device_leds,
193 &s3c_device_bluetooth,
188}; 194};
189 195
190static void __init h1940_map_io(void) 196static void __init h1940_map_io(void)