public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Catalin Popescu <catalin.popescu@leica-geosystems.com>
To: amitkumar.karwar@nxp.com, neeraj.sanjaykale@nxp.com,
	marcel@holtmann.org, luiz.dentz@gmail.com, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org, p.zabel@pengutronix.de
Cc: linux-bluetooth@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, m.felsch@pengutronix.de,
	bsp-development.geo@leica-geosystems.com,
	Catalin Popescu <catalin.popescu@leica-geosystems.com>
Subject: [PATCH 2/2] Bluetooth: btnxpuart: implement powerup sequence.
Date: Fri,  4 Oct 2024 13:35:57 +0200	[thread overview]
Message-ID: <20241004113557.2851060-2-catalin.popescu@leica-geosystems.com> (raw)
In-Reply-To: <20241004113557.2851060-1-catalin.popescu@leica-geosystems.com>

NXP bluetooth chip shares power supply and reset gpio with a WLAN
chip. Add support for power supply and reset and enforce powerup
sequence:
1. apply power supply
2. deassert reset/powerdown

Signed-off-by: Catalin Popescu <catalin.popescu@leica-geosystems.com>
---
 drivers/bluetooth/btnxpuart.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
index 4f493be763b8..e58e7ac7999f 100644
--- a/drivers/bluetooth/btnxpuart.c
+++ b/drivers/bluetooth/btnxpuart.c
@@ -16,6 +16,8 @@
 #include <linux/crc8.h>
 #include <linux/crc32.h>
 #include <linux/string_helpers.h>
+#include <linux/regulator/consumer.h>
+#include <linux/reset.h>
 
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
@@ -188,6 +190,7 @@ struct btnxpuart_dev {
 
 	struct ps_data psdata;
 	struct btnxpuart_data *nxp_data;
+	struct reset_control *pdn;
 };
 
 #define NXP_V1_FW_REQ_PKT	0xa5
@@ -1458,6 +1461,7 @@ static int nxp_serdev_probe(struct serdev_device *serdev)
 {
 	struct hci_dev *hdev;
 	struct btnxpuart_dev *nxpdev;
+	int err;
 
 	nxpdev = devm_kzalloc(&serdev->dev, sizeof(*nxpdev), GFP_KERNEL);
 	if (!nxpdev)
@@ -1485,6 +1489,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) {
@@ -1492,6 +1506,8 @@ static int nxp_serdev_probe(struct serdev_device *serdev)
 		return -ENOMEM;
 	}
 
+	reset_control_deassert(nxpdev->pdn);
+
 	nxpdev->hdev = hdev;
 
 	hdev->bus = HCI_UART;
@@ -1509,6 +1525,7 @@ static int nxp_serdev_probe(struct serdev_device *serdev)
 
 	if (hci_register_dev(hdev) < 0) {
 		dev_err(&serdev->dev, "Can't register HCI device\n");
+		reset_control_assert(nxpdev->pdn);
 		hci_free_dev(hdev);
 		return -ENODEV;
 	}
@@ -1540,6 +1557,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);
 }
 
-- 
2.34.1


  reply	other threads:[~2024-10-04 11:36 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-04 11:35 [PATCH 1/2] dt-bindings: net: bluetooth: nxp: add support for supply and reset Catalin Popescu
2024-10-04 11:35 ` Catalin Popescu [this message]
2024-10-06  9:04   ` [PATCH 2/2] Bluetooth: btnxpuart: implement powerup sequence Sherry Sun
2024-10-07 12:45     ` POPESCU Catalin
2024-11-20  4:48       ` Neeraj Sanjay Kale
2024-10-04 15:24 ` [PATCH 1/2] dt-bindings: net: bluetooth: nxp: add support for supply and reset Conor Dooley
2024-10-06  8:49 ` Sherry Sun
2024-10-06 11:33   ` Krzysztof Kozlowski
2024-10-07 12:58     ` POPESCU Catalin
2024-10-07 14:54       ` Krzysztof Kozlowski
2024-10-21  6:41         ` Marco Felsch
2024-10-21  7:50           ` Krzysztof Kozlowski
2024-10-21 10:25             ` Marco Felsch
2024-10-22  5:11               ` Krzysztof Kozlowski
2024-10-22  7:12                 ` Marco Felsch
2024-10-22  7:30                   ` Krzysztof Kozlowski
2024-10-22  7:32                     ` Krzysztof Kozlowski
2024-10-22  8:13                       ` Marco Felsch
2024-10-22  8:23                         ` Krzysztof Kozlowski
2024-10-22  5:13               ` Sherry Sun
2024-10-22  7:23                 ` Marco Felsch
2024-10-22  8:09                   ` Sherry Sun
2024-10-22  8:21                     ` POPESCU Catalin
2024-10-22  8:22                     ` Marco Felsch
2024-10-22 14:24                       ` Sherry Sun
2024-10-22 15:49                         ` POPESCU Catalin
2024-10-23 14:16                           ` Sherry Sun
2024-10-23 14:38                             ` POPESCU Catalin
2024-10-28  4:27                               ` Sherry Sun
2024-10-28  9:00                                 ` Marco Felsch
2024-10-28  9:59                                   ` Sherry Sun
2024-10-28 11:51                                     ` Marco Felsch
2024-10-28 13:16                                       ` Sherry Sun
2024-10-28 15:00                                         ` Marco Felsch
2024-11-18 22:17                                           ` Marco Felsch
2024-11-19 10:09                                             ` Sherry Sun
2024-11-19 12:51                                               ` Marco Felsch
2024-11-20  3:14                                                 ` ttyRe: " Sherry Sun
2024-11-20  4:44                                                   ` Neeraj Sanjay Kale

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241004113557.2851060-2-catalin.popescu@leica-geosystems.com \
    --to=catalin.popescu@leica-geosystems.com \
    --cc=amitkumar.karwar@nxp.com \
    --cc=bsp-development.geo@leica-geosystems.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=m.felsch@pengutronix.de \
    --cc=marcel@holtmann.org \
    --cc=neeraj.sanjaykale@nxp.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox