aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/ti-st/st_kim.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/ti-st/st_kim.c')
-rw-r--r--drivers/misc/ti-st/st_kim.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
index 73b6c8b0e869..707c85826417 100644
--- a/drivers/misc/ti-st/st_kim.c
+++ b/drivers/misc/ti-st/st_kim.c
@@ -32,11 +32,7 @@
32#include <linux/sched.h> 32#include <linux/sched.h>
33#include <linux/rfkill.h> 33#include <linux/rfkill.h>
34 34
35/* understand BT events for fw response */ 35#include <linux/skbuff.h>
36#include <net/bluetooth/bluetooth.h>
37#include <net/bluetooth/hci_core.h>
38#include <net/bluetooth/hci.h>
39
40#include <linux/ti_wilink_st.h> 36#include <linux/ti_wilink_st.h>
41 37
42 38
@@ -134,7 +130,7 @@ static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len)
134 /* Packet header has non-zero payload length and 130 /* Packet header has non-zero payload length and
135 * we have enough space in created skb. Lets read 131 * we have enough space in created skb. Lets read
136 * payload data */ 132 * payload data */
137 kim_gdata->rx_state = ST_BT_W4_DATA; 133 kim_gdata->rx_state = ST_W4_DATA;
138 kim_gdata->rx_count = len; 134 kim_gdata->rx_count = len;
139 return len; 135 return len;
140 } 136 }
@@ -158,8 +154,8 @@ void kim_int_recv(struct kim_data_s *kim_gdata,
158 const unsigned char *data, long count) 154 const unsigned char *data, long count)
159{ 155{
160 const unsigned char *ptr; 156 const unsigned char *ptr;
161 struct hci_event_hdr *eh;
162 int len = 0, type = 0; 157 int len = 0, type = 0;
158 unsigned char *plen;
163 159
164 pr_debug("%s", __func__); 160 pr_debug("%s", __func__);
165 /* Decode received bytes here */ 161 /* Decode received bytes here */
@@ -183,29 +179,27 @@ void kim_int_recv(struct kim_data_s *kim_gdata,
183 /* Check ST RX state machine , where are we? */ 179 /* Check ST RX state machine , where are we? */
184 switch (kim_gdata->rx_state) { 180 switch (kim_gdata->rx_state) {
185 /* Waiting for complete packet ? */ 181 /* Waiting for complete packet ? */
186 case ST_BT_W4_DATA: 182 case ST_W4_DATA:
187 pr_debug("Complete pkt received"); 183 pr_debug("Complete pkt received");
188 validate_firmware_response(kim_gdata); 184 validate_firmware_response(kim_gdata);
189 kim_gdata->rx_state = ST_W4_PACKET_TYPE; 185 kim_gdata->rx_state = ST_W4_PACKET_TYPE;
190 kim_gdata->rx_skb = NULL; 186 kim_gdata->rx_skb = NULL;
191 continue; 187 continue;
192 /* Waiting for Bluetooth event header ? */ 188 /* Waiting for Bluetooth event header ? */
193 case ST_BT_W4_EVENT_HDR: 189 case ST_W4_HEADER:
194 eh = (struct hci_event_hdr *)kim_gdata-> 190 plen =
195 rx_skb->data; 191 (unsigned char *)&kim_gdata->rx_skb->data[1];
196 pr_debug("Event header: evt 0x%2.2x" 192 pr_debug("event hdr: plen 0x%02x\n", *plen);
197 "plen %d", eh->evt, eh->plen); 193 kim_check_data_len(kim_gdata, *plen);
198 kim_check_data_len(kim_gdata, eh->plen);
199 continue; 194 continue;
200 } /* end of switch */ 195 } /* end of switch */
201 } /* end of if rx_state */ 196 } /* end of if rx_state */
202 switch (*ptr) { 197 switch (*ptr) {
203 /* Bluetooth event packet? */ 198 /* Bluetooth event packet? */
204 case HCI_EVENT_PKT: 199 case 0x04:
205 pr_info("Event packet"); 200 kim_gdata->rx_state = ST_W4_HEADER;
206 kim_gdata->rx_state = ST_BT_W4_EVENT_HDR; 201 kim_gdata->rx_count = 2;
207 kim_gdata->rx_count = HCI_EVENT_HDR_SIZE; 202 type = *ptr;
208 type = HCI_EVENT_PKT;
209 break; 203 break;
210 default: 204 default:
211 pr_info("unknown packet"); 205 pr_info("unknown packet");
@@ -216,16 +210,18 @@ void kim_int_recv(struct kim_data_s *kim_gdata,
216 ptr++; 210 ptr++;
217 count--; 211 count--;
218 kim_gdata->rx_skb = 212 kim_gdata->rx_skb =
219 bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC); 213 alloc_skb(1024+8, GFP_ATOMIC);
220 if (!kim_gdata->rx_skb) { 214 if (!kim_gdata->rx_skb) {
221 pr_err("can't allocate mem for new packet"); 215 pr_err("can't allocate mem for new packet");
222 kim_gdata->rx_state = ST_W4_PACKET_TYPE; 216 kim_gdata->rx_state = ST_W4_PACKET_TYPE;
223 kim_gdata->rx_count = 0; 217 kim_gdata->rx_count = 0;
224 return; 218 return;
225 } 219 }
226 bt_cb(kim_gdata->rx_skb)->pkt_type = type; 220 skb_reserve(kim_gdata->rx_skb, 8);
221 kim_gdata->rx_skb->cb[0] = 4;
222 kim_gdata->rx_skb->cb[1] = 0;
223
227 } 224 }
228 pr_info("done %s", __func__);
229 return; 225 return;
230} 226}
231 227
@@ -398,7 +394,7 @@ void st_kim_chip_toggle(enum proto_type type, enum kim_gpio_state state)
398 gpio_set_value(kim_gdata->gpios[ST_GPS], GPIO_LOW); 394 gpio_set_value(kim_gdata->gpios[ST_GPS], GPIO_LOW);
399 break; 395 break;
400 396
401 case ST_MAX: 397 case ST_MAX_CHANNELS:
402 default: 398 default:
403 break; 399 break;
404 } 400 }
@@ -416,7 +412,6 @@ void st_kim_recv(void *disc_data, const unsigned char *data, long count)
416 struct st_data_s *st_gdata = (struct st_data_s *)disc_data; 412 struct st_data_s *st_gdata = (struct st_data_s *)disc_data;
417 struct kim_data_s *kim_gdata = st_gdata->kim_data; 413 struct kim_data_s *kim_gdata = st_gdata->kim_data;
418 414
419 pr_info(" %s ", __func__);
420 /* copy to local buffer */ 415 /* copy to local buffer */
421 if (unlikely(data[4] == 0x01 && data[5] == 0x10 && data[0] == 0x04)) { 416 if (unlikely(data[4] == 0x01 && data[5] == 0x10 && data[0] == 0x04)) {
422 /* must be the read_ver_cmd */ 417 /* must be the read_ver_cmd */
@@ -578,7 +573,7 @@ static int kim_toggle_radio(void *data, bool blocked)
578 else 573 else
579 st_kim_chip_toggle(type, KIM_GPIO_ACTIVE); 574 st_kim_chip_toggle(type, KIM_GPIO_ACTIVE);
580 break; 575 break;
581 case ST_MAX: 576 case ST_MAX_CHANNELS:
582 pr_err(" wrong proto type "); 577 pr_err(" wrong proto type ");
583 break; 578 break;
584 } 579 }
@@ -664,12 +659,13 @@ static int kim_probe(struct platform_device *pdev)
664 /* refer to itself */ 659 /* refer to itself */
665 kim_gdata->core_data->kim_data = kim_gdata; 660 kim_gdata->core_data->kim_data = kim_gdata;
666 661
667 for (proto = 0; proto < ST_MAX; proto++) { 662 for (proto = 0; proto < ST_MAX_CHANNELS; proto++) {
668 kim_gdata->gpios[proto] = gpios[proto]; 663 kim_gdata->gpios[proto] = gpios[proto];
669 pr_info(" %ld gpio to be requested", gpios[proto]); 664 pr_info(" %ld gpio to be requested", gpios[proto]);
670 } 665 }
671 666
672 for (proto = 0; (proto < ST_MAX) && (gpios[proto] != -1); proto++) { 667 for (proto = 0; (proto < ST_MAX_CHANNELS)
668 && (gpios[proto] != -1); proto++) {
673 /* Claim the Bluetooth/FM/GPIO 669 /* Claim the Bluetooth/FM/GPIO
674 * nShutdown gpio from the system 670 * nShutdown gpio from the system
675 */ 671 */
@@ -704,7 +700,8 @@ static int kim_probe(struct platform_device *pdev)
704 init_completion(&kim_gdata->kim_rcvd); 700 init_completion(&kim_gdata->kim_rcvd);
705 init_completion(&kim_gdata->ldisc_installed); 701 init_completion(&kim_gdata->ldisc_installed);
706 702
707 for (proto = 0; (proto < ST_MAX) && (gpios[proto] != -1); proto++) { 703 for (proto = 0; (proto < ST_MAX_CHANNELS)
704 && (gpios[proto] != -1); proto++) {
708 /* TODO: should all types be rfkill_type_bt ? */ 705 /* TODO: should all types be rfkill_type_bt ? */
709 kim_gdata->rf_protos[proto] = proto; 706 kim_gdata->rf_protos[proto] = proto;
710 kim_gdata->rfkill[proto] = rfkill_alloc(protocol_names[proto], 707 kim_gdata->rfkill[proto] = rfkill_alloc(protocol_names[proto],
@@ -752,7 +749,8 @@ static int kim_remove(struct platform_device *pdev)
752 749
753 kim_gdata = dev_get_drvdata(&pdev->dev); 750 kim_gdata = dev_get_drvdata(&pdev->dev);
754 751
755 for (proto = 0; (proto < ST_MAX) && (gpios[proto] != -1); proto++) { 752 for (proto = 0; (proto < ST_MAX_CHANNELS)
753 && (gpios[proto] != -1); proto++) {
756 /* Claim the Bluetooth/FM/GPIO 754 /* Claim the Bluetooth/FM/GPIO
757 * nShutdown gpio from the system 755 * nShutdown gpio from the system
758 */ 756 */