mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address
@ 2025-01-14 10:40 Neeraj Sanjay Kale
  2025-01-14 10:40 ` [PATCH v1 2/2] Bluetooth: btnxpuart: Add support for " Neeraj Sanjay Kale
  2025-01-14 11:03 ` [PATCH v1 1/2] dt-bindings: net: bluetooth: nxp: Add support to " Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: Neeraj Sanjay Kale @ 2025-01-14 10:40 UTC (permalink / raw)
  To: marcel, luiz.dentz, robh, krzk+dt, conor+dt
  Cc: linux-bluetooth, linux-kernel, devicetree, amitkumar.karwar,
	neeraj.sanjaykale, sherry.sun, ziniu.wang_1, johan.korsnes,
	kristian.krohn, manjeet.gupta

This adds a new optional device tree property local-bd-address to allow
user to set custom BD address for NXP chipsets.

Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
---
 .../devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml      | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
index 0a2d7baf5db3..beae21c3758a 100644
--- a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
+++ b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
@@ -40,6 +40,8 @@ properties:
       Host-To-Chip power save mechanism is driven by this GPIO
       connected to BT_WAKE_IN pin of the NXP chipset.
 
+  local-bd-address: true
+
 required:
   - compatible
 
@@ -54,5 +56,6 @@ examples:
             fw-init-baudrate = <3000000>;
             firmware-name = "uartuart8987_bt_v0.bin";
             device-wakeup-gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
+            local-bd-address = [11 22 33 44 55 66];
         };
     };
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v1 2/2] Bluetooth: btnxpuart: Add support for set BD address
  2025-01-14 10:40 [PATCH v1 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address Neeraj Sanjay Kale
@ 2025-01-14 10:40 ` Neeraj Sanjay Kale
  2025-01-14 11:03 ` [PATCH v1 1/2] dt-bindings: net: bluetooth: nxp: Add support to " Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Neeraj Sanjay Kale @ 2025-01-14 10:40 UTC (permalink / raw)
  To: marcel, luiz.dentz, robh, krzk+dt, conor+dt
  Cc: linux-bluetooth, linux-kernel, devicetree, amitkumar.karwar,
	neeraj.sanjaykale, sherry.sun, ziniu.wang_1, johan.korsnes,
	kristian.krohn, manjeet.gupta

This adds support for setting BD address during hci registration. NXP
FW does not allow vendor commands unless it receives a reset command
after FW download and initialization done.
As a workaround, the .set_bdaddr callback function will first send the
HCI reset command, followed by the actual vendor command to set BD
address.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: Johan Korsnes <johan.korsnes@remarkable.no>
Signed-off-by: Kristian Husevåg Krohn <kristian.krohn@remarkable.no>
Tested-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
---
 drivers/bluetooth/btnxpuart.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
index 1230045d78a5..deb546a4e664 100644
--- a/drivers/bluetooth/btnxpuart.c
+++ b/drivers/bluetooth/btnxpuart.c
@@ -1197,6 +1197,34 @@ static int nxp_set_ind_reset(struct hci_dev *hdev, void *data)
 	return hci_recv_frame(hdev, skb);
 }
 
+static int nxp_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
+{
+	u8 data[8] = { 0xfe, 0x06, 0, 0, 0, 0, 0, 0 };
+	struct sk_buff *skb;
+	int err;
+
+	memcpy(data + 2, bdaddr, 6);
+
+	skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
+	if (IS_ERR(skb)) {
+		err = PTR_ERR(skb);
+		bt_dev_err(hdev, "Reset before setting local-bd-addr failed (%ld)",
+			   PTR_ERR(skb));
+		return err;
+	}
+	kfree_skb(skb);
+
+	skb = __hci_cmd_sync(hdev, 0xfc22, sizeof(data), data, HCI_CMD_TIMEOUT);
+	if (IS_ERR(skb)) {
+		err = PTR_ERR(skb);
+		bt_dev_err(hdev, "Changing device address failed (%d)", err);
+		return err;
+	}
+	kfree_skb(skb);
+
+	return 0;
+}
+
 /* NXP protocol */
 static int nxp_setup(struct hci_dev *hdev)
 {
@@ -1547,8 +1575,12 @@ static int nxp_serdev_probe(struct serdev_device *serdev)
 	hdev->send  = nxp_enqueue;
 	hdev->hw_error = nxp_hw_err;
 	hdev->shutdown = nxp_shutdown;
+	hdev->set_bdaddr = nxp_set_bdaddr;
+
 	SET_HCIDEV_DEV(hdev, &serdev->dev);
 
+	set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
+
 	if (hci_register_dev(hdev) < 0) {
 		dev_err(&serdev->dev, "Can't register HCI device\n");
 		goto probe_fail;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address
  2025-01-14 10:40 [PATCH v1 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address Neeraj Sanjay Kale
  2025-01-14 10:40 ` [PATCH v1 2/2] Bluetooth: btnxpuart: Add support for " Neeraj Sanjay Kale
@ 2025-01-14 11:03 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-14 11:03 UTC (permalink / raw)
  To: Neeraj Sanjay Kale, marcel, luiz.dentz, robh, krzk+dt, conor+dt
  Cc: linux-bluetooth, linux-kernel, devicetree, amitkumar.karwar,
	sherry.sun, ziniu.wang_1, johan.korsnes, kristian.krohn,
	manjeet.gupta

On 14/01/2025 11:40, Neeraj Sanjay Kale wrote:
> This adds a new optional device tree property local-bd-address to allow
> user to set custom BD address for NXP chipsets.
> 
> Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
> ---
>  .../devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml      | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
> index 0a2d7baf5db3..beae21c3758a 100644
> --- a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
> +++ b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
> @@ -40,6 +40,8 @@ properties:
>        Host-To-Chip power save mechanism is driven by this GPIO
>        connected to BT_WAKE_IN pin of the NXP chipset.
>  
> +  local-bd-address: true
You miss bluetooth ref with unevaluatedProperties: false. See mediatek.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-14 11:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-14 10:40 [PATCH v1 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address Neeraj Sanjay Kale
2025-01-14 10:40 ` [PATCH v1 2/2] Bluetooth: btnxpuart: Add support for " Neeraj Sanjay Kale
2025-01-14 11:03 ` [PATCH v1 1/2] dt-bindings: net: bluetooth: nxp: Add support to " Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®