.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Texas Instruments' Bluetooth HCILL UART protocol |
---|
3 | 4 | * |
---|
.. | .. |
---|
11 | 12 | * Acknowledgements: |
---|
12 | 13 | * This file is based on hci_h4.c, which was written |
---|
13 | 14 | * by Maxim Krasnyansky and Marcel Holtmann. |
---|
14 | | - * |
---|
15 | | - * This program is free software; you can redistribute it and/or modify |
---|
16 | | - * it under the terms of the GNU General Public License version 2 |
---|
17 | | - * as published by the Free Software Foundation |
---|
18 | | - * |
---|
19 | | - * This program is distributed in the hope that it will be useful, |
---|
20 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
21 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
22 | | - * GNU General Public License for more details. |
---|
23 | | - * |
---|
24 | | - * You should have received a copy of the GNU General Public License |
---|
25 | | - * along with this program; if not, write to the Free Software |
---|
26 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
27 | | - * |
---|
28 | 15 | */ |
---|
29 | 16 | |
---|
30 | 17 | #include <linux/module.h> |
---|
.. | .. |
---|
141 | 128 | |
---|
142 | 129 | if (hu->serdev) { |
---|
143 | 130 | struct ll_device *lldev = serdev_device_get_drvdata(hu->serdev); |
---|
| 131 | + |
---|
144 | 132 | if (!IS_ERR(lldev->ext_clk)) |
---|
145 | 133 | clk_prepare_enable(lldev->ext_clk); |
---|
146 | 134 | } |
---|
.. | .. |
---|
175 | 163 | |
---|
176 | 164 | if (hu->serdev) { |
---|
177 | 165 | struct ll_device *lldev = serdev_device_get_drvdata(hu->serdev); |
---|
| 166 | + |
---|
178 | 167 | gpiod_set_value_cansleep(lldev->enable_gpio, 0); |
---|
179 | 168 | |
---|
180 | 169 | clk_disable_unprepare(lldev->ext_clk); |
---|
.. | .. |
---|
230 | 219 | * perfectly safe to always send one. |
---|
231 | 220 | */ |
---|
232 | 221 | BT_DBG("dual wake-up-indication"); |
---|
233 | | - /* fall through */ |
---|
| 222 | + fallthrough; |
---|
234 | 223 | case HCILL_ASLEEP: |
---|
235 | 224 | /* acknowledge device wake up */ |
---|
236 | 225 | if (send_hcill_cmd(HCILL_WAKE_UP_ACK, hu) < 0) { |
---|
.. | .. |
---|
240 | 229 | break; |
---|
241 | 230 | default: |
---|
242 | 231 | /* any other state is illegal */ |
---|
243 | | - BT_ERR("received HCILL_WAKE_UP_IND in state %ld", ll->hcill_state); |
---|
| 232 | + BT_ERR("received HCILL_WAKE_UP_IND in state %ld", |
---|
| 233 | + ll->hcill_state); |
---|
244 | 234 | break; |
---|
245 | 235 | } |
---|
246 | 236 | |
---|
.. | .. |
---|
269 | 259 | |
---|
270 | 260 | /* sanity check */ |
---|
271 | 261 | if (ll->hcill_state != HCILL_AWAKE) |
---|
272 | | - BT_ERR("ERR: HCILL_GO_TO_SLEEP_IND in state %ld", ll->hcill_state); |
---|
| 262 | + BT_ERR("ERR: HCILL_GO_TO_SLEEP_IND in state %ld", |
---|
| 263 | + ll->hcill_state); |
---|
273 | 264 | |
---|
274 | 265 | /* acknowledge device sleep */ |
---|
275 | 266 | if (send_hcill_cmd(HCILL_GO_TO_SLEEP_ACK, hu) < 0) { |
---|
.. | .. |
---|
302 | 293 | |
---|
303 | 294 | /* sanity check */ |
---|
304 | 295 | if (ll->hcill_state != HCILL_ASLEEP_TO_AWAKE) |
---|
305 | | - BT_ERR("received HCILL_WAKE_UP_ACK in state %ld", ll->hcill_state); |
---|
| 296 | + BT_ERR("received HCILL_WAKE_UP_ACK in state %ld", |
---|
| 297 | + ll->hcill_state); |
---|
306 | 298 | |
---|
307 | 299 | /* send pending packets and change state to HCILL_AWAKE */ |
---|
308 | 300 | __ll_do_awake(ll); |
---|
.. | .. |
---|
351 | 343 | skb_queue_tail(&ll->tx_wait_q, skb); |
---|
352 | 344 | break; |
---|
353 | 345 | default: |
---|
354 | | - BT_ERR("illegal hcill state: %ld (losing packet)", ll->hcill_state); |
---|
355 | | - kfree_skb(skb); |
---|
| 346 | + BT_ERR("illegal hcill state: %ld (losing packet)", |
---|
| 347 | + ll->hcill_state); |
---|
| 348 | + dev_kfree_skb_irq(skb); |
---|
356 | 349 | break; |
---|
357 | 350 | } |
---|
358 | 351 | |
---|
.. | .. |
---|
451 | 444 | static struct sk_buff *ll_dequeue(struct hci_uart *hu) |
---|
452 | 445 | { |
---|
453 | 446 | struct ll_struct *ll = hu->priv; |
---|
| 447 | + |
---|
454 | 448 | return skb_dequeue(&ll->txq); |
---|
455 | 449 | } |
---|
456 | 450 | |
---|
.. | .. |
---|
462 | 456 | struct sk_buff *skb; |
---|
463 | 457 | struct hci_rp_read_local_version *ver; |
---|
464 | 458 | |
---|
465 | | - skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL, HCI_INIT_TIMEOUT); |
---|
| 459 | + skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL, |
---|
| 460 | + HCI_INIT_TIMEOUT); |
---|
466 | 461 | if (IS_ERR(skb)) { |
---|
467 | 462 | bt_dev_err(hdev, "Reading TI version information failed (%ld)", |
---|
468 | 463 | PTR_ERR(skb)); |
---|
.. | .. |
---|
482 | 477 | version = le16_to_cpu(ver->lmp_subver); |
---|
483 | 478 | |
---|
484 | 479 | out: |
---|
485 | | - if (err) bt_dev_err(hdev, "Failed to read TI version info: %d", err); |
---|
| 480 | + if (err) |
---|
| 481 | + bt_dev_err(hdev, "Failed to read TI version info: %d", err); |
---|
486 | 482 | kfree_skb(skb); |
---|
487 | 483 | return err ? err : version; |
---|
| 484 | +} |
---|
| 485 | + |
---|
| 486 | +static int send_command_from_firmware(struct ll_device *lldev, |
---|
| 487 | + struct hci_command *cmd) |
---|
| 488 | +{ |
---|
| 489 | + struct sk_buff *skb; |
---|
| 490 | + |
---|
| 491 | + if (cmd->opcode == HCI_VS_UPDATE_UART_HCI_BAUDRATE) { |
---|
| 492 | + /* ignore remote change |
---|
| 493 | + * baud rate HCI VS command |
---|
| 494 | + */ |
---|
| 495 | + bt_dev_warn(lldev->hu.hdev, |
---|
| 496 | + "change remote baud rate command in firmware"); |
---|
| 497 | + return 0; |
---|
| 498 | + } |
---|
| 499 | + if (cmd->prefix != 1) |
---|
| 500 | + bt_dev_dbg(lldev->hu.hdev, "command type %d", cmd->prefix); |
---|
| 501 | + |
---|
| 502 | + skb = __hci_cmd_sync(lldev->hu.hdev, cmd->opcode, cmd->plen, |
---|
| 503 | + &cmd->speed, HCI_INIT_TIMEOUT); |
---|
| 504 | + if (IS_ERR(skb)) { |
---|
| 505 | + bt_dev_err(lldev->hu.hdev, "send command failed"); |
---|
| 506 | + return PTR_ERR(skb); |
---|
| 507 | + } |
---|
| 508 | + kfree_skb(skb); |
---|
| 509 | + return 0; |
---|
488 | 510 | } |
---|
489 | 511 | |
---|
490 | 512 | /** |
---|
.. | .. |
---|
499 | 521 | unsigned char *ptr, *action_ptr; |
---|
500 | 522 | unsigned char bts_scr_name[40]; /* 40 char long bts scr name? */ |
---|
501 | 523 | const struct firmware *fw; |
---|
502 | | - struct sk_buff *skb; |
---|
503 | 524 | struct hci_command *cmd; |
---|
504 | 525 | |
---|
505 | 526 | version = read_local_version(lldev->hu.hdev); |
---|
.. | .. |
---|
541 | 562 | case ACTION_SEND_COMMAND: /* action send */ |
---|
542 | 563 | bt_dev_dbg(lldev->hu.hdev, "S"); |
---|
543 | 564 | cmd = (struct hci_command *)action_ptr; |
---|
544 | | - if (cmd->opcode == HCI_VS_UPDATE_UART_HCI_BAUDRATE) { |
---|
545 | | - /* ignore remote change |
---|
546 | | - * baud rate HCI VS command |
---|
547 | | - */ |
---|
548 | | - bt_dev_warn(lldev->hu.hdev, "change remote baud rate command in firmware"); |
---|
549 | | - break; |
---|
550 | | - } |
---|
551 | | - if (cmd->prefix != 1) |
---|
552 | | - bt_dev_dbg(lldev->hu.hdev, "command type %d", cmd->prefix); |
---|
553 | | - |
---|
554 | | - skb = __hci_cmd_sync(lldev->hu.hdev, cmd->opcode, cmd->plen, &cmd->speed, HCI_INIT_TIMEOUT); |
---|
555 | | - if (IS_ERR(skb)) { |
---|
556 | | - bt_dev_err(lldev->hu.hdev, "send command failed"); |
---|
557 | | - err = PTR_ERR(skb); |
---|
| 565 | + err = send_command_from_firmware(lldev, cmd); |
---|
| 566 | + if (err) |
---|
558 | 567 | goto out_rel_fw; |
---|
559 | | - } |
---|
560 | | - kfree_skb(skb); |
---|
561 | 568 | break; |
---|
562 | 569 | case ACTION_WAIT_EVENT: /* wait */ |
---|
563 | 570 | /* no need to wait as command was synchronous */ |
---|
.. | .. |
---|
689 | 696 | serdev_device_set_drvdata(serdev, lldev); |
---|
690 | 697 | lldev->serdev = hu->serdev = serdev; |
---|
691 | 698 | |
---|
692 | | - lldev->enable_gpio = devm_gpiod_get_optional(&serdev->dev, "enable", GPIOD_OUT_LOW); |
---|
| 699 | + lldev->enable_gpio = devm_gpiod_get_optional(&serdev->dev, |
---|
| 700 | + "enable", |
---|
| 701 | + GPIOD_OUT_LOW); |
---|
693 | 702 | if (IS_ERR(lldev->enable_gpio)) |
---|
694 | 703 | return PTR_ERR(lldev->enable_gpio); |
---|
695 | 704 | |
---|