public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Bluetooth: btnxpuart: Add support for IW624 chipset
@ 2023-08-11 10:12 Neeraj Sanjay Kale
  2023-08-11 10:12 ` [PATCH v2 1/2] Bluetooth: btnxpuart: Remove check for CTS low after FW download Neeraj Sanjay Kale
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Neeraj Sanjay Kale @ 2023-08-11 10:12 UTC (permalink / raw)
  To: marcel, johan.hedberg, luiz.dentz, amitkumar.karwar, rohit.fule,
	sherry.sun
  Cc: neeraj.sanjaykale, linux-bluetooth, linux-kernel

This patch series adds support for IW624 in btnxpuart driver.

The first patch removes check for CTS low after FW downloaded as
it was found to be redundant. It increases the delay from 1000msec
to 1200msec after FW download as IW624 requires more time to complete
FW initialization.

The second patch adds bootloader signatures and FW file names for
IW624 chip in btnxpuart.

Neeraj Sanjay Kale (2):
  Bluetooth: btnxpuart: Remove check for CTS low after FW download
  Bluetooth: btnxpuart: Add support for IW624 chipset

 drivers/bluetooth/btnxpuart.c | 44 ++++++++++++++++++++++++-----------
 1 file changed, 31 insertions(+), 13 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] Bluetooth: btnxpuart: Remove check for CTS low after FW download
  2023-08-11 10:12 [PATCH v2 0/2] Bluetooth: btnxpuart: Add support for IW624 chipset Neeraj Sanjay Kale
@ 2023-08-11 10:12 ` Neeraj Sanjay Kale
  2023-08-11 10:12 ` [PATCH v2 2/2] Bluetooth: btnxpuart: Add support for IW624 chipset Neeraj Sanjay Kale
  2023-08-16  0:10 ` [PATCH v2 0/2] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: Neeraj Sanjay Kale @ 2023-08-11 10:12 UTC (permalink / raw)
  To: marcel, johan.hedberg, luiz.dentz, amitkumar.karwar, rohit.fule,
	sherry.sun
  Cc: neeraj.sanjaykale, linux-bluetooth, linux-kernel

This removes the unnecessary check for CTS low after FW download.

After FW download is complete, the CTS line is already seen low.
It becomes high after 2 msec, and low again after FW initialization
is complete.
This makes the current check for CTS low redundant.

This removes the wait for CTS low section and increase delay to
1200msec instead, which is sufficiant for all NXP chipsets to
initialize FW.

Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
---
v2: Remove wait_for_cts low check in a separate commit (Francesco
Dolcini)
---
 drivers/bluetooth/btnxpuart.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
index ee6f6c872a34..1dd60c7e6fe0 100644
--- a/drivers/bluetooth/btnxpuart.c
+++ b/drivers/bluetooth/btnxpuart.c
@@ -558,16 +558,11 @@ static int nxp_download_firmware(struct hci_dev *hdev)
 	}
 
 	serdev_device_set_flow_control(nxpdev->serdev, true);
-	err = serdev_device_wait_for_cts(nxpdev->serdev, 1, 60000);
-	if (err < 0) {
-		bt_dev_err(hdev, "CTS is still high. FW Download failed.");
-		return err;
-	}
 	release_firmware(nxpdev->fw);
 	memset(nxpdev->fw_name, 0, sizeof(nxpdev->fw_name));
 
 	/* Allow the downloaded FW to initialize */
