hh.org updates
[hh.org.git] / arch / arm / mach-pxa / htcuniversal / htcuniversal_bt.c
blob2027e91394e745f44036ffa91312d0d956711b17
1 /* Bluetooth interface driver for TI BRF6150 on HX4700
3 * Copyright (c) 2005 SDG Systems, LLC
5 * 2005-04-21 Todd Blumer Created.
6 */
8 #include <linux/module.h>
9 #include <linux/kernel.h>
10 #include <linux/delay.h>
11 #include <linux/platform_device.h>
12 #include <linux/soc/asic3_base.h>
14 #include <asm/hardware.h>
15 #include <asm/arch/serial.h>
16 #include <asm/hardware/ipaq-asic3.h>
17 #include <asm/arch/htcuniversal-gpio.h>
18 #include <asm/arch/htcuniversal-asic.h>
20 #include "htcuniversal_bt.h"
22 static uint use_led=1;
24 static void
25 htcuniversal_bt_configure( int state )
27 int tries;
29 printk( KERN_NOTICE "htcuniversal configure bluetooth: %d\n", state );
30 switch (state) {
32 case PXA_UART_CFG_PRE_STARTUP:
33 break;
35 case PXA_UART_CFG_POST_STARTUP:
36 /* pre-serial-up hardware configuration */
37 htcuniversal_egpio_enable(EGPIO5_BT_3V3_ON);
38 mdelay(50);
39 asic3_set_gpio_out_c(&htcuniversal_asic3.dev, 1<<GPIOC_BT_PWR_ON, 1<<GPIOC_BT_PWR_ON);
40 mdelay(10);
41 asic3_set_gpio_out_c(&htcuniversal_asic3.dev, 1<<GPIOC_BT_RESET, 0);
42 mdelay(10);
43 asic3_set_gpio_out_c(&htcuniversal_asic3.dev, 1<<GPIOC_BT_RESET, 1<<GPIOC_BT_RESET);
44 mdelay(10);
47 * BRF6150's RTS goes low when firmware is ready
48 * so check for CTS=1 (nCTS=0 -> CTS=1). Typical 150ms
50 tries = 0;
51 do {
52 mdelay(10);
53 } while ((BTMSR & MSR_CTS) == 0 && tries++ < 50);
54 if (use_led) {
55 // htcuniversal_set_led(2, 16, 16);
57 break;
59 case PXA_UART_CFG_PRE_SHUTDOWN:
60 htcuniversal_egpio_disable(EGPIO5_BT_3V3_ON );
61 mdelay(50);
62 // htcuniversal_clear_led(2);
63 asic3_set_gpio_out_c(&htcuniversal_asic3.dev, 1<<GPIOC_BT_PWR_ON, 0);
64 break;
66 default:
67 break;
72 static int
73 htcuniversal_bt_probe( struct platform_device *dev )
75 struct htcuniversal_bt_funcs *funcs = dev->dev.platform_data;
77 /* configure bluetooth UART */
78 pxa_gpio_mode( GPIO_NR_HTCUNIVERSAL_BT_RXD_MD );
79 pxa_gpio_mode( GPIO_NR_HTCUNIVERSAL_BT_TXD_MD );
80 pxa_gpio_mode( GPIO_NR_HTCUNIVERSAL_BT_UART_CTS_MD );
81 pxa_gpio_mode( GPIO_NR_HTCUNIVERSAL_BT_UART_RTS_MD );
83 funcs->configure = htcuniversal_bt_configure;
85 /* Make sure the LED is off */
86 // htcuniversal_clear_led(2);
88 return 0;
91 static int
92 htcuniversal_bt_remove( struct platform_device *dev )
94 struct htcuniversal_bt_funcs *funcs = dev->dev.platform_data;
96 funcs->configure = NULL;
98 /* Make sure the LED is off */
99 // htcuniversal_clear_led(2);
101 return 0;
104 static struct platform_driver bt_driver = {
105 .driver = {
106 .name = "htcuniversal_bt",
108 .probe = htcuniversal_bt_probe,
109 .remove = htcuniversal_bt_remove,
112 module_param(use_led, uint, 0);
114 static int __init
115 htcuniversal_bt_init( void )
117 printk(KERN_NOTICE "htcuniversal Bluetooth Driver\n");
118 return platform_driver_register( &bt_driver );
121 static void __exit
122 htcuniversal_bt_exit( void )
124 platform_driver_unregister( &bt_driver );
127 module_init( htcuniversal_bt_init );
128 module_exit( htcuniversal_bt_exit );
130 MODULE_AUTHOR("Todd Blumer, SDG Systems, LLC");
131 MODULE_DESCRIPTION("HTC Universal Bluetooth Support Driver");
132 MODULE_LICENSE("GPL");
134 /* vim600: set noexpandtab sw=8 ts=8 :*/