All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 1/3] DT: net: document Bluetooth bindings in one place
@ 2017-09-05 18:58 ` Loic Poulain
  0 siblings, 0 replies; 14+ messages in thread
From: Loic Poulain @ 2017-09-05 18:58 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, lpoulain

From: lpoulain <loic.poulain-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

In the same way as Ethernet, gather the Bluetooth related bindings in
one file. Introduce the bluetooth-bd-address property which can be used
to store the assigned BD address.

Signed-off-by: lpoulain <loic.poulain-Re5JQEeQqe8AvxtiuMwx3w@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
 v5: remove 2/3 merged in bluetooth-next tree
     Add bluetooth.txt for common BT bindings
     expect local-bd-address in little-endian format

 Documentation/devicetree/bindings/net/bluetooth.txt | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/bluetooth.txt

diff --git a/Documentation/devicetree/bindings/net/bluetooth.txt b/Documentation/devicetree/bindings/net/bluetooth.txt
new file mode 100644
index 0000000..94797df
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/bluetooth.txt
@@ -0,0 +1,5 @@
+The following properties are common to the Bluetooth controllers:
+
+- local-bd-address: array of 6 bytes, specifies the BD address that was
+  uniquely assigned to the Bluetooth device, formatted with least significant
+  byte first (little-endian).
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v5 1/3] DT: net: document Bluetooth bindings in one place
@ 2017-09-05 18:58 ` Loic Poulain
  0 siblings, 0 replies; 14+ messages in thread
From: Loic Poulain @ 2017-09-05 18:58 UTC (permalink / raw)
  To: marcel, johan.hedberg, robh+dt
  Cc: linux-bluetooth, linux-arm-msm, devicetree, bjorn.andersson, lpoulain

From: lpoulain <loic.poulain@gmail.com>

In the same way as Ethernet, gather the Bluetooth related bindings in
one file. Introduce the bluetooth-bd-address property which can be used
to store the assigned BD address.

Signed-off-by: lpoulain <loic.poulain@gmail.com>
---
 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
 v5: remove 2/3 merged in bluetooth-next tree
     Add bluetooth.txt for common BT bindings
     expect local-bd-address in little-endian format

 Documentation/devicetree/bindings/net/bluetooth.txt | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/bluetooth.txt

diff --git a/Documentation/devicetree/bindings/net/bluetooth.txt b/Documentation/devicetree/bindings/net/bluetooth.txt
new file mode 100644
index 0000000..94797df
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/bluetooth.txt
@@ -0,0 +1,5 @@
+The following properties are common to the Bluetooth controllers:
+
+- local-bd-address: array of 6 bytes, specifies the BD address that was
+  uniquely assigned to the Bluetooth device, formatted with least significant
+  byte first (little-endian).
-- 
1.9.1

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

* [PATCH v5 2/3] dt-bindings: soc: qcom: Add local-bd-address property to WCNSS-BT
  2017-09-05 18:58 ` Loic Poulain
  (?)
@ 2017-09-05 18:58 ` Loic Poulain
  2017-09-13 16:21   ` Rob Herring
  -1 siblings, 1 reply; 14+ messages in thread
From: Loic Poulain @ 2017-09-05 18:58 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
 v5: remove 2/3 merged in bluetooth-next tree
     Add bluetooth.txt for common BT bindings
     expect local-bd-address in little-endian format

 Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt b/Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt
index 4ea39e9..042a2e4 100644
--- a/Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt
+++ b/Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt
@@ -37,6 +37,11 @@ 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: see Documentation/devicetree/bindings/net/bluetooth.txt
+
 == WiFi
 The following properties are defined to the WiFi node:
 
@@ -91,6 +96,9 @@ smd {
 
 			bt {
 				compatible = "qcom,wcnss-bt";
+
+				/* BD address 00:11:22:33:44:55 */
+				local-bd-address = [ 55 44 33 22 11 00 ];
 			};
 
 			wlan {
-- 
1.9.1

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

* [PATCH v5 3/3] Bluetooth: btqcomsmd: retieve BD address from DT
  2017-09-05 18:58 ` Loic Poulain
