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 <linux/gpio.h>
20 #include <linux/rfkill.h>
22 #include <mach/hardware.h>
23 #include <mach/regs-gpio.h>
27 #define DRV_NAME "h1940-bt"
29 /* Bluetooth control */
30 static void h1940bt_enable(int on
)
33 /* Power on the chip */
34 gpio_set_value(H1940_LATCH_BLUETOOTH_POWER
, 1);
38 gpio_set_value(S3C2410_GPH(1), 1);
40 gpio_set_value(S3C2410_GPH(1), 0);
42 h1940_led_blink_set(-EINVAL
, GPIO_LED_BLINK
, NULL
, NULL
);
45 gpio_set_value(S3C2410_GPH(1), 1);
47 gpio_set_value(S3C2410_GPH(1), 0);
49 gpio_set_value(H1940_LATCH_BLUETOOTH_POWER
, 0);
51 h1940_led_blink_set(-EINVAL
, GPIO_LED_NO_BLINK_LOW
, NULL
, NULL
);
55 static int h1940bt_set_block(void *data
, bool blocked
)
57 h1940bt_enable(!blocked
);
61 static const struct rfkill_ops h1940bt_rfkill_ops
= {
62 .set_block
= h1940bt_set_block
,
65 static int h1940bt_probe(struct platform_device
*pdev
)
70 ret
= gpio_request(S3C2410_GPH(1), dev_name(&pdev
->dev
));
72 dev_err(&pdev
->dev
, "could not get GPH1\n");
76 ret
= gpio_request(H1940_LATCH_BLUETOOTH_POWER
, dev_name(&pdev
->dev
));
78 gpio_free(S3C2410_GPH(1));
79 dev_err(&pdev
->dev
, "could not get BT_POWER\n");
83 /* Configures BT serial port GPIOs */
84 s3c_gpio_cfgpin(S3C2410_GPH(0), S3C2410_GPH0_nCTS0
);
85 s3c_gpio_setpull(S3C2410_GPH(0), S3C_GPIO_PULL_NONE
);
86 s3c_gpio_cfgpin(S3C2410_GPH(1), S3C2410_GPIO_OUTPUT
);
87 s3c_gpio_setpull(S3C2410_GPH(1), S3C_GPIO_PULL_NONE
);
88 s3c_gpio_cfgpin(S3C2410_GPH(2), S3C2410_GPH2_TXD0
);
89 s3c_gpio_setpull(S3C2410_GPH(2), S3C_GPIO_PULL_NONE
);
90 s3c_gpio_cfgpin(S3C2410_GPH(3), S3C2410_GPH3_RXD0
);
91 s3c_gpio_setpull(S3C2410_GPH(3), S3C_GPIO_PULL_NONE
);
93 rfk
= rfkill_alloc(DRV_NAME
, &pdev
->dev
, RFKILL_TYPE_BLUETOOTH
,
94 &h1940bt_rfkill_ops
, NULL
);
100 ret
= rfkill_register(rfk
);
104 platform_set_drvdata(pdev
, rfk
);
114 static int h1940bt_remove(struct platform_device
*pdev
)
116 struct rfkill
*rfk
= platform_get_drvdata(pdev
);
118 platform_set_drvdata(pdev
, NULL
);
119 gpio_free(S3C2410_GPH(1));
122 rfkill_unregister(rfk
);
133 static struct platform_driver h1940bt_driver
= {
137 .probe
= h1940bt_probe
,
138 .remove
= h1940bt_remove
,
141 module_platform_driver(h1940bt_driver
);
143 MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
144 MODULE_DESCRIPTION("Driver for the iPAQ H1940 bluetooth chip");
145 MODULE_LICENSE("GPL");