ARM: S3C24XX: make h1940.h and h1940-latch.h local
[deliverable/linux.git] / arch / arm / mach-s3c24xx / h1940-bluetooth.c
CommitLineData
7fdc7849
AP
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>
ec976d6e 19#include <linux/gpio.h>
1a71e4ad 20#include <linux/rfkill.h>
ec976d6e 21
a09e64fb 22#include <mach/hardware.h>
232910d6
KK
23#include <mach/regs-gpio.h>
24
25#include "h1940.h"
7fdc7849 26
50e2d10d 27#define DRV_NAME "h1940-bt"
7fdc7849 28
7fdc7849
AP
29/* Bluetooth control */
30static void h1940bt_enable(int on)
31{
32 if (on) {
7fdc7849 33 /* Power on the chip */
14477095 34 gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 1);
7fdc7849
AP
35 /* Reset the chip */
36 mdelay(10);
f4146a65
BD
37
38 gpio_set_value(S3C2410_GPH(1), 1);
7fdc7849 39 mdelay(10);
f4146a65 40 gpio_set_value(S3C2410_GPH(1), 0);
50e2d10d
VK
41
42 h1940_led_blink_set(-EINVAL, GPIO_LED_BLINK, NULL, NULL);
7fdc7849
AP
43 }
44 else {
f4146a65 45 gpio_set_value(S3C2410_GPH(1), 1);
7fdc7849 46 mdelay(10);
f4146a65 47 gpio_set_value(S3C2410_GPH(1), 0);
7fdc7849 48 mdelay(10);
14477095 49 gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 0);
50e2d10d
VK
50
51 h1940_led_blink_set(-EINVAL, GPIO_LED_NO_BLINK_LOW, NULL, NULL);
7fdc7849
AP
52 }
53}
54
1a71e4ad 55static int h1940bt_set_block(void *data, bool blocked)
7fdc7849 56{
1a71e4ad 57 h1940bt_enable(!blocked);
58 return 0;
7fdc7849
AP
59}
60
1a71e4ad 61static const struct rfkill_ops h1940bt_rfkill_ops = {
62 .set_block = h1940bt_set_block,
63};
7fdc7849 64
91a99dfc 65static int __devinit h1940bt_probe(struct platform_device *pdev)
7fdc7849 66{
1a71e4ad 67 struct rfkill *rfk;
68 int ret = 0;
69
f4146a65
BD
70 ret = gpio_request(S3C2410_GPH(1), dev_name(&pdev->dev));
71 if (ret) {
14477095
VK
72 dev_err(&pdev->dev, "could not get GPH1\n");
73 return ret;
74 }
75
76 ret = gpio_request(H1940_LATCH_BLUETOOTH_POWER, dev_name(&pdev->dev));
77 if (ret) {
78 gpio_free(S3C2410_GPH(1));
79 dev_err(&pdev->dev, "could not get BT_POWER\n");
f4146a65
BD
80 return ret;
81 }
82
7fdc7849 83 /* Configures BT serial port GPIOs */
40b956f0 84 s3c_gpio_cfgpin(S3C2410_GPH(0), S3C2410_GPH0_nCTS0);
6fc50eaf 85 s3c_gpio_setpull(S3C2410_GPH(0), S3C_GPIO_PULL_NONE);
40b956f0 86 s3c_gpio_cfgpin(S3C2410_GPH(1), S3C2410_GPIO_OUTPUT);
6fc50eaf 87 s3c_gpio_setpull(S3C2410_GPH(1), S3C_GPIO_PULL_NONE);
40b956f0 88 s3c_gpio_cfgpin(S3C2410_GPH(2), S3C2410_GPH2_TXD0);
6fc50eaf 89 s3c_gpio_setpull(S3C2410_GPH(2), S3C_GPIO_PULL_NONE);
40b956f0 90 s3c_gpio_cfgpin(S3C2410_GPH(3), S3C2410_GPH3_RXD0);
6fc50eaf 91 s3c_gpio_setpull(S3C2410_GPH(3), S3C_GPIO_PULL_NONE);
7fdc7849 92
1a71e4ad 93 rfk = rfkill_alloc(DRV_NAME, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
94 &h1940bt_rfkill_ops, NULL);
95 if (!rfk) {
96 ret = -ENOMEM;
97 goto err_rfk_alloc;
98 }
99
1a71e4ad 100 ret = rfkill_register(rfk);
101 if (ret)
102 goto err_rfkill;
103
104 platform_set_drvdata(pdev, rfk);
105
106 return 0;
7fdc7849 107
1a71e4ad 108err_rfkill:
109 rfkill_destroy(rfk);
110err_rfk_alloc:
111 return ret;
7fdc7849
AP
112}
113
114static int h1940bt_remove(struct platform_device *pdev)
115{
1a71e4ad 116 struct rfkill *rfk = platform_get_drvdata(pdev);
117
118 platform_set_drvdata(pdev, NULL);
f4146a65 119 gpio_free(S3C2410_GPH(1));
1a71e4ad 120
121 if (rfk) {
122 rfkill_unregister(rfk);
123 rfkill_destroy(rfk);
124 }
125 rfk = NULL;
126
127 h1940bt_enable(0);
128
7fdc7849
AP
129 return 0;
130}
131
132
133static struct platform_driver h1940bt_driver = {
134 .driver = {
135 .name = DRV_NAME,
136 },
137 .probe = h1940bt_probe,
138 .remove = h1940bt_remove,
139};
140
1fffc8b2 141module_platform_driver(h1940bt_driver);
7fdc7849
AP
142
143MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
144MODULE_DESCRIPTION("Driver for the iPAQ H1940 bluetooth chip");
145MODULE_LICENSE("GPL");
This page took 0.605136 seconds and 5 git commands to generate.