@ 2017-09-05 18:58     ` Loic Poulain
  -1 siblings, 0 replies; 14+ messages in thread
From: Loic Poulain @ 2017-09-05 18:58 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
 v5: remove 2/3 merged in bluetooth-next tree
     Add bluetooth.txt for common BT bindings
     expect local-bd-address in little-endian format

 drivers/bluetooth/btqcomsmd.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/bluetooth/btqcomsmd.c b/drivers/bluetooth/btqcomsmd.c
index bd810d0..c6d3fd9 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>
 
@@ -135,6 +137,7 @@ static int btqcomsmd_setup(struct hci_dev *hdev)
 
 static int btqcomsmd_probe(struct platform_device *pdev)
 {
+	const bdaddr_t *bdaddr;
 	struct btqcomsmd *btq;
 	struct hci_dev *hdev;
 	void *wcnss;
@@ -156,6 +159,15 @@ 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.
+	 */
+	bdaddr = of_get_property(pdev->dev.of_node, "local-bd-address", &ret);
+	if (bdaddr && ret == sizeof(bdaddr_t)) {
+		BT_INFO("BD address %pMR retrieved from device-tree", bdaddr);
+		bacpy(&btq->bdaddr, bdaddr);
+	}
+
 	hdev = hci_alloc_dev();
 	if (!hdev)
 		return -ENOMEM;
-- 
1.9.1

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

* [PATCH v5 3/3] Bluetooth: btqcomsmd: retieve BD address from DT
@ 2017-09-05 18:58     ` Loic Poulain
  0 siblings, 0 replies; 14+ messages in thread
From: Loic Poulain @ 2017-09-05 18:58 UTC (permalink / raw)
  To: marcel, johan.hedberg, robh+dt
  Cc: linux-bluetooth, linux-arm-msm, devicetree, bjorn.andersson,
	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@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
 v5: remove 2/3 merged in bluetooth-next tree
     Add bluetooth.txt for common BT bindings
     expect local-bd-address in little-endian format

 drivers/bluetooth/btqcomsmd.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/bluetooth/btqcomsmd.c b/drivers/bluetooth/btqcomsmd.c
index bd810d0..c6d3fd9 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>
 
