Skip to contentSkip to conversation

Bluetooth: Add AIC8800D80 SDIO firmware loader and UART HCI

RFC PATCH New Yanli Yang 3 participants 18 messages Sep 17 – Sep 21

Subsystems (2)
lore
Share & tools
lore

Yanli Yang

author
#0 lore raw

cover Bluetooth: Add AIC8800D80 SDIO firmware loader and UART HCI

Hi,

This RFC series adds initial Bluetooth support for the AIC8800D80. SDIO function 1 loads the Bluetooth firmware; HCI traffic uses a separate UART interface with H4 framing at 1500000 baud and hardware flow control.

The series adds the AIC vendor prefix, Device Tree bindings for the two interfaces, and the btaic driver with build and maintainer integration. The UART node references its SDIO firmware provider through the aic,firmware-sdio property.

Validation status:
- The vendor has confirmed that SDIO firmware loading works.
- UART HCI communication, controller initialization, scanning, pairing, connections and data transfer have not yet been validated.
- Suspend/resume and Wi-Fi/Bluetooth coexistence have not been validated.
- No hardware functionality beyond firmware loading is claimed.

This is an RFC for implementation and binding review, not a request for merging at this stage. Feedback is particularly welcome on the SDIO/UART split, the firmware-provider association and the device lifetime handling.

The driver requests the following external firmware files:
aic/aic8800d80/fw_adid_8800d80_u02.bin aic/aic8800d80/fw_patch_8800d80_u02.bin aic/aic8800d80/fw_patch_table_8800d80_u02.bin
Firmware binaries are not included in this kernel patch series.

This copy is sent to my own mailbox for private review.

Thanks,
Yanli

Yanli Yang (3):
dt-bindings: vendor-prefixes: Add AIC Semiconductor
dt-bindings: net: bluetooth: Add AIC8800D80
Bluetooth: btaic: Add AIC8800D80 SDIO loader and UART transport

 .../net/bluetooth/aic,aic8800d80-bt.yaml      |  87 ++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 MAINTAINERS                                   |  11 +
 drivers/bluetooth/Kconfig                     |  16 +
 drivers/bluetooth/Makefile                    |   3 +
 drivers/bluetooth/btaic.h                     |  26 +
 drivers/bluetooth/btaic_core.c                | 180 ++++
 drivers/bluetooth/btaic_sdio.c                | 886 ++++++++++++++++++
 drivers/bluetooth/btaic_uart.c                | 331 +++++++
 9 files changed, 1542 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml
 create mode 100644 drivers/bluetooth/btaic.h
 create mode 100644 drivers/bluetooth/btaic_core.c
 create mode 100644 drivers/bluetooth/btaic_sdio.c
 create mode 100644 drivers/bluetooth/btaic_uart.c

base-commit: 6696072ffe07205255cf83621a95a1aa2f9f6e62

Signature · 1 line
2.34.1
author
#1 lore raw

RFC PATCH 1/3 dt-bindings: vendor-prefixes: Add AIC Semiconductor

Add the vendor prefix for AIC Semiconductor (Shanghai) Co., Ltd., used by the AIC8800D80 Bluetooth bindings.

---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index 396044f368e7..a55d0d974cab 100644
@@ -76,6 +76,8 @@ patternProperties:
     description: Aeroflex Gaisler AB
   "^aesop,.*":
     description: AESOP Embedded Forum
+  "^aic,.*":
+    description: AIC Semiconductor (Shanghai) Co., Ltd.
   "^airoha,.*":
     description: Airoha
   "^al,.*":
Signature · 1 line
2.34.1
author
#2 lore raw

RFC PATCH 2/3 dt-bindings: net: bluetooth: Add AIC8800D80

In reply to Yanli Yang

Describe the AIC8800D80 Bluetooth SDIO firmware-loading function and UART HCI interface. Link the UART node to its SDIO firmware provider with the aic,firmware-sdio phandle.

The UART interface uses H4 at 1500000 baud with hardware flow control. Include an example showing both nodes and their association.

---
 .../net/bluetooth/aic,aic8800d80-bt.yaml      | 87 +++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml
Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml new file +87 -0
new file mode 100644
index 000000000000..6fabb226cf15
@@ -0,0 +1,87 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/bluetooth/aic,aic8800d80-bt.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: AIC AIC8800D80 Bluetooth
+
+maintainers:
+  - Zhirun Liu <[email protected]>
+  - Dijia Xu <[email protected]>
+  - Chunqiu Liu <[email protected]>
+  - Liheng Wei <[email protected]>
+  - Yanli Yang <[email protected]>
+
+description:
+  The AIC8800D80 is a Wi-Fi and Bluetooth combination chip. The Bluetooth
+  firmware is loaded through SDIO function 1, while Bluetooth HCI traffic uses
+  the H4 protocol over a UART interface with hardware flow control.
+
+properties:
+  compatible:
+    enum:
+      - aic,aic8800d80-bt
+      - aic,aic8800d80-bt-sdio
+
+  reg:
+    maxItems: 1
+
+  max-speed: true
+
+  aic,firmware-sdio:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      Phandle to the SDIO function used to load the Bluetooth firmware.
+
+required:
+  - compatible
+
+allOf:
+  - $ref: bluetooth-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          const: aic,aic8800d80-bt-sdio
+    then:
+      properties:
+        reg:
+          const: 1
+        max-speed: false
+        aic,firmware-sdio: false
+      required:
+        - reg
+    else:
+      properties:
+        reg: false
+        max-speed:
+          const: 1500000
+      required:
+        - max-speed
+        - aic,firmware-sdio
+      allOf:
+        - $ref: /schemas/serial/serial-peripheral-props.yaml#
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    mmc {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        bt_sdio: bluetooth@1 {
+            compatible = "aic,aic8800d80-bt-sdio";
+            reg = <1>;
+        };
+    };
+
+    serial {
+        uart-has-rtscts;
+
+        bluetooth {
+            compatible = "aic,aic8800d80-bt";
+            max-speed = <1500000>;
+            aic,firmware-sdio = <&bt_sdio>;
+        };
+    };
Signature · 1 line
2.34.1
author
#3 lore raw

RFC PATCH 3/3 Bluetooth: btaic: Add AIC8800D80 SDIO loader and UART transport

In reply to Yanli Yang

Add a driver for the AIC8800D80 combination chip, using SDIO function 1 for Bluetooth firmware loading and a serdev UART for H4 HCI traffic.

Load the ADID image, patch image and patch table through request_firmware(), validate the patch-table layout, and transfer firmware using the vendor SDIO command protocol. Recognize the U02 and U03 chip revisions.

Coordinate the SDIO firmware provider and UART consumer through a reference-counted boot state and a device link. Wait for firmware readiness before opening the UART, and use hardware flow control at 1500000 baud.

Add CONFIG_BT_AIC, build integration and a MAINTAINERS entry.

The vendor has confirmed SDIO firmware loading only. UART HCI operation and other Bluetooth functionality have not yet been validated. Submit this implementation as RFC for review before further functional testing.

---
 MAINTAINERS                    |  11 +
 drivers/bluetooth/Kconfig      |  16 +
 drivers/bluetooth/Makefile     |   3 +
 drivers/bluetooth/btaic.h      |  26 +
 drivers/bluetooth/btaic_core.c | 180 +++++++
 drivers/bluetooth/btaic_sdio.c | 886 +++++++++++++++++++++++++++++++++
 drivers/bluetooth/btaic_uart.c | 331 ++++++++++++
 7 files changed, 1453 insertions(+)
 create mode 100644 drivers/bluetooth/btaic.h
 create mode 100644 drivers/bluetooth/btaic_core.c
 create mode 100644 drivers/bluetooth/btaic_sdio.c
 create mode 100644 drivers/bluetooth/btaic_uart.c