-	usleep_range(800 * USEC_PER_MSEC, 1 * USEC_PER_SEC);
+	msleep(1200);
 
 	return 0;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] Bluetooth: btnxpuart: Add support for IW624 chipset
  2023-08-11 10:12 [PATCH v2 0/2] Bluetooth: btnxpuart: Add support for IW624 chipset Neeraj Sanjay Kale
  2023-08-11 10:12 ` [PATCH v2 1/2] Bluetooth: btnxpuart: Remove check for CTS low after FW download Neeraj Sanjay Kale
@ 2023-08-11 10:12 ` Neeraj Sanjay Kale
  2023-08-16  0:10 ` [PATCH v2 0/2] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: Neeraj Sanjay Kale @ 2023-08-11 10:12 UTC (permalink / raw)
  To: marcel, johan.hedberg, luiz.dentz, amitkumar.karwar, rohit.fule,
	sherry.sun
  Cc: neeraj.sanjaykale, linux-bluetooth, linux-kernel

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 <neeraj.sanjaykale@nxp.com>
---
v2: Remove wait_for_cts low check in a separate commit (Francesco
Dolcini)
---
 drivers/bluetooth/btnxpuart.c | 37 ++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)

diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
index 1dd60c7e6fe0..b42572ca63af 100644
--- a/drivers/bluetooth/btnxpuart.c
+++ b/drivers/bluetooth/btnxpuart.c
@@ -34,6 +34,8 @@
 #define FIRMWARE_W9098		"nxp/uartuart9098_bt_v1.bin"
 #define FIRMWARE_IW416		"nxp/uartiw416_bt_v0.bin"
 #define FIRMWARE_IW612		"nxp/uartspi_n61x_v1.bin.se"
+#define FIRMWARE_IW624		"nxp/uartiw624_bt.bin"
+#define FIRMWARE_SECURE_IW624	"nxp/uartiw624_bt.bin.se"
 #define FIRMWARE_AW693		"nxp/uartaw693_bt.bin"
 #define FIRMWARE_SECURE_AW693	"nxp/uartaw693_bt.bin.se"
 #define FIRMWARE_HELPER		"nxp/helper_uart_3000000.bin"
@@ -41,6 +43,8 @@
 #define CHIP_ID_W9098		0x5c03
 #define CHIP_ID_IW416		0x7201
 #define CHIP_ID_IW612		0x7601
+#define CHIP_ID_IW624a		0x8000
+#define CHIP_ID_IW624c		0x8001
 #define CHIP_ID_AW693		0x8200
 
 #define FW_SECURE_MASK		0xc0
@@ -152,6 +156,7 @@ struct btnxpuart_dev {
 	u32 fw_v1_sent_bytes;
 	u32 fw_v3_offset_correction;
 	u32 fw_v1_expected_len;
+	u32 boot_reg_offset;
 	wait_queue_head_t fw_dnld_done_wait_q;
 	wait_queue_head_t check_boot_sign_wait_q;
 
@@ -538,6 +543,7 @@ static int nxp_download_firmware(struct hci_dev *hdev)
 	nxpdev->fw_dnld_v1_offset = 0;
 	nxpdev->fw_v1_sent_bytes = 0;
 	nxpdev->fw_v1_expected_len = HDR_LEN;
+	nxpdev->boot_reg_offset = 0;
 	nxpdev->fw_v3_offset_correction = 0;
 	nxpdev->baudrate_changed = false;
 	nxpdev->timeout_changed = false;
@@ -547,7 +553,7 @@ static int nxp_download_firmware(struct hci_dev *hdev)
 	serdev_device_set_flow_control(nxpdev->serdev, false);
 	nxpdev->current_baudrate = HCI_NXP_PRI_BAUDRATE;
 
-	/* Wait till FW is downloaded and CTS becomes low */
+	/* Wait till FW is downloaded */
 	err = wait_event_interruptible_timeout(nxpdev->fw_dnld_done_wait_q,
 					       !test_bit(BTNXPUART_FW_DOWNLOADING,
 							 &nxpdev->tx_state),
@@ -586,6 +592,12 @@ static bool nxp_fw_change_baudrate(struct hci_dev *hdev, u16 req_len)
 	struct btnxpuart_dev *nxpdev = hci_get_drvdata(hdev);
 	struct nxp_bootloader_cmd nxp_cmd5;
 	struct uart_config uart_config;
+	u32 clkdivaddr = CLKDIVADDR - nxpdev->boot_reg_offset;
+	u32 uartdivaddr = UARTDIVADDR - nxpdev->boot_reg_offset;
+	u32 uartmcraddr = UARTMCRADDR - nxpdev->boot_reg_offset;
+	u32 uartreinitaddr = UARTREINITADDR - nxpdev->boot_reg_offset;
+	u32 uarticraddr = UARTICRADDR - nxpdev->boot_reg_offset;
+	u32 uartfcraddr = UARTFCRADDR - nxpdev->boot_reg_offset;
 
 	if (req_len == sizeof(nxp_cmd5)) {
 		nxp_cmd5.header = __cpu_to_le32(5);
@@ -598,17 +610,17 @@ static bool nxp_fw_change_baudrate(struct hci_dev *hdev, u16 req_len)
 		serdev_device_write_buf(nxpdev->serdev, (u8 *)&nxp_cmd5, sizeof(nxp_cmd5));
 		nxpdev->fw_v3_offset_correction += req_len;
 	} else if (req_len == sizeof(uart_config)) {
-		uart_config.clkdiv.address = __cpu_to_le32(CLKDIVADDR);
+		uart_config.clkdiv.address = __cpu_to_le32(clkdivaddr);
 		uart_config.clkdiv.value = __cpu_to_le32(0x00c00000);
-		uart_config.uartdiv.address = __cpu_to_le32(UARTDIVADDR);
+		uart_config.uartdiv.address = __cpu_to_le32(uartdivaddr);
 		uart_config.uartdiv.value = __cpu_to_le32(1);
-		uart_config.mcr.address = __cpu_to_le32(UARTMCRADDR);
+		uart_config.mcr.address = __cpu_to_le32(uartmcraddr);
 		uart_config.mcr.value = __cpu_to_le32(MCR);
-		uart_config.re_init.address = __cpu_to_le32(UARTREINITADDR);
+		uart_config.re_init.address = __cpu_to_le32(uartreinitaddr);
 		uart_config.re_init.value = __cpu_to_le32(INIT);
-		uart_config.icr.address = __cpu_to_le32(UARTICRADDR);
+		uart_config.icr.address = __cpu_to_le32(uarticraddr);
 		uart_config.icr.value = __cpu_to_le32(ICR);
-		uart_config.fcr.address = __cpu_to_le32(UARTFCRADDR);
+		uart_config.fcr.address = __cpu_to_le32(uartfcraddr);
 		uart_config.fcr.value = __cpu_to_le32(FCR);
 		/* FW expects swapped CRC bytes */
 		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)
 static char *nxp_get_fw_name_from_chipid(struct hci_dev *hdev, u16 chipid,
 					 u8 loader_ver)
 {
+	struct btnxpuart_dev *nxpdev = hci_get_drvdata(hdev);
 	char *fw_name = NULL;
 
 	switch (chipid) {
@@ -834,6 +847,16 @@ static char *nxp_get_fw_name_from_chipid(struct hci_dev *hdev, u16 chipid,
 	case CHIP_ID_IW612:
 		fw_name = FIRMWARE_IW612;
 		break;
+	case CHIP_ID_IW624a:
+	case CHIP_ID_IW624c:
+		nxpdev->boot_reg_offset = 1;
+		if ((loader_ver & FW_SECURE_MASK) == FW_OPEN)
+			fw_name = FIRMWARE_IW624;
+		else if ((loader_ver & FW_SECURE_MASK) != FW_AUTH_ILLEGAL)
+			fw_name = FIRMWARE_SECURE_IW624;
+		else
+			bt_dev_err(hdev, "Illegal loader version %02x", loader_ver);
+		break;
 	case CHIP_ID_AW693:
 		if ((loader_ver & FW_SECURE_MASK) == FW_OPEN)
 			fw_name = FIRMWARE_AW693;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] Bluetooth: btnxpuart: Add support for IW624 chipset
  2023-08-11 10:12 [PATCH v2 0/2] Bluetooth: btnxpuart: Add support for IW624 chipset Neeraj Sanjay Kale
  2023-08-11 10:12 ` [PATCH v2 1/2] Bluetooth: btnxpuart: Remove check for CTS low after FW download Neeraj Sanjay Kale
  2023-08-11 10:12 ` [PATCH v2 2/2] Bluetooth: btnxpuart: Add support for IW624 chipset Neeraj Sanjay Kale
@ 2023-08-16  0:10 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2023-08-16  0:10 UTC (permalink / raw)
  To: Neeraj Sanjay Kale
  Cc: marcel, johan.hedberg, luiz.dentz, amitkumar.karwar, rohit.fule,
	sherry.sun, linux-bluetooth, linux-kernel

Hello:

This series was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Fri, 11 Aug 2023 15:42:30 +0530 you wrote:
> This patch series adds support for IW624 in btnxpuart driver.
> 
> The first patch removes check for CTS low after FW downloaded as
> it was found to be redundant. It increases the delay from 1000msec
> to 1200msec after FW download as IW624 requires more time to complete
> FW initialization.
> 
> [...]

Here is the summary with links:
  - [v2,1/2] Bluetooth: btnxpuart: Remove check for CTS low after FW download
    https://git.kernel.org/bluetooth/bluetooth-next/c/8f24666933f1
  - [v2,2/2] Bluetooth: btnxpuart: Add support for IW624 chipset
    https://git.kernel.org/bluetooth/bluetooth-next/c/f6b00a4fae83

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-16  0:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-11 10:12 [PATCH v2 0/2] Bluetooth: btnxpuart: Add support for IW624 chipset Neeraj Sanjay Kale
2023-08-11 10:12 ` [PATCH v2 1/2] Bluetooth: btnxpuart: Remove check for CTS low after FW download Neeraj Sanjay Kale
2023-08-11 10:12 ` [PATCH v2 2/2] Bluetooth: btnxpuart: Add support for IW624 chipset Neeraj Sanjay Kale
2023-08-16  0:10 ` [PATCH v2 0/2] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox