]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Bluetooth: btnxpuart: implement powerup sequence
authorCatalin Popescu <catalin.popescu@leica-geosystems.com>
Wed, 2 Jul 2025 11:41:05 +0000 (13:41 +0200)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 23 Jul 2025 14:28:14 +0000 (10:28 -0400)
NXP bluetooth chip shares power supply and reset gpio with a WLAN
chip. Add support for power supply and reset and enforce powerup
sequence:
- apply power supply
- deassert reset/powerdown

Signed-off-by: Catalin Popescu <catalin.popescu@leica-geosystems.com>
Reviewed-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
drivers/bluetooth/btnxpuart.c

index 7c6592bf773cb1af10aaa4fa818f9879de80617a..52e5cc3eb451d5eceb2b042b5b87984500006efe 100644 (file)
@@ -18,6 +18,8 @@
 #include <linux/string_helpers.h>
 #include <linux/gpio/consumer.h>
 #include <linux/of_irq.h>
+#include <linux/regulator/consumer.h>
+#include <linux/reset.h>
 
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
@@ -209,6 +211,7 @@ struct btnxpuart_dev {
 
        struct ps_data psdata;
        struct btnxpuart_data *nxp_data;
+       struct reset_control *pdn;
 };
 
 #define NXP_V1_FW_REQ_PKT      0xa5
@@ -1757,6 +1760,7 @@ static int nxp_serdev_probe(struct serdev_device *serdev)
        struct hci_dev *hdev;
        struct btnxpuart_dev *nxpdev;
        bdaddr_t ba = {0};
+       int err;
 
        nxpdev = devm_kzalloc(&serdev->dev, sizeof(*nxpdev), GFP_KERNEL);
        if (!nxpdev)
@@ -1795,6 +1799,16 @@ static int nxp_serdev_probe(struct serdev_device *serdev)
 
        crc8_populate_msb(crc8_table, POLYNOMIAL8);
 
+       nxpdev->pdn = devm_reset_control_get_optional_shared(&serdev->dev, NULL);
+       if (IS_ERR(nxpdev->pdn))
+               return PTR_ERR(nxpdev->pdn);
+
+       err = devm_regulator_get_enable(&serdev->dev, "vcc");
+       if (err) {
+               dev_err(&serdev->dev, "Failed to enable vcc regulator\n");
+               return err;
+       }
+
        /* Initialize and register HCI device */
        hdev = hci_alloc_dev();
        if (!hdev) {
@@ -1802,6 +1816,8 @@ static int nxp_serdev_probe(struct serdev_device *serdev)
                return -ENOMEM;
        }
 
+       reset_control_deassert(nxpdev->pdn);
+
        nxpdev->hdev = hdev;
 
        hdev->bus = HCI_UART;
@@ -1840,6 +1856,7 @@ static int nxp_serdev_probe(struct serdev_device *serdev)
        return 0;
 
 probe_fail:
+       reset_control_assert(nxpdev->pdn);
        hci_free_dev(hdev);
        return -ENODEV;
 }
@@ -1867,6 +1884,7 @@ static void nxp_serdev_remove(struct serdev_device *serdev)
 
        ps_cleanup(nxpdev);
        hci_unregister_dev(hdev);
+       reset_control_assert(nxpdev->pdn);
        hci_free_dev(hdev);
 }