GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / arm / mach-s3c2410 / h1940-bluetooth.c
blob8cdeb14af5929601492a74a593e9322f3a947c91
1 /*
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
7 * more details.
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 <linux/gpio.h>
20 #include <linux/rfkill.h>
22 #include <mach/regs-gpio.h>
23 #include <mach/hardware.h>
24 #include <mach/h1940-latch.h>
26 #define DRV_NAME "h1940-bt"
28 /* Bluetooth control */
29 static void h1940bt_enable(int on)
31 if (on) {
32 /* Power on the chip */
33 h1940_latch_control(0, H1940_LATCH_BLUETOOTH_POWER);
34 /* Reset the chip */
35 mdelay(10);
37 gpio_set_value(S3C2410_GPH(1), 1);
38 mdelay(10);
39 gpio_set_value(S3C2410_GPH(1), 0);
41 else {
42 gpio_set_value(S3C2410_GPH(1), 1);
43 mdelay(10);
44 gpio_set_value(S3C2410_GPH(1), 0);
45 mdelay(10);
46 h1940_latch_control(H1940_LATCH_BLUETOOTH_POWER, 0);
50 static int h1940bt_set_block(void *data, bool blocked)
52 h1940bt_enable(!blocked);
53 return 0;
56 static const struct rfkill_ops h1940bt_rfkill_ops = {
57 .set_block = h1940bt_set_block,
60 static int __devinit h1940bt_probe(struct platform_device *pdev)
62 struct rfkill *rfk;
63 int ret = 0;
65 ret = gpio_request(S3C2410_GPH(1), dev_name(&pdev->dev));
66 if (ret) {
67 dev_err(&pdev->dev, "could not get GPH1\n");\
68 return ret;
71 /* Configures BT serial port GPIOs */
72 s3c_gpio_cfgpin(S3C2410_GPH(0), S3C2410_GPH0_nCTS0);
73 s3c_gpio_cfgpull(S3C2410_GPH(0), S3C_GPIO_PULL_NONE);
74 s3c_gpio_cfgpin(S3C2410_GPH(1), S3C2410_GPIO_OUTPUT);
75 s3c_gpio_cfgpull(S3C2410_GPH(1), S3C_GPIO_PULL_NONE);
76 s3c_gpio_cfgpin(S3C2410_GPH(2), S3C2410_GPH2_TXD0);
77 s3c_gpio_cfgpull(S3C2410_GPH(2), S3C_GPIO_PULL_NONE);
78 s3c_gpio_cfgpin(S3C2410_GPH(3), S3C2410_GPH3_RXD0);
79 s3c_gpio_cfgpull(S3C2410_GPH(3), S3C_GPIO_PULL_NONE);
82 rfk = rfkill_alloc(DRV_NAME, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
83 &h1940bt_rfkill_ops, NULL);
84 if (!rfk) {
85 ret = -ENOMEM;
86 goto err_rfk_alloc;
89 rfkill_set_led_trigger_name(rfk, "h1940-bluetooth");
91 ret = rfkill_register(rfk);
92 if (ret)
93 goto err_rfkill;
95 platform_set_drvdata(pdev, rfk);
97 return 0;
99 err_rfkill:
100 rfkill_destroy(rfk);
101 err_rfk_alloc:
102 return ret;
105 static int h1940bt_remove(struct platform_device *pdev)
107 struct rfkill *rfk = platform_get_drvdata(pdev);
109 platform_set_drvdata(pdev, NULL);
110 gpio_free(S3C2410_GPH(1));
112 if (rfk) {
113 rfkill_unregister(rfk);
114 rfkill_destroy(rfk);
116 rfk = NULL;
118 h1940bt_enable(0);
120 return 0;
124 static struct platform_driver h1940bt_driver = {
125 .driver = {
126 .name = DRV_NAME,
128 .probe = h1940bt_probe,
129 .remove = h1940bt_remove,
133 static int __init h1940bt_init(void)
135 return platform_driver_register(&h1940bt_driver);
138 static void __exit h1940bt_exit(void)
140 platform_driver_unregister(&h1940bt_driver);
143 module_init(h1940bt_init);
144 module_exit(h1940bt_exit);
146 MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
147 MODULE_DESCRIPTION("Driver for the iPAQ H1940 bluetooth chip");
148 MODULE_LICENSE("GPL");