Re: [PATCH v3 4/6] Bluetooth: Introduce Qualcomm IPQ5018 IPC based HCI driver

From: Bartosz Golaszewski

Date: Fri Jul 03 2026 - 09:13:35 EST


On Fri, 3 Jul 2026 07:01:52 +0200, George Moussalem via B4 Relay
<devnull+george.moussalem.outlook.com@xxxxxxxxxx> said:
> From: George Moussalem <george.moussalem@xxxxxxxxxxx>
>
> Add support for the Bluetooth controller found in the IPQ5018 SoC.
> This driver implements firmware loading and the transport layer between
> the HCI core and the Bluetooth controller.
>
> The firmware is loaded by the host into the dedicated reserved memory
> carveout and authenticated by TrustZone. A Secure Channel Manager (SCM)
> call safely brings the peripheral core out of reset.
>
> A shared memory ring buffer topology handles runtime data frame
> transport between the host APSS and the controller.
>
> An outgoing APCS IPC bit and an incoming GIC interrupt handle host/guest
> signaling.
>
> Signed-off-by: George Moussalem <george.moussalem@xxxxxxxxxxx>
> ---
> drivers/bluetooth/Kconfig | 11 +
> drivers/bluetooth/Makefile | 1 +
> drivers/bluetooth/btqcomipc.c | 1041 +++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 1053 insertions(+)
>
> diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
> index 4e8c24d757e9..c9785f43c87c 100644
> --- a/drivers/bluetooth/Kconfig
> +++ b/drivers/bluetooth/Kconfig
> @@ -413,6 +413,17 @@ config BT_MTKUART
> Say Y here to compile support for MediaTek Bluetooth UART devices
> into the kernel or say M to compile it as module (btmtkuart).
>
> +config BT_QCOMIPC
> + tristate "Qualcomm IPQ5018 IPC based HCI support"
> + select BT_QCA

You seem to need to depend on CONFIG_OF.

> + help
> + Qualcomm IPQ5018 IPC based HCI driver.
> + This driver is used to load firmware and bridge HCI data onto shared
> + memory between the host and the Bluetooth controller.
> +
> + Say Y here to compile support for HCI over Qualcomm IPC into the
> + kernel or say M to compile as a module.
> +
> config BT_QCOMSMD
> tristate "Qualcomm SMD based HCI support"
> depends on RPMSG || (COMPILE_TEST && RPMSG=n)

...

Sashiko already generated a wall-of-text review but just a few more nits:

> +
> +static int btqcomipc_probe(struct platform_device *pdev)
> +{
> + struct reset_control *btss_reset;
> + struct device *dev = &pdev->dev;
> + struct qcom_btss *desc;
> + struct hci_dev *hdev;
> + unsigned int args[2];
> + struct clk *lpo_clk;
> + int ret;
> +
> + desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
> + if (!desc)
> + return -ENOMEM;
> +
> + desc->dev = dev;
> +
> + ret = of_property_read_string(dev->of_node, "firmware-name",
> + &desc->firmware);
> + if (ret < 0)
> + return ret;
> +
> + ret = btqcomipc_alloc_memory_region(desc);
> + if (ret)
> + return ret;
> +
> + desc->regmap = syscon_regmap_lookup_by_phandle_args(dev->of_node,
> + "qcom,ipc",
> + 2, args);
> + if (IS_ERR(desc->regmap))
> + return PTR_ERR(desc->regmap);
> +
> + desc->offset = args[0];
> + desc->bit = args[1];
> +
> + lpo_clk = devm_clk_get_enabled(dev, "lpo");
> + if (IS_ERR(lpo_clk))
> + return dev_err_probe(dev, PTR_ERR(lpo_clk),
> + "Failed to get lpo clock\n");
> +
> + btss_reset = devm_reset_control_get_exclusive_deasserted(dev, NULL);
> + if (IS_ERR_OR_NULL(btss_reset))
> + return dev_err_probe(dev, PTR_ERR(btss_reset),
> + "unable to deassert reset\n");
> +
> + desc->irq = platform_get_irq(pdev, 0);
> + if (desc->irq < 0)
> + return dev_err_probe(dev, desc->irq, "Failed to acquire IRQ\n");
> +
> + ret = btqcomipc_init(desc);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to initialize\n");
> +
> + hdev = hci_alloc_dev();
> + if (!hdev) {
> + btqcomipc_deinit(desc);
> + return -ENOMEM;
> + }
> +
> + hci_set_drvdata(hdev, desc);
> + desc->hdev = hdev;
> + SET_HCIDEV_DEV(hdev, &pdev->dev);
> + hdev->bus = HCI_IPC;
> +
> + hdev->open = btqcomipc_open;
> + hdev->close = btqcomipc_close;
> + hdev->setup = btqcomipc_setup;
> + hdev->send = btqcomipc_send;
> + hdev->flush = btqcomipc_flush;
> + hdev->set_bdaddr = qca_set_bdaddr;
> +
> + ret = hci_register_dev(hdev);
> + if (ret < 0) {
> + btqcomipc_deinit(desc);
> + hci_free_dev(hdev);
> + return dev_err_probe(dev, -EBUSY, "Failed to register hdev\n");
> + }
> +
> + platform_set_drvdata(pdev, desc);
> +
> + return 0;
> +}
> +
> +static void btqcomipc_remove(struct platform_device *pdev)
> +{
> + struct qcom_btss *desc = platform_get_drvdata(pdev);
> +
> + if (!desc)
> + return;

This is only called if probe succeeded so desc can't be NULL.

> +
> + btqcomipc_deinit(desc);
> +

This is a different ordering of cleanup from the initialization, is this
on purpose?

> + if (desc->hdev) {
> + hci_unregister_dev(desc->hdev);
> + hci_free_dev(desc->hdev);
> + }
> +}
> +
> +static const struct of_device_id btqcomipc_of_match[] = {
> + { .compatible = "qcom,ipq5018-bt" },
> + { /* sentinel */},
> +};
> +MODULE_DEVICE_TABLE(of, btqcomipc_of_match);
> +
> +static struct platform_driver btqcomipc_driver = {
> + .probe = btqcomipc_probe,
> + .remove = btqcomipc_remove,
> + .driver = {
> + .name = "btqcomipc",
> + .of_match_table = btqcomipc_of_match,
> + },
> +};
> +
> +module_platform_driver(btqcomipc_driver);
> +
> +MODULE_DESCRIPTION("Qualcomm Bluetooth IPC Driver");
> +MODULE_LICENSE("GPL");
>
> --
> 2.53.0
>
>
>

Bart