2 * arch/arm/mach-s3c2410/h1940-bluetooth.c
3 * Copyright (c) Arnaud Patard <arnaud.patard@rtp-net.org>
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
9 * S3C2410 bluetooth "driver"
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>
23 #define DRV_NAME "h1940-bt"
25 #ifdef CONFIG_LEDS_H1940
26 DEFINE_LED_TRIGGER(bt_led_trigger);
31 /* Bluetooth control */
32 static void h1940bt_enable(int on)
35 #ifdef CONFIG_LEDS_H1940
37 led_trigger_event(bt_led_trigger, LED_HALF);
40 /* Power on the chip */
41 h1940_latch_control(0, H1940_LATCH_BLUETOOTH_POWER);
44 s3c2410_gpio_setpin(S3C2410_GPH1, 1);
46 s3c2410_gpio_setpin(S3C2410_GPH1, 0);
51 #ifdef CONFIG_LEDS_H1940
52 led_trigger_event(bt_led_trigger, 0);
55 s3c2410_gpio_setpin(S3C2410_GPH1, 1);
57 s3c2410_gpio_setpin(S3C2410_GPH1, 0);
59 h1940_latch_control(H1940_LATCH_BLUETOOTH_POWER, 0);
65 static ssize_t h1940bt_show(struct device *dev, struct device_attribute *attr, char *buf)
67 return snprintf(buf, PAGE_SIZE, "%d\n", state);
70 static ssize_t h1940bt_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
75 new_state = simple_strtoul(buf, &endp, 0);
76 if (*endp && !isspace(*endp))
79 h1940bt_enable(new_state);
83 static DEVICE_ATTR(enable, 0644,
87 static int __init h1940bt_probe(struct platform_device *pdev)
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);
99 #ifdef CONFIG_LEDS_H1940
100 led_trigger_register_simple("h1940-bluetooth", &bt_led_trigger);
103 /* disable BT by default */
106 return device_create_file(&pdev->dev, &dev_attr_enable);
109 static int h1940bt_remove(struct platform_device *pdev)
111 #ifdef CONFIG_LEDS_H1940
112 led_trigger_unregister_simple(bt_led_trigger);
118 static struct platform_driver h1940bt_driver = {
122 .probe = h1940bt_probe,
123 .remove = h1940bt_remove,
127 static int __init h1940bt_init(void)
129 return platform_driver_register(&h1940bt_driver);
132 static void __exit h1940bt_exit(void)
134 platform_driver_unregister(&h1940bt_driver);
137 module_init(h1940bt_init);
138 module_exit(h1940bt_exit);
140 MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
141 MODULE_DESCRIPTION("Driver for the iPAQ H1940 bluetooth chip");
142 MODULE_LICENSE("GPL");