1 // SPDX-License-Identifier: GPL-2.0-only
3 * Shared Transport Line discipline driver Core
4 * Init Manager module responsible for GPIO control
5 * and firmware download
6 * Copyright (C) 2009-2010 Texas Instruments
7 * Author: Pavan Savoy <pavan_savoy@ti.com>
10 #define pr_fmt(fmt) "(stk) :" fmt
11 #include <linux/platform_device.h>
12 #include <linux/jiffies.h>
13 #include <linux/firmware.h>
14 #include <linux/delay.h>
15 #include <linux/wait.h>
16 #include <linux/gpio.h>
17 #include <linux/debugfs.h>
18 #include <linux/seq_file.h>
19 #include <linux/sched.h>
20 #include <linux/sysfs.h>
21 #include <linux/tty.h>
23 #include <linux/skbuff.h>
24 #include <linux/ti_wilink_st.h>
25 #include <linux/module.h>
27 #define MAX_ST_DEVICES 3 /* Imagine 1 on each UART for now */
28 static struct platform_device
*st_kim_devices
[MAX_ST_DEVICES
];
30 /**********************************************************************/
31 /* internal functions */
34 * st_get_plat_device -
35 * function which returns the reference to the platform device
36 * requested by id. As of now only 1 such device exists (id=0)
37 * the context requesting for reference can get the id to be
38 * requested by a. The protocol driver which is registering or
39 * b. the tty device which is opened.
41 static struct platform_device
*st_get_plat_device(int id
)
43 return st_kim_devices
[id
];
47 * validate_firmware_response -
48 * function to return whether the firmware response was proper
49 * in case of error don't complete so that waiting for proper
52 static void validate_firmware_response(struct kim_data_s
*kim_gdata
)
54 struct sk_buff
*skb
= kim_gdata
->rx_skb
;
58 /* these magic numbers are the position in the response buffer which
59 * allows us to distinguish whether the response is for the read
60 * version info. command
62 if (skb
->data
[2] == 0x01 && skb
->data
[3] == 0x01 &&
63 skb
->data
[4] == 0x10 && skb
->data
[5] == 0x00) {
64 /* fw version response */
65 memcpy(kim_gdata
->resp_buffer
,
66 kim_gdata
->rx_skb
->data
,
67 kim_gdata
->rx_skb
->len
);
68 kim_gdata
->rx_state
= ST_W4_PACKET_TYPE
;
69 kim_gdata
->rx_skb
= NULL
;
70 kim_gdata
->rx_count
= 0;
71 } else if (unlikely(skb
->data
[5] != 0)) {
72 pr_err("no proper response during fw download");
73 pr_err("data6 %x", skb
->data
[5]);
75 return; /* keep waiting for the proper response */
77 /* becos of all the script being downloaded */
78 complete_all(&kim_gdata
->kim_rcvd
);
82 /* check for data len received inside kim_int_recv
83 * most often hit the last case to update state to waiting for data
85 static inline int kim_check_data_len(struct kim_data_s
*kim_gdata
, int len
)
87 register int room
= skb_tailroom(kim_gdata
->rx_skb
);
89 pr_debug("len %d room %d", len
, room
);
92 validate_firmware_response(kim_gdata
);
93 } else if (len
> room
) {
94 /* Received packet's payload length is larger.
95 * We can't accommodate it in created skb.
97 pr_err("Data length is too large len %d room %d", len
,
99 kfree_skb(kim_gdata
->rx_skb
);
101 /* Packet header has non-zero payload length and
102 * we have enough space in created skb. Lets read
104 kim_gdata
->rx_state
= ST_W4_DATA
;
105 kim_gdata
->rx_count
= len
;
109 /* Change ST LL state to continue to process next
111 kim_gdata
->rx_state
= ST_W4_PACKET_TYPE
;
112 kim_gdata
->rx_skb
= NULL
;
113 kim_gdata
->rx_count
= 0;
119 * kim_int_recv - receive function called during firmware download
120 * firmware download responses on different UART drivers
121 * have been observed to come in bursts of different
122 * tty_receive and hence the logic
124 static void kim_int_recv(struct kim_data_s
*kim_gdata
,
125 const unsigned char *data
, long count
)
127 const unsigned char *ptr
;
131 pr_debug("%s", __func__
);
132 /* Decode received bytes here */
134 if (unlikely(ptr
== NULL
)) {
135 pr_err(" received null from TTY ");
140 if (kim_gdata
->rx_count
) {
141 len
= min_t(unsigned int, kim_gdata
->rx_count
, count
);
142 skb_put_data(kim_gdata
->rx_skb
, ptr
, len
);
143 kim_gdata
->rx_count
-= len
;
147 if (kim_gdata
->rx_count
)
150 /* Check ST RX state machine , where are we? */
151 switch (kim_gdata
->rx_state
) {
152 /* Waiting for complete packet ? */
154 pr_debug("Complete pkt received");
155 validate_firmware_response(kim_gdata
);
156 kim_gdata
->rx_state
= ST_W4_PACKET_TYPE
;
157 kim_gdata
->rx_skb
= NULL
;
159 /* Waiting for Bluetooth event header ? */
162 (unsigned char *)&kim_gdata
->rx_skb
->data
[1];
163 pr_debug("event hdr: plen 0x%02x\n", *plen
);
164 kim_check_data_len(kim_gdata
, *plen
);
166 } /* end of switch */
167 } /* end of if rx_state */
169 /* Bluetooth event packet? */
171 kim_gdata
->rx_state
= ST_W4_HEADER
;
172 kim_gdata
->rx_count
= 2;
175 pr_info("unknown packet");
183 alloc_skb(1024+8, GFP_ATOMIC
);
184 if (!kim_gdata
->rx_skb
) {
185 pr_err("can't allocate mem for new packet");
186 kim_gdata
->rx_state
= ST_W4_PACKET_TYPE
;
187 kim_gdata
->rx_count
= 0;
190 skb_reserve(kim_gdata
->rx_skb
, 8);
191 kim_gdata
->rx_skb
->cb
[0] = 4;
192 kim_gdata
->rx_skb
->cb
[1] = 0;
198 static long read_local_version(struct kim_data_s
*kim_gdata
, char *bts_scr_name
)
200 unsigned short version
= 0, chip
= 0, min_ver
= 0, maj_ver
= 0;
201 static const char read_ver_cmd
[] = { 0x01, 0x01, 0x10, 0x00 };
204 pr_debug("%s", __func__
);
206 reinit_completion(&kim_gdata
->kim_rcvd
);
207 if (4 != st_int_write(kim_gdata
->core_data
, read_ver_cmd
, 4)) {
208 pr_err("kim: couldn't write 4 bytes");
212 timeout
= wait_for_completion_interruptible_timeout(
213 &kim_gdata
->kim_rcvd
, msecs_to_jiffies(CMD_RESP_TIME
));
215 pr_err(" waiting for ver info- timed out or received signal");
216 return timeout
? -ERESTARTSYS
: -ETIMEDOUT
;
218 reinit_completion(&kim_gdata
->kim_rcvd
);
219 /* the positions 12 & 13 in the response buffer provide with the
220 * chip, major & minor numbers
224 MAKEWORD(kim_gdata
->resp_buffer
[12],
225 kim_gdata
->resp_buffer
[13]);
226 chip
= (version
& 0x7C00) >> 10;
227 min_ver
= (version
& 0x007F);
228 maj_ver
= (version
& 0x0380) >> 7;
230 if (version
& 0x8000)
233 sprintf(bts_scr_name
, "ti-connectivity/TIInit_%d.%d.%d.bts",
234 chip
, maj_ver
, min_ver
);
236 /* to be accessed later via sysfs entry */
237 kim_gdata
->version
.full
= version
;
238 kim_gdata
->version
.chip
= chip
;
239 kim_gdata
->version
.maj_ver
= maj_ver
;
240 kim_gdata
->version
.min_ver
= min_ver
;
242 pr_info("%s", bts_scr_name
);
246 static void skip_change_remote_baud(unsigned char **ptr
, long *len
)
248 unsigned char *nxt_action
, *cur_action
;
251 nxt_action
= cur_action
+ sizeof(struct bts_action
) +
252 ((struct bts_action
*) cur_action
)->size
;
254 if (((struct bts_action
*) nxt_action
)->type
!= ACTION_WAIT_EVENT
) {
255 pr_err("invalid action after change remote baud command");
257 *ptr
= *ptr
+ sizeof(struct bts_action
) +
258 ((struct bts_action
*)cur_action
)->size
;
259 *len
= *len
- (sizeof(struct bts_action
) +
260 ((struct bts_action
*)cur_action
)->size
);
261 /* warn user on not commenting these in firmware */
262 pr_warn("skipping the wait event of change remote baud");
267 * download_firmware -
268 * internal function which parses through the .bts firmware
269 * script file intreprets SEND, DELAY actions only as of now
271 static long download_firmware(struct kim_data_s
*kim_gdata
)
275 unsigned char *ptr
= NULL
;
276 unsigned char *action_ptr
= NULL
;
277 unsigned char bts_scr_name
[40] = { 0 }; /* 40 char long bts scr name? */
280 unsigned long timeout
;
282 err
= read_local_version(kim_gdata
, bts_scr_name
);
284 pr_err("kim: failed to read local ver");
288 request_firmware(&kim_gdata
->fw_entry
, bts_scr_name
,
289 &kim_gdata
->kim_pdev
->dev
);
290 if (unlikely((err
!= 0) || (kim_gdata
->fw_entry
->data
== NULL
) ||
291 (kim_gdata
->fw_entry
->size
== 0))) {
292 pr_err(" request_firmware failed(errno %ld) for %s", err
,
296 ptr
= (void *)kim_gdata
->fw_entry
->data
;
297 len
= kim_gdata
->fw_entry
->size
;
298 /* bts_header to remove out magic number and
301 ptr
+= sizeof(struct bts_header
);
302 len
-= sizeof(struct bts_header
);
304 while (len
> 0 && ptr
) {
305 pr_debug(" action size %d, type %d ",
306 ((struct bts_action
*)ptr
)->size
,
307 ((struct bts_action
*)ptr
)->type
);
309 switch (((struct bts_action
*)ptr
)->type
) {
310 case ACTION_SEND_COMMAND
: /* action send */
312 action_ptr
= &(((struct bts_action
*)ptr
)->data
[0]);
314 (((struct hci_command
*)action_ptr
)->opcode
==
316 /* ignore remote change
317 * baud rate HCI VS command */
318 pr_warn("change remote baud"
319 " rate command in firmware");
320 skip_change_remote_baud(&ptr
, &len
);
324 * Make sure we have enough free space in uart
325 * tx buffer to write current firmware command
327 cmd_size
= ((struct bts_action
*)ptr
)->size
;
328 timeout
= jiffies
+ msecs_to_jiffies(CMD_WR_TIME
);
331 st_get_uart_wr_room(kim_gdata
->core_data
);
332 if (wr_room_space
< 0) {
333 pr_err("Unable to get free "
334 "space info from uart tx buffer");
335 release_firmware(kim_gdata
->fw_entry
);
336 return wr_room_space
;
338 mdelay(1); /* wait 1ms before checking room */
339 } while ((wr_room_space
< cmd_size
) &&
340 time_before(jiffies
, timeout
));
342 /* Timeout happened ? */
343 if (time_after_eq(jiffies
, timeout
)) {
344 pr_err("Timeout while waiting for free "
345 "free space in uart tx buffer");
346 release_firmware(kim_gdata
->fw_entry
);
349 /* reinit completion before sending for the
352 reinit_completion(&kim_gdata
->kim_rcvd
);
355 * Free space found in uart buffer, call st_int_write
356 * to send current firmware command to the uart tx
359 err
= st_int_write(kim_gdata
->core_data
,
360 ((struct bts_action_send
*)action_ptr
)->data
,
361 ((struct bts_action
*)ptr
)->size
);
362 if (unlikely(err
< 0)) {
363 release_firmware(kim_gdata
->fw_entry
);
367 * Check number of bytes written to the uart tx buffer
368 * and requested command write size
370 if (err
!= cmd_size
) {
371 pr_err("Number of bytes written to uart "
372 "tx buffer are not matching with "
373 "requested cmd write size");
374 release_firmware(kim_gdata
->fw_entry
);
378 case ACTION_WAIT_EVENT
: /* wait */
380 err
= wait_for_completion_interruptible_timeout(
381 &kim_gdata
->kim_rcvd
,
382 msecs_to_jiffies(CMD_RESP_TIME
));
384 pr_err("response timeout/signaled during fw download ");
386 release_firmware(kim_gdata
->fw_entry
);
387 return err
? -ERESTARTSYS
: -ETIMEDOUT
;
389 reinit_completion(&kim_gdata
->kim_rcvd
);
391 case ACTION_DELAY
: /* sleep */
392 pr_info("sleep command in scr");
393 action_ptr
= &(((struct bts_action
*)ptr
)->data
[0]);
394 mdelay(((struct bts_action_delay
*)action_ptr
)->msec
);
398 len
- (sizeof(struct bts_action
) +
399 ((struct bts_action
*)ptr
)->size
);
401 ptr
+ sizeof(struct bts_action
) +
402 ((struct bts_action
*)ptr
)->size
;
404 /* fw download complete */
405 release_firmware(kim_gdata
->fw_entry
);
409 /**********************************************************************/
410 /* functions called from ST core */
411 /* called from ST Core, when REG_IN_PROGRESS (registration in progress)
413 * 1. response to read local version
414 * 2. during send/recv's of firmware download
416 void st_kim_recv(void *disc_data
, const unsigned char *data
, long count
)
418 struct st_data_s
*st_gdata
= (struct st_data_s
*)disc_data
;
419 struct kim_data_s
*kim_gdata
= st_gdata
->kim_data
;
421 /* proceed to gather all data and distinguish read fw version response
422 * from other fw responses when data gathering is complete
424 kim_int_recv(kim_gdata
, data
, count
);
428 /* to signal completion of line discipline installation
429 * called from ST Core, upon tty_open
431 void st_kim_complete(void *kim_data
)
433 struct kim_data_s
*kim_gdata
= (struct kim_data_s
*)kim_data
;
434 complete(&kim_gdata
->ldisc_installed
);
438 * st_kim_start - called from ST Core upon 1st registration
439 * This involves toggling the chip enable gpio, reading
440 * the firmware version from chip, forming the fw file name
441 * based on the chip version, requesting the fw, parsing it
442 * and perform download(send/recv).
444 long st_kim_start(void *kim_data
)
447 long retry
= POR_RETRY_COUNT
;
448 struct ti_st_plat_data
*pdata
;
449 struct kim_data_s
*kim_gdata
= (struct kim_data_s
*)kim_data
;
451 pr_info(" %s", __func__
);
452 pdata
= kim_gdata
->kim_pdev
->dev
.platform_data
;
455 /* platform specific enabling code here */
456 if (pdata
->chip_enable
)
457 pdata
->chip_enable(kim_gdata
);
459 /* Configure BT nShutdown to HIGH state */
460 gpio_set_value_cansleep(kim_gdata
->nshutdown
, GPIO_LOW
);
461 mdelay(5); /* FIXME: a proper toggle */
462 gpio_set_value_cansleep(kim_gdata
->nshutdown
, GPIO_HIGH
);
464 /* re-initialize the completion */
465 reinit_completion(&kim_gdata
->ldisc_installed
);
466 /* send notification to UIM */
467 kim_gdata
->ldisc_install
= 1;
468 pr_info("ldisc_install = 1");
469 sysfs_notify(&kim_gdata
->kim_pdev
->dev
.kobj
,
471 /* wait for ldisc to be installed */
472 err
= wait_for_completion_interruptible_timeout(
473 &kim_gdata
->ldisc_installed
, msecs_to_jiffies(LDISC_TIME
));
475 /* ldisc installation timeout,
476 * flush uart, power cycle BT_EN */
477 pr_err("ldisc installation timeout");
478 err
= st_kim_stop(kim_gdata
);
481 /* ldisc installed now */
482 pr_info("line discipline installed");
483 err
= download_firmware(kim_gdata
);
485 /* ldisc installed but fw download failed,
486 * flush uart & power cycle BT_EN */
487 pr_err("download firmware failed");
488 err
= st_kim_stop(kim_gdata
);
490 } else { /* on success don't retry */
499 * st_kim_stop - stop communication with chip.
500 * This can be called from ST Core/KIM, on the-
501 * (a) last un-register when chip need not be powered there-after,
502 * (b) upon failure to either install ldisc or download firmware.
503 * The function is responsible to (a) notify UIM about un-installation,
504 * (b) flush UART if the ldisc was installed.
505 * (c) reset BT_EN - pull down nshutdown at the end.
506 * (d) invoke platform's chip disabling routine.
508 long st_kim_stop(void *kim_data
)
511 struct kim_data_s
*kim_gdata
= (struct kim_data_s
*)kim_data
;
512 struct ti_st_plat_data
*pdata
=
513 kim_gdata
->kim_pdev
->dev
.platform_data
;
514 struct tty_struct
*tty
= kim_gdata
->core_data
->tty
;
516 reinit_completion(&kim_gdata
->ldisc_installed
);
518 if (tty
) { /* can be called before ldisc is installed */
519 /* Flush any pending characters in the driver and discipline. */
520 tty_ldisc_flush(tty
);
521 tty_driver_flush_buffer(tty
);
524 /* send uninstall notification to UIM */
525 pr_info("ldisc_install = 0");
526 kim_gdata
->ldisc_install
= 0;
527 sysfs_notify(&kim_gdata
->kim_pdev
->dev
.kobj
, NULL
, "install");
529 /* wait for ldisc to be un-installed */
530 err
= wait_for_completion_interruptible_timeout(
531 &kim_gdata
->ldisc_installed
, msecs_to_jiffies(LDISC_TIME
));
532 if (!err
) { /* timeout */
533 pr_err(" timed out waiting for ldisc to be un-installed");
537 /* By default configure BT nShutdown to LOW state */
538 gpio_set_value_cansleep(kim_gdata
->nshutdown
, GPIO_LOW
);
540 gpio_set_value_cansleep(kim_gdata
->nshutdown
, GPIO_HIGH
);
542 gpio_set_value_cansleep(kim_gdata
->nshutdown
, GPIO_LOW
);
544 /* platform specific disable */
545 if (pdata
->chip_disable
)
546 pdata
->chip_disable(kim_gdata
);
550 /**********************************************************************/
551 /* functions called from subsystems */
552 /* called when debugfs entry is read from */
554 static int version_show(struct seq_file
*s
, void *unused
)
556 struct kim_data_s
*kim_gdata
= (struct kim_data_s
*)s
->private;
557 seq_printf(s
, "%04X %d.%d.%d\n", kim_gdata
->version
.full
,
558 kim_gdata
->version
.chip
, kim_gdata
->version
.maj_ver
,
559 kim_gdata
->version
.min_ver
);
563 static int list_show(struct seq_file
*s
, void *unused
)
565 struct kim_data_s
*kim_gdata
= (struct kim_data_s
*)s
->private;
566 kim_st_list_protocols(kim_gdata
->core_data
, s
);
570 static ssize_t
show_install(struct device
*dev
,
571 struct device_attribute
*attr
, char *buf
)
573 struct kim_data_s
*kim_data
= dev_get_drvdata(dev
);
574 return sprintf(buf
, "%d\n", kim_data
->ldisc_install
);
578 static ssize_t
store_dev_name(struct device
*dev
,
579 struct device_attribute
*attr
, const char *buf
, size_t count
)
581 struct kim_data_s
*kim_data
= dev_get_drvdata(dev
);
582 pr_debug("storing dev name >%s<", buf
);
583 strncpy(kim_data
->dev_name
, buf
, count
);
584 pr_debug("stored dev name >%s<", kim_data
->dev_name
);
588 static ssize_t
store_baud_rate(struct device
*dev
,
589 struct device_attribute
*attr
, const char *buf
, size_t count
)
591 struct kim_data_s
*kim_data
= dev_get_drvdata(dev
);
592 pr_debug("storing baud rate >%s<", buf
);
593 sscanf(buf
, "%ld", &kim_data
->baud_rate
);
594 pr_debug("stored baud rate >%ld<", kim_data
->baud_rate
);
597 #endif /* if DEBUG */
599 static ssize_t
show_dev_name(struct device
*dev
,
600 struct device_attribute
*attr
, char *buf
)
602 struct kim_data_s
*kim_data
= dev_get_drvdata(dev
);
603 return sprintf(buf
, "%s\n", kim_data
->dev_name
);
606 static ssize_t
show_baud_rate(struct device
*dev
,
607 struct device_attribute
*attr
, char *buf
)
609 struct kim_data_s
*kim_data
= dev_get_drvdata(dev
);
610 return sprintf(buf
, "%d\n", kim_data
->baud_rate
);
613 static ssize_t
show_flow_cntrl(struct device
*dev
,
614 struct device_attribute
*attr
, char *buf
)
616 struct kim_data_s
*kim_data
= dev_get_drvdata(dev
);
617 return sprintf(buf
, "%d\n", kim_data
->flow_cntrl
);
620 /* structures specific for sysfs entries */
621 static struct kobj_attribute ldisc_install
=
622 __ATTR(install
, 0444, (void *)show_install
, NULL
);
624 static struct kobj_attribute uart_dev_name
=
625 #ifdef DEBUG /* TODO: move this to debug-fs if possible */
626 __ATTR(dev_name
, 0644, (void *)show_dev_name
, (void *)store_dev_name
);
628 __ATTR(dev_name
, 0444, (void *)show_dev_name
, NULL
);
631 static struct kobj_attribute uart_baud_rate
=
632 #ifdef DEBUG /* TODO: move to debugfs */
633 __ATTR(baud_rate
, 0644, (void *)show_baud_rate
, (void *)store_baud_rate
);
635 __ATTR(baud_rate
, 0444, (void *)show_baud_rate
, NULL
);
638 static struct kobj_attribute uart_flow_cntrl
=
639 __ATTR(flow_cntrl
, 0444, (void *)show_flow_cntrl
, NULL
);
641 static struct attribute
*uim_attrs
[] = {
644 &uart_baud_rate
.attr
,
645 &uart_flow_cntrl
.attr
,
649 static const struct attribute_group uim_attr_grp
= {
654 * st_kim_ref - reference the core's data
655 * This references the per-ST platform device in the arch/xx/
657 * This would enable multiple such platform devices to exist
658 * on a given platform
660 void st_kim_ref(struct st_data_s
**core_data
, int id
)
662 struct platform_device
*pdev
;
663 struct kim_data_s
*kim_gdata
;
664 /* get kim_gdata reference from platform device */
665 pdev
= st_get_plat_device(id
);
668 kim_gdata
= platform_get_drvdata(pdev
);
672 *core_data
= kim_gdata
->core_data
;
678 DEFINE_SHOW_ATTRIBUTE(version
);
679 DEFINE_SHOW_ATTRIBUTE(list
);
681 /**********************************************************************/
682 /* functions called from platform device driver subsystem
683 * need to have a relevant platform device entry in the platform's
687 static struct dentry
*kim_debugfs_dir
;
688 static int kim_probe(struct platform_device
*pdev
)
690 struct kim_data_s
*kim_gdata
;
691 struct ti_st_plat_data
*pdata
= pdev
->dev
.platform_data
;
694 if ((pdev
->id
!= -1) && (pdev
->id
< MAX_ST_DEVICES
)) {
695 /* multiple devices could exist */
696 st_kim_devices
[pdev
->id
] = pdev
;
698 /* platform's sure about existence of 1 device */
699 st_kim_devices
[0] = pdev
;
702 kim_gdata
= kzalloc(sizeof(struct kim_data_s
), GFP_KERNEL
);
704 pr_err("no mem to allocate");
707 platform_set_drvdata(pdev
, kim_gdata
);
709 err
= st_core_init(&kim_gdata
->core_data
);
711 pr_err(" ST core init failed");
715 /* refer to itself */
716 kim_gdata
->core_data
->kim_data
= kim_gdata
;
718 /* Claim the chip enable nShutdown gpio from the system */
719 kim_gdata
->nshutdown
= pdata
->nshutdown_gpio
;
720 err
= gpio_request(kim_gdata
->nshutdown
, "kim");
722 pr_err(" gpio %d request failed ", kim_gdata
->nshutdown
);
723 goto err_sysfs_group
;
726 /* Configure nShutdown GPIO as output=0 */
727 err
= gpio_direction_output(kim_gdata
->nshutdown
, 0);
729 pr_err(" unable to configure gpio %d", kim_gdata
->nshutdown
);
730 goto err_sysfs_group
;
732 /* get reference of pdev for request_firmware
734 kim_gdata
->kim_pdev
= pdev
;
735 init_completion(&kim_gdata
->kim_rcvd
);
736 init_completion(&kim_gdata
->ldisc_installed
);
738 err
= sysfs_create_group(&pdev
->dev
.kobj
, &uim_attr_grp
);
740 pr_err("failed to create sysfs entries");
741 goto err_sysfs_group
;
744 /* copying platform data */
745 strncpy(kim_gdata
->dev_name
, pdata
->dev_name
, UART_DEV_NAME_LEN
);
746 kim_gdata
->flow_cntrl
= pdata
->flow_cntrl
;
747 kim_gdata
->baud_rate
= pdata
->baud_rate
;
748 pr_info("sysfs entries created\n");
750 kim_debugfs_dir
= debugfs_create_dir("ti-st", NULL
);
752 debugfs_create_file("version", S_IRUGO
, kim_debugfs_dir
,
753 kim_gdata
, &version_fops
);
754 debugfs_create_file("protocols", S_IRUGO
, kim_debugfs_dir
,
755 kim_gdata
, &list_fops
);
759 st_core_exit(kim_gdata
->core_data
);
767 static int kim_remove(struct platform_device
*pdev
)
769 /* free the GPIOs requested */
770 struct ti_st_plat_data
*pdata
= pdev
->dev
.platform_data
;
771 struct kim_data_s
*kim_gdata
;
773 kim_gdata
= platform_get_drvdata(pdev
);
775 /* Free the Bluetooth/FM/GPIO
776 * nShutdown gpio from the system
778 gpio_free(pdata
->nshutdown_gpio
);
779 pr_info("nshutdown GPIO Freed");
781 debugfs_remove_recursive(kim_debugfs_dir
);
782 sysfs_remove_group(&pdev
->dev
.kobj
, &uim_attr_grp
);
783 pr_info("sysfs entries removed");
785 kim_gdata
->kim_pdev
= NULL
;
786 st_core_exit(kim_gdata
->core_data
);
793 static int kim_suspend(struct platform_device
*pdev
, pm_message_t state
)
795 struct ti_st_plat_data
*pdata
= pdev
->dev
.platform_data
;
798 return pdata
->suspend(pdev
, state
);
803 static int kim_resume(struct platform_device
*pdev
)
805 struct ti_st_plat_data
*pdata
= pdev
->dev
.platform_data
;
808 return pdata
->resume(pdev
);
813 /**********************************************************************/
814 /* entry point for ST KIM module, called in from ST Core */
815 static struct platform_driver kim_platform_driver
= {
817 .remove
= kim_remove
,
818 .suspend
= kim_suspend
,
819 .resume
= kim_resume
,
825 module_platform_driver(kim_platform_driver
);
827 MODULE_AUTHOR("Pavan Savoy <pavan_savoy@ti.com>");
828 MODULE_DESCRIPTION("Shared Transport Driver for TI BT/FM/GPS combo chips ");
829 MODULE_LICENSE("GPL");