MAINTAINERS +11 -0
index 891c064a881b..83b618662d86 100644
@@ -730,6 +730,17 @@ S:	Maintained
 F:	drivers/scsi/aha152x*
 F:	drivers/scsi/pcmcia/aha152x*
 
+AIC BLUETOOTH DRIVER
+M:	Zhirun Liu <[email protected]>
+M:	Dijia Xu <[email protected]>
+M:	Chunqiu Liu <[email protected]>
+M:	Liheng Wei <[email protected]>
+M:	Yanli Yang <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml
+F:	drivers/bluetooth/btaic*
+
 AIC7XXX / AIC79XX SCSI DRIVER
 M:	Hannes Reinecke <[email protected]>
 L:	[email protected]
drivers/bluetooth/Kconfig +16 -0
index 4e8c24d757e9..c8f66742f98b 100644
@@ -472,4 +472,20 @@ config BT_INTEL_PCIE
 
 	  Say Y here to compiler support for Intel Bluetooth PCIe device into
 	  the kernel or say M to compile it as module (btintel_pcie)
+
+config BT_AIC
+	tristate "AIC8800D80 Bluetooth support"
+	depends on MMC
+	depends on SERIAL_DEV_BUS
+	depends on BT_HCIUART
+	select BT_HCIUART_H4
+	select FW_LOADER
+	help
+	  Bluetooth support for the AIC8800D80 combination chip, using an
+	  SDIO function for firmware loading and a UART interface for the
+	  HCI transport.
+
+	  Say Y here to compile support into the kernel or M to build it as
+	  a module named btaic.
+
 endmenu
drivers/bluetooth/Makefile +3 -0
index e6b1c1180d1d..d9569d6563f1 100644
@@ -20,6 +20,7 @@ obj-$(CONFIG_BT_MRVL)		+= btmrvl.o
 obj-$(CONFIG_BT_MRVL_SDIO)	+= btmrvl_sdio.o
 obj-$(CONFIG_BT_MTKSDIO)	+= btmtksdio.o
 obj-$(CONFIG_BT_MTKUART)	+= btmtkuart.o
+obj-$(CONFIG_BT_AIC)		+= btaic.o
 obj-$(CONFIG_BT_QCOMSMD)	+= btqcomsmd.o
 obj-$(CONFIG_BT_BCM)		+= btbcm.o
 obj-$(CONFIG_BT_RTL)		+= btrtl.o
@@ -51,4 +52,6 @@ hci_uart-$(CONFIG_BT_HCIUART_MRVL)	+= hci_mrvl.o
 hci_uart-$(CONFIG_BT_HCIUART_AML)	+= hci_aml.o
 hci_uart-objs				:= $(hci_uart-y)
 
+btaic-y				:= btaic_core.o btaic_sdio.o btaic_uart.o
+
 CONTEXT_ANALYSIS := y
drivers/bluetooth/btaic.h new file +26 -0
new file mode 100644
index 000000000000..dc631b495697
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __BTAIC_H
+#define __BTAIC_H
+
+#include <linux/types.h>
+
+struct device;
+struct fwnode_handle;
+
+struct aic_bt_boot;
+
+struct aic_bt_boot *aic_bt_boot_register(struct device *dev);
+void aic_bt_boot_ready(struct aic_bt_boot *boot, int status);
+void aic_bt_boot_unregister(struct aic_bt_boot *boot);
+
+struct aic_bt_boot *aic_bt_boot_get(const struct fwnode_handle *fwnode);
+void aic_bt_boot_put(struct aic_bt_boot *boot);
+int aic_bt_boot_wait(struct aic_bt_boot *boot, unsigned long timeout);
+struct device *aic_bt_boot_device(struct aic_bt_boot *boot);
+
+int aic_bt_sdio_register(void);
+void aic_bt_sdio_unregister(void);
+int aic_bt_uart_register(void);
+void aic_bt_uart_unregister(void);
+
+#endif
drivers/bluetooth/btaic_core.c new file +180 -0

180 lines not on this page · raw message

drivers/bluetooth/btaic_sdio.c new file +886 -0

886 lines not on this page · raw message

drivers/bluetooth/btaic_uart.c new file +331 -0

331 lines not on this page · raw message

Signature · 1 line
2.34.1
#4 lore raw

Re: [RFC PATCH bluetooth-next 3/3] Bluetooth: btaic: Add AIC8800D80 SDIO loader and UART transport

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] bluetooth: btaic: use-after-free of rx_skb during concurrent flush and receive - [Medium]…

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] bluetooth: btaic: use-after-free of rx_skb during concurrent flush and receive
- [Medium] bluetooth: btaic: off-by-one in credits check causes timeout for exact-fit payloads
- [Medium] bluetooth: btaic: spurious command failure due to delayed completion signal --

commit d0fbf93152e71e54fc5cd6389eb4e023f7adbfc3
Author: Yanli Yang <[email protected]>
Subject: Bluetooth: btaic: Add AIC8800D80 SDIO loader and UART transport

This commit adds a driver for the AIC8800D80 combination chip. It utilizes SDIO function 1 for loading Bluetooth firmware and a serdev UART interface for handling the H4 HCI traffic. The firmware loading process uses a vendor protocol to validate patch-table layouts and transfer the necessary images.

Quoted 3 lines
drivers/bluetooth/btaic_sdio.c new file +0 -0
@@ -0,0 +1,886 @@

[ ... ]

Quoted 29 lines
drivers/bluetooth/btaic_sdio.c new file +29 -0
+static void aic_bt_complete_response(struct aic_bt_sdio *btdev,
+				     const struct aic_bt_e2a_header *message,
+				     size_t message_len)
+{
+	unsigned long flags;
+	size_t param_len;
+	u16 id;
+	bool complete_command = false;
+
+	if (message_len < sizeof(*message))
+		return;
+
+	id = get_unaligned_le16(&message->id);
+	param_len = get_unaligned_le16(&message->param_len);
+	if (param_len > message_len - sizeof(*message))
+		return;
+
+	spin_lock_irqsave(&btdev->response_lock, flags);
+	if (!btdev->waiting_response || id != btdev->expected_response)
+		goto unlock;
+
+	if (btdev->response && param_len < btdev->response_size) {
+		btdev->command_result = -EMSGSIZE;
+	} else {
+		if (btdev->response)
+			memcpy(btdev->response, message->param,
+			       btdev->response_size);
+		btdev->command_result = 0;
+	}

drivers/bluetooth/btaic_sdio.c line 189

Quoted 10 lines
drivers/bluetooth/btaic_sdio.c new file +10 -0
+
+	btdev->waiting_response = false;
+	complete_command = true;
+
+unlock:
+	spin_unlock_irqrestore(&btdev->response_lock, flags);
+
+	if (complete_command)
+		complete(&btdev->command_done);
+}

[Severity: Medium]
Could this delayed completion signal cause a race condition with a subsequent command?

If a command times out, aic_bt_command() aborts and unlocks command_mutex. If the SDIO IRQ handler processes the timed-out command's delayed response concurrently, it releases response_lock just before calling complete().

If another thread executing aic_bt_command() acquires command_mutex and calls reinit_completion() in this narrow window, the delayed complete() might satisfy the new command's wait immediately. The new command would then incorrectly return its initial command_result (-EINPROGRESS) instead of waiting for its own response.

[ ... ]

