blob: 45007be7cfb74b27767dda7d9eeec49694b6955a [file] [log] [blame]
Pavan Savoyd0088ce2010-04-08 13:16:54 -05001/*
2 * Shared Transport Line discipline driver Core
3 * Init Manager module responsible for GPIO control
4 * and firmware download
Pavan Savoya0cc2f32010-10-06 12:18:14 -04005 * Copyright (C) 2009-2010 Texas Instruments
6 * Author: Pavan Savoy <pavan_savoy@ti.com>
Pavan Savoyd0088ce2010-04-08 13:16:54 -05007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#define pr_fmt(fmt) "(stk) :" fmt
24#include <linux/platform_device.h>
25#include <linux/jiffies.h>
26#include <linux/firmware.h>
27#include <linux/delay.h>
28#include <linux/wait.h>
29#include <linux/gpio.h>
Pavan Savoyc1afac12010-07-28 02:25:59 -050030#include <linux/debugfs.h>
31#include <linux/seq_file.h>
Pavan Savoyd0088ce2010-04-08 13:16:54 -050032#include <linux/sched.h>
Randy Dunlap773d6792011-04-26 09:18:51 -070033#include <linux/sysfs.h>
Pavan Savoyec60d0a2011-02-04 02:23:10 -060034#include <linux/tty.h>
Pavan Savoyd0088ce2010-04-08 13:16:54 -050035
Pavan Savoy5c88b022011-02-04 02:23:09 -060036#include <linux/skbuff.h>
Pavan Savoye5558672010-09-30 16:13:30 -040037#include <linux/ti_wilink_st.h>
Paul Gortmakereb12a672011-07-03 15:14:56 -040038#include <linux/module.h>
Pavan Savoy83ef41f2010-09-17 12:06:11 -040039
Pavan Savoyd0088ce2010-04-08 13:16:54 -050040
Pavan Savoydbd3a872010-08-19 14:08:51 -040041#define MAX_ST_DEVICES 3 /* Imagine 1 on each UART for now */
Pavan Savoy73f12e82010-10-12 16:27:38 -040042static struct platform_device *st_kim_devices[MAX_ST_DEVICES];
Pavan Savoyd0088ce2010-04-08 13:16:54 -050043
44/**********************************************************************/
45/* internal functions */
46
Pavan Savoy36b5aee2010-07-22 05:32:06 -050047/**
Pavan Savoydbd3a872010-08-19 14:08:51 -040048 * st_get_plat_device -
49 * function which returns the reference to the platform device
50 * requested by id. As of now only 1 such device exists (id=0)
51 * the context requesting for reference can get the id to be
52 * requested by a. The protocol driver which is registering or
53 * b. the tty device which is opened.
54 */
55static struct platform_device *st_get_plat_device(int id)
56{
57 return st_kim_devices[id];
58}
59
60/**
Pavan Savoy36b5aee2010-07-22 05:32:06 -050061 * validate_firmware_response -
62 * function to return whether the firmware response was proper
63 * in case of error don't complete so that waiting for proper
64 * response times out
Pavan Savoyd0088ce2010-04-08 13:16:54 -050065 */
Pavan Savoy27712b32012-08-03 14:49:40 -050066static void validate_firmware_response(struct kim_data_s *kim_gdata)
Pavan Savoyd0088ce2010-04-08 13:16:54 -050067{
Pavan Savoy38d9df42010-07-08 08:55:17 -050068 struct sk_buff *skb = kim_gdata->rx_skb;
Pavan Savoy8565adb2012-08-03 14:49:43 -050069 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)) {
Pavan Savoyd0088ce2010-04-08 13:16:54 -050087 pr_err("no proper response during fw download");
88 pr_err("data6 %x", skb->data[5]);
Pavan Savoy76ff0e62011-08-10 10:18:36 -050089 kfree_skb(skb);
Pavan Savoyd0088ce2010-04-08 13:16:54 -050090 return; /* keep waiting for the proper response */
91 }
92 /* becos of all the script being downloaded */
93 complete_all(&kim_gdata->kim_rcvd);
94 kfree_skb(skb);
95}
96
97/* check for data len received inside kim_int_recv
98 * most often hit the last case to update state to waiting for data
99 */
Pavan Savoy38d9df42010-07-08 08:55:17 -0500100static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len)
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500101{
102 register int room = skb_tailroom(kim_gdata->rx_skb);
103
Pavan Savoye6d9e642010-07-22 05:32:05 -0500104 pr_debug("len %d room %d", len, room);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500105
106 if (!len) {
Pavan Savoy38d9df42010-07-08 08:55:17 -0500107 validate_firmware_response(kim_gdata);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500108 } else if (len > room) {
109 /* Received packet's payload length is larger.
110 * We can't accommodate it in created skb.
111 */
112 pr_err("Data length is too large len %d room %d", len,
113 room);
114 kfree_skb(kim_gdata->rx_skb);
115 } else {
116 /* Packet header has non-zero payload length and
117 * we have enough space in created skb. Lets read
118 * payload data */
Pavan Savoy5c88b022011-02-04 02:23:09 -0600119 kim_gdata->rx_state = ST_W4_DATA;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500120 kim_gdata->rx_count = len;
121 return len;
122 }
123
124 /* Change ST LL state to continue to process next
125 * packet */
126 kim_gdata->rx_state = ST_W4_PACKET_TYPE;
127 kim_gdata->rx_skb = NULL;
128 kim_gdata->rx_count = 0;
129
130 return 0;
131}
132
Pavan Savoy36b5aee2010-07-22 05:32:06 -0500133/**
134 * kim_int_recv - receive function called during firmware download
135 * firmware download responses on different UART drivers
136 * have been observed to come in bursts of different
137 * tty_receive and hence the logic
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500138 */
Pavan Savoy27712b32012-08-03 14:49:40 -0500139static void kim_int_recv(struct kim_data_s *kim_gdata,
Pavan Savoy38d9df42010-07-08 08:55:17 -0500140 const unsigned char *data, long count)
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500141{
Pavan Savoy73f12e82010-10-12 16:27:38 -0400142 const unsigned char *ptr;
Pavan Savoy73f12e82010-10-12 16:27:38 -0400143 int len = 0, type = 0;
Pavan Savoy5c88b022011-02-04 02:23:09 -0600144 unsigned char *plen;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500145
Pavan Savoye6d9e642010-07-22 05:32:05 -0500146 pr_debug("%s", __func__);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500147 /* Decode received bytes here */
Pavan Savoy73f12e82010-10-12 16:27:38 -0400148 ptr = data;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500149 if (unlikely(ptr == NULL)) {
150 pr_err(" received null from TTY ");
151 return;
152 }
Pavan Savoy73f12e82010-10-12 16:27:38 -0400153
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500154 while (count) {
155 if (kim_gdata->rx_count) {
156 len = min_t(unsigned int, kim_gdata->rx_count, count);
157 memcpy(skb_put(kim_gdata->rx_skb, len), ptr, len);
158 kim_gdata->rx_count -= len;
159 count -= len;
160 ptr += len;
161
162 if (kim_gdata->rx_count)
163 continue;
164
165 /* Check ST RX state machine , where are we? */
166 switch (kim_gdata->rx_state) {
167 /* Waiting for complete packet ? */
Pavan Savoy5c88b022011-02-04 02:23:09 -0600168 case ST_W4_DATA:
Pavan Savoye6d9e642010-07-22 05:32:05 -0500169 pr_debug("Complete pkt received");
Pavan Savoy38d9df42010-07-08 08:55:17 -0500170 validate_firmware_response(kim_gdata);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500171 kim_gdata->rx_state = ST_W4_PACKET_TYPE;
172 kim_gdata->rx_skb = NULL;
173 continue;
174 /* Waiting for Bluetooth event header ? */
Pavan Savoy5c88b022011-02-04 02:23:09 -0600175 case ST_W4_HEADER:
176 plen =
177 (unsigned char *)&kim_gdata->rx_skb->data[1];
178 pr_debug("event hdr: plen 0x%02x\n", *plen);
179 kim_check_data_len(kim_gdata, *plen);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500180 continue;
181 } /* end of switch */
182 } /* end of if rx_state */
183 switch (*ptr) {
184 /* Bluetooth event packet? */
Pavan Savoy5c88b022011-02-04 02:23:09 -0600185 case 0x04:
186 kim_gdata->rx_state = ST_W4_HEADER;
187 kim_gdata->rx_count = 2;
188 type = *ptr;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500189 break;
190 default:
191 pr_info("unknown packet");
192 ptr++;
193 count--;
194 continue;
Pavan Savoy36b5aee2010-07-22 05:32:06 -0500195 }
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500196 ptr++;
197 count--;
198 kim_gdata->rx_skb =
Pavan Savoy5c88b022011-02-04 02:23:09 -0600199 alloc_skb(1024+8, GFP_ATOMIC);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500200 if (!kim_gdata->rx_skb) {
201 pr_err("can't allocate mem for new packet");
202 kim_gdata->rx_state = ST_W4_PACKET_TYPE;
203 kim_gdata->rx_count = 0;
204 return;
Pavan Savoy36b5aee2010-07-22 05:32:06 -0500205 }
Pavan Savoy5c88b022011-02-04 02:23:09 -0600206 skb_reserve(kim_gdata->rx_skb, 8);
207 kim_gdata->rx_skb->cb[0] = 4;
208 kim_gdata->rx_skb->cb[1] = 0;
209
Pavan Savoy36b5aee2010-07-22 05:32:06 -0500210 }
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500211 return;
212}
213
Pavan Savoy38d9df42010-07-08 08:55:17 -0500214static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name)
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500215{
216 unsigned short version = 0, chip = 0, min_ver = 0, maj_ver = 0;
Pavan Savoy73f12e82010-10-12 16:27:38 -0400217 const char read_ver_cmd[] = { 0x01, 0x01, 0x10, 0x00 };
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500218
Pavan Savoye6d9e642010-07-22 05:32:05 -0500219 pr_debug("%s", __func__);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500220
Wolfram Sang16735d02013-11-14 14:32:02 -0800221 reinit_completion(&kim_gdata->kim_rcvd);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500222 if (4 != st_int_write(kim_gdata->core_data, read_ver_cmd, 4)) {
223 pr_err("kim: couldn't write 4 bytes");
Pavan Savoy70442662011-02-04 02:23:11 -0600224 return -EIO;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500225 }
226
Pavan Savoy53702352012-08-03 14:49:42 -0500227 if (!wait_for_completion_interruptible_timeout(
228 &kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME))) {
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500229 pr_err(" waiting for ver info- timed out ");
Pavan Savoy70442662011-02-04 02:23:11 -0600230 return -ETIMEDOUT;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500231 }
Wolfram Sang16735d02013-11-14 14:32:02 -0800232 reinit_completion(&kim_gdata->kim_rcvd);
Pavan Savoy8565adb2012-08-03 14:49:43 -0500233 /* the positions 12 & 13 in the response buffer provide with the
234 * chip, major & minor numbers
235 */
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500236
237 version =
Pavan Savoy8565adb2012-08-03 14:49:43 -0500238 MAKEWORD(kim_gdata->resp_buffer[12],
239 kim_gdata->resp_buffer[13]);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500240 chip = (version & 0x7C00) >> 10;
241 min_ver = (version & 0x007F);
242 maj_ver = (version & 0x0380) >> 7;
243
244 if (version & 0x8000)
245 maj_ver |= 0x0008;
246
247 sprintf(bts_scr_name, "TIInit_%d.%d.%d.bts", chip, maj_ver, min_ver);
Naveen Jaine2a53282010-06-09 03:45:33 -0500248
249 /* to be accessed later via sysfs entry */
250 kim_gdata->version.full = version;
251 kim_gdata->version.chip = chip;
252 kim_gdata->version.maj_ver = maj_ver;
253 kim_gdata->version.min_ver = min_ver;
254
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500255 pr_info("%s", bts_scr_name);
Pavan Savoy320920c2010-07-14 08:21:12 -0500256 return 0;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500257}
258
Pavan Savoy27712b32012-08-03 14:49:40 -0500259static void skip_change_remote_baud(unsigned char **ptr, long *len)
Pavan Savoyef04d122011-02-04 02:23:13 -0600260{
261 unsigned char *nxt_action, *cur_action;
262 cur_action = *ptr;
263
264 nxt_action = cur_action + sizeof(struct bts_action) +
265 ((struct bts_action *) cur_action)->size;
266
267 if (((struct bts_action *) nxt_action)->type != ACTION_WAIT_EVENT) {
268 pr_err("invalid action after change remote baud command");
269 } else {
270 *ptr = *ptr + sizeof(struct bts_action) +
Shahar Lev9d031d92011-05-23 11:36:11 +0300271 ((struct bts_action *)cur_action)->size;
Pavan Savoyef04d122011-02-04 02:23:13 -0600272 *len = *len - (sizeof(struct bts_action) +
Shahar Lev9d031d92011-05-23 11:36:11 +0300273 ((struct bts_action *)cur_action)->size);
Pavan Savoyef04d122011-02-04 02:23:13 -0600274 /* warn user on not commenting these in firmware */
275 pr_warn("skipping the wait event of change remote baud");
276 }
277}
278
Pavan Savoy36b5aee2010-07-22 05:32:06 -0500279/**
280 * download_firmware -
281 * internal function which parses through the .bts firmware
282 * script file intreprets SEND, DELAY actions only as of now
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500283 */
Pavan Savoy38d9df42010-07-08 08:55:17 -0500284static long download_firmware(struct kim_data_s *kim_gdata)
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500285{
Pavan Savoy320920c2010-07-14 08:21:12 -0500286 long err = 0;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500287 long len = 0;
Pavan Savoy73f12e82010-10-12 16:27:38 -0400288 unsigned char *ptr = NULL;
289 unsigned char *action_ptr = NULL;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500290 unsigned char bts_scr_name[30] = { 0 }; /* 30 char long bts scr name? */
Pavan Savoyef04d122011-02-04 02:23:13 -0600291 int wr_room_space;
292 int cmd_size;
293 unsigned long timeout;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500294
Pavan Savoy38d9df42010-07-08 08:55:17 -0500295 err = read_local_version(kim_gdata, bts_scr_name);
Pavan Savoy320920c2010-07-14 08:21:12 -0500296 if (err != 0) {
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500297 pr_err("kim: failed to read local ver");
298 return err;
299 }
300 err =
301 request_firmware(&kim_gdata->fw_entry, bts_scr_name,
302 &kim_gdata->kim_pdev->dev);
303 if (unlikely((err != 0) || (kim_gdata->fw_entry->data == NULL) ||
304 (kim_gdata->fw_entry->size == 0))) {
305 pr_err(" request_firmware failed(errno %ld) for %s", err,
306 bts_scr_name);
Pavan Savoy70442662011-02-04 02:23:11 -0600307 return -EINVAL;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500308 }
309 ptr = (void *)kim_gdata->fw_entry->data;
310 len = kim_gdata->fw_entry->size;
311 /* bts_header to remove out magic number and
312 * version
313 */
314 ptr += sizeof(struct bts_header);
315 len -= sizeof(struct bts_header);
316
317 while (len > 0 && ptr) {
Pavan Savoye6d9e642010-07-22 05:32:05 -0500318 pr_debug(" action size %d, type %d ",
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500319 ((struct bts_action *)ptr)->size,
320 ((struct bts_action *)ptr)->type);
321
322 switch (((struct bts_action *)ptr)->type) {
323 case ACTION_SEND_COMMAND: /* action send */
Pavan Savoy2f81a022011-08-10 10:18:34 -0500324 pr_debug("S");
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500325 action_ptr = &(((struct bts_action *)ptr)->data[0]);
326 if (unlikely
327 (((struct hci_command *)action_ptr)->opcode ==
328 0xFF36)) {
329 /* ignore remote change
330 * baud rate HCI VS command */
Pavan Savoyef04d122011-02-04 02:23:13 -0600331 pr_warn("change remote baud"
Pavan Savoye6d9e642010-07-22 05:32:05 -0500332 " rate command in firmware");
Pavan Savoyef04d122011-02-04 02:23:13 -0600333 skip_change_remote_baud(&ptr, &len);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500334 break;
335 }
Pavan Savoyef04d122011-02-04 02:23:13 -0600336 /*
337 * Make sure we have enough free space in uart
338 * tx buffer to write current firmware command
339 */
340 cmd_size = ((struct bts_action *)ptr)->size;
341 timeout = jiffies + msecs_to_jiffies(CMD_WR_TIME);
342 do {
343 wr_room_space =
344 st_get_uart_wr_room(kim_gdata->core_data);
345 if (wr_room_space < 0) {
346 pr_err("Unable to get free "
347 "space info from uart tx buffer");
348 release_firmware(kim_gdata->fw_entry);
349 return wr_room_space;
350 }
351 mdelay(1); /* wait 1ms before checking room */
352 } while ((wr_room_space < cmd_size) &&
353 time_before(jiffies, timeout));
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500354
Pavan Savoyef04d122011-02-04 02:23:13 -0600355 /* Timeout happened ? */
356 if (time_after_eq(jiffies, timeout)) {
357 pr_err("Timeout while waiting for free "
358 "free space in uart tx buffer");
359 release_firmware(kim_gdata->fw_entry);
360 return -ETIMEDOUT;
361 }
Pavan Savoy2f81a022011-08-10 10:18:34 -0500362 /* reinit completion before sending for the
363 * relevant wait
364 */
Wolfram Sang16735d02013-11-14 14:32:02 -0800365 reinit_completion(&kim_gdata->kim_rcvd);
Pavan Savoyef04d122011-02-04 02:23:13 -0600366
367 /*
368 * Free space found in uart buffer, call st_int_write
369 * to send current firmware command to the uart tx
370 * buffer.
371 */
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500372 err = st_int_write(kim_gdata->core_data,
373 ((struct bts_action_send *)action_ptr)->data,
374 ((struct bts_action *)ptr)->size);
375 if (unlikely(err < 0)) {
376 release_firmware(kim_gdata->fw_entry);
Pavan Savoy70442662011-02-04 02:23:11 -0600377 return err;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500378 }
Pavan Savoyef04d122011-02-04 02:23:13 -0600379 /*
380 * Check number of bytes written to the uart tx buffer
381 * and requested command write size
382 */
383 if (err != cmd_size) {
384 pr_err("Number of bytes written to uart "
385 "tx buffer are not matching with "
386 "requested cmd write size");
387 release_firmware(kim_gdata->fw_entry);
388 return -EIO;
389 }
390 break;
391 case ACTION_WAIT_EVENT: /* wait */
Pavan Savoy2f81a022011-08-10 10:18:34 -0500392 pr_debug("W");
Pavan Savoy53702352012-08-03 14:49:42 -0500393 if (!wait_for_completion_interruptible_timeout(
394 &kim_gdata->kim_rcvd,
395 msecs_to_jiffies(CMD_RESP_TIME))) {
Pavan Savoyef04d122011-02-04 02:23:13 -0600396 pr_err("response timeout during fw download ");
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500397 /* timed out */
398 release_firmware(kim_gdata->fw_entry);
Pavan Savoy70442662011-02-04 02:23:11 -0600399 return -ETIMEDOUT;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500400 }
Wolfram Sang16735d02013-11-14 14:32:02 -0800401 reinit_completion(&kim_gdata->kim_rcvd);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500402 break;
403 case ACTION_DELAY: /* sleep */
404 pr_info("sleep command in scr");
405 action_ptr = &(((struct bts_action *)ptr)->data[0]);
406 mdelay(((struct bts_action_delay *)action_ptr)->msec);
407 break;
408 }
409 len =
410 len - (sizeof(struct bts_action) +
411 ((struct bts_action *)ptr)->size);
412 ptr =
413 ptr + sizeof(struct bts_action) +
414 ((struct bts_action *)ptr)->size;
415 }
416 /* fw download complete */
417 release_firmware(kim_gdata->fw_entry);
Pavan Savoy320920c2010-07-14 08:21:12 -0500418 return 0;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500419}
420
421/**********************************************************************/
422/* functions called from ST core */
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500423/* called from ST Core, when REG_IN_PROGRESS (registration in progress)
424 * can be because of
425 * 1. response to read local version
426 * 2. during send/recv's of firmware download
427 */
428void st_kim_recv(void *disc_data, const unsigned char *data, long count)
429{
Pavan Savoy38d9df42010-07-08 08:55:17 -0500430 struct st_data_s *st_gdata = (struct st_data_s *)disc_data;
431 struct kim_data_s *kim_gdata = st_gdata->kim_data;
432
Pavan Savoy8565adb2012-08-03 14:49:43 -0500433 /* proceed to gather all data and distinguish read fw version response
434 * from other fw responses when data gathering is complete
435 */
436 kim_int_recv(kim_gdata, data, count);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500437 return;
438}
439
440/* to signal completion of line discipline installation
441 * called from ST Core, upon tty_open
442 */
Pavan Savoy38d9df42010-07-08 08:55:17 -0500443void st_kim_complete(void *kim_data)
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500444{
Pavan Savoy38d9df42010-07-08 08:55:17 -0500445 struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500446 complete(&kim_gdata->ldisc_installed);
447}
448
Pavan Savoy36b5aee2010-07-22 05:32:06 -0500449/**
450 * st_kim_start - called from ST Core upon 1st registration
451 * This involves toggling the chip enable gpio, reading
452 * the firmware version from chip, forming the fw file name
453 * based on the chip version, requesting the fw, parsing it
454 * and perform download(send/recv).
455 */
Pavan Savoy38d9df42010-07-08 08:55:17 -0500456long st_kim_start(void *kim_data)
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500457{
Pavan Savoy320920c2010-07-14 08:21:12 -0500458 long err = 0;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500459 long retry = POR_RETRY_COUNT;
Pavan Savoy0d7c5f22011-08-10 10:18:31 -0500460 struct ti_st_plat_data *pdata;
Pavan Savoy38d9df42010-07-08 08:55:17 -0500461 struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;
462
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500463 pr_info(" %s", __func__);
Pavan Savoy0d7c5f22011-08-10 10:18:31 -0500464 pdata = kim_gdata->kim_pdev->dev.platform_data;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500465
466 do {
Pavan Savoy0d7c5f22011-08-10 10:18:31 -0500467 /* platform specific enabling code here */
468 if (pdata->chip_enable)
469 pdata->chip_enable(kim_gdata);
470
Luciano Coelhoa7e2ca12013-01-21 13:12:42 +0200471 /* Configure BT nShutdown to HIGH state */
472 gpio_set_value(kim_gdata->nshutdown, GPIO_LOW);
473 mdelay(5); /* FIXME: a proper toggle */
474 gpio_set_value(kim_gdata->nshutdown, GPIO_HIGH);
475 mdelay(100);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500476 /* re-initialize the completion */
Wolfram Sang16735d02013-11-14 14:32:02 -0800477 reinit_completion(&kim_gdata->ldisc_installed);
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600478 /* send notification to UIM */
479 kim_gdata->ldisc_install = 1;
480 pr_info("ldisc_install = 1");
481 sysfs_notify(&kim_gdata->kim_pdev->dev.kobj,
482 NULL, "install");
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500483 /* wait for ldisc to be installed */
Pavan Savoy53702352012-08-03 14:49:42 -0500484 err = wait_for_completion_interruptible_timeout(
485 &kim_gdata->ldisc_installed, msecs_to_jiffies(LDISC_TIME));
Pavan Savoy18ccecf2011-12-15 10:38:21 -0600486 if (!err) {
487 /* ldisc installation timeout,
488 * flush uart, power cycle BT_EN */
489 pr_err("ldisc installation timeout");
490 err = st_kim_stop(kim_gdata);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500491 continue;
492 } else {
493 /* ldisc installed now */
Pavan Savoy18ccecf2011-12-15 10:38:21 -0600494 pr_info("line discipline installed");
Pavan Savoy38d9df42010-07-08 08:55:17 -0500495 err = download_firmware(kim_gdata);
Pavan Savoy320920c2010-07-14 08:21:12 -0500496 if (err != 0) {
Pavan Savoy18ccecf2011-12-15 10:38:21 -0600497 /* ldisc installed but fw download failed,
498 * flush uart & power cycle BT_EN */
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500499 pr_err("download firmware failed");
Pavan Savoy18ccecf2011-12-15 10:38:21 -0600500 err = st_kim_stop(kim_gdata);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500501 continue;
502 } else { /* on success don't retry */
503 break;
504 }
505 }
506 } while (retry--);
507 return err;
508}
509
Pavan Savoy36b5aee2010-07-22 05:32:06 -0500510/**
Pavan Savoy18ccecf2011-12-15 10:38:21 -0600511 * st_kim_stop - stop communication with chip.
512 * This can be called from ST Core/KIM, on the-
513 * (a) last un-register when chip need not be powered there-after,
514 * (b) upon failure to either install ldisc or download firmware.
515 * The function is responsible to (a) notify UIM about un-installation,
516 * (b) flush UART if the ldisc was installed.
Luciano Coelhoa7e2ca12013-01-21 13:12:42 +0200517 * (c) reset BT_EN - pull down nshutdown at the end.
518 * (d) invoke platform's chip disabling routine.
Pavan Savoy36b5aee2010-07-22 05:32:06 -0500519 */
Pavan Savoy38d9df42010-07-08 08:55:17 -0500520long st_kim_stop(void *kim_data)
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500521{
Pavan Savoy320920c2010-07-14 08:21:12 -0500522 long err = 0;
Pavan Savoy38d9df42010-07-08 08:55:17 -0500523 struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;
Pavan Savoy0d7c5f22011-08-10 10:18:31 -0500524 struct ti_st_plat_data *pdata =
525 kim_gdata->kim_pdev->dev.platform_data;
Pavan Savoy18ccecf2011-12-15 10:38:21 -0600526 struct tty_struct *tty = kim_gdata->core_data->tty;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500527
Wolfram Sang16735d02013-11-14 14:32:02 -0800528 reinit_completion(&kim_gdata->ldisc_installed);
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600529
Pavan Savoy18ccecf2011-12-15 10:38:21 -0600530 if (tty) { /* can be called before ldisc is installed */
531 /* Flush any pending characters in the driver and discipline. */
532 tty_ldisc_flush(tty);
533 tty_driver_flush_buffer(tty);
Pavan Savoy18ccecf2011-12-15 10:38:21 -0600534 }
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600535
536 /* send uninstall notification to UIM */
537 pr_info("ldisc_install = 0");
538 kim_gdata->ldisc_install = 0;
539 sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, NULL, "install");
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500540
541 /* wait for ldisc to be un-installed */
Pavan Savoy53702352012-08-03 14:49:42 -0500542 err = wait_for_completion_interruptible_timeout(
543 &kim_gdata->ldisc_installed, msecs_to_jiffies(LDISC_TIME));
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500544 if (!err) { /* timeout */
545 pr_err(" timed out waiting for ldisc to be un-installed");
Pavan Savoyb64365a2012-08-03 14:49:41 -0500546 err = -ETIMEDOUT;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500547 }
548
Luciano Coelhoa7e2ca12013-01-21 13:12:42 +0200549 /* By default configure BT nShutdown to LOW state */
550 gpio_set_value(kim_gdata->nshutdown, GPIO_LOW);
551 mdelay(1);
552 gpio_set_value(kim_gdata->nshutdown, GPIO_HIGH);
553 mdelay(1);
554 gpio_set_value(kim_gdata->nshutdown, GPIO_LOW);
555
Pavan Savoy0d7c5f22011-08-10 10:18:31 -0500556 /* platform specific disable */
557 if (pdata->chip_disable)
558 pdata->chip_disable(kim_gdata);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500559 return err;
560}
561
562/**********************************************************************/
563/* functions called from subsystems */
Pavan Savoyc1afac12010-07-28 02:25:59 -0500564/* called when debugfs entry is read from */
Naveen Jaine2a53282010-06-09 03:45:33 -0500565
Pavan Savoyc1afac12010-07-28 02:25:59 -0500566static int show_version(struct seq_file *s, void *unused)
Naveen Jaine2a53282010-06-09 03:45:33 -0500567{
Pavan Savoyc1afac12010-07-28 02:25:59 -0500568 struct kim_data_s *kim_gdata = (struct kim_data_s *)s->private;
569 seq_printf(s, "%04X %d.%d.%d\n", kim_gdata->version.full,
Naveen Jaine2a53282010-06-09 03:45:33 -0500570 kim_gdata->version.chip, kim_gdata->version.maj_ver,
571 kim_gdata->version.min_ver);
Pavan Savoyc1afac12010-07-28 02:25:59 -0500572 return 0;
Naveen Jaine2a53282010-06-09 03:45:33 -0500573}
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500574
Pavan Savoyc1afac12010-07-28 02:25:59 -0500575static int show_list(struct seq_file *s, void *unused)
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500576{
Pavan Savoyc1afac12010-07-28 02:25:59 -0500577 struct kim_data_s *kim_gdata = (struct kim_data_s *)s->private;
578 kim_st_list_protocols(kim_gdata->core_data, s);
579 return 0;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500580}
581
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600582static ssize_t show_install(struct device *dev,
583 struct device_attribute *attr, char *buf)
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500584{
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600585 struct kim_data_s *kim_data = dev_get_drvdata(dev);
586 return sprintf(buf, "%d\n", kim_data->ldisc_install);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500587}
588
Pavan Savoy933aae52011-12-15 10:38:22 -0600589#ifdef DEBUG
590static ssize_t store_dev_name(struct device *dev,
591 struct device_attribute *attr, const char *buf, size_t count)
592{
593 struct kim_data_s *kim_data = dev_get_drvdata(dev);
594 pr_debug("storing dev name >%s<", buf);
595 strncpy(kim_data->dev_name, buf, count);
596 pr_debug("stored dev name >%s<", kim_data->dev_name);
597 return count;
598}
599
600static ssize_t store_baud_rate(struct device *dev,
601 struct device_attribute *attr, const char *buf, size_t count)
602{
603 struct kim_data_s *kim_data = dev_get_drvdata(dev);
604 pr_debug("storing baud rate >%s<", buf);
605 sscanf(buf, "%ld", &kim_data->baud_rate);
606 pr_debug("stored baud rate >%ld<", kim_data->baud_rate);
607 return count;
608}
609#endif /* if DEBUG */
610
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600611static ssize_t show_dev_name(struct device *dev,
612 struct device_attribute *attr, char *buf)
613{
614 struct kim_data_s *kim_data = dev_get_drvdata(dev);
615 return sprintf(buf, "%s\n", kim_data->dev_name);
616}
617
618static ssize_t show_baud_rate(struct device *dev,
619 struct device_attribute *attr, char *buf)
620{
621 struct kim_data_s *kim_data = dev_get_drvdata(dev);
622 return sprintf(buf, "%ld\n", kim_data->baud_rate);
623}
624
625static ssize_t show_flow_cntrl(struct device *dev,
626 struct device_attribute *attr, char *buf)
627{
628 struct kim_data_s *kim_data = dev_get_drvdata(dev);
629 return sprintf(buf, "%d\n", kim_data->flow_cntrl);
630}
631
632/* structures specific for sysfs entries */
633static struct kobj_attribute ldisc_install =
634__ATTR(install, 0444, (void *)show_install, NULL);
635
636static struct kobj_attribute uart_dev_name =
Pavan Savoy933aae52011-12-15 10:38:22 -0600637#ifdef DEBUG /* TODO: move this to debug-fs if possible */
638__ATTR(dev_name, 0644, (void *)show_dev_name, (void *)store_dev_name);
639#else
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600640__ATTR(dev_name, 0444, (void *)show_dev_name, NULL);
Pavan Savoy933aae52011-12-15 10:38:22 -0600641#endif
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600642
643static struct kobj_attribute uart_baud_rate =
Pavan Savoy933aae52011-12-15 10:38:22 -0600644#ifdef DEBUG /* TODO: move to debugfs */
645__ATTR(baud_rate, 0644, (void *)show_baud_rate, (void *)store_baud_rate);
646#else
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600647__ATTR(baud_rate, 0444, (void *)show_baud_rate, NULL);
Pavan Savoy933aae52011-12-15 10:38:22 -0600648#endif
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600649
650static struct kobj_attribute uart_flow_cntrl =
651__ATTR(flow_cntrl, 0444, (void *)show_flow_cntrl, NULL);
652
653static struct attribute *uim_attrs[] = {
654 &ldisc_install.attr,
655 &uart_dev_name.attr,
656 &uart_baud_rate.attr,
657 &uart_flow_cntrl.attr,
658 NULL,
659};
660
661static struct attribute_group uim_attr_grp = {
662 .attrs = uim_attrs,
663};
664
Pavan Savoy36b5aee2010-07-22 05:32:06 -0500665/**
666 * st_kim_ref - reference the core's data
667 * This references the per-ST platform device in the arch/xx/
668 * board-xx.c file.
669 * This would enable multiple such platform devices to exist
670 * on a given platform
671 */
Pavan Savoydbd3a872010-08-19 14:08:51 -0400672void st_kim_ref(struct st_data_s **core_data, int id)
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500673{
Pavan Savoy38d9df42010-07-08 08:55:17 -0500674 struct platform_device *pdev;
675 struct kim_data_s *kim_gdata;
676 /* get kim_gdata reference from platform device */
Pavan Savoydbd3a872010-08-19 14:08:51 -0400677 pdev = st_get_plat_device(id);
Steven Rostedt7316a9f2011-05-23 16:45:32 -0400678 if (!pdev) {
679 *core_data = NULL;
680 return;
681 }
Jingoo Han9093ca82013-05-23 19:35:23 +0900682 kim_gdata = platform_get_drvdata(pdev);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500683 *core_data = kim_gdata->core_data;
684}
685
Pavan Savoyc1afac12010-07-28 02:25:59 -0500686static int kim_version_open(struct inode *i, struct file *f)
687{
688 return single_open(f, show_version, i->i_private);
689}
690
691static int kim_list_open(struct inode *i, struct file *f)
692{
693 return single_open(f, show_list, i->i_private);
694}
695
696static const struct file_operations version_debugfs_fops = {
697 /* version info */
698 .open = kim_version_open,
699 .read = seq_read,
700 .llseek = seq_lseek,
701 .release = single_release,
702};
703static const struct file_operations list_debugfs_fops = {
704 /* protocols info */
705 .open = kim_list_open,
706 .read = seq_read,
707 .llseek = seq_lseek,
708 .release = single_release,
709};
710
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500711/**********************************************************************/
712/* functions called from platform device driver subsystem
713 * need to have a relevant platform device entry in the platform's
714 * board-*.c file
715 */
716
Pavan Savoy27712b32012-08-03 14:49:40 -0500717static struct dentry *kim_debugfs_dir;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500718static int kim_probe(struct platform_device *pdev)
719{
Pavan Savoy38d9df42010-07-08 08:55:17 -0500720 struct kim_data_s *kim_gdata;
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600721 struct ti_st_plat_data *pdata = pdev->dev.platform_data;
Matthias Kaehlckeb2997382012-11-22 23:26:14 +0100722 int err;
Pavan Savoy38d9df42010-07-08 08:55:17 -0500723
Pavan Savoydfb7ef72010-09-10 15:58:55 -0400724 if ((pdev->id != -1) && (pdev->id < MAX_ST_DEVICES)) {
725 /* multiple devices could exist */
726 st_kim_devices[pdev->id] = pdev;
727 } else {
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300728 /* platform's sure about existence of 1 device */
Pavan Savoydfb7ef72010-09-10 15:58:55 -0400729 st_kim_devices[0] = pdev;
730 }
731
Pavan Savoy38d9df42010-07-08 08:55:17 -0500732 kim_gdata = kzalloc(sizeof(struct kim_data_s), GFP_ATOMIC);
733 if (!kim_gdata) {
734 pr_err("no mem to allocate");
735 return -ENOMEM;
736 }
Jingoo Han9093ca82013-05-23 19:35:23 +0900737 platform_set_drvdata(pdev, kim_gdata);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500738
Matthias Kaehlckeb2997382012-11-22 23:26:14 +0100739 err = st_core_init(&kim_gdata->core_data);
740 if (err != 0) {
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500741 pr_err(" ST core init failed");
Matthias Kaehlckeb2997382012-11-22 23:26:14 +0100742 err = -EIO;
743 goto err_core_init;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500744 }
Pavan Savoy38d9df42010-07-08 08:55:17 -0500745 /* refer to itself */
746 kim_gdata->core_data->kim_data = kim_gdata;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500747
Luciano Coelhoa7e2ca12013-01-21 13:12:42 +0200748 /* Claim the chip enable nShutdown gpio from the system */
749 kim_gdata->nshutdown = pdata->nshutdown_gpio;
750 err = gpio_request(kim_gdata->nshutdown, "kim");
751 if (unlikely(err)) {
752 pr_err(" gpio %ld request failed ", kim_gdata->nshutdown);
753 return err;
754 }
755
756 /* Configure nShutdown GPIO as output=0 */
757 err = gpio_direction_output(kim_gdata->nshutdown, 0);
758 if (unlikely(err)) {
759 pr_err(" unable to configure gpio %ld", kim_gdata->nshutdown);
760 return err;
761 }
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500762 /* get reference of pdev for request_firmware
763 */
764 kim_gdata->kim_pdev = pdev;
765 init_completion(&kim_gdata->kim_rcvd);
766 init_completion(&kim_gdata->ldisc_installed);
Naveen Jainb38fc2d2010-06-09 03:45:32 -0500767
Matthias Kaehlckeb2997382012-11-22 23:26:14 +0100768 err = sysfs_create_group(&pdev->dev.kobj, &uim_attr_grp);
769 if (err) {
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600770 pr_err("failed to create sysfs entries");
Matthias Kaehlckeb2997382012-11-22 23:26:14 +0100771 goto err_sysfs_group;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500772 }
Naveen Jaine2a53282010-06-09 03:45:33 -0500773
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600774 /* copying platform data */
775 strncpy(kim_gdata->dev_name, pdata->dev_name, UART_DEV_NAME_LEN);
776 kim_gdata->flow_cntrl = pdata->flow_cntrl;
777 kim_gdata->baud_rate = pdata->baud_rate;
778 pr_info("sysfs entries created\n");
779
Pavan Savoyc1afac12010-07-28 02:25:59 -0500780 kim_debugfs_dir = debugfs_create_dir("ti-st", NULL);
Robin van der Gracht37685282014-06-16 16:38:56 +0200781 if (!kim_debugfs_dir) {
Pavan Savoyc1afac12010-07-28 02:25:59 -0500782 pr_err(" debugfs entries creation failed ");
Matthias Kaehlckeb2997382012-11-22 23:26:14 +0100783 err = -EIO;
784 goto err_debugfs_dir;
Naveen Jaine2a53282010-06-09 03:45:33 -0500785 }
Pavan Savoyc1afac12010-07-28 02:25:59 -0500786
787 debugfs_create_file("version", S_IRUGO, kim_debugfs_dir,
788 kim_gdata, &version_debugfs_fops);
789 debugfs_create_file("protocols", S_IRUGO, kim_debugfs_dir,
790 kim_gdata, &list_debugfs_fops);
Pavan Savoy320920c2010-07-14 08:21:12 -0500791 return 0;
Matthias Kaehlckeb2997382012-11-22 23:26:14 +0100792
793err_debugfs_dir:
794 sysfs_remove_group(&pdev->dev.kobj, &uim_attr_grp);
795
796err_sysfs_group:
797 st_core_exit(kim_gdata->core_data);
798
799err_core_init:
800 kfree(kim_gdata);
801
802 return err;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500803}
804
805static int kim_remove(struct platform_device *pdev)
806{
Luciano Coelhoa7e2ca12013-01-21 13:12:42 +0200807 /* free the GPIOs requested */
808 struct ti_st_plat_data *pdata = pdev->dev.platform_data;
Pavan Savoy38d9df42010-07-08 08:55:17 -0500809 struct kim_data_s *kim_gdata;
810
Jingoo Han9093ca82013-05-23 19:35:23 +0900811 kim_gdata = platform_get_drvdata(pdev);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500812
Luciano Coelhoa7e2ca12013-01-21 13:12:42 +0200813 /* Free the Bluetooth/FM/GPIO
814 * nShutdown gpio from the system
815 */
816 gpio_free(pdata->nshutdown_gpio);
817 pr_info("nshutdown GPIO Freed");
818
Pavan Savoy781a7392011-02-04 02:23:15 -0600819 debugfs_remove_recursive(kim_debugfs_dir);
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600820 sysfs_remove_group(&pdev->dev.kobj, &uim_attr_grp);
Pavan Savoy781a7392011-02-04 02:23:15 -0600821 pr_info("sysfs entries removed");
822
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500823 kim_gdata->kim_pdev = NULL;
824 st_core_exit(kim_gdata->core_data);
Pavan Savoy38d9df42010-07-08 08:55:17 -0500825
826 kfree(kim_gdata);
827 kim_gdata = NULL;
Pavan Savoy320920c2010-07-14 08:21:12 -0500828 return 0;
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500829}
830
Pavan Savoy27712b32012-08-03 14:49:40 -0500831static int kim_suspend(struct platform_device *pdev, pm_message_t state)
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600832{
833 struct ti_st_plat_data *pdata = pdev->dev.platform_data;
834
835 if (pdata->suspend)
836 return pdata->suspend(pdev, state);
837
838 return -EOPNOTSUPP;
839}
840
Pavan Savoy27712b32012-08-03 14:49:40 -0500841static int kim_resume(struct platform_device *pdev)
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600842{
843 struct ti_st_plat_data *pdata = pdev->dev.platform_data;
844
845 if (pdata->resume)
846 return pdata->resume(pdev);
847
848 return -EOPNOTSUPP;
849}
850
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500851/**********************************************************************/
852/* entry point for ST KIM module, called in from ST Core */
Pavan Savoyec60d0a2011-02-04 02:23:10 -0600853static struct platform_driver kim_platform_driver = {
854 .probe = kim_probe,
855 .remove = kim_remove,
856 .suspend = kim_suspend,
857 .resume = kim_resume,
858 .driver = {
859 .name = "kim",
860 .owner = THIS_MODULE,
861 },
862};
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500863
Axel Linb00e1262012-01-22 15:33:49 +0800864module_platform_driver(kim_platform_driver);
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500865
Pavan Savoyd0088ce2010-04-08 13:16:54 -0500866MODULE_AUTHOR("Pavan Savoy <pavan_savoy@ti.com>");
867MODULE_DESCRIPTION("Shared Transport Driver for TI BT/FM/GPS combo chips ");
868MODULE_LICENSE("GPL");