Skip to content

Commit

Permalink
Bluetooth: hci_ll: set operational frequency earlier
Browse files Browse the repository at this point in the history
Uploading the firmware needs quite a few seconds if done at 115200 kbps. So set
the operational frequency, usually 3 MHz, before uploading the firmware.

I have successfully tested this with a wl1837mod.

Signed-off-by: Philipp Puschmann <philipp.puschmann@emlix.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Philipp Puschmann authored and Marcel Holtmann committed Jul 6, 2019
1 parent 98d9856 commit a2e02f3
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions drivers/bluetooth/hci_ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,13 @@ static int ll_setup(struct hci_uart *hu)

serdev_device_set_flow_control(serdev, true);

if (hu->oper_speed)
speed = hu->oper_speed;
else if (hu->proto->oper_speed)
speed = hu->proto->oper_speed;
else
speed = 0;

do {
/* Reset the Bluetooth device */
gpiod_set_value_cansleep(lldev->enable_gpio, 0);
Expand All @@ -612,6 +619,20 @@ static int ll_setup(struct hci_uart *hu)
return err;
}

if (speed) {
__le32 speed_le = cpu_to_le32(speed);
struct sk_buff *skb;

skb = __hci_cmd_sync(hu->hdev,
HCI_VS_UPDATE_UART_HCI_BAUDRATE,
sizeof(speed_le), &speed_le,
HCI_INIT_TIMEOUT);
if (!IS_ERR(skb)) {
kfree_skb(skb);
serdev_device_set_baudrate(serdev, speed);
}
}

err = download_firmware(lldev);
if (!err)
break;
Expand All @@ -636,25 +657,7 @@ static int ll_setup(struct hci_uart *hu)
}

/* Operational speed if any */
if (hu->oper_speed)
speed = hu->oper_speed;
else if (hu->proto->oper_speed)
speed = hu->proto->oper_speed;
else
speed = 0;

if (speed) {
__le32 speed_le = cpu_to_le32(speed);
struct sk_buff *skb;

skb = __hci_cmd_sync(hu->hdev, HCI_VS_UPDATE_UART_HCI_BAUDRATE,
sizeof(speed_le), &speed_le,
HCI_INIT_TIMEOUT);
if (!IS_ERR(skb)) {
kfree_skb(skb);
serdev_device_set_baudrate(serdev, speed);
}
}

return 0;
}
Expand Down

0 comments on commit a2e02f3

Please sign in to comment.