Quoted 4 lines
drivers/bluetooth/btaic_sdio.c new file +4 -0
+static int aic_bt_wait_for_credits(struct aic_bt_sdio *btdev, size_t tx_len)
+{
+	unsigned int retry;
+	int err;

drivers/bluetooth/btaic_sdio.c line 299

Quoted 10 lines
drivers/bluetooth/btaic_sdio.c new file +10 -0
+
+	for (retry = 0; retry < AIC_SDIO_FLOW_RETRIES; retry++) {
+		u8 credits;
+
+		credits = sdio_readb(btdev->func, AIC_SDIO_FLOW_CTRL_Q1, &err);
+		if (err)
+			return err;
+
+		if (credits && tx_len < (size_t)credits * AIC_SDIO_BUFFER_SIZE)
+			return 0;

[Severity: Medium]
Does this strict inequality incorrectly reject a transmission that exactly fits the available credit buffers?

For example, when aic_bt_mem_block_write() sends firmware chunks of 1024 bytes, the total tx_len (including headers and padding) is calculated as 1536 bytes. If the hardware advertises exactly 1 credit (1536 bytes of capacity), the check (1536 < 1536) evaluates to false, causing the driver to unnecessarily spin until it times out.

Quoted 22 lines
drivers/bluetooth/btaic_sdio.c new file +22 -0
+
+		if (retry < 30)
+			usleep_range(30, 50);
+		else if (retry < 40)
+			usleep_range(1000, 1500);
+		else
+			usleep_range(10000, 12000);
+	}
+
+	return -ETIMEDOUT;
+}
+
+static int aic_bt_command(struct aic_bt_sdio *btdev, u16 request_id,
+			  const void *param, size_t param_len, u16 response_id,
+			  void *response, size_t response_size)
+{
+	unsigned long flags;
+	size_t frame_len;
+	size_t message_len;
+	size_t tx_len;
+	long timeout;
+	int err;

[ ... ]

Quoted 8 lines
drivers/bluetooth/btaic_sdio.c new file +8 -0
+	reinit_completion(&btdev->command_done);
+	spin_lock_irqsave(&btdev->response_lock, flags);
+	btdev->expected_response = response_id;
+	btdev->response = response;
+	btdev->response_size = response_size;
+	btdev->command_result = -EINPROGRESS;
+	btdev->waiting_response = true;
+	spin_unlock_irqrestore(&btdev->response_lock, flags);

[ ... ]

Quoted 3 lines
drivers/bluetooth/btaic_uart.c new file +0 -0
@@ -0,0 +1,331 @@

[ ... ]

Quoted 8 lines
drivers/bluetooth/btaic_uart.c new file +8 -0
+static size_t aic_bt_receive_buf(struct serdev_device *serdev,
+				 const u8 *data, size_t count)
+{
+	struct aic_bt_uart *uart = serdev_device_get_drvdata(serdev);
+
+	uart->rx_skb = h4_recv_buf(&uart->hu, uart->rx_skb, data, count,
+				   aic_bt_recv_pkts,
+				   ARRAY_SIZE(aic_bt_recv_pkts));

[ ... ]

Quoted 7 lines
drivers/bluetooth/btaic_uart.c new file +7 -0
+static int aic_bt_close(struct hci_dev *hdev)
+{
+	struct aic_bt_uart *uart = hci_get_drvdata(hdev);
+
+	serdev_device_close(uart->serdev);
+	return 0;
+}

drivers/bluetooth/btaic_uart.c line 188

Quoted 10 lines
drivers/bluetooth/btaic_uart.c new file +10 -0
+
+static int aic_bt_flush(struct hci_dev *hdev)
+{
+	struct aic_bt_uart *uart = hci_get_drvdata(hdev);
+
+	serdev_device_write_flush(uart->serdev);
+	cancel_work_sync(&uart->tx_work);
+	skb_queue_purge(&uart->txq);
+	kfree_skb(uart->rx_skb);
+	uart->rx_skb = NULL;

[Severity: High]
Can this lead to a use-after-free of uart->rx_skb if data is received concurrently during teardown?

During interface teardown, the HCI stack calls hdev->flush() before it calls hdev->close(). This means aic_bt_flush() will free uart->rx_skb while the UART serdev is still open.

If a UART receive interrupt fires before aic_bt_close() runs, aic_bt_receive_buf() could be called and pass the freed uart->rx_skb pointer into h4_recv_buf(), causing memory corruption.

Quoted 5 lines
drivers/bluetooth/btaic_uart.c new file +5 -0
+	clear_bit(AIC_BT_TX_ACTIVE, &uart->tx_state);
+	clear_bit(AIC_BT_TX_WAKEUP, &uart->tx_state);
+
+	return 0;
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
author
#6 lore raw

RFC PATCH v2 1/3 dt-bindings: vendor-prefixes: Add AIC Semiconductor

In reply to Yanli Yang

Add the vendor prefix for AIC Semiconductor (Shanghai) Co., Ltd., used by the AIC8800D80 Bluetooth bindings.

---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index ba2002969373..8d35a4b7d8ed 100644
@@ -76,6 +76,8 @@ patternProperties:
     description: Aeroflex Gaisler AB
   "^aesop,.*":
     description: AESOP Embedded Forum
+  "^aic,.*":
+    description: AIC Semiconductor (Shanghai) Co., Ltd.
   "^airoha,.*":
     description: Airoha
   "^al,.*":
Signature · 1 line
2.34.1
author
#5 lore raw

v2 cover Bluetooth: Add AIC8800D80 SDIO firmware loader and UART HCI

In reply to Yanli Yang

Hi,

This RFC series adds initial Bluetooth support for the AIC8800D80. SDIO function 1 loads the Bluetooth firmware; HCI traffic uses a separate UART interface with H4 framing at 1500000 baud and hardware flow control.

The series adds the AIC vendor prefix, Device Tree bindings for the two interfaces, and the btaic driver with build and maintainer integration. The UART node references its SDIO firmware provider through the aic,firmware-sdio property.

All issues reported by the automated checks on v1 have been addressed. This version is also regenerated against the latest bluetooth-next master.

Validation status:
- The vendor has confirmed that SDIO firmware loading works.
- UART HCI communication, controller initialization, scanning, pairing, connections and data transfer have not yet been validated.
- Suspend/resume and Wi-Fi/Bluetooth coexistence have not been validated.
- No hardware functionality beyond firmware loading is claimed.

This is an RFC for implementation and binding review, not a request for merging at this stage. Feedback is particularly welcome on the SDIO/UART split, the firmware-provider association and the device lifetime handling.

The driver requests the following external firmware files:
aic/aic8800d80/fw_adid_8800d80_u02.bin aic/aic8800d80/fw_patch_8800d80_u02.bin aic/aic8800d80/fw_patch_table_8800d80_u02.bin
Firmware binaries are not included in this kernel patch series.

Changes in v2:
- Fix the Device Tree schema encoding of the SDIO reg constant.
- Preallocate the SDIO receive buffer used by the interrupt handler.
- Prevent late responses from timed-out SDIO commands from racing the next command and its completion state.
- Accept transfers that exactly consume the available SDIO credits.
- Free the UART receive skb only after receive callbacks have stopped.
- Use the fixed baud rate required by the binding.
- Sync the series to bluetooth-next commit 019debf20bfd.

v1: https://lore.kernel.org/linux-bluetooth/[email protected]/

Thanks,
Yanli

Yanli Yang (3):
dt-bindings: vendor-prefixes: Add AIC Semiconductor
dt-bindings: net: bluetooth: Add AIC8800D80
Bluetooth: btaic: Add AIC8800D80 SDIO loader and UART transport

 .../net/bluetooth/aic,aic8800d80-bt.yaml      |  87 ++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 MAINTAINERS                                   |  11 +
 drivers/bluetooth/Kconfig                     |  16 +
 drivers/bluetooth/Makefile                    |   3 +
 drivers/bluetooth/btaic.h                     |  26 +
 drivers/bluetooth/btaic_core.c                | 180 ++++
 drivers/bluetooth/btaic_sdio.c                | 901 ++++++++++++++++++
 drivers/bluetooth/btaic_uart.c                | 328 +++++++
 9 files changed, 1554 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml
 create mode 100644 drivers/bluetooth/btaic.h
 create mode 100644 drivers/bluetooth/btaic_core.c
 create mode 100644 drivers/bluetooth/btaic_sdio.c
 create mode 100644 drivers/bluetooth/btaic_uart.c

base-commit: 019debf20bfd648b40ba10377ee0168db5eb241e

Signature · 1 line
2.34.1
author
#8 lore raw

RFC PATCH v2 2/3 dt-bindings: net: bluetooth: Add AIC8800D80

Describe the AIC8800D80 Bluetooth SDIO firmware-loading function and UART HCI interface. Link the UART node to its SDIO firmware provider with the aic,firmware-sdio phandle.

The UART interface uses H4 at 1500000 baud with hardware flow control. Include an example showing both nodes and their association.

---
 .../net/bluetooth/aic,aic8800d80-bt.yaml      | 87 +++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml
Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml new file +87 -0
new file mode 100644
index 000000000000..d3ea780e85da
@@ -0,0 +1,87 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/bluetooth/aic,aic8800d80-bt.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: AIC AIC8800D80 Bluetooth
+
+maintainers:
+  - Zhirun Liu <[email protected]>
+  - Dijia Xu <[email protected]>
+  - Chunqiu Liu <[email protected]>
+  - Liheng Wei <[email protected]>
+  - Yanli Yang <[email protected]>
+
+description:
+  The AIC8800D80 is a Wi-Fi and Bluetooth combination chip. The Bluetooth
+  firmware is loaded through SDIO function 1, while Bluetooth HCI traffic uses
+  the H4 protocol over a UART interface with hardware flow control.
+
+properties:
+  compatible:
+    enum:
+      - aic,aic8800d80-bt
+      - aic,aic8800d80-bt-sdio
+
+  reg:
+    maxItems: 1
+
+  max-speed: true
+
+  aic,firmware-sdio:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      Phandle to the SDIO function used to load the Bluetooth firmware.
+
+required:
+  - compatible
+
+allOf:
+  - $ref: bluetooth-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          const: aic,aic8800d80-bt-sdio
+    then:
+      properties:
+        reg:
+          const: [[1]]
+        max-speed: false
+        aic,firmware-sdio: false
+      required:
+        - reg
+    else:
+      properties:
+        reg: false
+        max-speed:
+          const: 1500000
+      required:
+        - max-speed
+        - aic,firmware-sdio
+      allOf:
+        - $ref: /schemas/serial/serial-peripheral-props.yaml#
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    mmc {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        bt_sdio: bluetooth@1 {
+            compatible = "aic,aic8800d80-bt-sdio";
+            reg = <1>;
+        };
+    };
+
+    serial {
+        uart-has-rtscts;
+
+        bluetooth {
+            compatible = "aic,aic8800d80-bt";
+            max-speed = <1500000>;
+            aic,firmware-sdio = <&bt_sdio>;
+        };
+    };
Signature · 1 line
2.34.1
author
#10 lore raw

RFC PATCH v2 3/3 Bluetooth: btaic: Add AIC8800D80 SDIO loader and UART transport

In reply to Yanli Yang

Add a driver for the AIC8800D80 combination chip, using SDIO function 1 for Bluetooth firmware loading and a serdev UART for H4 HCI traffic.

Load the ADID image, patch image and patch table through request_firmware(), validate the patch-table layout, and transfer firmware using the vendor SDIO command protocol. Recognize the U02 and U03 chip revisions.

Coordinate the SDIO firmware provider and UART consumer through a reference-counted boot state and a device link. Wait for firmware readiness before opening the UART, and use hardware flow control at 1500000 baud.

Add CONFIG_BT_AIC, build integration and a MAINTAINERS entry.

The vendor has confirmed SDIO firmware loading only. UART HCI operation and other Bluetooth functionality have not yet been validated. Submit this implementation as RFC for review before further functional testing.

---
 MAINTAINERS                    |  11 +
 drivers/bluetooth/Kconfig      |  16 +
 drivers/bluetooth/Makefile     |   3 +
 drivers/bluetooth/btaic.h      |  26 +
 drivers/bluetooth/btaic_core.c | 180 +++++++
 drivers/bluetooth/btaic_sdio.c | 901 +++++++++++++++++++++++++++++++++
 drivers/bluetooth/btaic_uart.c | 328 ++++++++++++
 7 files changed, 1465 insertions(+)
 create mode 100644 drivers/bluetooth/btaic.h
 create mode 100644 drivers/bluetooth/btaic_core.c
 create mode 100644 drivers/bluetooth/btaic_sdio.c
 create mode 100644 drivers/bluetooth/btaic_uart.c
MAINTAINERS +11 -0
index af5a8b4b0bb5..a5c6889fbccc 100644
@@ -729,6 +729,17 @@ S:	Maintained
 F:	drivers/scsi/aha152x*
 F:	drivers/scsi/pcmcia/aha152x*
 
+AIC BLUETOOTH DRIVER
+M:	Zhirun Liu <[email protected]>
+M:	Dijia Xu <[email protected]>
+M:	Chunqiu Liu <[email protected]>
+M:	Liheng Wei <[email protected]>
+M:	Yanli Yang <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml
+F:	drivers/bluetooth/btaic*
+
 AIC7XXX / AIC79XX SCSI DRIVER
 M:	Hannes Reinecke <[email protected]>
 L:	[email protected]
drivers/bluetooth/Kconfig +16 -0
index db0189ca3cbe..2b01f3838363 100644
@@ -487,4 +487,20 @@ config BT_INTEL_PCIE
 
 	  Say Y here to compiler support for Intel Bluetooth PCIe device into
 	  the kernel or say M to compile it as module (btintel_pcie)
+
+config BT_AIC
+	tristate "AIC8800D80 Bluetooth support"
+	depends on MMC
+	depends on SERIAL_DEV_BUS
+	depends on BT_HCIUART
+	select BT_HCIUART_H4
+	select FW_LOADER
+	help
+	  Bluetooth support for the AIC8800D80 combination chip, using an
+	  SDIO function for firmware loading and a UART interface for the
+	  HCI transport.
+
+	  Say Y here to compile support into the kernel or M to build it as
+	  a module named btaic.
+
 endmenu
drivers/bluetooth/Makefile +3 -0
index d5eb2568af2e..19abc5252676 100644
@@ -20,6 +20,7 @@ obj-$(CONFIG_BT_MRVL)		+= btmrvl.o
 obj-$(CONFIG_BT_MRVL_SDIO)	+= btmrvl_sdio.o
 obj-$(CONFIG_BT_MTKSDIO)	+= btmtksdio.o
 obj-$(CONFIG_BT_MTKUART)	+= btmtkuart.o
+obj-$(CONFIG_BT_AIC)		+= btaic.o
 obj-$(CONFIG_BT_QCOMSMD)	+= btqcomsmd.o
 obj-$(CONFIG_BT_BCM)		+= btbcm.o
 obj-$(CONFIG_BT_RTL)		+= btrtl.o
@@ -55,3 +56,5 @@ btusb-y				:= btusb_main.o
 btusb-$(CONFIG_BT_HCIBTUSB_QCOM)	+= btusb_qcom.o
 
 CONTEXT_ANALYSIS := y
+
+btaic-y				:= btaic_core.o btaic_sdio.o btaic_uart.o
drivers/bluetooth/btaic.h new file +26 -0
new file mode 100644
index 000000000000..dc631b495697
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __BTAIC_H
+#define __BTAIC_H
+
+#include <linux/types.h>
+
+struct device;
+struct fwnode_handle;
+
+struct aic_bt_boot;
+
+struct aic_bt_boot *aic_bt_boot_register(struct device *dev);
+void aic_bt_boot_ready(struct aic_bt_boot *boot, int status);
+void aic_bt_boot_unregister(struct aic_bt_boot *boot);
+
+struct aic_bt_boot *aic_bt_boot_get(const struct fwnode_handle *fwnode);
+void aic_bt_boot_put(struct aic_bt_boot *boot);
+int aic_bt_boot_wait(struct aic_bt_boot *boot, unsigned long timeout);
+struct device *aic_bt_boot_device(struct aic_bt_boot *boot);
+
+int aic_bt_sdio_register(void);
+void aic_bt_sdio_unregister(void);
+int aic_bt_uart_register(void);
+void aic_bt_uart_unregister(void);
+
+#endif
drivers/bluetooth/btaic_core.c new file +180 -0

180 lines not on this page · raw message

drivers/bluetooth/btaic_sdio.c new file +901 -0

901 lines not on this page · raw message

drivers/bluetooth/btaic_uart.c new file +328 -0

328 lines not on this page · raw message

Signature · 1 line
2.34.1
#9 lore raw

Re: [RFC PATCH v2 2/3] dt-bindings: net: bluetooth: Add AIC8800D80

In reply to Yanli Yang
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] dt-bindings: net: bluetooth: Incorrect max-speed property constraint - [Low] dt-bindings: net…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] dt-bindings: net: bluetooth: Incorrect max-speed property constraint
- [Low] dt-bindings: net: bluetooth: Unidiomatic reg property constraint syntax --

commit 8cfd6d94bf45715d77abf03541df961e63f18ae5
Author: Yanli Yang <[email protected]>

dt-bindings: net: bluetooth: Add AIC8800D80

This commit adds a devicetree binding for the AIC8800D80 Bluetooth chip. It describes the SDIO firmware-loading function and the UART HCI interface which uses the H4 protocol with hardware flow control.

Quoted 4 lines
Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml new file +0 -0
new file mode 100644

[ ... ]

Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml line 49

Quoted 10 lines
Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml new file +10 -0
+allOf:
+  - $ref: bluetooth-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          const: aic,aic8800d80-bt-sdio
+    then:
+      properties:
+        reg:
+          const: [[1]]

[Severity: Low]
Is this the correct syntax for constraining the reg property?

In devicetree YAML bindings, reg constraints are typically expressed using standard json-schema properties like minimum/maximum or an items list definition. Does using a 2D array [[1]] expose the internal parsing representation of dt-schema, making it unidiomatic? Could this fail validation in future tooling updates or confuse other developers?

Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml line 60

Quoted 11 lines
Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml new file +11 -0
+        max-speed: false
+        aic,firmware-sdio: false
+      required:
+        - reg
+    else:
+      properties:
+        reg: false
+        max-speed:
+          const: 1500000
+      required:
+        - max-speed

[Severity: Medium]
Does this incorrectly mandate a fixed max-speed?

According to standard devicetree principles and the core serial-peripheral-props.yaml specification, max-speed represents a board-specific hardware limitation and should only be present if the maximum is less than the slave device can support. By requiring it and forcing it to
const: 1500000, does this force redundant, fixed configuration into every device tree using this compatible string?

Would this also prevent developers from specifying a lower speed if their particular board design has signal quality issues? If the device always operates at 1.5 Mbaud by default, should the kernel driver handle that based on the compatible string rather than hardcoding a required static property in the DT?

Quoted 3 lines
Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml new file +3 -0
+        - aic,firmware-sdio
+      allOf:
+        - $ref: /schemas/serial/serial-peripheral-props.yaml#
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#7 lore raw
In reply to Yanli Yang

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1169702/

---Test result---

Test Summary:

CheckPatch                    FAIL      5.16 seconds
VerifyFixes                   PASS      0.13 seconds
VerifySignedoff               PASS      0.13 seconds
GitLint                       FAIL      1.04 seconds
SubjectPrefix                 FAIL      0.39 seconds
BuildKernel                   PASS      29.36 seconds
CheckAllWarning               PASS      33.40 seconds
CheckSparse                   PASS      36.21 seconds
BuildKernel32                 PASS      35.25 seconds
CheckKernelLLVM               PASS      33.21 seconds
TestRunnerSetup               PASS      795.41 seconds
TestRunner_l2cap-tester       PASS      16.56 seconds
TestRunner_iso-tester         PASS      33.05 seconds
TestRunner_bnep-tester        PASS      3.17 seconds
TestRunner_mgmt-tester        FAIL      61.10 seconds
TestRunner_rfcomm-tester      PASS      4.50 seconds
TestRunner_sco-tester         PASS      7.68 seconds
TestRunner_ioctl-tester       PASS      4.68 seconds
TestRunner_mesh-tester        FAIL      7.86 seconds
TestRunner_smp-tester         PASS      4.39 seconds
TestRunner_userchan-tester    PASS      3.26 seconds
TestRunner_6lowpan-tester     PASS      5.03 seconds
IncrementalBuild              PASS      34.05 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[RFC,v2,2/3] dt-bindings: net: bluetooth: Add AIC8800D80
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #90:
new file mode 100644

total: 0 errors, 1 warnings, 87 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

/home/runner/work/bluetooth-next/bluetooth-next/src/patch/14832276.patch has style problems, please review.

NOTE: Ignored message types: UNKNOWN_COMMIT_ID

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[RFC,v2,2/3] dt-bindings: net: bluetooth: Add AIC8800D80

18: B1 Line exceeds max length (90>80): " create mode 100644 Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml"
##############################
Test: SubjectPrefix - FAIL
Desc: Check subject contains "Bluetooth" prefix
Output:
"Bluetooth: " prefix is not specified in the subject
"Bluetooth: " prefix is not specified in the subject
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 501, Passed: 496 (99.0%), Failed: 1, Not Run: 4

Failed Test Cases
Read Exp Feature - Success Failed 0.021 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0

Failed Test Cases

Mesh - Send cancel - 1                               Timed out    2.382 seconds
Mesh - Send cancel - 2                               Timed out    1.998 seconds

https://github.com/bluez/bluetooth-next/pull/805

---
Regards,
Linux Bluetooth

author
#11 lore raw

v3 cover Bluetooth: Add AIC8800D80 support

In reply to Yanli Yang

Hi,

This RFC series adds initial Bluetooth support for the AIC8800D80. SDIO function 1 loads the Bluetooth firmware; HCI traffic uses a separate UART interface with H4 framing at 1500000 baud and hardware flow control.

The series adds the AIC vendor prefix, Device Tree bindings for the two interfaces, and the btaic driver with build and maintainer integration. The UART node references its SDIO firmware provider through the aic,firmware-sdio property.

Validation status:
- The vendor has confirmed that SDIO firmware loading works.
- UART HCI communication, controller initialization, scanning, pairing, connections and data transfer have not yet been validated.
- Suspend/resume and Wi-Fi/Bluetooth coexistence have not been validated.
- No hardware functionality beyond firmware loading is claimed.

This is an RFC for implementation and binding review, not a request for merging at this stage. Feedback is particularly welcome on the SDIO/UART split, the firmware-provider association and the device lifetime handling.

The driver requests the following external firmware files:
aic/aic8800d80/fw_adid_8800d80_u02.bin aic/aic8800d80/fw_patch_8800d80_u02.bin aic/aic8800d80/fw_patch_table_8800d80_u02.bin
Firmware binaries are not included in this kernel patch series.

Changes in v3:
- Express the SDIO reg constraint using an items list.
- Drop the max-speed property because the driver selects the fixed 1500000 baud rate based on the compatible string.
- Update MAINTAINERS in each patch that adds new files.
- Use the Bluetooth subject prefix for all patches.

The BlueZ GitLint check may flag the auto-generated "create mode" summary line for the binding path as exceeding 80 columns. No source or commit message line is involved.

Changes in v2:
- Preallocate the SDIO receive buffer used by the interrupt handler.
- Prevent late responses from timed-out SDIO commands from racing the next command and its completion state.
- Accept transfers that exactly consume the available SDIO credits.
- Free the UART receive skb only after receive callbacks have stopped.
- Use the fixed baud rate required by the controller.
- Sync the series to bluetooth-next commit 019debf20bfd.

v2: https://lore.kernel.org/linux-bluetooth/[email protected]/
v1: https://lore.kernel.org/linux-bluetooth/[email protected]/

Thanks,
Yanli

Yanli Yang (3):
Bluetooth: dt-bindings: Add AIC vendor prefix
Bluetooth: dt-bindings: Add AIC8800D80
Bluetooth: btaic: Add AIC8800D80 support

 .../net/bluetooth/aic,aic8800d80-bt.yaml      |  83 ++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 MAINTAINERS                                   |  11 +
 drivers/bluetooth/Kconfig                     |  16 +
 drivers/bluetooth/Makefile                    |   3 +
 drivers/bluetooth/btaic.h                     |  26 +
 drivers/bluetooth/btaic_core.c                | 180 ++++
 drivers/bluetooth/btaic_sdio.c                | 901 ++++++++++++++++++
 drivers/bluetooth/btaic_uart.c                | 328 +++++++
 9 files changed, 1550 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml
 create mode 100644 drivers/bluetooth/btaic.h
 create mode 100644 drivers/bluetooth/btaic_core.c
 create mode 100644 drivers/bluetooth/btaic_sdio.c
 create mode 100644 drivers/bluetooth/btaic_uart.c

base-commit: 019debf20bfd648b40ba10377ee0168db5eb241e

Signature · 1 line
2.34.1
author
#12 lore raw

RFC PATCH v3 1/3 Bluetooth: dt-bindings: Add AIC vendor prefix

Add the vendor prefix for AIC Semiconductor (Shanghai) Co., Ltd., used by the AIC8800D80 Bluetooth bindings.

---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index ba2002969373..8d35a4b7d8ed 100644
@@ -76,6 +76,8 @@ patternProperties:
     description: Aeroflex Gaisler AB
   "^aesop,.*":
     description: AESOP Embedded Forum
+  "^aic,.*":
+    description: AIC Semiconductor (Shanghai) Co., Ltd.
   "^airoha,.*":
     description: Airoha
   "^al,.*":
Signature · 1 line
2.34.1
author
#14 lore raw

RFC PATCH v3 2/3 Bluetooth: dt-bindings: Add AIC8800D80

In reply to Yanli Yang

Describe the AIC8800D80 Bluetooth SDIO firmware-loading function and UART HCI interface. Link the UART node to its SDIO firmware provider with the aic,firmware-sdio phandle.

Add the binding file to the AIC Bluetooth MAINTAINERS entry.

---
 .../net/bluetooth/aic,aic8800d80-bt.yaml      | 83 +++++++++++++++++++
 MAINTAINERS                                   | 10 +++
 2 files changed, 93 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml
Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml new file +83 -0
new file mode 100644
index 000000000000..9c04ba62ecef
@@ -0,0 +1,83 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/bluetooth/aic,aic8800d80-bt.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: AIC AIC8800D80 Bluetooth
+
+maintainers:
+  - Zhirun Liu <[email protected]>
+  - Dijia Xu <[email protected]>
+  - Chunqiu Liu <[email protected]>
+  - Liheng Wei <[email protected]>
+  - Yanli Yang <[email protected]>
+
+description:
+  The AIC8800D80 is a Wi-Fi and Bluetooth combination chip. The Bluetooth
+  firmware is loaded through SDIO function 1, while Bluetooth HCI traffic uses
+  the H4 protocol over a UART interface with hardware flow control.
+
+properties:
+  compatible:
+    enum:
+      - aic,aic8800d80-bt
+      - aic,aic8800d80-bt-sdio
+
+  reg:
+    maxItems: 1
+
+  max-speed: false
+
+  aic,firmware-sdio:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      Phandle to the SDIO function used to load the Bluetooth firmware.
+
+required:
+  - compatible
+
+allOf:
+  - $ref: bluetooth-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          const: aic,aic8800d80-bt-sdio
+    then:
+      properties:
+        reg:
+          items:
+            - const: 1
+        aic,firmware-sdio: false
+      required:
+        - reg
+    else:
+      properties:
+        reg: false
+      required:
+        - aic,firmware-sdio
+      allOf:
+        - $ref: /schemas/serial/serial-peripheral-props.yaml#
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    mmc {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        bt_sdio: bluetooth@1 {
+            compatible = "aic,aic8800d80-bt-sdio";
+            reg = <1>;
+        };
+    };
+
+    serial {
+        uart-has-rtscts;
+
+        bluetooth {
+            compatible = "aic,aic8800d80-bt";
+            aic,firmware-sdio = <&bt_sdio>;
+        };
+    };
MAINTAINERS +10 -0
index af5a8b4b0bb5..20662fe78632 100644
@@ -729,6 +729,16 @@ S:	Maintained
 F:	drivers/scsi/aha152x*
 F:	drivers/scsi/pcmcia/aha152x*
 
+AIC BLUETOOTH DRIVER
+M:	Zhirun Liu <[email protected]>
+M:	Dijia Xu <[email protected]>
+M:	Chunqiu Liu <[email protected]>
+M:	Liheng Wei <[email protected]>
+M:	Yanli Yang <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml
+
 AIC7XXX / AIC79XX SCSI DRIVER
 M:	Hannes Reinecke <[email protected]>
 L:	[email protected]
Signature · 1 line
2.34.1
author
#16 lore raw

RFC PATCH v3 3/3 Bluetooth: btaic: Add AIC8800D80 support

In reply to Yanli Yang

Add a driver for the AIC8800D80 combination chip, using SDIO function 1 for Bluetooth firmware loading and a serdev UART for H4 HCI traffic.

Load the ADID image, patch image and patch table through request_firmware(), validate the patch-table layout, and transfer firmware using the vendor SDIO command protocol. Recognize the U02 and U03 chip revisions.

Coordinate the SDIO firmware provider and UART consumer through a reference-counted boot state and a device link. Wait for firmware readiness before opening the UART, and use hardware flow control at 1500000 baud.

Add CONFIG_BT_AIC, build integration and the driver file pattern to the AIC Bluetooth MAINTAINERS entry.

The vendor has confirmed SDIO firmware loading only. UART HCI operation and other Bluetooth functionality have not yet been validated. Submit this implementation as RFC for review before further functional testing.

---
 MAINTAINERS                    |   1 +
 drivers/bluetooth/Kconfig      |  16 +
 drivers/bluetooth/Makefile     |   3 +
 drivers/bluetooth/btaic.h      |  26 +
 drivers/bluetooth/btaic_core.c | 180 +++++++
 drivers/bluetooth/btaic_sdio.c | 901 +++++++++++++++++++++++++++++++++
 drivers/bluetooth/btaic_uart.c | 328 ++++++++++++
 7 files changed, 1455 insertions(+)
 create mode 100644 drivers/bluetooth/btaic.h
 create mode 100644 drivers/bluetooth/btaic_core.c
 create mode 100644 drivers/bluetooth/btaic_sdio.c
 create mode 100644 drivers/bluetooth/btaic_uart.c
MAINTAINERS +1 -0
index 20662fe78632..a5c6889fbccc 100644
@@ -738,6 +738,7 @@ M:	Yanli Yang <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml
+F:	drivers/bluetooth/btaic*
 
 AIC7XXX / AIC79XX SCSI DRIVER
 M:	Hannes Reinecke <[email protected]>
drivers/bluetooth/Kconfig +16 -0
index db0189ca3cbe..2b01f3838363 100644
@@ -487,4 +487,20 @@ config BT_INTEL_PCIE
 
 	  Say Y here to compiler support for Intel Bluetooth PCIe device into
 	  the kernel or say M to compile it as module (btintel_pcie)
+
+config BT_AIC
+	tristate "AIC8800D80 Bluetooth support"
+	depends on MMC
+	depends on SERIAL_DEV_BUS
+	depends on BT_HCIUART
+	select BT_HCIUART_H4
+	select FW_LOADER
+	help
+	  Bluetooth support for the AIC8800D80 combination chip, using an
+	  SDIO function for firmware loading and a UART interface for the
+	  HCI transport.
+
+	  Say Y here to compile support into the kernel or M to build it as
+	  a module named btaic.
+
 endmenu
drivers/bluetooth/Makefile +3 -0
index d5eb2568af2e..19abc5252676 100644
@@ -20,6 +20,7 @@ obj-$(CONFIG_BT_MRVL)		+= btmrvl.o
 obj-$(CONFIG_BT_MRVL_SDIO)	+= btmrvl_sdio.o
 obj-$(CONFIG_BT_MTKSDIO)	+= btmtksdio.o
 obj-$(CONFIG_BT_MTKUART)	+= btmtkuart.o
+obj-$(CONFIG_BT_AIC)		+= btaic.o
 obj-$(CONFIG_BT_QCOMSMD)	+= btqcomsmd.o
 obj-$(CONFIG_BT_BCM)		+= btbcm.o
 obj-$(CONFIG_BT_RTL)		+= btrtl.o
@@ -55,3 +56,5 @@ btusb-y				:= btusb_main.o
 btusb-$(CONFIG_BT_HCIBTUSB_QCOM)	+= btusb_qcom.o
 
 CONTEXT_ANALYSIS := y
+
+btaic-y				:= btaic_core.o btaic_sdio.o btaic_uart.o
drivers/bluetooth/btaic.h new file +26 -0
new file mode 100644
index 000000000000..dc631b495697
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __BTAIC_H
+#define __BTAIC_H
+
+#include <linux/types.h>
+
+struct device;
+struct fwnode_handle;
+
+struct aic_bt_boot;
+
+struct aic_bt_boot *aic_bt_boot_register(struct device *dev);
+void aic_bt_boot_ready(struct aic_bt_boot *boot, int status);
+void aic_bt_boot_unregister(struct aic_bt_boot *boot);
+
+struct aic_bt_boot *aic_bt_boot_get(const struct fwnode_handle *fwnode);
+void aic_bt_boot_put(struct aic_bt_boot *boot);
+int aic_bt_boot_wait(struct aic_bt_boot *boot, unsigned long timeout);
+struct device *aic_bt_boot_device(struct aic_bt_boot *boot);
+
+int aic_bt_sdio_register(void);
+void aic_bt_sdio_unregister(void);
+int aic_bt_uart_register(void);
+void aic_bt_uart_unregister(void);
+
+#endif
drivers/bluetooth/btaic_core.c new file +180 -0

180 lines not on this page · raw message

drivers/bluetooth/btaic_sdio.c new file +901 -0

901 lines not on this page · raw message

drivers/bluetooth/btaic_uart.c new file +328 -0

328 lines not on this page · raw message

Signature · 1 line
2.34.1
#15 lore raw

Re: [RFC PATCH v3 2/3] Bluetooth: dt-bindings: Add AIC8800D80

In reply to Yanli Yang
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] dt-bindings: unsatisfiable constraint on reg property causes validation failure --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dt-bindings: unsatisfiable constraint on reg property causes validation failure --

