* [PATCH v4 1/3] dt-bindings: soc: qcom: Add local-bd-address property to WCNSS-BT
@ 2017-09-05 10:26 Loic Poulain
2017-09-05 10:26 ` [PATCH v4 2/3] Bluetooth: btqcomsmd: BD address setup Loic Poulain
[not found] ` <1504607164-12645-1-git-send-email-loic.poulain-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
0 siblings, 2 replies; 7+ messages in thread
From: Loic Poulain @ 2017-09-05 10:26 UTC (permalink / raw)
To: marcel, johan.hedberg, robh+dt
Cc: linux-bluetooth, linux-arm-msm, devicetree, bjorn.andersson,
Loic Poulain
Add optional local-bd-address property which is a 6-byte array
storing the assigned BD address. Since having a unique BD address
is critical, a per-device property value should be allocated.
This property is usually added by the boot loader which has access
to the provisioned data.
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
v2: Set device as unconfigured if default address detected
Add warning if BD addr retrieved from DT
v3: if no addr retrieved from DT, unconditionally set
the invalid BD addr flag.
swap and set bdaddr in the platform probe
v4: Add dt-bindings documentation
split patch in two parts (setup, dt prop)
use local-bd-address name instead of local-mac-address
Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt b/Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt
index 4ea39e9186a7..1edfcdc6e267 100644
--- a/Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt
+++ b/Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt
@@ -37,6 +37,12 @@ The following properties are defined to the bluetooth node:
Definition: must be:
"qcom,wcnss-bt"
+- local-bd-address:
+ Usage: optional
+ Value type: <u8 array>
+ Definition: should specify the unique 6-byte BD address assigned to the
+ BT controller. Usually added at runtime by the boot loader.
+
== WiFi
The following properties are defined to the WiFi node:
--
2.13.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v4 2/3] Bluetooth: btqcomsmd: BD address setup
2017-09-05 10:26 [PATCH v4 1/3] dt-bindings: soc: qcom: Add local-bd-address property to WCNSS-BT Loic Poulain
@ 2017-09-05 10:26 ` Loic Poulain
[not found] ` <1504607164-12645-2-git-send-email-loic.poulain-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
[not found] ` <1504607164-12645-1-git-send-email-loic.poulain-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
1 sibling, 1 reply; 7+ messages in thread
From: Loic Poulain @ 2017-09-05 10:26 UTC (permalink / raw)
To: marcel, johan.hedberg, robh+dt
Cc: linux-bluetooth, linux-arm-msm, devicetree, bjorn.andersson,
Loic Poulain
This patch implements the hdev setup function.
wcnss-bt does not have persistent memory to store
an allocated BD address. The device is therefore
marked as unconfigured if no BD address has been
previously retrieved.
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
v2: Set device as unconfigured if default address detected
Add warning if BD addr retrieved from DT
v3: if no addr retrieved from DT, unconditionally set
the invalid BD addr flag.
swap and set bdaddr in the platform probe
v4: Add dt-bindings documentation
split patch in two parts (setup, dt prop)
use local-bd-address name instead of local-mac-address
drivers/bluetooth/btqcomsmd.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/bluetooth/btqcomsmd.c b/drivers/bluetooth/btqcomsmd.c
index ef730c173d4b..c70fae75c4ad 100644
--- a/drivers/bluetooth/btqcomsmd.c
+++ b/drivers/bluetooth/btqcomsmd.c
@@ -26,6 +26,7 @@
struct btqcomsmd {
struct hci_dev *hdev;
+ bdaddr_t bdaddr;
struct rpmsg_endpoint *acl_channel;
struct rpmsg_endpoint *cmd_channel;
};
@@ -100,6 +101,29 @@ static int btqcomsmd_close(struct hci_dev *hdev)
return 0;
}
+static int btqcomsmd_setup(struct hci_dev *hdev)
+{
+ struct btqcomsmd *btq = hci_get_drvdata(hdev);
+ struct sk_buff *skb;
+
+ skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
+ if (IS_ERR(skb))
+ return PTR_ERR(skb);
+ kfree_skb(skb);
+
+ /* Device does not have persistent storage for BD address.
+ * Mark the device with invalid BD addr flag if no address
+ * retrieved during probe.
+ */
+ if (!bacmp(&btq->bdaddr, BDADDR_ANY)) {
+ bt_dev_info(hdev, "No BD address configured");
+ set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
+ return 0;
+ }
+
+ return qca_set_bdaddr_rome(hdev, &btq->bdaddr);
+}
+
static int btqcomsmd_probe(struct platform_device *pdev)
{
struct btqcomsmd *btq;
@@ -135,6 +159,7 @@ static int btqcomsmd_probe(struct platform_device *pdev)
hdev->open = btqcomsmd_open;
hdev->close = btqcomsmd_close;
hdev->send = btqcomsmd_send;
+ hdev->setup = btqcomsmd_setup;
hdev->set_bdaddr = qca_set_bdaddr_rome;
ret = hci_register_dev(hdev);
--
2.13.0
^ permalink raw reply related [flat|nested] 7+ messages in thread[parent not found: <1504607164-12645-1-git-send-email-loic.poulain-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>]
* [PATCH v4 3/3] Bluetooth: btqcomsmd: retieve BD address from DT
[not found] ` <1504607164-12645-1-git-send-email-loic.poulain-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2017-09-05 10:26 ` Loic Poulain
[not found] ` <1504607164-12645-3-git-send-email-loic.poulain-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-09-05 11:54 ` [PATCH v4 1/3] dt-bindings: soc: qcom: Add local-bd-address property to WCNSS-BT Marcel Holtmann
1 sibling, 1 reply; 7+ messages in thread
From: Loic Poulain @ 2017-09-05 10:26 UTC (permalink / raw)
To: marcel-kz+m5ild9QBg9hUCZPvPmw,
johan.hedberg-Re5JQEeQqe8AvxtiuMwx3w,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-bluetooth-u79uwXL29TY76Z2rM5mHXA,
linux-arm-msm-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A, Loic Poulain
Retrieve BD address from the DT local-bd-address property.
This address must be unique and is usually added in the DT
by the bootloader which has access to the provisioned data.
Signed-off-by: Loic Poulain <loic.poulain-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
v2: Set device as unconfigured if default address detected
Add warning if BD addr retrieved from DT
v3: if no addr retrieved from DT, unconditionally set
the invalid BD addr flag.
swap and set bdaddr in the platform probe
v4: Add dt-bindings documentation
split patch in two parts (setup, dt prop)
use local-bd-address name instead of local-mac-address
drivers/bluetooth/btqcomsmd.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/bluetooth/btqcomsmd.c b/drivers/bluetooth/btqcomsmd.c
index c70fae75c4ad..08a83cb30af6 100644
--- a/drivers/bluetooth/btqcomsmd.c
+++ b/drivers/bluetooth/btqcomsmd.c
@@ -15,6 +15,8 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/rpmsg.h>
+#include <linux/of.h>
+
#include <linux/soc/qcom/wcnss_ctrl.h>
#include <linux/platform_device.h>
@@ -126,6 +128,7 @@ static int btqcomsmd_setup(struct hci_dev *hdev)
static int btqcomsmd_probe(struct platform_device *pdev)
{
+ const bdaddr_t *local_bd_addr;
struct btqcomsmd *btq;
struct hci_dev *hdev;
void *wcnss;
@@ -147,6 +150,18 @@ static int btqcomsmd_probe(struct platform_device *pdev)
if (IS_ERR(btq->cmd_channel))
return PTR_ERR(btq->cmd_channel);
+ /* The local-bd-address DT property is usually injected by the
+ * bootloader which has access to the allocated BD address.
+ */
+ local_bd_addr = of_get_property(pdev->dev.of_node, "local-mac-address",
+ &ret);
+ if (local_bd_addr && ret == sizeof(bdaddr_t)) {
+ /* local-bd-address stored with most significant byte first */
+ baswap(&btq->bdaddr, local_bd_addr);
+ BT_INFO("BD address %pMR retrieved from device-tree",
+ &btq->bdaddr);
+ }
+
hdev = hci_alloc_dev();
if (!hdev)
return -ENOMEM;
--
2.13.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v4 1/3] dt-bindings: soc: qcom: Add local-bd-address property to WCNSS-BT
[not found] ` <1504607164-12645-1-git-send-email-loic.poulain-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-09-05 10:26 ` [PATCH v4 3/3] Bluetooth: btqcomsmd: retieve BD address from DT Loic Poulain
@ 2017-09-05 11:54 ` Marcel Holtmann
1 sibling, 0 replies; 7+ messages in thread
From: Marcel Holtmann @ 2017-09-05 11:54 UTC (permalink / raw)
To: Loic Poulain
Cc: Johan Hedberg, Rob Herring, open list:BLUETOOTH DRIVERS,
linux-arm-msm-u79uwXL29TY76Z2rM5mHXA, devicetree,
bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A
Hi Loic,
> Add optional local-bd-address property which is a 6-byte array
> storing the assigned BD address. Since having a unique BD address
> is critical, a per-device property value should be allocated.
> This property is usually added by the boot loader which has access
> to the provisioned data.
>
> Signed-off-by: Loic Poulain <loic.poulain-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
> v2: Set device as unconfigured if default address detected
> Add warning if BD addr retrieved from DT
> v3: if no addr retrieved from DT, unconditionally set
> the invalid BD addr flag.
> swap and set bdaddr in the platform probe
> v4: Add dt-bindings documentation
> split patch in two parts (setup, dt prop)
> use local-bd-address name instead of local-mac-address
>
> Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt b/Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt
> index 4ea39e9186a7..1edfcdc6e267 100644
> --- a/Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt
> +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt
> @@ -37,6 +37,12 @@ The following properties are defined to the bluetooth node:
> Definition: must be:
> "qcom,wcnss-bt"
>
> +- local-bd-address:
> + Usage: optional
> + Value type: <u8 array>
> + Definition: should specify the unique 6-byte BD address assigned to the
> + BT controller. Usually added at runtime by the boot loader.
> +
as mentioned in my other email, I would really add an example on how to format this. Especially since these are formatted in little-endian order. So adding an example of “00:11:22:33:44:55” string representation on how it converts to [ 55 44 33 22 11 00 ] would be super helpful.
It might also be useful to create a generic bluetooth.txt similar to ethernet.txt. And then just reference it from here.
Of course we need to have Rob sign off on this and also make sure the boot loader people get this done correctly.
Regards
Marcel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-09-08 3:54 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-05 10:26 [PATCH v4 1/3] dt-bindings: soc: qcom: Add local-bd-address property to WCNSS-BT Loic Poulain
2017-09-05 10:26 ` [PATCH v4 2/3] Bluetooth: btqcomsmd: BD address setup Loic Poulain
[not found] ` <1504607164-12645-2-git-send-email-loic.poulain-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-09-05 12:14 ` Marcel Holtmann
[not found] ` <1504607164-12645-1-git-send-email-loic.poulain-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-09-05 10:26 ` [PATCH v4 3/3] Bluetooth: btqcomsmd: retieve BD address from DT Loic Poulain
[not found] ` <1504607164-12645-3-git-send-email-loic.poulain-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-09-05 12:13 ` Marcel Holtmann
2017-09-08 3:54 ` kbuild test robot
2017-09-05 11:54 ` [PATCH v4 1/3] dt-bindings: soc: qcom: Add local-bd-address property to WCNSS-BT Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).