* [PATCH v2 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address @ 2025-01-14 13:35 Neeraj Sanjay Kale 2025-01-14 13:35 ` [PATCH v2 2/2] Bluetooth: btnxpuart: Add support for " Neeraj Sanjay Kale 2025-01-14 13:39 ` [PATCH v2 1/2] dt-bindings: net: bluetooth: nxp: Add support to " Krzysztof Kozlowski 0 siblings, 2 replies; 7+ messages in thread From: Neeraj Sanjay Kale @ 2025-01-14 13:35 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> --- v2: Add allOf and unevaluatedProperties: false (Krzysztof) --- .../devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml | 8 +++++++- 1 file changed, 7 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..5d75a45cac14 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: @@ -40,10 +43,12 @@ 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 -additionalProperties: false +unevaluatedProperties: false examples: - | @@ -54,5 +59,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 related [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] Bluetooth: btnxpuart: Add support for set BD address 2025-01-14 13:35 [PATCH v2 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address Neeraj Sanjay Kale @ 2025-01-14 13:35 ` Neeraj Sanjay Kale 2025-01-14 13:53 ` Johan Korsnes 2025-01-14 13:39 ` [PATCH v2 1/2] dt-bindings: net: bluetooth: nxp: Add support to " Krzysztof Kozlowski 1 sibling, 1 reply; 7+ messages in thread From: Neeraj Sanjay Kale @ 2025-01-14 13:35 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 related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] Bluetooth: btnxpuart: Add support for set BD address 2025-01-14 13:35 ` [PATCH v2 2/2] Bluetooth: btnxpuart: Add support for " Neeraj Sanjay Kale @ 2025-01-14 13:53 ` Johan Korsnes 2025-01-14 14:07 ` Neeraj Sanjay Kale 0 siblings, 1 reply; 7+ messages in thread From: Johan Korsnes @ 2025-01-14 13:53 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, kristian.krohn, manjeet.gupta On 1/14/25 2:35 PM, Neeraj Sanjay Kale wrote: > 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. > Hi Neeraj, If NXP firmware does not allow vendor commands prior to this reset, would it not be better to perform this reset during probe/init? Kind regards, Johan ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] Bluetooth: btnxpuart: Add support for set BD address 2025-01-14 13:53 ` Johan Korsnes @ 2025-01-14 14:07 ` Neeraj Sanjay Kale 2025-01-14 14:09 ` Johan Korsnes 0 siblings, 1 reply; 7+ messages in thread From: Neeraj Sanjay Kale @ 2025-01-14 14:07 UTC (permalink / raw) To: Johan Korsnes, marcel@holtmann.org, luiz.dentz@gmail.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Amitkumar Karwar, Sherry Sun, Luke Wang, kristian.krohn@remarkable.no, Manjeet Gupta Hi Johan, > > On 1/14/25 2:35 PM, Neeraj Sanjay Kale wrote: > > 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. > > > > Hi Neeraj, > > If NXP firmware does not allow vendor commands prior to this reset, would it > not be better to perform this reset during probe/init? > HCI reset is already part of kernel init sequence hci_init0_sync(). However, .set_bdaddr() is called immediately after FW download is complete, but before this init sequence. Also, if local-bd-address property is not defined in the DTB, sending HCI reset command in probe does not add any value. With current implementation, if local-bd-address is defined, driver sends HCI reset, followed by set BD address vendor command, and kernel continues with the HCI init sequence. Thanks, Neeraj ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] Bluetooth: btnxpuart: Add support for set BD address 2025-01-14 14:07 ` Neeraj Sanjay Kale @ 2025-01-14 14:09 ` Johan Korsnes 0 siblings, 0 replies; 7+ messages in thread From: Johan Korsnes @ 2025-01-14 14:09 UTC (permalink / raw) To: Neeraj Sanjay Kale, marcel@holtmann.org, luiz.dentz@gmail.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Amitkumar Karwar, Sherry Sun, Luke Wang, kristian.krohn@remarkable.no, Manjeet Gupta On 1/14/25 3:07 PM, Neeraj Sanjay Kale wrote: > > Hi Johan, > >> >> On 1/14/25 2:35 PM, Neeraj Sanjay Kale wrote: >>> 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. >>> >> >> Hi Neeraj, >> >> If NXP firmware does not allow vendor commands prior to this reset, would it >> not be better to perform this reset during probe/init? >> > HCI reset is already part of kernel init sequence hci_init0_sync(). > However, .set_bdaddr() is called immediately after FW download is complete, but before this init sequence. > > Also, if local-bd-address property is not defined in the DTB, sending HCI reset command in probe does not add any value. > > With current implementation, if local-bd-address is defined, driver sends HCI reset, followed by set BD address vendor command, and kernel continues with the HCI init sequence. > Thanks for clarifying, that makes sense :-) Kind regards, Johan > Thanks, > Neeraj ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address 2025-01-14 13:35 [PATCH v2 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address Neeraj Sanjay Kale 2025-01-14 13:35 ` [PATCH v2 2/2] Bluetooth: btnxpuart: Add support for " Neeraj Sanjay Kale @ 2025-01-14 13:39 ` Krzysztof Kozlowski 2025-01-14 14:21 ` Neeraj Sanjay Kale 1 sibling, 1 reply; 7+ messages in thread From: Krzysztof Kozlowski @ 2025-01-14 13:39 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 14:35, Neeraj Sanjay Kale wrote: > This adds a new optional device tree property local-bd-address to allow Please do not use "This commit/patch/change", but imperative mood. See longer explanation here: https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95 > user to set custom BD address for NXP chipsets. > > Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com> > --- > v2: Add allOf and unevaluatedProperties: false (Krzysztof) > --- > .../devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml | 8 +++++++- > 1 file changed, 7 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..5d75a45cac14 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: > @@ -40,10 +43,12 @@ 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 In case I was not clear: drop. And rephrase the commit msg to reflect this. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address 2025-01-14 13:39 ` [PATCH v2 1/2] dt-bindings: net: bluetooth: nxp: Add support to " Krzysztof Kozlowski @ 2025-01-14 14:21 ` Neeraj Sanjay Kale 0 siblings, 0 replies; 7+ messages in thread From: Neeraj Sanjay Kale @ 2025-01-14 14:21 UTC (permalink / raw) To: Krzysztof Kozlowski, marcel@holtmann.org, luiz.dentz@gmail.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Amitkumar Karwar, Sherry Sun, Luke Wang, johan.korsnes@remarkable.no, kristian.krohn@remarkable.no, Manjeet Gupta Hi Krzysztof, Thank you for the review. If I understood it correctly, local-bd-address property would be picked from bluetooth-controller.yaml ref. Updated commit msg accordingly. Please let me know if any further comments. Thanks, Neeraj. > -----Original Message----- > From: Krzysztof Kozlowski <krzk@kernel.org> > Sent: Tuesday, January 14, 2025 7:09 PM > To: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>; marcel@holtmann.org; > luiz.dentz@gmail.com; robh@kernel.org; krzk+dt@kernel.org; > conor+dt@kernel.org > Cc: linux-bluetooth@vger.kernel.org; linux-kernel@vger.kernel.org; > devicetree@vger.kernel.org; Amitkumar Karwar > <amitkumar.karwar@nxp.com>; Sherry Sun <sherry.sun@nxp.com>; Luke > Wang <ziniu.wang_1@nxp.com>; johan.korsnes@remarkable.no; > kristian.krohn@remarkable.no; Manjeet Gupta <manjeet.gupta@nxp.com> > Subject: [EXT] Re: [PATCH v2 1/2] dt-bindings: net: bluetooth: nxp: Add > support to set BD address > > Caution: This is an external email. Please take care when clicking links or > opening attachments. When in doubt, report the message using the 'Report > this email' button > > > On 14/01/2025 14:35, Neeraj Sanjay Kale wrote: > > This adds a new optional device tree property local-bd-address to > > allow > > Please do not use "This commit/patch/change", but imperative mood. See > longer explanation here: > https://elixir.b/ > ootlin.com%2Flinux%2Fv5.17.1%2Fsource%2FDocumentation%2Fprocess%2F > submitting- > patches.rst%23L95&data=05%7C02%7Cneeraj.sanjaykale%40nxp.com%7C84b > bc484675244ce050308dd34a0d9ac%7C686ea1d3bc2b4c6fa92cd99c5c301635 > %7C0%7C0%7C638724587636722337%7CUnknown%7CTWFpbGZsb3d8eyJFb > XB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWF > pbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=EH9V57j1ClNq7VMsUt%2 > BzcZ3sisbeSIrOCogGt02Ca1M%3D&reserved=0 > > > user to set custom BD address for NXP chipsets. > > > > > > Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com> > > --- > > v2: Add allOf and unevaluatedProperties: false (Krzysztof) > > --- > > .../devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml | 8 > > +++++++- > > 1 file changed, 7 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..5d75a45cac14 100644 > > --- > > a/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.yaml > > +++ b/Documentation/devicetree/bindings/net/bluetooth/nxp,88w8987-bt.y > > +++ aml > > @@ -17,6 +17,9 @@ description: > > maintainers: > > - Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com> > > > > +allOf: > > + - $ref: bluetooth-controller.yaml# > > + > > properties: > > compatible: > > enum: > > @@ -40,10 +43,12 @@ 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 > > In case I was not clear: drop. And rephrase the commit msg to reflect this. > > Best regards, > Krzysztof ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-01-14 14:21 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-01-14 13:35 [PATCH v2 1/2] dt-bindings: net: bluetooth: nxp: Add support to set BD address Neeraj Sanjay Kale 2025-01-14 13:35 ` [PATCH v2 2/2] Bluetooth: btnxpuart: Add support for " Neeraj Sanjay Kale 2025-01-14 13:53 ` Johan Korsnes 2025-01-14 14:07 ` Neeraj Sanjay Kale 2025-01-14 14:09 ` Johan Korsnes 2025-01-14 13:39 ` [PATCH v2 1/2] dt-bindings: net: bluetooth: nxp: Add support to " Krzysztof Kozlowski 2025-01-14 14:21 ` 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