Skip to content

Commit 8b7630d

Browse files
NeerajSanjayKaleVudentz
authored andcommitted
Bluetooth: btnxpuart: Add support for IW624 chipset
This adds support for NXP IW624 chipset in btnxpuart driver by adding FW name and bootloader signature. Based on the loader version bits 7:6 of the bootloader signature, the driver can choose between selecting secure and non-secure FW files. For cmd5 payload during FW download, this chip has addresses of few registers offset by 1, so added boot_reg_offset to handle the chip specific offset. Signed-off-by: Neeraj Sanjay Kale <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 7de05cb commit 8b7630d

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

drivers/bluetooth/btnxpuart.c

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@
3434
#define FIRMWARE_W9098 "nxp/uartuart9098_bt_v1.bin"
3535
#define FIRMWARE_IW416 "nxp/uartiw416_bt_v0.bin"
3636
#define FIRMWARE_IW612 "nxp/uartspi_n61x_v1.bin.se"
37+
#define FIRMWARE_IW624 "nxp/uartiw624_bt.bin"
38+
#define FIRMWARE_SECURE_IW624 "nxp/uartiw624_bt.bin.se"
3739
#define FIRMWARE_AW693 "nxp/uartaw693_bt.bin"
3840
#define FIRMWARE_SECURE_AW693 "nxp/uartaw693_bt.bin.se"
3941
#define FIRMWARE_HELPER "nxp/helper_uart_3000000.bin"
4042

4143
#define CHIP_ID_W9098 0x5c03
4244
#define CHIP_ID_IW416 0x7201
4345
#define CHIP_ID_IW612 0x7601
46+
#define CHIP_ID_IW624a 0x8000
47+
#define CHIP_ID_IW624c 0x8001
4448
#define CHIP_ID_AW693 0x8200
4549

