mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v5 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address
@ 2025-02-20 11:41 Neeraj Sanjay Kale
  2025-02-20 11:41 ` [PATCH v5 2/2] Bluetooth: btnxpuart: Add support for " Neeraj Sanjay Kale
  2025-02-20 11:45 ` [PATCH v5 1/2] dt-bindings: net: bluetooth: nxp: Add support to " Paul Menzel
  0 siblings, 2 replies; 11+ messages in thread
From: Neeraj Sanjay Kale @ 2025-02-20 11:41 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

Allow user to set custom BD address for NXP chipsets.

Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
v2: Add allOf and unevaluatedProperties: false (Krzysztof)
v3: Drop local-bd-address: true (Krzysztof)
---
 .../devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
index 0a2d7baf5db3..a84c1c21b024 100644
--- a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
+++ b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
@@ -17,6 +17,9 @@ description:
 maintainers:
   - Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
 
+allOf:
+  - $ref: bluetooth-controller.yaml#
+
 properties:
   compatible:
     enum:
@@ -43,7 +46,7 @@ properties:
 required:
   - compatible
 
-additionalProperties: false
+unevaluatedProperties: false
 
 examples:
   - |
@@ -54,5 +57,6 @@ examples:
             fw-init-baudrate = <3000000>;
             firmware-name = "uartuart8987_bt_v0.bin";
             device-wakeup-gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
+            local-bd-address = [66 55 44 33 22 11];
         };
     };
-- 
2.25.1


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

