aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorPavan Savoy <pavan_savoy@ti.com>2012-08-03 15:49:43 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-08-16 13:11:45 -0400
commit8565adbc821487accbabe82a03c40daf7a3b92ca (patch)
treecb529f742681ff2eccfc55dca50192e16a4ed621 /drivers/misc
parent537023580d2de09fed3c3ebdca7025572a4ad083 (diff)
drivers/misc/ti-st: fix read fw version cmd
If the read firmware version response from the chip is split into multiple frames of UART buffer being received by the host, the TI-ST driver as of today is unable to put the pieces of response together unlike other responses. Signed-off-by: Pavan Savoy <pavan_savoy@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/ti-st/st_kim.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
index 0f36db3aa40f..04a819944f6b 100644
--- a/drivers/misc/ti-st/st_kim.c
+++ b/drivers/misc/ti-st/st_kim.c
@@ -66,7 +66,24 @@ static struct platform_device *st_get_plat_device(int id)
66static void validate_firmware_response(struct kim_data_s *kim_gdata) 66static void validate_firmware_response(struct kim_data_s *kim_gdata)
67{ 67{
68 struct sk_buff *skb = kim_gdata->rx_skb; 68 struct sk_buff *skb = kim_gdata->rx_skb;
69 if (unlikely(skb->data[5] != 0)) { 69 if (!skb)
70 return;
71
72 /* these magic numbers are the position in the response buffer which
73 * allows us to distinguish whether the response is for the read
74 * version info. command
75 */
76 if (skb->data[2] == 0x01 && skb->data[3] == 0x01 &&
77 skb->data[4] == 0x10 && skb->data[5] == 0x00) {
78 /* fw version response */
79 memcpy(kim_gdata->resp_buffer,
80 kim_gdata->rx_skb->data,
81 kim_gdata->rx_skb->len);
82 complete_all(&kim_gdata->kim_rcvd);
83 kim_gdata->rx_state = ST_W4_PACKET_TYPE;
84 kim_gdata->rx_skb = NULL;
85 kim_gdata->rx_count = 0;
86 } else if (unlikely(skb->data[5] != 0)) {
70 pr_err("no proper response during fw download"); 87 pr_err("no proper response during fw download");
71 pr_err("data6 %x", skb->data[5]); 88 pr_err("data6 %x", skb->data[5]);
72 kfree_skb(skb); 89 kfree_skb(skb);
@@ -213,10 +230,13 @@ static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name)
213 return -ETIMEDOUT; 230 return -ETIMEDOUT;
214 } 231 }
215 INIT_COMPLETION(kim_gdata->kim_rcvd); 232 INIT_COMPLETION(kim_gdata->kim_rcvd);
233 /* the positions 12 & 13 in the response buffer provide with the
234 * chip, major & minor numbers
235 */
216 236
217 version = 237 version =
218 MAKEWORD(kim_gdata->resp_buffer[13], 238 MAKEWORD(kim_gdata->resp_buffer[12],
219 kim_gdata->resp_buffer[14]); 239 kim_gdata->resp_buffer[13]);
220 chip = (version & 0x7C00) >> 10; 240 chip = (version & 0x7C00) >> 10;
221 min_ver = (version & 0x007F); 241 min_ver = (version & 0x007F);
222 maj_ver = (version & 0x0380) >> 7; 242 maj_ver = (version & 0x0380) >> 7;
@@ -410,16 +430,10 @@ void st_kim_recv(void *disc_data, const unsigned char *data, long count)
410 struct st_data_s *st_gdata = (struct st_data_s *)disc_data; 430 struct st_data_s *st_gdata = (struct st_data_s *)disc_data;
411 struct kim_data_s *kim_gdata = st_gdata->kim_data; 431 struct kim_data_s *kim_gdata = st_gdata->kim_data;
412 432
413 /* copy to local buffer */ 433 /* proceed to gather all data and distinguish read fw version response
414 if (unlikely(data[4] == 0x01 && data[5] == 0x10 && data[0] == 0x04)) { 434 * from other fw responses when data gathering is complete
415 /* must be the read_ver_cmd */ 435 */
416 memcpy(kim_gdata->resp_buffer, data, count); 436 kim_int_recv(kim_gdata, data, count);
417 complete_all(&kim_gdata->kim_rcvd);
418 return;
419 } else {
420 kim_int_recv(kim_gdata, data, count);
421 /* either completes or times out */
422 }
423 return; 437 return;
424} 438}
425 439