4650
#define FW_SECURE_MASK 0xc0
@@ -152,6 +156,7 @@ struct btnxpuart_dev {
152156
u32 fw_v1_sent_bytes;
153157
u32 fw_v3_offset_correction;
154158
u32 fw_v1_expected_len;
159+
u32 boot_reg_offset;
155160
wait_queue_head_t fw_dnld_done_wait_q;
156161
wait_queue_head_t check_boot_sign_wait_q;
157162

@@ -538,6 +543,7 @@ static int nxp_download_firmware(struct hci_dev *hdev)
538543
nxpdev->fw_dnld_v1_offset = 0;
539544
nxpdev->fw_v1_sent_bytes = 0;
540545
nxpdev->fw_v1_expected_len = HDR_LEN;
546+
nxpdev->boot_reg_offset = 0;
541547
nxpdev->fw_v3_offset_correction = 0;
542548
nxpdev->baudrate_changed = false;
543549
nxpdev->timeout_changed = false;
@@ -547,7 +553,7 @@ static int nxp_download_firmware(struct hci_dev *hdev)
547553
serdev_device_set_flow_control(nxpdev->serdev, false);
548554
nxpdev->current_baudrate = HCI_NXP_PRI_BAUDRATE;
549555

550-
/* Wait till FW is downloaded and CTS becomes low */
556+
/* Wait till FW is downloaded */
551557
err = wait_event_interruptible_timeout(nxpdev->fw_dnld_done_wait_q,
552558
!test_bit(BTNXPUART_FW_DOWNLOADING,
553559
&nxpdev->tx_state),
@@ -586,6 +592,12 @@ static bool nxp_fw_change_baudrate(struct hci_dev *hdev, u16 req_len)
586592
struct btnxpuart_dev *nxpdev = hci_get_drvdata(hdev);
587593
struct nxp_bootloader_cmd nxp_cmd5;
588594
struct uart_config uart_config;
595+
u32 clkdivaddr = CLKDIVADDR - nxpdev->boot_reg_offset;
596+
u32 uartdivaddr = UARTDIVADDR - nxpdev->boot_reg_offset;
597+
u32 uartmcraddr = UARTMCRADDR - nxpdev->boot_reg_offset;
598+
u32 uartreinitaddr = UARTREINITADDR - nxpdev->boot_reg_offset;
599+
u32 uarticraddr = UARTICRADDR - nxpdev->boot_reg_offset;
600+
u32 uartfcraddr = UARTFCRADDR - nxpdev->boot_reg_offset;
589601

590602
if (req_len == sizeof(nxp_cmd5)) {
591603
nxp_cmd5.header = __cpu_to_le32(5);
@@ -598,17 +610,17 @@ static bool nxp_fw_change_baudrate(struct hci_dev *hdev, u16 req_len)
598610
serdev_device_write_buf(nxpdev->serdev, (u8 *)&nxp_cmd5, sizeof(nxp_cmd5));
599611
nxpdev->fw_v3_offset_correction += req_len;
600612
} else if (req_len == sizeof(uart_config)) {
601-
uart_config.clkdiv.address = __cpu_to_le32(CLKDIVADDR);
613+
uart_config.clkdiv.address = __cpu_to_le32(clkdivaddr);
602614
uart_config.clkdiv.value = __cpu_to_le32(0x00c00000);
603-
uart_config.uartdiv.address = __cpu_to_le32(UARTDIVADDR);
615+
uart_config.uartdiv.address = __cpu_to_le32(uartdivaddr);
604616
uart_config.uartdiv.value = __cpu_to_le32(1);
605-
uart_config.mcr.address = __cpu_to_le32(UARTMCRADDR);
617+
uart_config.mcr.address = __cpu_to_le32(uartmcraddr);
606618
uart_config.mcr.value = __cpu_to_le32(MCR);
607-
uart_config.re_init.address = __cpu_to_le32(UARTREINITADDR);
619+
uart_config.re_init.address = __cpu_to_le32(uartreinitaddr);
608620
uart_config.re_init.value = __cpu_to_le32(INIT);
609-
uart_config.icr.address = __cpu_to_le32(UARTICRADDR);
621+
uart_config.icr.address = __cpu_to_le32(uarticraddr);
610622
uart_config.icr.value = __cpu_to_le32(ICR);
611-
uart_config.fcr.address = __cpu_to_le32(UARTFCRADDR);
623+
uart_config.fcr.address = __cpu_to_le32(uartfcraddr);
612624
uart_config.fcr.value = __cpu_to_le32(FCR);
613625
/* FW expects swapped CRC bytes */
614626
uart_config.crc = __cpu_to_be32(crc32_be(0UL, (char *)&uart_config,
@@ -822,6 +834,7 @@ static int nxp_recv_fw_req_v1(struct hci_dev *hdev, struct sk_buff *skb)
822834
static char *nxp_get_fw_name_from_chipid(struct hci_dev *hdev, u16 chipid,
823835
u8 loader_ver)
824836
{
837+
struct btnxpuart_dev *nxpdev = hci_get_drvdata(hdev);
825838
char *fw_name = NULL;
826839

827840
switch (chipid) {
@@ -834,6 +847,16 @@ static char *nxp_get_fw_name_from_chipid(struct hci_dev *hdev, u16 chipid,
834847
case CHIP_ID_IW612:
835848
fw_name = FIRMWARE_IW612;
836849
break;
850+
case CHIP_ID_IW624a:
851+
case CHIP_ID_IW624c:
852+
nxpdev->boot_reg_offset = 1;
853+
if ((loader_ver & FW_SECURE_MASK) == FW_OPEN)
854+
fw_name = FIRMWARE_IW624;
855+
else if ((loader_ver & FW_SECURE_MASK) != FW_AUTH_ILLEGAL)
856+
fw_name = FIRMWARE_SECURE_IW624;
857+
else
858+
bt_dev_err(hdev, "Illegal loader version %02x", loader_ver);
859+
break;
837860
case CHIP_ID_AW693:
838861
if ((loader_ver & FW_SECURE_MASK) == FW_OPEN)
839862
fw_name = FIRMWARE_AW693;

0 commit comments

Comments
 (0)