* [PATCH v5 2/2] Bluetooth: btnxpuart: Add support for set BD address
  2025-02-20 11:41 [PATCH v5 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address Neeraj Sanjay Kale
@ 2025-02-20 11:41 ` Neeraj Sanjay Kale
  2025-02-20 12:04   ` Paul Menzel
  2025-02-20 11:45 ` [PATCH v5 1/2] dt-bindings: net: bluetooth: nxp: Add support to " Paul Menzel
  1 sibling, 1 reply; 11+ messages in thread
From: Neeraj Sanjay Kale @ 2025-02-20 11:41 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>
---
v4: hci0 interface shows RAW mode if 'local-bd-address' not defined and
    HCI_QUIRK_USE_BDADDR_PROPERTY is set. Add Quirk only if device tree
    property 'local-bd-address' found. (Neeraj)
v5: Initialize local variable ba, update Copywrite year. (Kristian)
---
 drivers/bluetooth/btnxpuart.c | 39 ++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
index 1230045d78a5..dd9161bfd52c 100644
--- a/drivers/bluetooth/btnxpuart.c
+++ b/drivers/bluetooth/btnxpuart.c
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
  *  NXP Bluetooth driver
- *  Copyright 2023 NXP
+ *  Copyright 2023-2025 NXP
  */
 
 #include <linux/module.h>
@@ -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)
 {
@@ -1500,6 +1528,7 @@ static int nxp_serdev_probe(struct serdev_device *serdev)
 {
 	struct hci_dev *hdev;
 	struct btnxpuart_dev *nxpdev;
+	bdaddr_t ba = {0};
 
 	nxpdev = devm_kzalloc(&serdev->dev, sizeof(*nxpdev), GFP_KERNEL);
 	if (!nxpdev)
@@ -1547,8 +1576,16 @@ 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);
 
+	device_property_read_u8_array(&nxpdev->serdev->dev,
+				      "local-bd-address",
+				      (u8 *)&ba, sizeof(ba));
+	if (bacmp(&ba, BDADDR_ANY))
+		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] 11+ messages in thread

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

Dear Neeraj,


Thank you for your patch.


Am 20.02.25 um 12:41 schrieb Neeraj Sanjay Kale:
> Allow user to set custom BD address for NXP chipsets.
> 
> Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
> v2: Add allOf and unevaluatedProperties: false (Krzysztof)
> v3: Drop local-bd-address: true (Krzysztof)
> ---
>   .../devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml   | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
> index 0a2d7baf5db3..a84c1c21b024 100644
> --- a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
> +++ b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
> @@ -17,6 +17,9 @@ description:
>   maintainers:
>     - Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
>   
> +allOf:
> +  - $ref: bluetooth-controller.yaml#
> +
>   properties:
>     compatible:
>       enum:
> @@ -43,7 +46,7 @@ properties:
>   required:
>     - compatible
>   
> -additionalProperties: false
> +unevaluatedProperties: false

How is this diff related to the change mentioned in the commit message?

>   
>   examples:
>     - |
> @@ -54,5 +57,6 @@ examples:
>               fw-init-baudrate = <3000000>;
>               firmware-name = "uartuart8987_bt_v0.bin";
>               device-wakeup-gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
> +            local-bd-address = [66 55 44 33 22 11];
>           };
>       };


Kind regards,

Paul

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

* Re: [PATCH v5 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address
  2025-02-20 11:45 ` [PATCH v5 1/2] dt-bindings: net: bluetooth: nxp: Add support to " Paul Menzel
@ 2025-02-20 11:59   ` Neeraj Sanjay Kale
  2025-02-20 12:11     ` Paul Menzel
  2025-02-20 17:59   ` Krzysztof Kozlowski
  1 sibling, 1 reply; 11+ messages in thread
From: Neeraj Sanjay Kale @ 2025-02-20 11:59 UTC (permalink / raw)
  To: Paul Menzel
  Cc: marcel, luiz.dentz, robh, krzk+dt, conor+dt, linux-bluetooth,
	linux-kernel, devicetree, Amitkumar Karwar, Sherry Sun,
	Luke Wang, johan.korsnes, kristian.krohn, Manjeet Gupta

Hi Paul,

Thank you your review comment.
 
> 
> Dear Neeraj,
> 
> 
> Thank you for your patch.
> 
> 
> Am 20.02.25 um 12:41 schrieb Neeraj Sanjay Kale:
> > Allow user to set custom BD address for NXP chipsets.
> >
> > Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
> > Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> > ---
> > v2: Add allOf and unevaluatedProperties: false (Krzysztof)
> > v3: Drop local-bd-address: true (Krzysztof)
> > ---
> >   .../devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml   | 6 +++++-
> >   1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git
> a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
> b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
> > index 0a2d7baf5db3..a84c1c21b024 100644
> > --- a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-
> bt.yaml
> > +++ b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-
> bt.yaml
> > @@ -17,6 +17,9 @@ description:
> >   maintainers:
> >     - Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
> >
> > +allOf:
> > +  - $ref: bluetooth-controller.yaml#
> > +
> >   properties:
> >     compatible:
> >       enum:
> > @@ -43,7 +46,7 @@ properties:
> >   required:
> >     - compatible
> >
> > -additionalProperties: false
> > +unevaluatedProperties: false
> 
> How is this diff related to the change mentioned in the commit message?

This is based on review comment from Krzysztof in V1 DT patch.
allOf ref will import all properties defined in bluetooth-controller.yaml, including local-bd-address:
https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/net/bluetooth/bluetooth-controller.yaml#L18

> 
> >
> >   examples:
> >     - |
> > @@ -54,5 +57,6 @@ examples:
> >               fw-init-baudrate = <3000000>;
> >               firmware-name = "uartuart8987_bt_v0.bin";
> >               device-wakeup-gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
> > +            local-bd-address = [66 55 44 33 22 11];
> >           };
> >       };
> 

Thanks,
Neeraj

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

* Re: [PATCH v5 2/2] Bluetooth: btnxpuart: Add support for set BD address
  2025-02-20 11:41 ` [PATCH v5 2/2] Bluetooth: btnxpuart: Add support for " Neeraj Sanjay Kale
@ 2025-02-20 12:04   ` Paul Menzel
  2025-02-28 15:32     ` Neeraj Sanjay Kale
  0 siblings, 1 reply; 11+ messages in thread
From: Paul Menzel @ 2025-02-20 12:04 UTC (permalink / raw)
  To: Neeraj Sanjay Kale
  Cc: marcel, luiz.dentz, robh, krzk+dt, conor+dt, linux-bluetooth,
	linux-kernel, devicetree, amitkumar.karwar, sherry.sun,
	ziniu.wang_1, johan.korsnes, kristian.krohn, manjeet.gupta

Dear Neeraj,


Thank you for your patch. In the summary/title you could use *to set* or 
*for setting*.

Am 20.02.25 um 12:41 schrieb Neeraj Sanjay Kale:
> 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.

I’d add a blank line between paragraphs.

> 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.

Where is the command 0xfc22 documented?

How did you verify this? Maybe document the commands how to set the BD 
address, and how to verify it.

Does Linux log new messages with your patch?

> 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>

The last name has some wrong character.

> Tested-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
> Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
> ---
> v4: hci0 interface shows RAW mode if 'local-bd-address' not defined and
>      HCI_QUIRK_USE_BDADDR_PROPERTY is set. Add Quirk only if device tree
>      property 'local-bd-address' found. (Neeraj)
> v5: Initialize local variable ba, update Copywrite year. (Kristian)
> ---
>   drivers/bluetooth/btnxpuart.c | 39 ++++++++++++++++++++++++++++++++++-
>   1 file changed, 38 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
> index 1230045d78a5..dd9161bfd52c 100644
> --- a/drivers/bluetooth/btnxpuart.c
> +++ b/drivers/bluetooth/btnxpuart.c
> @@ -1,7 +1,7 @@
>   // SPDX-License-Identifier: GPL-2.0-or-later
>   /*
>    *  NXP Bluetooth driver
> - *  Copyright 2023 NXP
> + *  Copyright 2023-2025 NXP
>    */
>   
>   #include <linux/module.h>
> @@ -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);
> +