@@ -135,6 +137,7 @@ static int btqcomsmd_setup(struct hci_dev *hdev)
 
 static int btqcomsmd_probe(struct platform_device *pdev)
 {
+	const bdaddr_t *bdaddr;
 	struct btqcomsmd *btq;
 	struct hci_dev *hdev;
 	void *wcnss;
@@ -156,6 +159,15 @@ 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.
+	 */
+	bdaddr = of_get_property(pdev->dev.of_node, "local-bd-address", &ret);
+	if (bdaddr && ret == sizeof(bdaddr_t)) {
+		BT_INFO("BD address %pMR retrieved from device-tree", bdaddr);
+		bacpy(&btq->bdaddr, bdaddr);
+	}
+
 	hdev = hci_alloc_dev();
 	if (!hdev)
 		return -ENOMEM;
-- 
1.9.1

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

* Re: [PATCH v5 3/3] Bluetooth: btqcomsmd: retieve BD address from DT
  2017-09-05 18:58     ` Loic Poulain
@ 2017-09-05 21:47         ` Rob Herring
  -1 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2017-09-05 21:47 UTC (permalink / raw)
  To: Loic Poulain
  Cc: Marcel Holtmann, Johan Hedberg, open list:BLUETOOTH DRIVERS,
	linux-arm-msm, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Bjorn Andersson

On Tue, Sep 5, 2017 at 1:58 PM, Loic Poulain <loic.poulain-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
> 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
>  v5: remove 2/3 merged in bluetooth-next tree
>      Add bluetooth.txt for common BT bindings
>      expect local-bd-address in little-endian format
>
>  drivers/bluetooth/btqcomsmd.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/bluetooth/btqcomsmd.c b/drivers/bluetooth/btqcomsmd.c
> index bd810d0..c6d3fd9 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>
>
> @@ -135,6 +137,7 @@ static int btqcomsmd_setup(struct hci_dev *hdev)
>
>  static int btqcomsmd_probe(struct platform_device *pdev)
>  {
> +       const bdaddr_t *bdaddr;
>         struct btqcomsmd *btq;
>         struct hci_dev *hdev;
>         void *wcnss;
> @@ -156,6 +159,15 @@ 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.
> +        */
> +       bdaddr = of_get_property(pdev->dev.of_node, "local-bd-address", &ret);
> +       if (bdaddr && ret == sizeof(bdaddr_t)) {
> +               BT_INFO("BD address %pMR retrieved from device-tree", bdaddr);
> +               bacpy(&btq->bdaddr, bdaddr);
> +       }

Can we put all this into a helper function before we get more
instances. And use the u8 array property function. We're trying to
make of_get_property an internal function.

Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v5 3/3] Bluetooth: btqcomsmd: retieve BD address from DT
@ 2017-09-05 21:47         ` Rob Herring
  0 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2017-09-05 21:47 UTC (permalink / raw)
  To: Loic Poulain
  Cc: Marcel Holtmann, Johan Hedberg, open list:BLUETOOTH DRIVERS,
	linux-arm-msm, devicetree, Bjorn Andersson

On Tue, Sep 5, 2017 at 1:58 PM, Loic Poulain <loic.poulain@linaro.org> wrote:
> 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@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
>  v5: remove 2/3 merged in bluetooth-next tree
>      Add bluetooth.txt for common BT bindings
>      expect local-bd-address in little-endian format
>
>  drivers/bluetooth/btqcomsmd.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/bluetooth/btqcomsmd.c b/drivers/bluetooth/btqcomsmd.c
> index bd810d0..c6d3fd9 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>
>
> @@ -135,6 +137,7 @@ static int btqcomsmd_setup(struct hci_dev *hdev)
>
>  static int btqcomsmd_probe(struct platform_device *pdev)
>  {
> +       const bdaddr_t *bdaddr;
>         struct btqcomsmd *btq;
>         struct hci_dev *hdev;
>         void *wcnss;
> @@ -156,6 +159,15 @@ 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.
> +        */
> +       bdaddr = of_get_property(pdev->dev.of_node, "local-bd-address", &ret);
> +       if (bdaddr && ret == sizeof(bdaddr_t)) {
> +               BT_INFO("BD address %pMR retrieved from device-tree", bdaddr);
> +               bacpy(&btq->bdaddr, bdaddr);
> +       }

Can we put all this into a helper function before we get more
instances. And use the u8 array property function. We're trying to
make of_get_property an internal function.

Rob

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

* Re: [PATCH v5 3/3] Bluetooth: btqcomsmd: retieve BD address from DT
  2017-09-05 21:47         ` Rob Herring
@ 2017-09-06  7:04             ` Marcel Holtmann
  -1 siblings, 0 replies; 14+ messages in thread
From: Marcel Holtmann @ 2017-09-06  7:04 UTC (permalink / raw)
  To: Rob Herring
  Cc: Loic Poulain, Johan Hedberg, open list:BLUETOOTH DRIVERS,
	linux-arm-msm, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Bjorn Andersson

Hi Rob,

>> 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
>> v5: remove 2/3 merged in bluetooth-next tree
>>     Add bluetooth.txt for common BT bindings
>>     expect local-bd-address in little-endian format
>> 
>> drivers/bluetooth/btqcomsmd.c | 12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>> 
>> diff --git a/drivers/bluetooth/btqcomsmd.c b/drivers/bluetooth/btqcomsmd.c
>> index bd810d0..c6d3fd9 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>
>> 
>> @@ -135,6 +137,7 @@ static int btqcomsmd_setup(struct hci_dev *hdev)
>> 
>> static int btqcomsmd_probe(struct platform_device *pdev)
>> {
>> +       const bdaddr_t *bdaddr;
>>        struct btqcomsmd *btq;
>>        struct hci_dev *hdev;
>>        void *wcnss;
>> @@ -156,6 +159,15 @@ 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.
>> +        */
>> +       bdaddr = of_get_property(pdev->dev.of_node, "local-bd-address", &ret);
>> +       if (bdaddr && ret == sizeof(bdaddr_t)) {
>> +               BT_INFO("BD address %pMR retrieved from device-tree", bdaddr);
>> +               bacpy(&btq->bdaddr, bdaddr);
>> +       }
> 
> Can we put all this into a helper function before we get more
> instances. And use the u8 array property function. We're trying to
> make of_get_property an internal function.

using of_property_read_u8_array seems sensible since that would shorten this into

	if (!of_property_read_u8_array(pdev->dev.of_node, “local-bd-address”, &btq->bdaddr, 6))
		bt_dev_info(pdev->dev, “BD address %pMR ..”, &btq->bdaddr);

Creating a Bluetooth internal helper function seems rather pointless at this stage. If more users appears, then we might need to move this into the Bluetooth core to deal with this. However as said before, I am not a big fan of IEEE address assignment via DT since that forces to have the smarts in the boot loader and the boot loader doing the right thing. There are too many boards and DT where this will not be true. In a lot of cases it would make more sense to store the BD address as part of your file system. Since we do support this in a total generic fashion, I rather push for that method and have the QCOM SMD based SoC being the exception.

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v5 3/3] Bluetooth: btqcomsmd: retieve BD address from DT
@ 2017-09-06  7:04             ` Marcel Holtmann
  0 siblings, 0 replies; 14+ messages in thread
From: Marcel Holtmann @ 2017-09-06  7:04 UTC (permalink / raw)
  To: Rob Herring
  Cc: Loic Poulain, Johan Hedberg, open list:BLUETOOTH DRIVERS,
	linux-arm-msm, devicetree, Bjorn Andersson

Hi Rob,

>> 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@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
>> v5: remove 2/3 merged in bluetooth-next tree
>>     Add bluetooth.txt for common BT bindings
>>     expect local-bd-address in little-endian format
>> 
>> drivers/bluetooth/btqcomsmd.c | 12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>> 
>> diff --git a/drivers/bluetooth/btqcomsmd.c b/drivers/bluetooth/btqcomsmd.c
>> index bd810d0..c6d3fd9 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>
>> 
>> @@ -135,6 +137,7 @@ static int btqcomsmd_setup(struct hci_dev *hdev)
>> 
>> static int btqcomsmd_probe(struct platform_device *pdev)
>> {
>> +       const bdaddr_t *bdaddr;
>>        struct btqcomsmd *btq;
>>        struct hci_dev *hdev;
>>        void *wcnss;
>> @@ -156,6 +159,15 @@ 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.
>> +        */
>> +       bdaddr = of_get_property(pdev->dev.of_node, "local-bd-address", &ret);
>> +       if (bdaddr && ret == sizeof(bdaddr_t)) {
>> +               BT_INFO("BD address %pMR retrieved from device-tree", bdaddr);
>> +               bacpy(&btq->bdaddr, bdaddr);
>> +       }
> 
> Can we put all this into a helper function before we get more
> instances. And use the u8 array property function. We're trying to
> make of_get_property an internal function.

using of_property_read_u8_array seems sensible since that would shorten this into

	if (!of_property_read_u8_array(pdev->dev.of_node, “local-bd-address”, &btq->bdaddr, 6))
		bt_dev_info(pdev->dev, “BD address %pMR ..”, &btq->bdaddr);

Creating a Bluetooth internal helper function seems rather pointless at this stage. If more users appears, then we might need to move this into the Bluetooth core to deal with this. However as said before, I am not a big fan of IEEE address assignment via DT since that forces to have the smarts in the boot loader and the boot loader doing the right thing. There are too many boards and DT where this will not be true. In a lot of cases it would make more sense to store the BD address as part of your file system. Since we do support this in a total generic fashion, I rather push for that method and have the QCOM SMD based SoC being the exception.

Regards

Marcel


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

* Re: [PATCH v5 3/3] Bluetooth: btqcomsmd: retieve BD address from DT
  2017-09-06  7:04             ` Marcel Holtmann
@ 2017-09-07 15:50                 ` Rob Herring
  -1 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2017-09-07 15:50 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Loic Poulain, Johan Hedberg, open list:BLUETOOTH DRIVERS,
	linux-arm-msm, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Bjorn Andersson

On Wed, Sep 6, 2017 at 2:04 AM, Marcel Holtmann <marcel-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org> wrote:
> Hi Rob,
>
>>> 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>

[...]

>>> +       /* The local-bd-address DT property is usually injected by the
>>> +        * bootloader which has access to the allocated BD address.
>>> +        */
>>> +       bdaddr = of_get_property(pdev->dev.of_node, "local-bd-address", &ret);
>>> +       if (bdaddr && ret == sizeof(bdaddr_t)) {
>>> +               BT_INFO("BD address %pMR retrieved from device-tree", bdaddr);
>>> +               bacpy(&btq->bdaddr, bdaddr);
>>> +       }
>>
>> Can we put all this into a helper function before we get more
>> instances. And use the u8 array property function. We're trying to
>> make of_get_property an internal function.
>
> using of_property_read_u8_array seems sensible since that would shorten this into
>
>         if (!of_property_read_u8_array(pdev->dev.of_node, “local-bd-address”, &btq->bdaddr, 6))
>                 bt_dev_info(pdev->dev, “BD address %pMR ..”, &btq->bdaddr);
>

Yes.

> Creating a Bluetooth internal helper function seems rather pointless at this stage. If more users appears, then we might need to move this into the Bluetooth core to deal with this. However as said before, I am not a big fan of IEEE address assignment via DT since that forces to have the smarts in the boot loader and the boot loader doing the right thing. There are too many boards and DT where this will not be true. In a lot of cases it would make more sense to store the BD address as part of your file system. Since we do support this in a total generic fashion, I rather push for that method and have the QCOM SMD based SoC being the exception.

Okay, sounds reasonable and it's your call anyway.

Rob

BTW, your mails are always quoted-printable encoding which shouldn't
be used on lists AIUI.

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

* Re: [PATCH v5 3/3] Bluetooth: btqcomsmd: retieve BD address from DT
@ 2017-09-07 15:50                 ` Rob Herring
  0 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2017-09-07 15:50 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Loic Poulain, Johan Hedberg, open list:BLUETOOTH DRIVERS,
	linux-arm-msm, devicetree, Bjorn Andersson

On Wed, Sep 6, 2017 at 2:04 AM, Marcel Holtmann <marcel@holtmann.org> wrote=
:
> Hi Rob,
>
>>> 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@linaro.org>

[...]

>>> +       /* The local-bd-address DT property is usually injected by the
>>> +        * bootloader which has access to the allocated BD address.
>>> +        */
>>> +       bdaddr =3D of_get_property(pdev->dev.of_node, "local-bd-address=
", &ret);
>>> +       if (bdaddr && ret =3D=3D sizeof(bdaddr_t)) {
>>> +               BT_INFO("BD address %pMR retrieved from device-tree", b=
daddr);
>>> +               bacpy(&btq->bdaddr, bdaddr);
>>> +       }
>>
>> Can we put all this into a helper function before we get more
>> instances. And use the u8 array property function. We're trying to
>> make of_get_property an internal function.
>
> using of_property_read_u8_array seems sensible since that would shorten t=
his into
>
>         if (!of_property_read_u8_array(pdev->dev.of_node, =E2=80=9Clocal-=
bd-address=E2=80=9D, &btq->bdaddr, 6))
>                 bt_dev_info(pdev->dev, =E2=80=9CBD address %pMR ..=E2=80=
=9D, &btq->bdaddr);
>

Yes.

> Creating a Bluetooth internal helper function seems rather pointless at t=
his stage. If more users appears, then we might need to move this into the =
Bluetooth core to deal with this. However as said before, I am not a big fa=
n of IEEE address assignment via DT since that forces to have the smarts in=
 the boot loader and the boot loader doing the right thing. There are too m=
any boards and DT where this will not be true. In a lot of cases it would m=
ake more sense to store the BD address as part of your file system. Since w=
e do support this in a total generic fashion, I rather push for that method=
 and have the QCOM SMD based SoC being the exception.

Okay, sounds reasonable and it's your call anyway.

Rob

BTW, your mails are always quoted-printable encoding which shouldn't
be used on lists AIUI.

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

* Re: [PATCH v5 1/3] DT: net: document Bluetooth bindings in one place
  2017-09-05 18:58 ` Loic Poulain
@ 2017-09-13 16:21     ` Rob Herring
  -1 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2017-09-13 16:21 UTC (permalink / raw)
  To: Loic Poulain
  Cc: marcel-kz+m5ild9QBg9hUCZPvPmw,
	johan.hedberg-Re5JQEeQqe8AvxtiuMwx3w,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-msm-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A, lpoulain

On Tue, Sep 05, 2017 at 08:58:41PM +0200, Loic Poulain wrote:
> From: lpoulain <loic.poulain-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> 
> In the same way as Ethernet, gather the Bluetooth related bindings in
> one file. Introduce the bluetooth-bd-address property which can be used
> to store the assigned BD address.
> 
> Signed-off-by: lpoulain <loic.poulain-Re5JQEeQqe8AvxtiuMwx3w@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
>  v5: remove 2/3 merged in bluetooth-next tree
>      Add bluetooth.txt for common BT bindings
>      expect local-bd-address in little-endian format
> 
>  Documentation/devicetree/bindings/net/bluetooth.txt | 5 +++++
>  1 file changed, 5 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/bluetooth.txt

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

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

* Re: [PATCH v5 1/3] DT: net: document Bluetooth bindings in one place
@ 2017-09-13 16:21     ` Rob Herring
  0 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2017-09-13 16:21 UTC (permalink / raw)
  To: Loic Poulain
  Cc: marcel, johan.hedberg, linux-bluetooth, linux-arm-msm,
	devicetree, bjorn.andersson, lpoulain

On Tue, Sep 05, 2017 at 08:58:41PM +0200, Loic Poulain wrote:
> From: lpoulain <loic.poulain@gmail.com>
> 
> In the same way as Ethernet, gather the Bluetooth related bindings in
> one file. Introduce the bluetooth-bd-address property which can be used
> to store the assigned BD address.
> 
> Signed-off-by: lpoulain <loic.poulain@gmail.com>
> ---
>  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
>  v5: remove 2/3 merged in bluetooth-next tree
>      Add bluetooth.txt for common BT bindings
>      expect local-bd-address in little-endian format
> 
>  Documentation/devicetree/bindings/net/bluetooth.txt | 5 +++++
>  1 file changed, 5 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/bluetooth.txt

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v5 2/3] dt-bindings: soc: qcom: Add local-bd-address property to WCNSS-BT
  2017-09-05 18:58 ` [PATCH v5 2/3] dt-bindings: soc: qcom: Add local-bd-address property to WCNSS-BT Loic Poulain
@ 2017-09-13 16:21   ` Rob Herring
  0 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2017-09-13 16:21 UTC (permalink / raw)
  To: Loic Poulain
  Cc: marcel, johan.hedberg, linux-bluetooth, linux-arm-msm,
	devicetree, bjorn.andersson

On Tue, Sep 05, 2017 at 08:58:42PM +0200, Loic Poulain wrote:
> 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
>  v5: remove 2/3 merged in bluetooth-next tree
>      Add bluetooth.txt for common BT bindings
>      expect local-bd-address in little-endian format
> 
>  Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt | 8 ++++++++
>  1 file changed, 8 insertions(+)

Acked-by: Rob Herring <robh@kernel.org>

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

end of thread, other threads:[~2017-09-13 16:21 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-05 18:58 [PATCH v5 1/3] DT: net: document Bluetooth bindings in one place Loic Poulain
2017-09-05 18:58 ` Loic Poulain
2017-09-05 18:58 ` [PATCH v5 2/3] dt-bindings: soc: qcom: Add local-bd-address property to WCNSS-BT Loic Poulain
2017-09-13 16:21   ` Rob Herring
     [not found] ` <1504637923-21652-1-git-send-email-loic.poulain-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-09-05 18:58   ` [PATCH v5 3/3] Bluetooth: btqcomsmd: retieve BD address from DT Loic Poulain
2017-09-05 18:58     ` Loic Poulain
     [not found]     ` <1504637923-21652-3-git-send-email-loic.poulain-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-09-05 21:47       ` Rob Herring
2017-09-05 21:47         ` Rob Herring
     [not found]         ` <CAL_JsqJhEaZkcBA6qnC3rVduQJ9Yesrz_h9i_WXo1bRaq1NT4Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-09-06  7:04           ` Marcel Holtmann
2017-09-06  7:04             ` Marcel Holtmann
     [not found]             ` <46A7D7AE-FDBB-424D-8E85-7180FEE24A14-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org>
2017-09-07 15:50               ` Rob Herring
2017-09-07 15:50                 ` Rob Herring
2017-09-13 16:21   ` [PATCH v5 1/3] DT: net: document Bluetooth bindings in one place Rob Herring
2017-09-13 16:21     ` Rob Herring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.