GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / staging / ti-st / st_kim.c
blobeb1454b9ee67a6e4caab2c7351a5f5790a0a936e
1 /*
2 * Shared Transport Line discipline driver Core
3 * Init Manager module responsible for GPIO control
4 * and firmware download
5 * Copyright (C) 2009 Texas Instruments
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.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #define pr_fmt(fmt) "(stk) :" fmt
23 #include <linux/platform_device.h>
24 #include <linux/jiffies.h>
25 #include <linux/firmware.h>
26 #include <linux/delay.h>
27 #include <linux/wait.h>
28 #include <linux/gpio.h>
29 #include <linux/debugfs.h>
30 #include <linux/seq_file.h>
32 #include <linux/sched.h>
34 #include "st_kim.h"
35 /* understand BT events for fw response */
36 #include <net/bluetooth/bluetooth.h>
37 #include <net/bluetooth/hci_core.h>
38 #include <net/bluetooth/hci.h>
41 static int kim_probe(struct platform_device *pdev);
42 static int kim_remove(struct platform_device *pdev);
44 /* KIM platform device driver structure */
45 static struct platform_driver kim_platform_driver = {
46 .probe = kim_probe,
47 .remove = kim_remove,
48 /* TODO: ST driver power management during suspend/resume ?
50 .driver = {
51 .name = "kim",
52 .owner = THIS_MODULE,
56 static int kim_toggle_radio(void*, bool);
57 static const struct rfkill_ops kim_rfkill_ops = {
58 .set_block = kim_toggle_radio,
61 /* strings to be used for rfkill entries and by
62 * ST Core to be used for sysfs debug entry
64 #define PROTO_ENTRY(type, name) name
65 const unsigned char *protocol_names[] = {
66 PROTO_ENTRY(ST_BT, "Bluetooth"),
67 PROTO_ENTRY(ST_FM, "FM"),
68 PROTO_ENTRY(ST_GPS, "GPS"),
71 #define MAX_ST_DEVICES 3 /* Imagine 1 on each UART for now */
72 struct platform_device *st_kim_devices[MAX_ST_DEVICES];
74 /**********************************************************************/
75 /* internal functions */
77 /**
78 * st_get_plat_device -
79 * function which returns the reference to the platform device
80 * requested by id. As of now only 1 such device exists (id=0)
81 * the context requesting for reference can get the id to be
82 * requested by a. The protocol driver which is registering or
83 * b. the tty device which is opened.
85 static struct platform_device *st_get_plat_device(int id)
87 return st_kim_devices[id];
90 /**
91 * validate_firmware_response -
92 * function to return whether the firmware response was proper
93 * in case of error don't complete so that waiting for proper
94 * response times out
96 void validate_firmware_response(struct kim_data_s *kim_gdata)
98 struct sk_buff *skb = kim_gdata->rx_skb;
99 if (unlikely(skb->data[5] != 0)) {
100 pr_err("no proper response during fw download");
101 pr_err("data6 %x", skb->data[5]);
102 return; /* keep waiting for the proper response */
104 /* becos of all the script being downloaded */
105 complete_all(&kim_gdata->kim_rcvd);
106 kfree_skb(skb);
109 /* check for data len received inside kim_int_recv
110 * most often hit the last case to update state to waiting for data
112 static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len)
114 register int room = skb_tailroom(kim_gdata->rx_skb);
116 pr_debug("len %d room %d", len, room);
118 if (!len) {
119 validate_firmware_response(kim_gdata);
120 } else if (len > room) {
121 /* Received packet's payload length is larger.
122 * We can't accommodate it in created skb.
124 pr_err("Data length is too large len %d room %d", len,
125 room);
126 kfree_skb(kim_gdata->rx_skb);
127 } else {
128 /* Packet header has non-zero payload length and
129 * we have enough space in created skb. Lets read
130 * payload data */
131 kim_gdata->rx_state = ST_BT_W4_DATA;
132 kim_gdata->rx_count = len;
133 return len;
136 /* Change ST LL state to continue to process next
137 * packet */
138 kim_gdata->rx_state = ST_W4_PACKET_TYPE;
139 kim_gdata->rx_skb = NULL;
140 kim_gdata->rx_count = 0;
142 return 0;
146 * kim_int_recv - receive function called during firmware download
147 * firmware download responses on different UART drivers
148 * have been observed to come in bursts of different
149 * tty_receive and hence the logic
151 void kim_int_recv(struct kim_data_s *kim_gdata,
152 const unsigned char *data, long count)
154 register char *ptr;
155 struct hci_event_hdr *eh;
156 register int len = 0, type = 0;
158 pr_debug("%s", __func__);
159 /* Decode received bytes here */
160 ptr = (char *)data;
161 if (unlikely(ptr == NULL)) {
162 pr_err(" received null from TTY ");
163 return;
165 while (count) {
166 if (kim_gdata->rx_count) {
167 len = min_t(unsigned int, kim_gdata->rx_count, count);
168 memcpy(skb_put(kim_gdata->rx_skb, len), ptr, len);
169 kim_gdata->rx_count -= len;
170 count -= len;
171 ptr += len;
173 if (kim_gdata->rx_count)
174 continue;
176 /* Check ST RX state machine , where are we? */
177 switch (kim_gdata->rx_state) {
178 /* Waiting for complete packet ? */
179 case ST_BT_W4_DATA:
180 pr_debug("Complete pkt received");
181 validate_firmware_response(kim_gdata);
182 kim_gdata->rx_state = ST_W4_PACKET_TYPE;
183 kim_gdata->rx_skb = NULL;
184 continue;
185 /* Waiting for Bluetooth event header ? */
186 case ST_BT_W4_EVENT_HDR:
187 eh = (struct hci_event_hdr *)kim_gdata->
188 rx_skb->data;
189 pr_debug("Event header: evt 0x%2.2x"
190 "plen %d", eh->evt, eh->plen);
191 kim_check_data_len(kim_gdata, eh->plen);
192 continue;
193 } /* end of switch */
194 } /* end of if rx_state */
195 switch (*ptr) {
196 /* Bluetooth event packet? */
197 case HCI_EVENT_PKT:
198 pr_info("Event packet");
199 kim_gdata->rx_state = ST_BT_W4_EVENT_HDR;
200 kim_gdata->rx_count = HCI_EVENT_HDR_SIZE;
201 type = HCI_EVENT_PKT;
202 break;
203 default:
204 pr_info("unknown packet");
205 ptr++;
206 count--;
207 continue;
209 ptr++;
210 count--;
211 kim_gdata->rx_skb =
212 bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);
213 if (!kim_gdata->rx_skb) {
214 pr_err("can't allocate mem for new packet");
215 kim_gdata->rx_state = ST_W4_PACKET_TYPE;
216 kim_gdata->rx_count = 0;
217 return;
219 bt_cb(kim_gdata->rx_skb)->pkt_type = type;
221 pr_info("done %s", __func__);
222 return;
225 static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name)
227 unsigned short version = 0, chip = 0, min_ver = 0, maj_ver = 0;
228 char read_ver_cmd[] = { 0x01, 0x01, 0x10, 0x00 };
230 pr_debug("%s", __func__);
232 INIT_COMPLETION(kim_gdata->kim_rcvd);
233 if (4 != st_int_write(kim_gdata->core_data, read_ver_cmd, 4)) {
234 pr_err("kim: couldn't write 4 bytes");
235 return -1;
238 if (!wait_for_completion_timeout
239 (&kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME))) {
240 pr_err(" waiting for ver info- timed out ");
241 return -1;
244 version =
245 MAKEWORD(kim_gdata->resp_buffer[13],
246 kim_gdata->resp_buffer[14]);
247 chip = (version & 0x7C00) >> 10;
248 min_ver = (version & 0x007F);
249 maj_ver = (version & 0x0380) >> 7;
251 if (version & 0x8000)
252 maj_ver |= 0x0008;
254 sprintf(bts_scr_name, "TIInit_%d.%d.%d.bts", chip, maj_ver, min_ver);
256 /* to be accessed later via sysfs entry */
257 kim_gdata->version.full = version;
258 kim_gdata->version.chip = chip;
259 kim_gdata->version.maj_ver = maj_ver;
260 kim_gdata->version.min_ver = min_ver;
262 pr_info("%s", bts_scr_name);
263 return 0;
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)
273 long err = 0;
274 long len = 0;
275 register unsigned char *ptr = NULL;
276 register unsigned char *action_ptr = NULL;
277 unsigned char bts_scr_name[30] = { 0 }; /* 30 char long bts scr name? */
279 err = read_local_version(kim_gdata, bts_scr_name);
280 if (err != 0) {
281 pr_err("kim: failed to read local ver");
282 return err;
284 err =
285 request_firmware(&kim_gdata->fw_entry, bts_scr_name,
286 &kim_gdata->kim_pdev->dev);
287 if (unlikely((err != 0) || (kim_gdata->fw_entry->data == NULL) ||
288 (kim_gdata->fw_entry->size == 0))) {
289 pr_err(" request_firmware failed(errno %ld) for %s", err,
290 bts_scr_name);
291 return -1;
293 ptr = (void *)kim_gdata->fw_entry->data;
294 len = kim_gdata->fw_entry->size;
295 /* bts_header to remove out magic number and
296 * version
298 ptr += sizeof(struct bts_header);
299 len -= sizeof(struct bts_header);
301 while (len > 0 && ptr) {
302 pr_debug(" action size %d, type %d ",
303 ((struct bts_action *)ptr)->size,
304 ((struct bts_action *)ptr)->type);
306 switch (((struct bts_action *)ptr)->type) {
307 case ACTION_SEND_COMMAND: /* action send */
308 action_ptr = &(((struct bts_action *)ptr)->data[0]);
309 if (unlikely
310 (((struct hci_command *)action_ptr)->opcode ==
311 0xFF36)) {
312 /* ignore remote change
313 * baud rate HCI VS command */
314 pr_err
315 (" change remote baud"
316 " rate command in firmware");
317 break;
320 INIT_COMPLETION(kim_gdata->kim_rcvd);
321 err = st_int_write(kim_gdata->core_data,
322 ((struct bts_action_send *)action_ptr)->data,
323 ((struct bts_action *)ptr)->size);
324 if (unlikely(err < 0)) {
325 release_firmware(kim_gdata->fw_entry);
326 return -1;
328 if (!wait_for_completion_timeout
329 (&kim_gdata->kim_rcvd,
330 msecs_to_jiffies(CMD_RESP_TIME))) {
331 pr_err
332 (" response timeout during fw download ");
333 /* timed out */
334 release_firmware(kim_gdata->fw_entry);
335 return -1;
337 break;
338 case ACTION_DELAY: /* sleep */
339 pr_info("sleep command in scr");
340 action_ptr = &(((struct bts_action *)ptr)->data[0]);
341 mdelay(((struct bts_action_delay *)action_ptr)->msec);
342 break;
344 len =
345 len - (sizeof(struct bts_action) +
346 ((struct bts_action *)ptr)->size);
347 ptr =
348 ptr + sizeof(struct bts_action) +
349 ((struct bts_action *)ptr)->size;
351 /* fw download complete */
352 release_firmware(kim_gdata->fw_entry);
353 return 0;
356 /**********************************************************************/
357 /* functions called from ST core */
358 /* function to toggle the GPIO
359 * needs to know whether the GPIO is active high or active low
361 void st_kim_chip_toggle(enum proto_type type, enum kim_gpio_state state)
363 struct platform_device *kim_pdev;
364 struct kim_data_s *kim_gdata;
365 pr_info(" %s ", __func__);
367 kim_pdev = st_get_plat_device(0);
368 kim_gdata = dev_get_drvdata(&kim_pdev->dev);
370 if (kim_gdata->gpios[type] == -1) {
371 pr_info(" gpio not requested for protocol %s",
372 protocol_names[type]);
373 return;
375 switch (type) {
376 case ST_BT:
377 /*Do Nothing */
378 break;
380 case ST_FM:
381 if (state == KIM_GPIO_ACTIVE)
382 gpio_set_value(kim_gdata->gpios[ST_FM], GPIO_LOW);
383 else
384 gpio_set_value(kim_gdata->gpios[ST_FM], GPIO_HIGH);
385 break;
387 case ST_GPS:
388 if (state == KIM_GPIO_ACTIVE)
389 gpio_set_value(kim_gdata->gpios[ST_GPS], GPIO_HIGH);
390 else
391 gpio_set_value(kim_gdata->gpios[ST_GPS], GPIO_LOW);
392 break;
394 case ST_MAX:
395 default:
396 break;
399 return;
402 /* called from ST Core, when REG_IN_PROGRESS (registration in progress)
403 * can be because of
404 * 1. response to read local version
405 * 2. during send/recv's of firmware download
407 void st_kim_recv(void *disc_data, const unsigned char *data, long count)
409 struct st_data_s *st_gdata = (struct st_data_s *)disc_data;
410 struct kim_data_s *kim_gdata = st_gdata->kim_data;
412 pr_info(" %s ", __func__);
413 /* copy to local buffer */
414 if (unlikely(data[4] == 0x01 && data[5] == 0x10 && data[0] == 0x04)) {
415 /* must be the read_ver_cmd */
416 memcpy(kim_gdata->resp_buffer, 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 */
423 return;
426 /* to signal completion of line discipline installation
427 * called from ST Core, upon tty_open
429 void st_kim_complete(void *kim_data)
431 struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;
432 complete(&kim_gdata->ldisc_installed);
436 * st_kim_start - called from ST Core upon 1st registration
437 * This involves toggling the chip enable gpio, reading
438 * the firmware version from chip, forming the fw file name
439 * based on the chip version, requesting the fw, parsing it
440 * and perform download(send/recv).
442 long st_kim_start(void *kim_data)
444 long err = 0;
445 long retry = POR_RETRY_COUNT;
446 struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;
448 pr_info(" %s", __func__);
450 do {
451 /* TODO: this is only because rfkill sub-system
452 * doesn't send events to user-space if the state
453 * isn't changed
455 rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 1);
456 /* Configure BT nShutdown to HIGH state */
457 gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_LOW);
458 mdelay(5);
459 gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_HIGH);
460 mdelay(100);
461 /* re-initialize the completion */
462 INIT_COMPLETION(kim_gdata->ldisc_installed);
463 /* unblock and send event to UIM via /dev/rfkill */
464 rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 0);
465 /* wait for ldisc to be installed */
466 err = wait_for_completion_timeout(&kim_gdata->ldisc_installed,
467 msecs_to_jiffies(LDISC_TIME));
468 if (!err) { /* timeout */
469 pr_err("line disc installation timed out ");
470 err = -1;
471 continue;
472 } else {
473 /* ldisc installed now */
474 pr_info(" line discipline installed ");
475 err = download_firmware(kim_gdata);
476 if (err != 0) {
477 pr_err("download firmware failed");
478 continue;
479 } else { /* on success don't retry */
480 break;
483 } while (retry--);
484 return err;
488 * st_kim_stop - called from ST Core, on the last un-registration
489 * toggle low the chip enable gpio
491 long st_kim_stop(void *kim_data)
493 long err = 0;
494 struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;
496 INIT_COMPLETION(kim_gdata->ldisc_installed);
497 /* set BT rfkill to be blocked */
498 err = rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 1);
500 /* wait for ldisc to be un-installed */
501 err = wait_for_completion_timeout(&kim_gdata->ldisc_installed,
502 msecs_to_jiffies(LDISC_TIME));
503 if (!err) { /* timeout */
504 pr_err(" timed out waiting for ldisc to be un-installed");
505 return -1;
508 /* By default configure BT nShutdown to LOW state */
509 gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_LOW);
510 mdelay(1);
511 gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_HIGH);
512 mdelay(1);
513 gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_LOW);
514 return err;
517 /**********************************************************************/
518 /* functions called from subsystems */
519 /* called when debugfs entry is read from */
521 static int show_version(struct seq_file *s, void *unused)
523 struct kim_data_s *kim_gdata = (struct kim_data_s *)s->private;
524 seq_printf(s, "%04X %d.%d.%d\n", kim_gdata->version.full,
525 kim_gdata->version.chip, kim_gdata->version.maj_ver,
526 kim_gdata->version.min_ver);
527 return 0;
530 static int show_list(struct seq_file *s, void *unused)
532 struct kim_data_s *kim_gdata = (struct kim_data_s *)s->private;
533 kim_st_list_protocols(kim_gdata->core_data, s);
534 return 0;
537 /* function called from rfkill subsystem, when someone from
538 * user space would write 0/1 on the sysfs entry
539 * /sys/class/rfkill/rfkill0,1,3/state
541 static int kim_toggle_radio(void *data, bool blocked)
543 enum proto_type type = *((enum proto_type *)data);
544 pr_debug(" %s: %d ", __func__, type);
546 switch (type) {
547 case ST_BT:
548 /* do nothing */
549 break;
550 case ST_FM:
551 case ST_GPS:
552 if (blocked)
553 st_kim_chip_toggle(type, KIM_GPIO_INACTIVE);
554 else
555 st_kim_chip_toggle(type, KIM_GPIO_ACTIVE);
556 break;
557 case ST_MAX:
558 pr_err(" wrong proto type ");
559 break;
561 return 0;
565 * st_kim_ref - reference the core's data
566 * This references the per-ST platform device in the arch/xx/
567 * board-xx.c file.
568 * This would enable multiple such platform devices to exist
569 * on a given platform
571 void st_kim_ref(struct st_data_s **core_data, int id)
573 struct platform_device *pdev;
574 struct kim_data_s *kim_gdata;
575 /* get kim_gdata reference from platform device */
576 pdev = st_get_plat_device(id);
577 kim_gdata = dev_get_drvdata(&pdev->dev);
578 *core_data = kim_gdata->core_data;
581 static int kim_version_open(struct inode *i, struct file *f)
583 return single_open(f, show_version, i->i_private);
586 static int kim_list_open(struct inode *i, struct file *f)
588 return single_open(f, show_list, i->i_private);
591 static const struct file_operations version_debugfs_fops = {
592 /* version info */
593 .open = kim_version_open,
594 .read = seq_read,
595 .llseek = seq_lseek,
596 .release = single_release,
598 static const struct file_operations list_debugfs_fops = {
599 /* protocols info */
600 .open = kim_list_open,
601 .read = seq_read,
602 .llseek = seq_lseek,
603 .release = single_release,
606 /**********************************************************************/
607 /* functions called from platform device driver subsystem
608 * need to have a relevant platform device entry in the platform's
609 * board-*.c file
612 struct dentry *kim_debugfs_dir;
613 static int kim_probe(struct platform_device *pdev)
615 long status;
616 long proto;
617 long *gpios = pdev->dev.platform_data;
618 struct kim_data_s *kim_gdata;
620 st_kim_devices[pdev->id] = pdev;
621 kim_gdata = kzalloc(sizeof(struct kim_data_s), GFP_ATOMIC);
622 if (!kim_gdata) {
623 pr_err("no mem to allocate");
624 return -ENOMEM;
626 dev_set_drvdata(&pdev->dev, kim_gdata);
628 status = st_core_init(&kim_gdata->core_data);
629 if (status != 0) {
630 pr_err(" ST core init failed");
631 return -1;
633 /* refer to itself */
634 kim_gdata->core_data->kim_data = kim_gdata;
636 for (proto = 0; proto < ST_MAX; proto++) {
637 kim_gdata->gpios[proto] = gpios[proto];
638 pr_info(" %ld gpio to be requested", gpios[proto]);
641 for (proto = 0; (proto < ST_MAX) && (gpios[proto] != -1); proto++) {
642 /* Claim the Bluetooth/FM/GPIO
643 * nShutdown gpio from the system
645 status = gpio_request(gpios[proto], "kim");
646 if (unlikely(status)) {
647 pr_err(" gpio %ld request failed ", gpios[proto]);
648 proto -= 1;
649 while (proto >= 0) {
650 if (gpios[proto] != -1)
651 gpio_free(gpios[proto]);
653 return status;
656 /* Configure nShutdown GPIO as output=0 */
657 status =
658 gpio_direction_output(gpios[proto], 0);
659 if (unlikely(status)) {
660 pr_err(" unable to configure gpio %ld",
661 gpios[proto]);
662 proto -= 1;
663 while (proto >= 0) {
664 if (gpios[proto] != -1)
665 gpio_free(gpios[proto]);
667 return status;
670 /* get reference of pdev for request_firmware
672 kim_gdata->kim_pdev = pdev;
673 init_completion(&kim_gdata->kim_rcvd);
674 init_completion(&kim_gdata->ldisc_installed);
676 for (proto = 0; (proto < ST_MAX) && (gpios[proto] != -1); proto++) {
677 /* TODO: should all types be rfkill_type_bt ? */
678 kim_gdata->rf_protos[proto] = proto;
679 kim_gdata->rfkill[proto] = rfkill_alloc(protocol_names[proto],
680 &pdev->dev, RFKILL_TYPE_BLUETOOTH,
681 &kim_rfkill_ops, &kim_gdata->rf_protos[proto]);
682 if (kim_gdata->rfkill[proto] == NULL) {
683 pr_err("cannot create rfkill entry for gpio %ld",
684 gpios[proto]);
685 continue;
687 /* block upon creation */
688 rfkill_init_sw_state(kim_gdata->rfkill[proto], 1);
689 status = rfkill_register(kim_gdata->rfkill[proto]);
690 if (unlikely(status)) {
691 pr_err("rfkill registration failed for gpio %ld",
692 gpios[proto]);
693 rfkill_unregister(kim_gdata->rfkill[proto]);
694 continue;
696 pr_info("rfkill entry created for %ld", gpios[proto]);
699 kim_debugfs_dir = debugfs_create_dir("ti-st", NULL);
700 if (IS_ERR(kim_debugfs_dir)) {
701 pr_err(" debugfs entries creation failed ");
702 kim_debugfs_dir = NULL;
703 return -1;
706 debugfs_create_file("version", S_IRUGO, kim_debugfs_dir,
707 kim_gdata, &version_debugfs_fops);
708 debugfs_create_file("protocols", S_IRUGO, kim_debugfs_dir,
709 kim_gdata, &list_debugfs_fops);
710 pr_info(" debugfs entries created ");
711 return 0;
714 static int kim_remove(struct platform_device *pdev)
716 /* free the GPIOs requested
718 long *gpios = pdev->dev.platform_data;
719 long proto;
720 struct kim_data_s *kim_gdata;
722 kim_gdata = dev_get_drvdata(&pdev->dev);
724 for (proto = 0; (proto < ST_MAX) && (gpios[proto] != -1); proto++) {
725 /* Claim the Bluetooth/FM/GPIO
726 * nShutdown gpio from the system
728 gpio_free(gpios[proto]);
729 rfkill_unregister(kim_gdata->rfkill[proto]);
730 rfkill_destroy(kim_gdata->rfkill[proto]);
731 kim_gdata->rfkill[proto] = NULL;
733 pr_info("kim: GPIO Freed");
734 debugfs_remove_recursive(kim_debugfs_dir);
735 kim_gdata->kim_pdev = NULL;
736 st_core_exit(kim_gdata->core_data);
738 kfree(kim_gdata);
739 kim_gdata = NULL;
740 return 0;
743 /**********************************************************************/
744 /* entry point for ST KIM module, called in from ST Core */
746 static int __init st_kim_init(void)
748 long ret = 0;
749 ret = platform_driver_register(&kim_platform_driver);
750 if (ret != 0) {
751 pr_err("platform drv registration failed");
752 return -1;
754 return 0;
757 static void __exit st_kim_deinit(void)
759 /* the following returns void */
760 platform_driver_unregister(&kim_platform_driver);
764 module_init(st_kim_init);
765 module_exit(st_kim_deinit);
766 MODULE_AUTHOR("Pavan Savoy <pavan_savoy@ti.com>");
767 MODULE_DESCRIPTION("Shared Transport Driver for TI BT/FM/GPS combo chips ");
768 MODULE_LICENSE("GPL");