commit c2a5ac7736c6234041d0e5fd1d5e6d9742fc0653
Author: Yanli Yang <[email protected]>

Bluetooth: dt-bindings: Add AIC8800D80

This commit adds the device tree binding for the AIC8800D80 Bluetooth SDIO and UART HCI interface. It describes the firmware-loading function and links the UART node to the SDIO firmware provider. It also updates the MAINTAINERS file.

Quoted 5 lines
Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml new file +0 -0
new file mode 100644
index 0000000000000..9c04ba62ecefd

[ ... ]

Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml line 50

Quoted 11 lines
Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml new file +11 -0
+allOf:
+  - $ref: bluetooth-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          const: aic,aic8800d80-bt-sdio
+    then:
+      properties:
+        reg:
+          items:
+            - const: 1

[Severity: Low]
Does this constraint on the reg property cause a validation failure?

In dt-schema, the reg property is always decoded as a matrix (an array of arrays), even for single-cell values. For example, reg = <1> in the provided example is parsed internally as [[1]].

Because JSON Schema evaluates this by checking if the first element of the outer array exactly matches the literal integer 1, this constraint is impossible to satisfy and causes make dt_binding_check to unconditionally fail.

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#17 lore raw

Re: [RFC PATCH v3 3/3] Bluetooth: btaic: Add AIC8800D80 support

