hh.org updates
[hh.org.git] / arch / arm / mach-pxa / hx4700 / hx4700_bt.c
blob26e652f3977858e20d3468697b506919dc1a26a4
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/fs.h>
13 #include <linux/leds.h>
15 #include <asm/hardware.h>
16 #include <asm/arch/serial.h>
17 #include <asm/arch/hx4700-gpio.h>
18 #include <asm/arch/hx4700-core.h>
20 #include "hx4700_bt.h"
22 static void
23 hx4700_bt_configure( int state )
25 int tries;
27 // printk( KERN_NOTICE "hx4700 configure bluetooth: %d\n", state );
28 switch (state) {
30 case PXA_UART_CFG_PRE_STARTUP:
31 break;
33 case PXA_UART_CFG_POST_STARTUP:
34 /* pre-serial-up hardware configuration */
35 hx4700_egpio_enable( EGPIO5_BT_3V3_ON );
36 SET_HX4700_GPIO( CPU_BT_RESET_N, 0 );
37 mdelay(1);
38 SET_HX4700_GPIO( CPU_BT_RESET_N, 1 );
41 * BRF6150's RTS goes low when firmware is ready
42 * so check for CTS=1 (nCTS=0 -> CTS=1). Typical 150ms
44 tries = 0;
45 do {
46 mdelay(10);
47 } while ((BTMSR & MSR_CTS) == 0 && tries++ < 50);
48 led_trigger_event_shared(hx4700_radio_trig, LED_FULL);
49 break;
51 case PXA_UART_CFG_PRE_SHUTDOWN:
52 hx4700_egpio_disable( EGPIO5_BT_3V3_ON );
53 mdelay(1);
54 led_trigger_event_shared(hx4700_radio_trig, LED_OFF);
55 break;
57 default:
58 break;
63 static int
64 hx4700_bt_probe( struct platform_device *pdev )
66 struct hx4700_bt_funcs *funcs = pdev->dev.platform_data;
68 /* configure bluetooth UART */
69 pxa_gpio_mode( GPIO_NR_HX4700_BT_RXD_MD );
70 pxa_gpio_mode( GPIO_NR_HX4700_BT_TXD_MD );
71 pxa_gpio_mode( GPIO_NR_HX4700_BT_UART_CTS_MD );
72 pxa_gpio_mode( GPIO_NR_HX4700_BT_UART_RTS_MD );
74 funcs->configure = hx4700_bt_configure;
76 return 0;
79 static int
80 hx4700_bt_remove( struct platform_device *pdev )
82 struct hx4700_bt_funcs *funcs = pdev->dev.platform_data;
84 funcs->configure = NULL;
86 return 0;
89 static struct platform_driver bt_driver = {
90 .driver = {
91 .name = "hx4700-bt",
93 .probe = hx4700_bt_probe,
94 .remove = hx4700_bt_remove,
97 static int __init
98 hx4700_bt_init( void )
100 printk(KERN_NOTICE "hx4700 Bluetooth Driver\n");
101 return platform_driver_register( &bt_driver );
104 static void __exit
105 hx4700_bt_exit( void )
107 platform_driver_unregister( &bt_driver );
110 module_init( hx4700_bt_init );
111 module_exit( hx4700_bt_exit );
113 MODULE_AUTHOR("Todd Blumer, SDG Systems, LLC");
114 MODULE_DESCRIPTION("hx4700 Bluetooth Support Driver");
115 MODULE_LICENSE("GPL");
117 /* vim600: set noexpandtab sw=8 ts=8 :*/