Add a comment about the firmware limitation/requirement?

> +	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)
>   {
> @@ -1500,6 +1528,7 @@ static int nxp_serdev_probe(struct serdev_device *serdev)
>   {
>   	struct hci_dev *hdev;
>   	struct btnxpuart_dev *nxpdev;
> +	bdaddr_t ba = {0};
>   
>   	nxpdev = devm_kzalloc(&serdev->dev, sizeof(*nxpdev), GFP_KERNEL);
>   	if (!nxpdev)
> @@ -1547,8 +1576,16 @@ 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);
>   
> +	device_property_read_u8_array(&nxpdev->serdev->dev,
> +				      "local-bd-address",
> +				      (u8 *)&ba, sizeof(ba));
> +	if (bacmp(&ba, BDADDR_ANY))
> +		set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);

Please elaborate in the commit message, why the quirk is needed.

> +
>   	if (hci_register_dev(hdev) < 0) {
>   		dev_err(&serdev->dev, "Can't register HCI device\n");
>   		goto probe_fail;


Kind regards,

Paul

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

* Re: [PATCH v5 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address
  2025-02-20 11:59   ` Neeraj Sanjay Kale
@ 2025-02-20 12:11     ` Paul Menzel
  2025-02-20 12:30       ` Neeraj Sanjay Kale
  2025-02-20 17:08       ` Conor Dooley
  0 siblings, 2 replies; 11+ messages in thread
From: Paul Menzel @ 2025-02-20 12:11 UTC (permalink / raw)
  To: Neeraj Sanjay Kale
  Cc: marcel, luiz.dentz, robh, krzk+dt, Conor Dooley, linux-bluetooth,
	linux-kernel, devicetree, Amitkumar Karwar, Sherry Sun,
	Luke Wang, johan.korsnes, kristian.krohn, Manjeet Gupta

Dear Neeraj,


Thank you for your prompt reply.

Am 20.02.25 um 12:59 schrieb Neeraj Sanjay Kale:

>> Am 20.02.25 um 12:41 schrieb Neeraj Sanjay Kale:
>>> Allow user to set custom BD address for NXP chipsets.
>>>
>>> Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
>>> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>>> ---
>>> v2: Add allOf and unevaluatedProperties: false (Krzysztof)
>>> v3: Drop local-bd-address: true (Krzysztof)
>>> ---
>>>    .../devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml   | 6 +++++-
>>>    1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git
>> a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
>> b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
>>> index 0a2d7baf5db3..a84c1c21b024 100644
>>> --- a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
>>> +++ b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
>>> @@ -17,6 +17,9 @@ description:
>>>    maintainers:
>>>      - Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
>>>
>>> +allOf:
>>> +  - $ref: bluetooth-controller.yaml#
>>> +
>>>    properties:
>>>      compatible:
>>>        enum:
>>> @@ -43,7 +46,7 @@ properties:
>>>    required:
>>>      - compatible
>>>
>>> -additionalProperties: false
>>> +unevaluatedProperties: false
>>
>> How is this diff related to the change mentioned in the commit message?
> 
> This is based on review comment from Krzysztof in V1 DT patch.
> allOf ref will import all properties defined in bluetooth-controller.yaml, including local-bd-address:
> https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/net/bluetooth/bluetooth-controller.yaml#L18

Thank you. I’d include this in the commit message, but my comment was 
about the replacement of `additionalProperties` by `unevaluatedProperties`.

>>>
>>>    examples:
>>>      - |
>>> @@ -54,5 +57,6 @@ examples:
>>>                fw-init-baudrate = <3000000>;
>>>                firmware-name = "uartuart8987_bt_v0.bin";
>>>                device-wakeup-gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
>>> +            local-bd-address = [66 55 44 33 22 11];
>>>            };
>>>        };