In reply to Yanli Yang
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider: - [High] bt: aic: struct layout mismatch breaks firmware loading - [High] bt: aic: synchronous…

Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:
- [High] bt: aic: struct layout mismatch breaks firmware loading
- [High] bt: aic: synchronous request_firmware in probe deadlocks SDIO bus
- [High] bt: aic: type mismatch in h4_recv_buf() causes out-of-bounds access
- [Medium] bt: aic: rx_skb memory leak and state corruption on open failure
- [Medium] bt: aic: memory leak of skb on skb_cow_head failure
- [Low] bt: aic: build failure due to undefined kzalloc_obj macro
--

commit 0701d7f81641131610e34be895b933ef2ec43de9
Author: Yanli Yang <[email protected]>

Bluetooth: btaic: Add AIC8800D80 support

Add a driver for the AIC8800D80 combination chip, using SDIO function 1 for Bluetooth firmware loading and a serdev UART for H4 HCI traffic.

Quoted 4 lines
drivers/bluetooth/btaic_core.c new file +0 -0
@@ -0,0 +1,180 @@

[ ... ]

drivers/bluetooth/btaic_core.c line 50

Quoted 7 lines
drivers/bluetooth/btaic_core.c new file +7 -0
+struct aic_bt_boot *aic_bt_boot_register(struct device *dev)
+{
+	struct aic_bt_boot *boot;
+
+	boot = kzalloc_obj(*boot);
+	if (!boot)
+		return ERR_PTR(-ENOMEM);

[Severity: Low]
Is kzalloc_obj() defined in the kernel?

In aic_bt_boot_register(), the code attempts to allocate memory using kzalloc_obj(). This macro is not a standard Linux kernel macro and does not appear to be defined anywhere in the kernel source or driver headers. Will this cause a compilation failure?

Quoted 4 lines
drivers/bluetooth/btaic_sdio.c new file +0 -0
@@ -0,0 +1,901 @@

[ ... ]

drivers/bluetooth/btaic_sdio.c line 103

Quoted 8 lines
drivers/bluetooth/btaic_sdio.c new file +8 -0
+struct aic_bt_e2a_header {
+	__le16 id;
+	__le16 dest_id;
+	__le16 src_id;
+	__le16 param_len;
+	__le32 pattern;
+	u8 param[];
+} __packed;

[Severity: High]
Does this struct layout match the hardware format constructed during TX?

The driver manually constructs SDIO TX messages with a 4-byte zero padding (pattern) starting at offset 4 of the buffer, followed by request_id at offset 8, dest_id at 10, etc., in aic_bt_command():

	put_unaligned_le16(request_id, btdev->tx_buf + 8);
	put_unaligned_le16(AIC_TASK_DBG, btdev->tx_buf + 10);
	put_unaligned_le16(AIC_DRIVER_TASK, btdev->tx_buf + 12);
	put_unaligned_le16(param_len, btdev->tx_buf + 14);
	if (param_len)
		memcpy(btdev->tx_buf + 16, param, param_len);

However, the RX parser receives the payload starting at offset 4 and casts it to struct aic_bt_e2a_header. This struct defines __le16 id at offset 0 and __le32 pattern at offset 8, which reverses the TX layout.

Due to this layout mismatch, message->id reads the zero padding instead of the ID, and message->param_len reads the dest_id. Does this cause all received responses to fail validation in aic_bt_complete_response() and prevent firmware loading?

[ ... ]

Quoted 12 lines
drivers/bluetooth/btaic_sdio.c new file +12 -0
+static int aic_bt_download_firmware(struct aic_bt_sdio *btdev)
+{
+	const struct firmware *table;
+	u32 chip_id;
+	u32 adid_addr;
+	u32 patch_addr;
+	u8 revision;
+	int err;
+
+	err = aic_bt_mem_read(btdev, AIC_BT_CHIP_ID_ADDR, &chip_id);
+	if (err)
+		return err;

drivers/bluetooth/btaic_sdio.c line 659

Quoted 10 lines
drivers/bluetooth/btaic_sdio.c new file +10 -0
+
+	revision = (chip_id >> 16) & 0x3f;
+	if (revision != AIC_BT_CHIP_REV_U02 &&
+	    revision != AIC_BT_CHIP_REV_U03) {
+		dev_err(&btdev->func->dev,
+			"unsupported AIC8800D80 revision %u\n", revision);
+		return -ENODEV;
+	}
+
+	err = request_firmware(&table, AIC_BT_FW_TABLE, &btdev->func->dev);

[Severity: High]
Can calling request_firmware() synchronously from the SDIO probe path deadlock the bus?

The SDIO probe function aic_bt_sdio_probe() calls aic_bt_download_firmware(), which initiates synchronous request_firmware() calls.

SDIO probes execute in the context of the MMC host worker thread. Blocking the MMC host worker thread prevents the MMC subsystem from servicing other requests.

If the requested firmware resides on a filesystem mounted via the same MMC host, this could create an unresolvable deadlock. Even if it does not, a missing firmware file might block the MMC bus for 60 seconds waiting for the user-mode helper timeout.

Quoted 4 lines
drivers/bluetooth/btaic_uart.c new file +0 -0
@@ -0,0 +1,328 @@

[ ... ]

drivers/bluetooth/btaic_uart.c line 120

Quoted 8 lines
drivers/bluetooth/btaic_uart.c new file +8 -0
+static size_t aic_bt_receive_buf(struct serdev_device *serdev,
+				 const u8 *data, size_t count)
+{
+	struct aic_bt_uart *uart = serdev_device_get_drvdata(serdev);
+
+	uart->rx_skb = h4_recv_buf(&uart->hu, uart->rx_skb, data, count,
+				   aic_bt_recv_pkts,
+				   ARRAY_SIZE(aic_bt_recv_pkts));

[Severity: High]
Does this pass the correct pointer type to h4_recv_buf()?

The generic Bluetooth core function h4_recv_buf() requires a struct hci_dev *hdev as its first parameter. However, aic_bt_receive_buf() passes &uart->hu, which is a pointer to struct hci_uart.

If h4_recv_buf() encounters a framing error or an internal issue, it logs the error using bt_dev_err(hdev, ...). Passing the incorrect struct pointer could cause the generic core to read out-of-bounds memory when evaluating hdev->name, potentially leading to garbage logs, memory corruption, or kernel panics.

[ ... ]

Quoted 12 lines
drivers/bluetooth/btaic_uart.c new file +12 -0
+static int aic_bt_open(struct hci_dev *hdev)
+{
+	struct aic_bt_uart *uart = hci_get_drvdata(hdev);
+	unsigned int actual_speed;
+	int err;
+
+	err = aic_bt_boot_wait(uart->boot,
+			       msecs_to_jiffies(AIC_BT_BOOT_TIMEOUT_MS));
+	if (err) {
+		bt_dev_err(hdev, "Bluetooth firmware is not ready (%d)", err);
+		return err;
+	}

drivers/bluetooth/btaic_uart.c line 164

Quoted 10 lines
drivers/bluetooth/btaic_uart.c new file +10 -0
+
+	err = serdev_device_open(uart->serdev);
+	if (err)
+		return err;
+
+	actual_speed = serdev_device_set_baudrate(uart->serdev, AIC_BT_UART_DEFAULT_SPEED);
+	if (!actual_speed) {
+		serdev_device_close(uart->serdev);
+		return -EIO;
+	}

[Severity: Medium]
Does this error path leak uart->rx_skb?

In aic_bt_open(), the serdev is opened before the baudrate is set. RX data may arrive immediately and allocate uart->rx_skb via the RX callback.

If setting the baudrate fails, the function returns -EIO and closes the serdev, but uart->rx_skb is not freed or set to NULL on this error path.

Since the HCI core considers the device unopened on failure, close() is never called. If the interface is subsequently brought up again, the stale rx_skb will corrupt the next received packet sequence, and the original allocation is leaked.

[ ... ]

drivers/bluetooth/btaic_uart.c line 202

Quoted 9 lines
drivers/bluetooth/btaic_uart.c new file +9 -0
+static int aic_bt_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
+{
+	struct aic_bt_uart *uart = hci_get_drvdata(hdev);
+	u8 pkt_type = hci_skb_pkt_type(skb);
+	int err;
+
+	err = skb_cow_head(skb, 1);
+	if (err)
+		return err;

[Severity: Medium]
Should this error path free the skb?

The Bluetooth HCI core transfers ownership of the skb to the driver's hdev->send() callback. If the driver's send callback drops the packet (even if it returns an error), it must free the skb.

In aic_bt_send_frame(), if skb_cow_head() fails, the function returns -ENOMEM but does not invoke kfree_skb(skb). Could this silently drop the reference and create a memory leak?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#13 lore raw

RE: Bluetooth: Add AIC8800D80 support

In reply to Yanli Yang

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1170116/

---Test result---

Test Summary:

CheckPatch                    PASS      5.29 seconds
VerifyFixes                   PASS      0.12 seconds
VerifySignedoff               PASS      0.12 seconds
GitLint                       FAIL      1.00 seconds
SubjectPrefix                 PASS      0.35 seconds
BuildKernel                   PASS      28.40 seconds
CheckAllWarning               PASS      32.90 seconds
CheckSparse                   PASS      35.55 seconds
BuildKernel32                 PASS      28.49 seconds
CheckKernelLLVM               PASS      34.42 seconds
TestRunnerSetup               PASS      751.80 seconds
TestRunner_l2cap-tester       PASS      16.32 seconds
TestRunner_iso-tester         PASS      28.59 seconds
TestRunner_bnep-tester        PASS      3.14 seconds
TestRunner_mgmt-tester        FAIL      60.07 seconds
TestRunner_rfcomm-tester      PASS      4.45 seconds
TestRunner_sco-tester         PASS      7.54 seconds
TestRunner_ioctl-tester       PASS      4.62 seconds
TestRunner_mesh-tester        FAIL      8.76 seconds
TestRunner_smp-tester         PASS      4.67 seconds
TestRunner_userchan-tester    PASS      3.20 seconds
TestRunner_6lowpan-tester     PASS      13.28 seconds
IncrementalBuild              PASS      33.50 seconds

Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[RFC,v3,2/3] Bluetooth: dt-bindings: Add AIC8800D80

18: B1 Line exceeds max length (90>80): " create mode 100644 Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml"
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 501, Passed: 496 (99.0%), Failed: 1, Not Run: 4

Failed Test Cases
Read Exp Feature - Success Failed 0.019 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0

Failed Test Cases

Mesh - Send cancel - 1                               Timed out    2.452 seconds
Mesh - Send cancel - 2                               Timed out    1.999 seconds

https://github.com/bluez/bluetooth-next/pull/807

---
Regards,
Linux Bluetooth