Bluetooth: Add AIC8800D80 SDIO firmware loader and UART HCI
Subsystems (2)
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.
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
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
@@ -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
This is an automated email and please do not reply to this email.
Dear Submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.
----- Output -----
error: patch failed: drivers/bluetooth/Makefile:51
error: drivers/bluetooth/Makefile: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Please resolve the issue and submit the patches again.
---
Regards,
Linux Bluetooth
RFC PATCH 2/3 dt-bindings: net: bluetooth: Add AIC8800D80
In reply to Yanli YangDescribe 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
@@ -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
[email protected]
AI reviewRe: [RFC PATCH bluetooth-next 2/3] dt-bindings: net: bluetooth: Add AIC8800D80
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] dt-bindings: schema validation failure due to scalar const on reg array --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dt-bindings: schema validation failure due to scalar const on reg array --
commit 5a068ab01e12921fd595c8f96d78f55f50333071
Author: Yanli Yang <[email protected]>
Subject: dt-bindings: net: bluetooth: Add AIC8800D80
This commit describes the AIC8800D80 Bluetooth SDIO firmware-loading function and UART HCI interface. It links the UART node to its SDIO firmware provider using the aic,firmware-sdio phandle and includes an example configuration.
Quoted 5 lines
Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml new file +0
-0
[ ... ]
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]
Does this scalar constraint cause a schema validation failure?
In the allOf.if.then.properties.reg block for the SDIO variant, the reg property is constrained with a scalar integer const: 1. The reg property in Device Tree schemas is intrinsically evaluated by dt-schema as a matrix/array of integers (e.g., reg = <1> becomes [[1]]).
Because of this, JSON Schema validation compares the array [[1]] against the scalar 1, resulting in a type mismatch and validation failure when running make dt_binding_check against the example or valid device trees.
Quoted 4 lines
Documentation/devicetree/bindings/net/bluetooth/aic,aic8800d80-bt.yaml new file +4
-0+ max-speed: false + aic,firmware-sdio: false + required: + - reg
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
RFC PATCH 3/3 Bluetooth: btaic: Add AIC8800D80 SDIO loader and UART transport
In reply to Yanli YangAdd 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
@@ -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
@@ -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
@@ -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
@@ -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
[email protected]
AI reviewRe: [RFC PATCH bluetooth-next 3/3] Bluetooth: btaic: Add AIC8800D80 SDIO loader and UART transport
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider: - [High] bluetooth: btaic: off-by-one in SDIO credit check causes timeout - [High] bluetooth: btaic…
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] bluetooth: btaic: off-by-one in SDIO credit check causes timeout
- [High] bluetooth: btaic: missing SDIO transaction sequence numbers
- [High] bluetooth: btaic: UAF race in aic_bt_flush with RX path
- [High] bluetooth: btaic: deadlock in SDIO IRQ due to GFP_KERNEL allocation
- [Medium] bluetooth: btaic: UART max-speed DT property breaks firmware baud rate sync --
commit c8b56eafa02e3f8c8946ccb2113f1c30e8b1cd4f
Author: Yanli Yang <[email protected]>
Subject: Bluetooth: btaic: Add AIC8800D80 SDIO loader and UART transport
Adds a driver for the AIC8800D80 combination chip. It implements an SDIO firmware loader and a serdev UART for H4 HCI traffic.
Quoted 3 lines
drivers/bluetooth/btaic_sdio.c +0
-0
[ ... ]
Quoted 4 lines
static void aic_bt_complete_response(struct
aic_bt_sdio*btdev,
const structaic_bt_e2a_header*message,size_tmessage_len)
{
[ ... ]
Quoted 3 lines
spin_lock_irqsave(&btdev->response_lock, flags); if (!btdev->waiting_response || id != btdev->expected_response) goto unlock;
[Severity: High]
Is there a risk of mismatched responses if a command times out?
In aic_bt_command(), a timeout clears waiting_response and aborts, leaving the hardware state machine active:
spin_lock_irqsave(&btdev->response_lock, flags);
btdev->waiting_response = false;
btdev->response = NULL;If a subsequent command of the same type is sent, and the hardware belatedly responds to the timed-out request, aic_bt_complete_response() would accept the late response since the expected_response ID matches. Could this corrupt the initialization sequence?
[ ... ]
Quoted 2 lines
static void
aic_bt_sdio_irq(struct sdio_func *func){
[ ... ]
Quoted 1 line
data = kmalloc(data_len, GFP_KERNEL);
[Severity: High]
Could this allocation deadlock under memory pressure?
The mmc core's sdio_irq_thread calls aic_bt_sdio_irq() with the mmc host lock held. If GFP_KERNEL triggers direct reclaim, and reclaim tries to flush dirty pages to a block device on the same mmc host, it would attempt to acquire the host lock again, hanging the system.
[ ... ]
Quoted 2 lines
static int
aic_bt_wait_for_credits(struct aic_bt_sdio *btdev, size_t tx_len){
[ ... ]
Quoted 9 lines
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: High]
Can this condition prevent transmission when exactly the right amount of credits are available?
If the hardware grants exactly the required number of credits, this strictly less-than check evaluates to false, causing the initialization to time out. Should this be a <= check?
[ ... ]
Quoted 3 lines
static u32
aic_bt_mode_value(unsigned int pair, u32 firmware_value){ switch (pair) {
[ ... ]
Quoted 2 lines
case 5: return AIC_BT_UART_BAUD;
[Severity: Medium]
Does this firmware configuration get out of sync with the device tree speed?
Here, aic_bt_mode_value() hardcodes the firmware's baud rate patch to 1,500,000. However, in aic_bt_uart_probe(), the max-speed DT property is read and configures the host UART speed. If the device tree specifies a different speed, the host and controller will operate at different baud rates, causing HCI communication to fail.
Quoted 3 lines
drivers/bluetooth/btaic_uart.c +0
-0
[ ... ]
Quoted 6 lines
static
size_taic_bt_receive_buf(structserdev_device*serdev,
const u8 *data,size_tcount){ struct aic_bt_uart *uart = serdev_device_get_drvdata(serdev); uart->rx_skb = h4_recv_buf(&uart->hu, uart->rx_skb, data, count,
[ ... ]
Quoted 2 lines
static int
aic_bt_flush(struct hci_dev *hdev)
{
[ ... ]
Quoted 2 lines
kfree_skb(uart->rx_skb); uart->rx_skb = NULL;
[Severity: High]
Could this race with concurrent UART receives and cause a use-after-free?
When the HCI core invokes aic_bt_flush(), it frees uart->rx_skb. But the serdev device is not closed until aic_bt_close(), meaning aic_bt_receive_buf() could be executing simultaneously on another CPU, calling h4_recv_buf() on the freed socket buffer.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3