.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Shared Transport Line discipline driver Core |
---|
3 | 4 | * Init Manager module responsible for GPIO control |
---|
4 | 5 | * and firmware download |
---|
5 | 6 | * Copyright (C) 2009-2010 Texas Instruments |
---|
6 | 7 | * Author: Pavan Savoy <pavan_savoy@ti.com> |
---|
7 | | - * |
---|
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 | 8 | */ |
---|
22 | 9 | |
---|
23 | 10 | #define pr_fmt(fmt) "(stk) :" fmt |
---|
.. | .. |
---|
43 | 30 | /**********************************************************************/ |
---|
44 | 31 | /* internal functions */ |
---|
45 | 32 | |
---|
46 | | -/** |
---|
| 33 | +/* |
---|
47 | 34 | * st_get_plat_device - |
---|
48 | 35 | * function which returns the reference to the platform device |
---|
49 | 36 | * requested by id. As of now only 1 such device exists (id=0) |
---|
.. | .. |
---|
56 | 43 | return st_kim_devices[id]; |
---|
57 | 44 | } |
---|
58 | 45 | |
---|
59 | | -/** |
---|
| 46 | +/* |
---|
60 | 47 | * validate_firmware_response - |
---|
61 | 48 | * function to return whether the firmware response was proper |
---|
62 | 49 | * in case of error don't complete so that waiting for proper |
---|
.. | .. |
---|
68 | 55 | if (!skb) |
---|
69 | 56 | return; |
---|
70 | 57 | |
---|
71 | | - /* these magic numbers are the position in the response buffer which |
---|
| 58 | + /* |
---|
| 59 | + * these magic numbers are the position in the response buffer which |
---|
72 | 60 | * allows us to distinguish whether the response is for the read |
---|
73 | 61 | * version info. command |
---|
74 | 62 | */ |
---|
.. | .. |
---|
92 | 80 | kfree_skb(skb); |
---|
93 | 81 | } |
---|
94 | 82 | |
---|
95 | | -/* check for data len received inside kim_int_recv |
---|
| 83 | +/* |
---|
| 84 | + * check for data len received inside kim_int_recv |
---|
96 | 85 | * most often hit the last case to update state to waiting for data |
---|
97 | 86 | */ |
---|
98 | 87 | static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len) |
---|
.. | .. |
---|
104 | 93 | if (!len) { |
---|
105 | 94 | validate_firmware_response(kim_gdata); |
---|
106 | 95 | } else if (len > room) { |
---|
107 | | - /* Received packet's payload length is larger. |
---|
| 96 | + /* |
---|
| 97 | + * Received packet's payload length is larger. |
---|
108 | 98 | * We can't accommodate it in created skb. |
---|
109 | 99 | */ |
---|
110 | 100 | pr_err("Data length is too large len %d room %d", len, |
---|
111 | 101 | room); |
---|
112 | 102 | kfree_skb(kim_gdata->rx_skb); |
---|
113 | 103 | } else { |
---|
114 | | - /* Packet header has non-zero payload length and |
---|
| 104 | + /* |
---|
| 105 | + * Packet header has non-zero payload length and |
---|
115 | 106 | * we have enough space in created skb. Lets read |
---|
116 | 107 | * payload data */ |
---|
117 | 108 | kim_gdata->rx_state = ST_W4_DATA; |
---|
.. | .. |
---|
119 | 110 | return len; |
---|
120 | 111 | } |
---|
121 | 112 | |
---|
122 | | - /* Change ST LL state to continue to process next |
---|
123 | | - * packet */ |
---|
| 113 | + /* |
---|
| 114 | + * Change ST LL state to continue to process next |
---|
| 115 | + * packet |
---|
| 116 | + */ |
---|
124 | 117 | kim_gdata->rx_state = ST_W4_PACKET_TYPE; |
---|
125 | 118 | kim_gdata->rx_skb = NULL; |
---|
126 | 119 | kim_gdata->rx_count = 0; |
---|
.. | .. |
---|
128 | 121 | return 0; |
---|
129 | 122 | } |
---|
130 | 123 | |
---|
131 | | -/** |
---|
| 124 | +/* |
---|
132 | 125 | * kim_int_recv - receive function called during firmware download |
---|
133 | 126 | * firmware download responses on different UART drivers |
---|
134 | 127 | * have been observed to come in bursts of different |
---|
.. | .. |
---|
211 | 204 | static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name) |
---|
212 | 205 | { |
---|
213 | 206 | unsigned short version = 0, chip = 0, min_ver = 0, maj_ver = 0; |
---|
214 | | - const char read_ver_cmd[] = { 0x01, 0x01, 0x10, 0x00 }; |
---|
| 207 | + static const char read_ver_cmd[] = { 0x01, 0x01, 0x10, 0x00 }; |
---|
215 | 208 | long timeout; |
---|
216 | 209 | |
---|
217 | 210 | pr_debug("%s", __func__); |
---|
.. | .. |
---|
229 | 222 | return timeout ? -ERESTARTSYS : -ETIMEDOUT; |
---|
230 | 223 | } |
---|
231 | 224 | reinit_completion(&kim_gdata->kim_rcvd); |
---|
232 | | - /* the positions 12 & 13 in the response buffer provide with the |
---|
| 225 | + /* |
---|
| 226 | + * the positions 12 & 13 in the response buffer provide with the |
---|
233 | 227 | * chip, major & minor numbers |
---|
234 | 228 | */ |
---|
235 | 229 | |
---|
.. | .. |
---|
276 | 270 | } |
---|
277 | 271 | } |
---|
278 | 272 | |
---|
279 | | -/** |
---|
| 273 | +/* |
---|
280 | 274 | * download_firmware - |
---|
281 | 275 | * internal function which parses through the .bts firmware |
---|
282 | 276 | * script file intreprets SEND, DELAY actions only as of now |
---|
.. | .. |
---|
308 | 302 | } |
---|
309 | 303 | ptr = (void *)kim_gdata->fw_entry->data; |
---|
310 | 304 | len = kim_gdata->fw_entry->size; |
---|
311 | | - /* bts_header to remove out magic number and |
---|
| 305 | + /* |
---|
| 306 | + * bts_header to remove out magic number and |
---|
312 | 307 | * version |
---|
313 | 308 | */ |
---|
314 | 309 | ptr += sizeof(struct bts_header); |
---|
.. | .. |
---|
326 | 321 | if (unlikely |
---|
327 | 322 | (((struct hci_command *)action_ptr)->opcode == |
---|
328 | 323 | 0xFF36)) { |
---|
329 | | - /* ignore remote change |
---|
330 | | - * baud rate HCI VS command */ |
---|
| 324 | + /* |
---|
| 325 | + * ignore remote change |
---|
| 326 | + * baud rate HCI VS command |
---|
| 327 | + */ |
---|
331 | 328 | pr_warn("change remote baud" |
---|
332 | 329 | " rate command in firmware"); |
---|
333 | 330 | skip_change_remote_baud(&ptr, &len); |
---|
.. | .. |
---|
359 | 356 | release_firmware(kim_gdata->fw_entry); |
---|
360 | 357 | return -ETIMEDOUT; |
---|
361 | 358 | } |
---|
362 | | - /* reinit completion before sending for the |
---|
| 359 | + /* |
---|
| 360 | + * reinit completion before sending for the |
---|
363 | 361 | * relevant wait |
---|
364 | 362 | */ |
---|
365 | 363 | reinit_completion(&kim_gdata->kim_rcvd); |
---|
.. | .. |
---|
431 | 429 | struct st_data_s *st_gdata = (struct st_data_s *)disc_data; |
---|
432 | 430 | struct kim_data_s *kim_gdata = st_gdata->kim_data; |
---|
433 | 431 | |
---|
434 | | - /* proceed to gather all data and distinguish read fw version response |
---|
| 432 | + /* |
---|
| 433 | + * proceed to gather all data and distinguish read fw version response |
---|
435 | 434 | * from other fw responses when data gathering is complete |
---|
436 | 435 | */ |
---|
437 | 436 | kim_int_recv(kim_gdata, data, count); |
---|
438 | 437 | return; |
---|
439 | 438 | } |
---|
440 | 439 | |
---|
441 | | -/* to signal completion of line discipline installation |
---|
| 440 | +/* |
---|
| 441 | + * to signal completion of line discipline installation |
---|
442 | 442 | * called from ST Core, upon tty_open |
---|
443 | 443 | */ |
---|
444 | 444 | void st_kim_complete(void *kim_data) |
---|
.. | .. |
---|
447 | 447 | complete(&kim_gdata->ldisc_installed); |
---|
448 | 448 | } |
---|
449 | 449 | |
---|
450 | | -/** |
---|
| 450 | +/* |
---|
451 | 451 | * st_kim_start - called from ST Core upon 1st registration |
---|
452 | 452 | * This involves toggling the chip enable gpio, reading |
---|
453 | 453 | * the firmware version from chip, forming the fw file name |
---|
.. | .. |
---|
485 | 485 | err = wait_for_completion_interruptible_timeout( |
---|
486 | 486 | &kim_gdata->ldisc_installed, msecs_to_jiffies(LDISC_TIME)); |
---|
487 | 487 | if (!err) { |
---|
488 | | - /* ldisc installation timeout, |
---|
489 | | - * flush uart, power cycle BT_EN */ |
---|
| 488 | + /* |
---|
| 489 | + * ldisc installation timeout, |
---|
| 490 | + * flush uart, power cycle BT_EN |
---|
| 491 | + */ |
---|
490 | 492 | pr_err("ldisc installation timeout"); |
---|
491 | 493 | err = st_kim_stop(kim_gdata); |
---|
492 | 494 | continue; |
---|
.. | .. |
---|
495 | 497 | pr_info("line discipline installed"); |
---|
496 | 498 | err = download_firmware(kim_gdata); |
---|
497 | 499 | if (err != 0) { |
---|
498 | | - /* ldisc installed but fw download failed, |
---|
499 | | - * flush uart & power cycle BT_EN */ |
---|
| 500 | + /* |
---|
| 501 | + * ldisc installed but fw download failed, |
---|
| 502 | + * flush uart & power cycle BT_EN |
---|
| 503 | + */ |
---|
500 | 504 | pr_err("download firmware failed"); |
---|
501 | 505 | err = st_kim_stop(kim_gdata); |
---|
502 | 506 | continue; |
---|
.. | .. |
---|
508 | 512 | return err; |
---|
509 | 513 | } |
---|
510 | 514 | |
---|
511 | | -/** |
---|
| 515 | +/* |
---|
512 | 516 | * st_kim_stop - stop communication with chip. |
---|
513 | 517 | * This can be called from ST Core/KIM, on the- |
---|
514 | 518 | * (a) last un-register when chip need not be powered there-after, |
---|
.. | .. |
---|
564 | 568 | /* functions called from subsystems */ |
---|
565 | 569 | /* called when debugfs entry is read from */ |
---|
566 | 570 | |
---|
567 | | -static int show_version(struct seq_file *s, void *unused) |
---|
| 571 | +static int version_show(struct seq_file *s, void *unused) |
---|
568 | 572 | { |
---|
569 | 573 | struct kim_data_s *kim_gdata = (struct kim_data_s *)s->private; |
---|
570 | 574 | seq_printf(s, "%04X %d.%d.%d\n", kim_gdata->version.full, |
---|
.. | .. |
---|
573 | 577 | return 0; |
---|
574 | 578 | } |
---|
575 | 579 | |
---|
576 | | -static int show_list(struct seq_file *s, void *unused) |
---|
| 580 | +static int list_show(struct seq_file *s, void *unused) |
---|
577 | 581 | { |
---|
578 | 582 | struct kim_data_s *kim_gdata = (struct kim_data_s *)s->private; |
---|
579 | 583 | kim_st_list_protocols(kim_gdata->core_data, s); |
---|
.. | .. |
---|
663 | 667 | .attrs = uim_attrs, |
---|
664 | 668 | }; |
---|
665 | 669 | |
---|
666 | | -/** |
---|
| 670 | +/* |
---|
667 | 671 | * st_kim_ref - reference the core's data |
---|
668 | 672 | * This references the per-ST platform device in the arch/xx/ |
---|
669 | 673 | * board-xx.c file. |
---|
.. | .. |
---|
688 | 692 | *core_data = NULL; |
---|
689 | 693 | } |
---|
690 | 694 | |
---|
691 | | -static int kim_version_open(struct inode *i, struct file *f) |
---|
692 | | -{ |
---|
693 | | - return single_open(f, show_version, i->i_private); |
---|
694 | | -} |
---|
695 | | - |
---|
696 | | -static int kim_list_open(struct inode *i, struct file *f) |
---|
697 | | -{ |
---|
698 | | - return single_open(f, show_list, i->i_private); |
---|
699 | | -} |
---|
700 | | - |
---|
701 | | -static const struct file_operations version_debugfs_fops = { |
---|
702 | | - /* version info */ |
---|
703 | | - .open = kim_version_open, |
---|
704 | | - .read = seq_read, |
---|
705 | | - .llseek = seq_lseek, |
---|
706 | | - .release = single_release, |
---|
707 | | -}; |
---|
708 | | -static const struct file_operations list_debugfs_fops = { |
---|
709 | | - /* protocols info */ |
---|
710 | | - .open = kim_list_open, |
---|
711 | | - .read = seq_read, |
---|
712 | | - .llseek = seq_lseek, |
---|
713 | | - .release = single_release, |
---|
714 | | -}; |
---|
| 695 | +DEFINE_SHOW_ATTRIBUTE(version); |
---|
| 696 | +DEFINE_SHOW_ATTRIBUTE(list); |
---|
715 | 697 | |
---|
716 | 698 | /**********************************************************************/ |
---|
717 | 699 | /* functions called from platform device driver subsystem |
---|
.. | .. |
---|
764 | 746 | pr_err(" unable to configure gpio %d", kim_gdata->nshutdown); |
---|
765 | 747 | goto err_sysfs_group; |
---|
766 | 748 | } |
---|
767 | | - /* get reference of pdev for request_firmware |
---|
768 | | - */ |
---|
| 749 | + /* get reference of pdev for request_firmware */ |
---|
769 | 750 | kim_gdata->kim_pdev = pdev; |
---|
770 | 751 | init_completion(&kim_gdata->kim_rcvd); |
---|
771 | 752 | init_completion(&kim_gdata->ldisc_installed); |
---|
.. | .. |
---|
783 | 764 | pr_info("sysfs entries created\n"); |
---|
784 | 765 | |
---|
785 | 766 | kim_debugfs_dir = debugfs_create_dir("ti-st", NULL); |
---|
786 | | - if (!kim_debugfs_dir) { |
---|
787 | | - pr_err(" debugfs entries creation failed "); |
---|
788 | | - return 0; |
---|
789 | | - } |
---|
790 | 767 | |
---|
791 | 768 | debugfs_create_file("version", S_IRUGO, kim_debugfs_dir, |
---|
792 | | - kim_gdata, &version_debugfs_fops); |
---|
| 769 | + kim_gdata, &version_fops); |
---|
793 | 770 | debugfs_create_file("protocols", S_IRUGO, kim_debugfs_dir, |
---|
794 | | - kim_gdata, &list_debugfs_fops); |
---|
| 771 | + kim_gdata, &list_fops); |
---|
795 | 772 | return 0; |
---|
796 | 773 | |
---|
797 | 774 | err_sysfs_group: |
---|
.. | .. |
---|
811 | 788 | |
---|
812 | 789 | kim_gdata = platform_get_drvdata(pdev); |
---|
813 | 790 | |
---|
814 | | - /* Free the Bluetooth/FM/GPIO |
---|
| 791 | + /* |
---|
| 792 | + * Free the Bluetooth/FM/GPIO |
---|
815 | 793 | * nShutdown gpio from the system |
---|
816 | 794 | */ |
---|
817 | 795 | gpio_free(pdata->nshutdown_gpio); |
---|