Kind regards,

Paul

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

* Re: [PATCH v5 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address
  2025-02-20 12:11     ` Paul Menzel
@ 2025-02-20 12:30       ` Neeraj Sanjay Kale
  2025-02-20 17:08       ` Conor Dooley
  1 sibling, 0 replies; 11+ messages in thread
From: Neeraj Sanjay Kale @ 2025-02-20 12:30 UTC (permalink / raw)
  To: Paul Menzel
  Cc: marcel, luiz.dentz, robh, krzk+dt, Conor Dooley, linux-bluetooth,
	linux-kernel, devicetree, Amitkumar Karwar, Sherry Sun,
	Luke Wang, johan.korsnes, kristian.krohn, Manjeet Gupta

Hi Paul,
 
> >> Am 20.02.25 um 12:41 schrieb Neeraj Sanjay Kale:
> >>> Allow user to set custom BD address for NXP chipsets.
> >>>
> >>> Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
> >>> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> >>> ---
> >>> v2: Add allOf and unevaluatedProperties: false (Krzysztof)
> >>> v3: Drop local-bd-address: true (Krzysztof)
> >>> ---
> >>>    .../devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml   | 6 +++++-
> >>>    1 file changed, 5 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git
> >> a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-
> bt.yaml
> >> b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-
> bt.yaml
> >>> index 0a2d7baf5db3..a84c1c21b024 100644
> >>> ---
> >>> a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-
> bt.yam
> >>> l
> >>> +++ b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-
> bt
> >>> +++ .yaml
> >>> @@ -17,6 +17,9 @@ description:
> >>>    maintainers:
> >>>      - Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
> >>>
> >>> +allOf:
> >>> +  - $ref: bluetooth-controller.yaml#
> >>> +
> >>>    properties:
> >>>      compatible:
> >>>        enum:
> >>> @@ -43,7 +46,7 @@ properties:
> >>>    required:
> >>>      - compatible
> >>>
> >>> -additionalProperties: false
> >>> +unevaluatedProperties: false
> >>
> >> How is this diff related to the change mentioned in the commit message?
> >
> > This is based on review comment from Krzysztof in V1 DT patch.
> > allOf ref will import all properties defined in bluetooth-controller.yaml,
> including local-bd-address:
> > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> >
> ub.com%2Ftorvalds%2Flinux%2Fblob%2Fmaster%2FDocumentation%2Fdevic
> etree
> > %2Fbindings%2Fnet%2Fbluetooth%2Fbluetooth-
> controller.yaml%23L18&data=0
> >
> 5%7C02%7Cneeraj.sanjaykale%40nxp.com%7Cea6b9bba11954062a8ab08dd5
> 1a7c28
> >
> 9%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C638756503156741
> 597%7CUn
> >
> known%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAw
> MCIsIlAiOi
> >
> JXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=Nf
> 5EkxiY
> > rHPZQjCBa1XFeu8Y5T8cXpQwXHZ757YvGFw%3D&reserved=0
> 
> Thank you. I'd include this in the commit message, but my comment was
> about the replacement of `additionalProperties` by `unevaluatedProperties`.
As per DT documentation, if we include other schemas, we must use "unevaluatedProperties:false" instead of "additionalProperties:false"

https://docs.kernel.org/devicetree/bindings/writing-bindings.html

With "additionalProperties:false", make dt_binding_check fails as it is unable to find the 'local-bd-address' property.

> 
> >>>
> >>>    examples:
> >>>      - |
> >>> @@ -54,5 +57,6 @@ examples:
> >>>                fw-init-baudrate = <3000000>;
> >>>                firmware-name = "uartuart8987_bt_v0.bin";
> >>>                device-wakeup-gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
> >>> +            local-bd-address = [66 55 44 33 22 11];
> >>>            };
> >>>        };
> 

Thanks,
Neeraj

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

* Re: [PATCH v5 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address
  2025-02-20 12:11     ` Paul Menzel
  2025-02-20 12:30       ` Neeraj Sanjay Kale
@ 2025-02-20 17:08       ` Conor Dooley
  1 sibling, 0 replies; 11+ messages in thread
From: Conor Dooley @ 2025-02-20 17:08 UTC (permalink / raw)
  To: Paul Menzel
  Cc: Neeraj Sanjay Kale, marcel, luiz.dentz, robh, krzk+dt,
	Conor Dooley, linux-bluetooth, linux-kernel, devicetree,
	Amitkumar Karwar, Sherry Sun, Luke Wang, johan.korsnes,
	kristian.krohn, Manjeet Gupta

[-- Attachment #1: Type: text/plain, Size: 2258 bytes --]

On Thu, Feb 20, 2025 at 01:11:41PM +0100, Paul Menzel wrote:
> Dear Neeraj,
> 
> 
> Thank you for your prompt reply.
> 
> Am 20.02.25 um 12:59 schrieb Neeraj Sanjay Kale:
> 
> > > Am 20.02.25 um 12:41 schrieb Neeraj Sanjay Kale:
> > > > Allow user to set custom BD address for NXP chipsets.
> > > > 
> > > > Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
> > > > Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> > > > ---
> > > > v2: Add allOf and unevaluatedProperties: false (Krzysztof)
> > > > v3: Drop local-bd-address: true (Krzysztof)
> > > > ---
> > > >    .../devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml   | 6 +++++-
> > > >    1 file changed, 5 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git
> > > a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
> > > b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
> > > > index 0a2d7baf5db3..a84c1c21b024 100644
> > > > --- a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
> > > > +++ b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
> > > > @@ -17,6 +17,9 @@ description:
> > > >    maintainers:
> > > >      - Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
> > > > 
> > > > +allOf:
> > > > +  - $ref: bluetooth-controller.yaml#
> > > > +
> > > >    properties:
> > > >      compatible:
> > > >        enum:
> > > > @@ -43,7 +46,7 @@ properties:
> > > >    required:
> > > >      - compatible
> > > > 
> > > > -additionalProperties: false
> > > > +unevaluatedProperties: false
> > > 
> > > How is this diff related to the change mentioned in the commit message?
> > 
> > This is based on review comment from Krzysztof in V1 DT patch.
> > allOf ref will import all properties defined in bluetooth-controller.yaml, including local-bd-address:
> > https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/net/bluetooth/bluetooth-controller.yaml#L18
> 
> Thank you. I’d include this in the commit message, but my comment was about
> the replacement of `additionalProperties` by `unevaluatedProperties`.

The change is needed to permit the property defined in
bluetooth-controller.yaml to be used.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH v5 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address
  2025-02-20 11:45 ` [PATCH v5 1/2] dt-bindings: net: bluetooth: nxp: Add support to " Paul Menzel
  2025-02-20 11:59   ` Neeraj Sanjay Kale
@ 2025-02-20 17:59   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 11+ messages in thread
From: Krzysztof Kozlowski @ 2025-02-20 17:59 UTC (permalink / raw)
  To: Paul Menzel, Neeraj Sanjay Kale
  Cc: marcel, luiz.dentz, robh, krzk+dt, conor+dt, linux-bluetooth,
	linux-kernel, devicetree, amitkumar.karwar, sherry.sun,
	ziniu.wang_1, johan.korsnes, kristian.krohn, manjeet.gupta

On 20/02/2025 12:45, Paul Menzel wrote:
> Dear Neeraj,
> 
> 
> Thank you for your patch.
> 
> 
> Am 20.02.25 um 12:41 schrieb Neeraj Sanjay Kale:
>> Allow user to set custom BD address for NXP chipsets.
>>
>> Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
>> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>> ---
>> v2: Add allOf and unevaluatedProperties: false (Krzysztof)
>> v3: Drop local-bd-address: true (Krzysztof)
>> ---
>>   .../devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml   | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
>> index 0a2d7baf5db3..a84c1c21b024 100644
>> --- a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
>> +++ b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
>> @@ -17,6 +17,9 @@ description:
>>   maintainers:
>>     - Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
>>   
>> +allOf:
>> +  - $ref: bluetooth-controller.yaml#
>> +
>>   properties:
>>     compatible:
>>       enum:
>> @@ -43,7 +46,7 @@ properties:
>>   required:
>>     - compatible
>>   
>> -additionalProperties: false
>> +unevaluatedProperties: false
> 
> How is this diff related to the change mentioned in the commit message?

It is exactly related, because otherwise custom BD address would not be
allowed.

Read previous discussions and example schema before questioning, because
otherwise this is nitpicking.

Best regards,
Krzysztof

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

* Re: [PATCH v5 2/2] Bluetooth: btnxpuart: Add support for set BD address
  2025-02-20 12:04   ` Paul Menzel
@ 2025-02-28 15:32     ` Neeraj Sanjay Kale
  0 siblings, 0 replies; 11+ messages in thread
From: Neeraj Sanjay Kale @ 2025-02-28 15:32 UTC (permalink / raw)
  To: Paul Menzel
  Cc: marcel, luiz.dentz, robh, krzk+dt, conor+dt, linux-bluetooth,
	linux-kernel, devicetree, Amitkumar Karwar, Sherry Sun,
	Luke Wang, johan.korsnes, kristian.krohn, Manjeet Gupta

Hi Paul,

Thank you for reviewing this patch.

> Dear Neeraj,
> 
> 
> Thank you for your patch. In the summary/title you could use *to set* or *for
> setting*.
> 
> Am 20.02.25 um 12:41 schrieb Neeraj Sanjay Kale:
> > 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.
> 
> I’d add a blank line between paragraphs.
> 
> > 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.
> 
> Where is the command 0xfc22 documented?
> 
> How did you verify this? Maybe document the commands how to set the BD
> address, and how to verify it.
> 
> Does Linux log new messages with your patch?

I have added User Manual reference in a comment. There is no new message logged by the driver.

> 
> > 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>
> 
> The last name has some wrong character.
> 
> > Tested-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
> > Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
> > ---
> > v4: hci0 interface shows RAW mode if 'local-bd-address' not defined and
> >      HCI_QUIRK_USE_BDADDR_PROPERTY is set. Add Quirk only if device tree
> >      property 'local-bd-address' found. (Neeraj)
> > v5: Initialize local variable ba, update Copywrite year. (Kristian)
> > ---
> >   drivers/bluetooth/btnxpuart.c | 39
> ++++++++++++++++++++++++++++++++++-
> >   1 file changed, 38 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/bluetooth/btnxpuart.c
> > b/drivers/bluetooth/btnxpuart.c index 1230045d78a5..dd9161bfd52c
> > 100644
> > --- a/drivers/bluetooth/btnxpuart.c
> > +++ b/drivers/bluetooth/btnxpuart.c
> > @@ -1,7 +1,7 @@
> >   // SPDX-License-Identifier: GPL-2.0-or-later
> >   /*
> >    *  NXP Bluetooth driver
> > - *  Copyright 2023 NXP
> > + *  Copyright 2023-2025 NXP
> >    */
> >
> >   #include <linux/module.h>
> > @@ -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);
> > +
> 
> Add a comment about the firmware limitation/requirement?
> 
> > +     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)
> >   {
> > @@ -1500,6 +1528,7 @@ static int nxp_serdev_probe(struct serdev_device
> *serdev)
> >   {
> >       struct hci_dev *hdev;
> >       struct btnxpuart_dev *nxpdev;
> > +     bdaddr_t ba = {0};
> >
> >       nxpdev = devm_kzalloc(&serdev->dev, sizeof(*nxpdev), GFP_KERNEL);
> >       if (!nxpdev)
> > @@ -1547,8 +1576,16 @@ 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);
> >
> > +     device_property_read_u8_array(&nxpdev->serdev->dev,
> > +                                   "local-bd-address",
> > +                                   (u8 *)&ba, sizeof(ba));
> > +     if (bacmp(&ba, BDADDR_ANY))
> > +             set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
> 
> Please elaborate in the commit message, why the quirk is needed.
> 
> > +
> >       if (hci_register_dev(hdev) < 0) {
> >               dev_err(&serdev->dev, "Can't register HCI device\n");
> >               goto probe_fail;

Rest of the review comments I have resolved in V6 patch.

Thanks,
Neeraj

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

* [PATCH v5 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address
@ 2025-01-15 16:38 Neeraj Sanjay Kale
  0 siblings, 0 replies; 11+ messages in thread
From: Neeraj Sanjay Kale @ 2025-01-15 16:38 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

Allow user to set custom BD address for NXP chipsets.

Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
v2: Add allOf and unevaluatedProperties: false (Krzysztof)
v3: Drop local-bd-address: true (Krzysztof)
---
 .../devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
index 0a2d7baf5db3..a84c1c21b024 100644
--- a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
+++ b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml
@@ -17,6 +17,9 @@ description:
 maintainers:
   - Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
 
+allOf:
+  - $ref: bluetooth-controller.yaml#
+
 properties:
   compatible:
     enum:
@@ -43,7 +46,7 @@ properties:
 required:
   - compatible
 
-additionalProperties: false
+unevaluatedProperties: false
 
 examples:
   - |
@@ -54,5 +57,6 @@ examples:
             fw-init-baudrate = <3000000>;
             firmware-name = "uartuart8987_bt_v0.bin";
             device-wakeup-gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
+            local-bd-address = [66 55 44 33 22 11];
         };
     };
-- 
2.25.1


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

end of thread, other threads:[~2025-02-28 15:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-20 11:41 [PATCH v5 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address Neeraj Sanjay Kale
2025-02-20 11:41 ` [PATCH v5 2/2] Bluetooth: btnxpuart: Add support for " Neeraj Sanjay Kale
2025-02-20 12:04   ` Paul Menzel
2025-02-28 15:32     ` Neeraj Sanjay Kale
2025-02-20 11:45 ` [PATCH v5 1/2] dt-bindings: net: bluetooth: nxp: Add support to " Paul Menzel
2025-02-20 11:59   ` Neeraj Sanjay Kale
2025-02-20 12:11     ` Paul Menzel
2025-02-20 12:30       ` Neeraj Sanjay Kale
2025-02-20 17:08       ` Conor Dooley
2025-02-20 17:59   ` Krzysztof Kozlowski
  -- strict thread matches above, loose matches on Subject: below --
2025-01-15 16:38 Neeraj Sanjay Kale

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®