]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/bluetooth/omap/h6300_bt_brf6100.c
h63xx: bluetooth support
[linux-2.6-omap-h63xx.git] / drivers / bluetooth / omap / h6300_bt_brf6100.c
1 /* 
2  * Bluetooth interface driver for TI BRF6100 on h6300
3  * 
4  * Copyright (C) 2005 Mika Laitio <lamikr@cc.jyu.fi>
5  * Ideas taken from the brf6150 bt driver made by Todd Blumer for the pxa hx4700.
6  * 
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  */
11
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/delay.h>
15 #include <linux/platform_device.h>
16
17 #include <asm/hardware.h>
18 #include <asm/arch/gpio.h>
19
20 #include <asm/arch/h6300_uart_info.h>
21 #include "h6300_bt_led.h"
22
23 static void
24 h6300_bt_configure(struct uart_omap_port *up, int enable)
25 {
26         printk(KERN_NOTICE "h6300_bt_brf6100.c h6300_bt_configure() started, enable = %d\n", enable);
27         
28         // printk( KERN_NOTICE "h6300 configure bluetooth: %d\n", enable );
29         if (enable == 0) {
30                 omap_set_gpio_dataout(GPIO_N_BT_RST, 1);        // turn off gpio, note 1 == off for negative gpios
31                 mdelay(5);
32                 h6300_clear_led(INDEX_BT_LED);
33         }
34         else if (enable == 1) {
35                 omap_set_gpio_dataout(GPIO_N_BT_RST, 1);        // turn on gpio, note 0 == on for negative gpios
36                 mdelay(5);                              
37         }
38         else if (enable == 2) {
39                 /*
40                  * BRF6150's RTS goes low when firmware is ready
41                  * so check for CTS=1 (nCTS=0 -> CTS=1). Typical 150ms
42                  */
43 /*              
44                 int tries = 0; 
45                 do 
46                 {
47                         mdelay(10);
48                 } 
49                 while ((BTMSR & MSR_CTS) == 0 && tries++ < 50);
50 */                              
51                 h6300_set_led(INDEX_BT_LED, 16, 16);
52         }
53         printk(KERN_NOTICE "h6300_bt_brf6100.c h6300_bt_configure() done\n");
54 }
55
56 static void
57 h6300_bt_set_txrx(struct uart_omap_port *up, int txrx)
58 {
59         printk(KERN_NOTICE "h6300_bt_brf6100.c h6300_bt_set_txrx(), txrx = %d done\n", txrx);
60         /* do nothing */
61 }
62
63 static int
64 h6300_bt_get_txrx(struct uart_omap_port *up)
65 {
66         printk(KERN_NOTICE "h6300_bt_brf6100.c h6300_bt_get_txrx() done\n");
67         /* do nothing */
68         return 0;
69 }
70
71 static int
72 h6300_bt_probe(struct platform_device *pdev)
73 {
74         struct h6300_uart_funcs *funcs = (struct h6300_uart_funcs *)pdev->dev.platform_data;
75
76         omap_request_gpio(GPIO_BT_PWR_EN);              // ask bt_power_en gpio, remember to release in remove_function
77         omap_set_gpio_direction(GPIO_BT_PWR_EN, 1);     // set gpio direction to be output
78         omap_set_gpio_dataout(GPIO_BT_PWR_EN, 1);       // turn on gpio
79
80         mdelay(200);
81
82         omap_request_gpio(GPIO_N_BT_RST);               // ask bt_reset gpio, remember to release in remove_function
83         omap_set_gpio_direction(GPIO_N_BT_RST, 1);      // set gpio direction to be output
84         omap_set_gpio_dataout(GPIO_N_BT_RST, 0);        // turn on gpio, note 0 == on for negative gpios
85         
86         /* configure bluetooth UART */
87         //h6300_gpio_mode(GPIO_NR_H6300_BT_RXD_MD);
88         //h6300_gpio_mode(GPIO_NR_H6300_BT_TXD_MD);
89         //h6300_gpio_mode(GPIO_NR_H6300_BT_UART_CTS_MD);
90         //h6300_gpio_mode(GPIO_NR_H6300_BT_UART_RTS_MD);
91
92         funcs->configure        = h6300_bt_configure;
93         funcs->set_txrx         = h6300_bt_set_txrx;
94         funcs->get_txrx         = h6300_bt_get_txrx;
95
96         /* Make sure the LED is off */
97         h6300_clear_led(INDEX_BT_LED);
98         
99         printk(KERN_NOTICE "h6300_bt_brf6100.c h6300_bt_probe() done\n");       
100
101         return 0;
102 }
103
104 static int
105 h6300_bt_remove(struct platform_device *pdev)
106 {
107         struct h6300_uart_funcs *funcs = (struct h6300_uart_funcs *)pdev->dev.platform_data;
108         
109         printk(KERN_NOTICE "h6300_bt_brf6100.c h6300_bt_remove() started\n");   
110         
111         omap_free_gpio(GPIO_BT_PWR_EN);
112         omap_free_gpio(GPIO_N_BT_RST);
113
114         funcs->configure        = NULL;
115         funcs->set_txrx         = NULL;
116         funcs->get_txrx         = NULL;
117
118         /* Make sure the LED is off */
119         h6300_clear_led(INDEX_BT_LED);
120         
121         printk(KERN_NOTICE "h6300_bt_brf6100.c, h6300_bt_remove() done\n");
122
123         return 0;
124 }
125
126 static struct platform_driver bt_driver = {
127         .probe    = h6300_bt_probe,
128         .remove   = h6300_bt_remove,
129         .driver = {
130                 .name = "h6300_bt",
131         },
132 };
133
134 static int __init
135 h6300_bt_init(void)
136 {
137         printk(KERN_NOTICE "h6300 Bluetooth Driver init()\n");
138         return platform_driver_register(&bt_driver);
139 }
140
141 static void __exit
142 h6300_bt_exit(void)
143 {
144         printk(KERN_NOTICE "h6300 Bluetooth Driver exit()\n");
145         platform_driver_unregister(&bt_driver);
146 }
147
148 module_init(h6300_bt_init);
149 module_exit(h6300_bt_exit);
150
151 MODULE_AUTHOR("Mika Laitio, <lamikr@cc.jyu.fi>");
152 MODULE_DESCRIPTION("iPAQ h6300 BRF6100 Bluetooth driver.");
153 MODULE_LICENSE("GPL");
154