All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ARM64: dts: bcm2837-rpi-3-b: Add bcm43438 as serial slave device
@ 2017-07-31 10:03 ` Loic Poulain
  0 siblings, 0 replies; 10+ messages in thread
From: Loic Poulain @ 2017-07-31 10:03 UTC (permalink / raw)
  To: robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	f.fainelli-Re5JQEeQqe8AvxtiuMwx3w, rjui-dY08KVG/lbpWk0Htik3J/w,
	marcel-kz+m5ild9QBg9hUCZPvPmw
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Loic Poulain

Add BCM43438 as a slave device of uart0 (pl011/ttyAMA0).
This allows to automatically insert the bcm43438 to the bluetooth
subsystem instead of relying on userspace helpers (hciattach).

Overwrite bootargs to use aux uart (ttyS0) instead of ttyAMA0.

Signed-off-by: Loic Poulain <loic.poulain-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 .../devicetree/bindings/net/broadcom-bluetooth.txt | 29 ++++++++++++++++++++++
 arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts   | 17 +++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/broadcom-bluetooth.txt

diff --git a/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt b/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
new file mode 100644
index 0000000..c51ea1b
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
@@ -0,0 +1,29 @@
+Broadcom Bluetooth Chips
+---------------------
+
+This documents the binding structure and common properties for serial
+attached Broadcom devices.
+
+Serial attached Broadcom devices shall be a child node of the host UART
+device the slave device is attached to.
+
+Required properties:
+
+ - compatible: should contain one of the following:
+   * "brcm,bcm43438-bt"
+
+Optional properties:
+
+ - max-speed: see Documentation/devicetree/bindings/serial/slave-device.txt
+
+Example:
+
+&uart2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&uart2_pins>;
+
+       bluetooth {
+               compatible = "brcm,bcm43438-bt";
+               max-speed = <921600>;
+       };
+};
diff --git a/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts b/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts
index 972f14d..d0c669a 100644
--- a/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts
+++ b/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts
@@ -8,6 +8,11 @@
 	compatible = "raspberrypi,3-model-b", "brcm,bcm2837";
 	model = "Raspberry Pi 3 Model B";
 
+	chosen {
+		/* BCM2835 8250 auxiliar UART instead of pl011 */
+		bootargs = "console=ttyS0,115200 earlycon";
+	};
+
 	memory {
 		reg = <0 0x40000000>;
 	};
@@ -39,3 +44,15 @@
 	status = "okay";
 	bus-width = <4>;
 };
+
+/* UART0 is used to drive bcm43438 bluetooth controller */
+&uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_gpio32 &gpclk2_gpio43>;
+	status = "okay";
+
+	bluetooth {
+		compatible = "brcm,bcm43438-bt";
+		max-speed = <921600>;
+	};
+};
-- 
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] 10+ messages in thread

* [PATCH 1/2] ARM64: dts: bcm2837-rpi-3-b: Add bcm43438 as serial slave device
@ 2017-07-31 10:03 ` Loic Poulain
  0 siblings, 0 replies; 10+ messages in thread
From: Loic Poulain @ 2017-07-31 10:03 UTC (permalink / raw)
  To: robh+dt, f.fainelli, rjui, marcel
  Cc: devicetree, linux-bluetooth, linux-rpi-kernel, Loic Poulain

Add BCM43438 as a slave device of uart0 (pl011/ttyAMA0).
This allows to automatically insert the bcm43438 to the bluetooth
subsystem instead of relying on userspace helpers (hciattach).

Overwrite bootargs to use aux uart (ttyS0) instead of ttyAMA0.

Signed-off-by: Loic Poulain <loic.poulain@gmail.com>
---
 .../devicetree/bindings/net/broadcom-bluetooth.txt | 29 ++++++++++++++++++++++
 arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts   | 17 +++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/broadcom-bluetooth.txt

diff --git a/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt b/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
new file mode 100644
index 0000000..c51ea1b
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
@@ -0,0 +1,29 @@
+Broadcom Bluetooth Chips
+---------------------
+
+This documents the binding structure and common properties for serial
+attached Broadcom devices.
+
+Serial attached Broadcom devices shall be a child node of the host UART
+device the slave device is attached to.
+
+Required properties:
+
+ - compatible: should contain one of the following:
+   * "brcm,bcm43438-bt"
+
+Optional properties:
+
+ - max-speed: see Documentation/devicetree/bindings/serial/slave-device.txt
+
+Example:
+
+&uart2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&uart2_pins>;
+
+       bluetooth {
+               compatible = "brcm,bcm43438-bt";
+               max-speed = <921600>;
+       };
+};
diff --git a/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts b/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts
index 972f14d..d0c669a 100644
--- a/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts
+++ b/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts
@@ -8,6 +8,11 @@
 	compatible = "raspberrypi,3-model-b", "brcm,bcm2837";
 	model = "Raspberry Pi 3 Model B";
 
+	chosen {
+		/* BCM2835 8250 auxiliar UART instead of pl011 */
+		bootargs = "console=ttyS0,115200 earlycon";
+	};
+
 	memory {
 		reg = <0 0x40000000>;
 	};
@@ -39,3 +44,15 @@
 	status = "okay";
 	bus-width = <4>;
 };
+
+/* UART0 is used to drive bcm43438 bluetooth controller */
+&uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_gpio32 &gpclk2_gpio43>;
+	status = "okay";
+
+	bluetooth {
+		compatible = "brcm,bcm43438-bt";
+		max-speed = <921600>;
+	};
+};
-- 
1.9.1

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

* [PATCH 2/2] Bluetooth: hci_bcm: Add serdev support
  2017-07-31 10:03 ` Loic Poulain
@ 2017-07-31 10:03     ` Loic Poulain
  -1 siblings, 0 replies; 10+ messages in thread
From: Loic Poulain @ 2017-07-31 10:03 UTC (permalink / raw)
  To: robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	f.fainelli-Re5JQEeQqe8AvxtiuMwx3w, rjui-dY08KVG/lbpWk0Htik3J/w,
	marcel-kz+m5ild9QBg9hUCZPvPmw
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Loic Poulain

Add basic support for Broadcom serial slave devices.
Probe the serial device, retrieve its maximum speed and
register a new hci uart device.

Tested/compatible with bcm43438 (RPi3).

Signed-off-by: Loic Poulain <loic.poulain-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/bluetooth/hci_bcm.c | 82 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 78 insertions(+), 4 deletions(-)

diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index 6b42372..f824738 100644
--- a/drivers/bluetooth/hci_bcm.c
+++ b/drivers/bluetooth/hci_bcm.c
@@ -27,6 +27,7 @@
 #include <linux/firmware.h>
 #include <linux/module.h>
 #include <linux/acpi.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/gpio/consumer.h>
@@ -34,6 +35,7 @@
 #include <linux/interrupt.h>
 #include <linux/dmi.h>
 #include <linux/pm_runtime.h>
+#include <linux/serdev.h>
 
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
@@ -46,6 +48,7 @@
 
 #define BCM_AUTOSUSPEND_DELAY	5000 /* default autosleep delay */
 
+/* platform device driver resources */
 struct bcm_device {
 	struct list_head	list;
 
@@ -68,6 +71,12 @@ struct bcm_device {
 #endif
 };
 
+/* serdev driver resources */
+struct bcm_bt_device {
+	struct hci_uart hu;
+};
+
+/* generic bcm uart resources */
 struct bcm_data {
 	struct sk_buff		*rx_skb;
 	struct sk_buff_head	txq;
@@ -289,6 +298,11 @@ static int bcm_open(struct hci_uart *hu)
 
 	hu->priv = bcm;
 
+	if (hu->serdev) {
+		serdev_device_open(hu->serdev);
+		goto out;
+	}
+
 	if (!hu->tty->dev)
 		goto out;
 
@@ -323,6 +337,9 @@ static int bcm_close(struct hci_uart *hu)
 
 	bt_dev_dbg(hu->hdev, "hu %p", hu);
 
+	if (hu->serdev)
+		serdev_device_close(hu->serdev);
+
 	/* Protect bcm->dev against removal of the device or driver */
 	mutex_lock(&bcm_device_lock);
 	if (bcm_device_exists(bdev)) {
@@ -397,8 +414,12 @@ static int bcm_setup(struct hci_uart *hu)
 	else
 		speed = 0;
 
-	if (speed)
-		hci_uart_set_baudrate(hu, speed);
+	if (speed) {
+		if (hu->serdev)
+			serdev_device_set_baudrate(hu->serdev, speed);
+		else
+			hci_uart_set_baudrate(hu, speed);
+	}
 
 	/* Operational speed if any */
 	if (hu->oper_speed)
@@ -410,8 +431,12 @@ static int bcm_setup(struct hci_uart *hu)
 
 	if (speed) {
 		err = bcm_set_baudrate(hu, speed);
-		if (!err)
-			hci_uart_set_baudrate(hu, speed);
+		if (!err) {
+			if (hu->serdev)
+				serdev_device_set_baudrate(hu->serdev, speed);
+			else
+				hci_uart_set_baudrate(hu, speed);
+		}
 	}
 
 finalize:
@@ -903,9 +928,57 @@ static int bcm_remove(struct platform_device *pdev)
 	},
 };
 
+static int bcm_serdev_probe(struct serdev_device *serdev)
+{
+	struct bcm_bt_device *bcmdev;
+	u32 speed;
+	int err;
+
+	bcmdev = devm_kzalloc(&serdev->dev, sizeof(*bcmdev), GFP_KERNEL);
+	if (!bcmdev)
+		return -ENOMEM;
+
+	bcmdev->hu.serdev = serdev;
+	serdev_device_set_drvdata(serdev, bcmdev);
+
+	err = of_property_read_u32(serdev->dev.of_node, "max-speed", &speed);
+	if (!err)
+		bcmdev->hu.oper_speed = speed;
+
+	return hci_uart_register_device(&bcmdev->hu, &bcm_proto);
+}
+
+static void bcm_serdev_remove(struct serdev_device *serdev)
+{
+	struct bcm_bt_device *bcmdev = serdev_device_get_drvdata(serdev);
+
+	hci_uart_unregister_device(&bcmdev->hu);
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id bcm_bluetooth_of_match[] = {
+	{ .compatible = "brcm,bcm43438-bt" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, bcm_bluetooth_of_match);
+#endif
+
+static struct serdev_device_driver bcm_serdev_driver = {
+	.probe = bcm_serdev_probe,
+	.remove = bcm_serdev_remove,
+	.driver = {
+		.name = "hci_uart_bcm",
+		.of_match_table = of_match_ptr(bcm_bluetooth_of_match),
+	},
+};
+
 int __init bcm_init(void)
 {
+	/* For now, we need to keep both platform device
+	 * driver (ACPI generated) and serdev driver (DT).
+	 */
 	platform_driver_register(&bcm_driver);
+	serdev_device_driver_register(&bcm_serdev_driver);
 
 	return hci_uart_register_proto(&bcm_proto);
 }
@@ -913,6 +986,7 @@ int __init bcm_init(void)
 int __exit bcm_deinit(void)
 {
 	platform_driver_unregister(&bcm_driver);
+	serdev_device_driver_unregister(&bcm_serdev_driver);
 
 	return hci_uart_unregister_proto(&bcm_proto);
 }
-- 
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] 10+ messages in thread

* [PATCH 2/2] Bluetooth: hci_bcm: Add serdev support
@ 2017-07-31 10:03     ` Loic Poulain
  0 siblings, 0 replies; 10+ messages in thread
From: Loic Poulain @ 2017-07-31 10:03 UTC (permalink / raw)
  To: robh+dt, f.fainelli, rjui, marcel
  Cc: devicetree, linux-bluetooth, linux-rpi-kernel, Loic Poulain

Add basic support for Broadcom serial slave devices.
Probe the serial device, retrieve its maximum speed and
register a new hci uart device.

Tested/compatible with bcm43438 (RPi3).

Signed-off-by: Loic Poulain <loic.poulain@gmail.com>
---
 drivers/bluetooth/hci_bcm.c | 82 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 78 insertions(+), 4 deletions(-)

diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index 6b42372..f824738 100644
--- a/drivers/bluetooth/hci_bcm.c
+++ b/drivers/bluetooth/hci_bcm.c
@@ -27,6 +27,7 @@
 #include <linux/firmware.h>
 #include <linux/module.h>
 #include <linux/acpi.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/gpio/consumer.h>
@@ -34,6 +35,7 @@
 #include <linux/interrupt.h>
 #include <linux/dmi.h>
 #include <linux/pm_runtime.h>
+#include <linux/serdev.h>
 
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
@@ -46,6 +48,7 @@
 
 #define BCM_AUTOSUSPEND_DELAY	5000 /* default autosleep delay */
 
+/* platform device driver resources */
 struct bcm_device {
 	struct list_head	list;
 
@@ -68,6 +71,12 @@ struct bcm_device {
 #endif
 };
 
+/* serdev driver resources */
+struct bcm_bt_device {
+	struct hci_uart hu;
+};
+
+/* generic bcm uart resources */
 struct bcm_data {
 	struct sk_buff		*rx_skb;
 	struct sk_buff_head	txq;
@@ -289,6 +298,11 @@ static int bcm_open(struct hci_uart *hu)
 
 	hu->priv = bcm;
 
+	if (hu->serdev) {
+		serdev_device_open(hu->serdev);
+		goto out;
+	}
+
 	if (!hu->tty->dev)
 		goto out;
 
@@ -323,6 +337,9 @@ static int bcm_close(struct hci_uart *hu)
 
 	bt_dev_dbg(hu->hdev, "hu %p", hu);
 
+	if (hu->serdev)
+		serdev_device_close(hu->serdev);
+
 	/* Protect bcm->dev against removal of the device or driver */
 	mutex_lock(&bcm_device_lock);
 	if (bcm_device_exists(bdev)) {
@@ -397,8 +414,12 @@ static int bcm_setup(struct hci_uart *hu)
 	else
 		speed = 0;
 
-	if (speed)
-		hci_uart_set_baudrate(hu, speed);
+	if (speed) {
+		if (hu->serdev)
+			serdev_device_set_baudrate(hu->serdev, speed);
+		else
+			hci_uart_set_baudrate(hu, speed);
+	}
 
 	/* Operational speed if any */
 	if (hu->oper_speed)
@@ -410,8 +431,12 @@ static int bcm_setup(struct hci_uart *hu)
 
 	if (speed) {
 		err = bcm_set_baudrate(hu, speed);
-		if (!err)
-			hci_uart_set_baudrate(hu, speed);
+		if (!err) {
+			if (hu->serdev)
+				serdev_device_set_baudrate(hu->serdev, speed);
+			else
+				hci_uart_set_baudrate(hu, speed);
+		}
 	}
 
 finalize:
@@ -903,9 +928,57 @@ static int bcm_remove(struct platform_device *pdev)
 	},
 };
 
+static int bcm_serdev_probe(struct serdev_device *serdev)
+{
+	struct bcm_bt_device *bcmdev;
+	u32 speed;
+	int err;
+
+	bcmdev = devm_kzalloc(&serdev->dev, sizeof(*bcmdev), GFP_KERNEL);
+	if (!bcmdev)
+		return -ENOMEM;
+
+	bcmdev->hu.serdev = serdev;
+	serdev_device_set_drvdata(serdev, bcmdev);
+
+	err = of_property_read_u32(serdev->dev.of_node, "max-speed", &speed);
+	if (!err)
+		bcmdev->hu.oper_speed = speed;
+
+	return hci_uart_register_device(&bcmdev->hu, &bcm_proto);
+}
+
+static void bcm_serdev_remove(struct serdev_device *serdev)
+{
+	struct bcm_bt_device *bcmdev = serdev_device_get_drvdata(serdev);
+
+	hci_uart_unregister_device(&bcmdev->hu);
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id bcm_bluetooth_of_match[] = {
+	{ .compatible = "brcm,bcm43438-bt" },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, bcm_bluetooth_of_match);
+#endif
+
+static struct serdev_device_driver bcm_serdev_driver = {
+	.probe = bcm_serdev_probe,
+	.remove = bcm_serdev_remove,
+	.driver = {
+		.name = "hci_uart_bcm",
+		.of_match_table = of_match_ptr(bcm_bluetooth_of_match),
+	},
+};
+
 int __init bcm_init(void)
 {
+	/* For now, we need to keep both platform device
+	 * driver (ACPI generated) and serdev driver (DT).
+	 */
 	platform_driver_register(&bcm_driver);
+	serdev_device_driver_register(&bcm_serdev_driver);
 
 	return hci_uart_register_proto(&bcm_proto);
 }
@@ -913,6 +986,7 @@ int __init bcm_init(void)
 int __exit bcm_deinit(void)
 {
 	platform_driver_unregister(&bcm_driver);
+	serdev_device_driver_unregister(&bcm_serdev_driver);
 
 	return hci_uart_unregister_proto(&bcm_proto);
 }
-- 
1.9.1

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

* Re: [PATCH 1/2] ARM64: dts: bcm2837-rpi-3-b: Add bcm43438 as serial slave device
  2017-07-31 10:03 ` Loic Poulain
@ 2017-07-31 19:56     ` Stefan Wahren
  -1 siblings, 0 replies; 10+ messages in thread
From: Stefan Wahren @ 2017-07-31 19:56 UTC (permalink / raw)
  To: Loic Poulain
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, rjui-dY08KVG/lbpWk0Htik3J/w,
	marcel-kz+m5ild9QBg9hUCZPvPmw,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Hi Loic,

> Loic Poulain <loic.poulain-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> hat am 31. Juli 2017 um 12:03 geschrieben:
> 
> 
> Add BCM43438 as a slave device of uart0 (pl011/ttyAMA0).
> This allows to automatically insert the bcm43438 to the bluetooth
> subsystem instead of relying on userspace helpers (hciattach).
> 
> Overwrite bootargs to use aux uart (ttyS0) instead of ttyAMA0.
> 
> Signed-off-by: Loic Poulain <loic.poulain-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

i'm very happy to see this patch series and i can't wait to adapt it for RPI Zero W.

> ---
>  .../devicetree/bindings/net/broadcom-bluetooth.txt | 29 ++++++++++++++++++++++
>  arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts   | 17 +++++++++++++
>  2 files changed, 46 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
> 
> diff --git a/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt b/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
> new file mode 100644
> index 0000000..c51ea1b
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
> @@ -0,0 +1,29 @@
> +Broadcom Bluetooth Chips
> +---------------------
> +
> +This documents the binding structure and common properties for serial
> +attached Broadcom devices.
> +
> +Serial attached Broadcom devices shall be a child node of the host UART
> +device the slave device is attached to.
> +
> +Required properties:
> +
> + - compatible: should contain one of the following:
> +   * "brcm,bcm43438-bt"
> +
> +Optional properties:
> +
> + - max-speed: see Documentation/devicetree/bindings/serial/slave-device.txt
> +
> +Example:
> +
> +&uart2 {
> +       pinctrl-names = "default";
> +       pinctrl-0 = <&uart2_pins>;
> +
> +       bluetooth {
> +               compatible = "brcm,bcm43438-bt";
> +               max-speed = <921600>;
> +       };
> +};

This binding looks good to me, but please send it as a separate patch at first.

> diff --git a/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts b/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts
> index 972f14d..d0c669a 100644
> --- a/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts
> +++ b/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts
> @@ -8,6 +8,11 @@
>  	compatible = "raspberrypi,3-model-b", "brcm,bcm2837";
>  	model = "Raspberry Pi 3 Model B";
>  
> +	chosen {
> +		/* BCM2835 8250 auxiliar UART instead of pl011 */
> +		bootargs = "console=ttyS0,115200 earlycon";
> +	};
> +
>  	memory {
>  		reg = <0 0x40000000>;
>  	};
> @@ -39,3 +44,15 @@
>  	status = "okay";
>  	bus-width = <4>;
>  };
> +
> +/* UART0 is used to drive bcm43438 bluetooth controller */
> +&uart0 {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&uart0_gpio32 &gpclk2_gpio43>;
> +	status = "okay";
> +
> +	bluetooth {
> +		compatible = "brcm,bcm43438-bt";
> +		max-speed = <921600>;
> +	};
> +};
> -- 
> 1.9.1

This also looks good, but this conflicts with the recent changes (which will be applied soon):

[PATCH v2] ARM: dts: bcm283x: Move the BCM2837 DT contents from arm64 to arm.
[PATCH V2 0/3] ARM: bcm283x: Raspberry Pi Zero W support

Last question: how about another patch to enable serdev support as module for arm64/defconfig?

Best regards
Stefan

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

* Re: [PATCH 1/2] ARM64: dts: bcm2837-rpi-3-b: Add bcm43438 as serial slave device
@ 2017-07-31 19:56     ` Stefan Wahren
  0 siblings, 0 replies; 10+ messages in thread
From: Stefan Wahren @ 2017-07-31 19:56 UTC (permalink / raw)
  To: Loic Poulain
  Cc: linux-rpi-kernel, linux-bluetooth, rjui, devicetree, robh+dt,
	f.fainelli, marcel

Hi Loic,

> Loic Poulain <loic.poulain@gmail.com> hat am 31. Juli 2017 um 12:03 geschrieben:
> 
> 
> Add BCM43438 as a slave device of uart0 (pl011/ttyAMA0).
> This allows to automatically insert the bcm43438 to the bluetooth
> subsystem instead of relying on userspace helpers (hciattach).
> 
> Overwrite bootargs to use aux uart (ttyS0) instead of ttyAMA0.
> 
> Signed-off-by: Loic Poulain <loic.poulain@gmail.com>

i'm very happy to see this patch series and i can't wait to adapt it for RPI Zero W.

> ---
>  .../devicetree/bindings/net/broadcom-bluetooth.txt | 29 ++++++++++++++++++++++
>  arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts   | 17 +++++++++++++
>  2 files changed, 46 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
> 
> diff --git a/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt b/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
> new file mode 100644
> index 0000000..c51ea1b
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
> @@ -0,0 +1,29 @@
> +Broadcom Bluetooth Chips
> +---------------------
> +
> +This documents the binding structure and common properties for serial
> +attached Broadcom devices.
> +
> +Serial attached Broadcom devices shall be a child node of the host UART
> +device the slave device is attached to.
> +
> +Required properties:
> +
> + - compatible: should contain one of the following:
> +   * "brcm,bcm43438-bt"
> +
> +Optional properties:
> +
> + - max-speed: see Documentation/devicetree/bindings/serial/slave-device.txt
> +
> +Example:
> +
> +&uart2 {
> +       pinctrl-names = "default";
> +       pinctrl-0 = <&uart2_pins>;
> +
> +       bluetooth {
> +               compatible = "brcm,bcm43438-bt";
> +               max-speed = <921600>;
> +       };
> +};

This binding looks good to me, but please send it as a separate patch at first.

> diff --git a/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts b/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts
> index 972f14d..d0c669a 100644
> --- a/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts
> +++ b/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dts
> @@ -8,6 +8,11 @@
>  	compatible = "raspberrypi,3-model-b", "brcm,bcm2837";
>  	model = "Raspberry Pi 3 Model B";
>  
> +	chosen {
> +		/* BCM2835 8250 auxiliar UART instead of pl011 */
> +		bootargs = "console=ttyS0,115200 earlycon";
> +	};
> +
>  	memory {
>  		reg = <0 0x40000000>;
>  	};
> @@ -39,3 +44,15 @@
>  	status = "okay";
>  	bus-width = <4>;
>  };
> +
> +/* UART0 is used to drive bcm43438 bluetooth controller */
> +&uart0 {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&uart0_gpio32 &gpclk2_gpio43>;
> +	status = "okay";
> +
> +	bluetooth {
> +		compatible = "brcm,bcm43438-bt";
> +		max-speed = <921600>;
> +	};
> +};
> -- 
> 1.9.1

This also looks good, but this conflicts with the recent changes (which will be applied soon):

[PATCH v2] ARM: dts: bcm283x: Move the BCM2837 DT contents from arm64 to arm.
[PATCH V2 0/3] ARM: bcm283x: Raspberry Pi Zero W support

Last question: how about another patch to enable serdev support as module for arm64/defconfig?

Best regards
Stefan

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

* Re: [PATCH 2/2] Bluetooth: hci_bcm: Add serdev support
  2017-07-31 10:03     ` Loic Poulain
@ 2017-08-07  6:58         ` Peter Robinson
  -1 siblings, 0 replies; 10+ messages in thread
From: Peter Robinson @ 2017-08-07  6:58 UTC (permalink / raw)
  To: Loic Poulain
  Cc: robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	f.fainelli-Re5JQEeQqe8AvxtiuMwx3w, rjui-dY08KVG/lbpWk0Htik3J/w,
	marcel-kz+m5ild9QBg9hUCZPvPmw, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA

On Mon, Jul 31, 2017 at 11:03 AM, Loic Poulain <loic.poulain-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Add basic support for Broadcom serial slave devices.
> Probe the serial device, retrieve its maximum speed and
> register a new hci uart device.
>
> Tested/compatible with bcm43438 (RPi3).
>
> Signed-off-by: Loic Poulain <loic.poulain-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/bluetooth/hci_bcm.c | 82 ++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 78 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
> index 6b42372..f824738 100644
> --- a/drivers/bluetooth/hci_bcm.c
> +++ b/drivers/bluetooth/hci_bcm.c
> @@ -27,6 +27,7 @@
>  #include <linux/firmware.h>
>  #include <linux/module.h>
>  #include <linux/acpi.h>
> +#include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/clk.h>
>  #include <linux/gpio/consumer.h>
> @@ -34,6 +35,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/dmi.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/serdev.h>
>
>  #include <net/bluetooth/bluetooth.h>
>  #include <net/bluetooth/hci_core.h>
> @@ -46,6 +48,7 @@
>
>  #define BCM_AUTOSUSPEND_DELAY  5000 /* default autosleep delay */
>
> +/* platform device driver resources */
>  struct bcm_device {
>         struct list_head        list;
>
> @@ -68,6 +71,12 @@ struct bcm_device {
>  #endif
>  };
>
> +/* serdev driver resources */
> +struct bcm_bt_device {
> +       struct hci_uart hu;
> +};
> +
> +/* generic bcm uart resources */
>  struct bcm_data {
>         struct sk_buff          *rx_skb;
>         struct sk_buff_head     txq;
> @@ -289,6 +298,11 @@ static int bcm_open(struct hci_uart *hu)
>
>         hu->priv = bcm;
>
> +       if (hu->serdev) {
> +               serdev_device_open(hu->serdev);
> +               goto out;
> +       }
> +
>         if (!hu->tty->dev)
>                 goto out;
>
> @@ -323,6 +337,9 @@ static int bcm_close(struct hci_uart *hu)
>
>         bt_dev_dbg(hu->hdev, "hu %p", hu);
>
> +       if (hu->serdev)
> +               serdev_device_close(hu->serdev);
> +
>         /* Protect bcm->dev against removal of the device or driver */
>         mutex_lock(&bcm_device_lock);
>         if (bcm_device_exists(bdev)) {
> @@ -397,8 +414,12 @@ static int bcm_setup(struct hci_uart *hu)
>         else
>                 speed = 0;
>
> -       if (speed)
> -               hci_uart_set_baudrate(hu, speed);
> +       if (speed) {
> +               if (hu->serdev)
> +                       serdev_device_set_baudrate(hu->serdev, speed);
> +               else
> +                       hci_uart_set_baudrate(hu, speed);
> +       }
>
>         /* Operational speed if any */
>         if (hu->oper_speed)
> @@ -410,8 +431,12 @@ static int bcm_setup(struct hci_uart *hu)
>
>         if (speed) {
>                 err = bcm_set_baudrate(hu, speed);
> -               if (!err)
> -                       hci_uart_set_baudrate(hu, speed);
> +               if (!err) {
> +                       if (hu->serdev)
> +                               serdev_device_set_baudrate(hu->serdev, speed);
> +                       else
> +                               hci_uart_set_baudrate(hu, speed);
> +               }
>         }
>
>  finalize:
> @@ -903,9 +928,57 @@ static int bcm_remove(struct platform_device *pdev)
>         },
>  };
>
> +static int bcm_serdev_probe(struct serdev_device *serdev)
> +{
> +       struct bcm_bt_device *bcmdev;
> +       u32 speed;
> +       int err;
> +
> +       bcmdev = devm_kzalloc(&serdev->dev, sizeof(*bcmdev), GFP_KERNEL);
> +       if (!bcmdev)
> +               return -ENOMEM;
> +
> +       bcmdev->hu.serdev = serdev;
> +       serdev_device_set_drvdata(serdev, bcmdev);
> +
> +       err = of_property_read_u32(serdev->dev.of_node, "max-speed", &speed);
> +       if (!err)
> +               bcmdev->hu.oper_speed = speed;
> +
> +       return hci_uart_register_device(&bcmdev->hu, &bcm_proto);
> +}
> +
> +static void bcm_serdev_remove(struct serdev_device *serdev)
> +{
> +       struct bcm_bt_device *bcmdev = serdev_device_get_drvdata(serdev);
> +
> +       hci_uart_unregister_device(&bcmdev->hu);
> +}

I'm seeing the following warning when building this with Fedora-26/gcc7:

drivers/bluetooth/hci_bcm.c: In function 'bcm_serdev_remove':
drivers/bluetooth/hci_bcm.c:953:2: error: implicit declaration of
function 'hci_uart_unregister_device'; did you mean
'hci_uart_register_device'? [-Werror=implicit-function-declaration]
  hci_uart_unregister_device(&bcmdev->hu);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~
  hci_uart_register_device
cc1: some warnings being treated as errors

> +#ifdef CONFIG_OF
> +static const struct of_device_id bcm_bluetooth_of_match[] = {
> +       { .compatible = "brcm,bcm43438-bt" },
> +       { },
> +};
> +MODULE_DEVICE_TABLE(of, bcm_bluetooth_of_match);
> +#endif
> +
> +static struct serdev_device_driver bcm_serdev_driver = {
> +       .probe = bcm_serdev_probe,
> +       .remove = bcm_serdev_remove,
> +       .driver = {
> +               .name = "hci_uart_bcm",
> +               .of_match_table = of_match_ptr(bcm_bluetooth_of_match),
> +       },
> +};
> +
>  int __init bcm_init(void)
>  {
> +       /* For now, we need to keep both platform device
> +        * driver (ACPI generated) and serdev driver (DT).
> +        */
>         platform_driver_register(&bcm_driver);
> +       serdev_device_driver_register(&bcm_serdev_driver);
>
>         return hci_uart_register_proto(&bcm_proto);
>  }
> @@ -913,6 +986,7 @@ int __init bcm_init(void)
>  int __exit bcm_deinit(void)
>  {
>         platform_driver_unregister(&bcm_driver);
> +       serdev_device_driver_unregister(&bcm_serdev_driver);
>
>         return hci_uart_unregister_proto(&bcm_proto);
>  }
> --
> 1.9.1
>
>
> _______________________________________________
> linux-rpi-kernel mailing list
> linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel

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

* Re: [PATCH 2/2] Bluetooth: hci_bcm: Add serdev support
@ 2017-08-07  6:58         ` Peter Robinson
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Robinson @ 2017-08-07  6:58 UTC (permalink / raw)
  To: Loic Poulain
  Cc: robh+dt, f.fainelli, rjui, marcel, devicetree, linux-rpi-kernel,
	linux-bluetooth

On Mon, Jul 31, 2017 at 11:03 AM, Loic Poulain <loic.poulain@gmail.com> wrote:
> Add basic support for Broadcom serial slave devices.
> Probe the serial device, retrieve its maximum speed and
> register a new hci uart device.
>
> Tested/compatible with bcm43438 (RPi3).
>
> Signed-off-by: Loic Poulain <loic.poulain@gmail.com>
> ---
>  drivers/bluetooth/hci_bcm.c | 82 ++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 78 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
> index 6b42372..f824738 100644
> --- a/drivers/bluetooth/hci_bcm.c
> +++ b/drivers/bluetooth/hci_bcm.c
> @@ -27,6 +27,7 @@
>  #include <linux/firmware.h>
>  #include <linux/module.h>
>  #include <linux/acpi.h>
> +#include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/clk.h>
>  #include <linux/gpio/consumer.h>
> @@ -34,6 +35,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/dmi.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/serdev.h>
>
>  #include <net/bluetooth/bluetooth.h>
>  #include <net/bluetooth/hci_core.h>
> @@ -46,6 +48,7 @@
>
>  #define BCM_AUTOSUSPEND_DELAY  5000 /* default autosleep delay */
>
> +/* platform device driver resources */
>  struct bcm_device {
>         struct list_head        list;
>
> @@ -68,6 +71,12 @@ struct bcm_device {
>  #endif
>  };
>
> +/* serdev driver resources */
> +struct bcm_bt_device {
> +       struct hci_uart hu;
> +};
> +
> +/* generic bcm uart resources */
>  struct bcm_data {
>         struct sk_buff          *rx_skb;
>         struct sk_buff_head     txq;
> @@ -289,6 +298,11 @@ static int bcm_open(struct hci_uart *hu)
>
>         hu->priv = bcm;
>
> +       if (hu->serdev) {
> +               serdev_device_open(hu->serdev);
> +               goto out;
> +       }
> +
>         if (!hu->tty->dev)
>                 goto out;
>
> @@ -323,6 +337,9 @@ static int bcm_close(struct hci_uart *hu)
>
>         bt_dev_dbg(hu->hdev, "hu %p", hu);
>
> +       if (hu->serdev)
> +               serdev_device_close(hu->serdev);
> +
>         /* Protect bcm->dev against removal of the device or driver */
>         mutex_lock(&bcm_device_lock);
>         if (bcm_device_exists(bdev)) {
> @@ -397,8 +414,12 @@ static int bcm_setup(struct hci_uart *hu)
>         else
>                 speed = 0;
>
> -       if (speed)
> -               hci_uart_set_baudrate(hu, speed);
> +       if (speed) {
> +               if (hu->serdev)
> +                       serdev_device_set_baudrate(hu->serdev, speed);
> +               else
> +                       hci_uart_set_baudrate(hu, speed);
> +       }
>
>         /* Operational speed if any */
>         if (hu->oper_speed)
> @@ -410,8 +431,12 @@ static int bcm_setup(struct hci_uart *hu)
>
>         if (speed) {
>                 err = bcm_set_baudrate(hu, speed);
> -               if (!err)
> -                       hci_uart_set_baudrate(hu, speed);
> +               if (!err) {
> +                       if (hu->serdev)
> +                               serdev_device_set_baudrate(hu->serdev, speed);
> +                       else
> +                               hci_uart_set_baudrate(hu, speed);
> +               }
>         }
>
>  finalize:
> @@ -903,9 +928,57 @@ static int bcm_remove(struct platform_device *pdev)
>         },
>  };
>
> +static int bcm_serdev_probe(struct serdev_device *serdev)
> +{
> +       struct bcm_bt_device *bcmdev;
> +       u32 speed;
> +       int err;
> +
> +       bcmdev = devm_kzalloc(&serdev->dev, sizeof(*bcmdev), GFP_KERNEL);
> +       if (!bcmdev)
> +               return -ENOMEM;
> +
> +       bcmdev->hu.serdev = serdev;
> +       serdev_device_set_drvdata(serdev, bcmdev);
> +
> +       err = of_property_read_u32(serdev->dev.of_node, "max-speed", &speed);
> +       if (!err)
> +               bcmdev->hu.oper_speed = speed;
> +
> +       return hci_uart_register_device(&bcmdev->hu, &bcm_proto);
> +}
> +
> +static void bcm_serdev_remove(struct serdev_device *serdev)
> +{
> +       struct bcm_bt_device *bcmdev = serdev_device_get_drvdata(serdev);
> +
> +       hci_uart_unregister_device(&bcmdev->hu);
> +}

I'm seeing the following warning when building this with Fedora-26/gcc7:

drivers/bluetooth/hci_bcm.c: In function 'bcm_serdev_remove':
drivers/bluetooth/hci_bcm.c:953:2: error: implicit declaration of
function 'hci_uart_unregister_device'; did you mean
'hci_uart_register_device'? [-Werror=implicit-function-declaration]
  hci_uart_unregister_device(&bcmdev->hu);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~
  hci_uart_register_device
cc1: some warnings being treated as errors

> +#ifdef CONFIG_OF
> +static const struct of_device_id bcm_bluetooth_of_match[] = {
> +       { .compatible = "brcm,bcm43438-bt" },
> +       { },
> +};
> +MODULE_DEVICE_TABLE(of, bcm_bluetooth_of_match);
> +#endif
> +
> +static struct serdev_device_driver bcm_serdev_driver = {
> +       .probe = bcm_serdev_probe,
> +       .remove = bcm_serdev_remove,
> +       .driver = {
> +               .name = "hci_uart_bcm",
> +               .of_match_table = of_match_ptr(bcm_bluetooth_of_match),
> +       },
> +};
> +
>  int __init bcm_init(void)
>  {
> +       /* For now, we need to keep both platform device
> +        * driver (ACPI generated) and serdev driver (DT).
> +        */
>         platform_driver_register(&bcm_driver);
> +       serdev_device_driver_register(&bcm_serdev_driver);
>
>         return hci_uart_register_proto(&bcm_proto);
>  }
> @@ -913,6 +986,7 @@ int __init bcm_init(void)
>  int __exit bcm_deinit(void)
>  {
>         platform_driver_unregister(&bcm_driver);
> +       serdev_device_driver_unregister(&bcm_serdev_driver);
>
>         return hci_uart_unregister_proto(&bcm_proto);
>  }
> --
> 1.9.1
>
>
> _______________________________________________
> linux-rpi-kernel mailing list
> linux-rpi-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel

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

* Re: [PATCH 2/2] Bluetooth: hci_bcm: Add serdev support
  2017-08-07  6:58         ` Peter Robinson
@ 2017-08-07  9:19             ` Marcel Holtmann
  -1 siblings, 0 replies; 10+ messages in thread
From: Marcel Holtmann @ 2017-08-07  9:19 UTC (permalink / raw)
  To: Peter Robinson
  Cc: Loic Poulain, Rob Herring, f.fainelli-Re5JQEeQqe8AvxtiuMwx3w,
	rjui-dY08KVG/lbpWk0Htik3J/w, devicetree,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA

Hi Peter,

>> Add basic support for Broadcom serial slave devices.
>> Probe the serial device, retrieve its maximum speed and
>> register a new hci uart device.
>> 
>> Tested/compatible with bcm43438 (RPi3).
>> 
>> Signed-off-by: Loic Poulain <loic.poulain-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> ---
>> drivers/bluetooth/hci_bcm.c | 82 ++++++++++++++++++++++++++++++++++++++++++---
>> 1 file changed, 78 insertions(+), 4 deletions(-)
>> 
>> diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
>> index 6b42372..f824738 100644
>> --- a/drivers/bluetooth/hci_bcm.c
>> +++ b/drivers/bluetooth/hci_bcm.c
>> @@ -27,6 +27,7 @@
>> #include <linux/firmware.h>
>> #include <linux/module.h>
>> #include <linux/acpi.h>
>> +#include <linux/of.h>
>> #include <linux/platform_device.h>
>> #include <linux/clk.h>
>> #include <linux/gpio/consumer.h>
>> @@ -34,6 +35,7 @@
>> #include <linux/interrupt.h>
>> #include <linux/dmi.h>
>> #include <linux/pm_runtime.h>
>> +#include <linux/serdev.h>
>> 
>> #include <net/bluetooth/bluetooth.h>
>> #include <net/bluetooth/hci_core.h>
>> @@ -46,6 +48,7 @@
>> 
>> #define BCM_AUTOSUSPEND_DELAY  5000 /* default autosleep delay */
>> 
>> +/* platform device driver resources */
>> struct bcm_device {
>>        struct list_head        list;
>> 
>> @@ -68,6 +71,12 @@ struct bcm_device {
>> #endif
>> };
>> 
>> +/* serdev driver resources */
>> +struct bcm_bt_device {
>> +       struct hci_uart hu;
>> +};
>> +
>> +/* generic bcm uart resources */
>> struct bcm_data {
>>        struct sk_buff          *rx_skb;
>>        struct sk_buff_head     txq;
>> @@ -289,6 +298,11 @@ static int bcm_open(struct hci_uart *hu)
>> 
>>        hu->priv = bcm;
>> 
>> +       if (hu->serdev) {
>> +               serdev_device_open(hu->serdev);
>> +               goto out;
>> +       }
>> +
>>        if (!hu->tty->dev)
>>                goto out;
>> 
>> @@ -323,6 +337,9 @@ static int bcm_close(struct hci_uart *hu)
>> 
>>        bt_dev_dbg(hu->hdev, "hu %p", hu);
>> 
>> +       if (hu->serdev)
>> +               serdev_device_close(hu->serdev);
>> +
>>        /* Protect bcm->dev against removal of the device or driver */
>>        mutex_lock(&bcm_device_lock);
>>        if (bcm_device_exists(bdev)) {
>> @@ -397,8 +414,12 @@ static int bcm_setup(struct hci_uart *hu)
>>        else
>>                speed = 0;
>> 
>> -       if (speed)
>> -               hci_uart_set_baudrate(hu, speed);
>> +       if (speed) {
>> +               if (hu->serdev)
>> +                       serdev_device_set_baudrate(hu->serdev, speed);
>> +               else
>> +                       hci_uart_set_baudrate(hu, speed);
>> +       }
>> 
>>        /* Operational speed if any */
>>        if (hu->oper_speed)
>> @@ -410,8 +431,12 @@ static int bcm_setup(struct hci_uart *hu)
>> 
>>        if (speed) {
>>                err = bcm_set_baudrate(hu, speed);
>> -               if (!err)
>> -                       hci_uart_set_baudrate(hu, speed);
>> +               if (!err) {
>> +                       if (hu->serdev)
>> +                               serdev_device_set_baudrate(hu->serdev, speed);
>> +                       else
>> +                               hci_uart_set_baudrate(hu, speed);
>> +               }
>>        }
>> 
>> finalize:
>> @@ -903,9 +928,57 @@ static int bcm_remove(struct platform_device *pdev)
>>        },
>> };
>> 
>> +static int bcm_serdev_probe(struct serdev_device *serdev)
>> +{
>> +       struct bcm_bt_device *bcmdev;
>> +       u32 speed;
>> +       int err;
>> +
>> +       bcmdev = devm_kzalloc(&serdev->dev, sizeof(*bcmdev), GFP_KERNEL);
>> +       if (!bcmdev)
>> +               return -ENOMEM;
>> +
>> +       bcmdev->hu.serdev = serdev;
>> +       serdev_device_set_drvdata(serdev, bcmdev);
>> +
>> +       err = of_property_read_u32(serdev->dev.of_node, "max-speed", &speed);
>> +       if (!err)
>> +               bcmdev->hu.oper_speed = speed;
>> +
>> +       return hci_uart_register_device(&bcmdev->hu, &bcm_proto);
>> +}
>> +
>> +static void bcm_serdev_remove(struct serdev_device *serdev)
>> +{
>> +       struct bcm_bt_device *bcmdev = serdev_device_get_drvdata(serdev);
>> +
>> +       hci_uart_unregister_device(&bcmdev->hu);
>> +}
> 
> I'm seeing the following warning when building this with Fedora-26/gcc7:
> 
> drivers/bluetooth/hci_bcm.c: In function 'bcm_serdev_remove':
> drivers/bluetooth/hci_bcm.c:953:2: error: implicit declaration of
> function 'hci_uart_unregister_device'; did you mean
> 'hci_uart_register_device'? [-Werror=implicit-function-declaration]
>  hci_uart_unregister_device(&bcmdev->hu);
>  ^~~~~~~~~~~~~~~~~~~~~~~~~~
>  hci_uart_register_device
> cc1: some warnings being treated as errors

you might be missing some patches that are already in bluetooth-next and net-next.

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] 10+ messages in thread

* Re: [PATCH 2/2] Bluetooth: hci_bcm: Add serdev support
@ 2017-08-07  9:19             ` Marcel Holtmann
  0 siblings, 0 replies; 10+ messages in thread
From: Marcel Holtmann @ 2017-08-07  9:19 UTC (permalink / raw)
  To: Peter Robinson
  Cc: Loic Poulain, Rob Herring, f.fainelli, rjui, devicetree,
	linux-rpi-kernel, linux-bluetooth

Hi Peter,

>> Add basic support for Broadcom serial slave devices.
>> Probe the serial device, retrieve its maximum speed and
>> register a new hci uart device.
>> 
>> Tested/compatible with bcm43438 (RPi3).
>> 
>> Signed-off-by: Loic Poulain <loic.poulain@gmail.com>
>> ---
>> drivers/bluetooth/hci_bcm.c | 82 ++++++++++++++++++++++++++++++++++++++++++---
>> 1 file changed, 78 insertions(+), 4 deletions(-)
>> 
>> diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
>> index 6b42372..f824738 100644
>> --- a/drivers/bluetooth/hci_bcm.c
>> +++ b/drivers/bluetooth/hci_bcm.c
>> @@ -27,6 +27,7 @@
>> #include <linux/firmware.h>
>> #include <linux/module.h>
>> #include <linux/acpi.h>
>> +#include <linux/of.h>
>> #include <linux/platform_device.h>
>> #include <linux/clk.h>
>> #include <linux/gpio/consumer.h>
>> @@ -34,6 +35,7 @@
>> #include <linux/interrupt.h>
>> #include <linux/dmi.h>
>> #include <linux/pm_runtime.h>
>> +#include <linux/serdev.h>
>> 
>> #include <net/bluetooth/bluetooth.h>
>> #include <net/bluetooth/hci_core.h>
>> @@ -46,6 +48,7 @@
>> 
>> #define BCM_AUTOSUSPEND_DELAY  5000 /* default autosleep delay */
>> 
>> +/* platform device driver resources */
>> struct bcm_device {
>>        struct list_head        list;
>> 
>> @@ -68,6 +71,12 @@ struct bcm_device {
>> #endif
>> };
>> 
>> +/* serdev driver resources */
>> +struct bcm_bt_device {
>> +       struct hci_uart hu;
>> +};
>> +
>> +/* generic bcm uart resources */
>> struct bcm_data {
>>        struct sk_buff          *rx_skb;
>>        struct sk_buff_head     txq;
>> @@ -289,6 +298,11 @@ static int bcm_open(struct hci_uart *hu)
>> 
>>        hu->priv = bcm;
>> 
>> +       if (hu->serdev) {
>> +               serdev_device_open(hu->serdev);
>> +               goto out;
>> +       }
>> +
>>        if (!hu->tty->dev)
>>                goto out;
>> 
>> @@ -323,6 +337,9 @@ static int bcm_close(struct hci_uart *hu)
>> 
>>        bt_dev_dbg(hu->hdev, "hu %p", hu);
>> 
>> +       if (hu->serdev)
>> +               serdev_device_close(hu->serdev);
>> +
>>        /* Protect bcm->dev against removal of the device or driver */
>>        mutex_lock(&bcm_device_lock);
>>        if (bcm_device_exists(bdev)) {
>> @@ -397,8 +414,12 @@ static int bcm_setup(struct hci_uart *hu)
>>        else
>>                speed = 0;
>> 
>> -       if (speed)
>> -               hci_uart_set_baudrate(hu, speed);
>> +       if (speed) {
>> +               if (hu->serdev)
>> +                       serdev_device_set_baudrate(hu->serdev, speed);
>> +               else
>> +                       hci_uart_set_baudrate(hu, speed);
>> +       }
>> 
>>        /* Operational speed if any */
>>        if (hu->oper_speed)
>> @@ -410,8 +431,12 @@ static int bcm_setup(struct hci_uart *hu)
>> 
>>        if (speed) {
>>                err = bcm_set_baudrate(hu, speed);
>> -               if (!err)
>> -                       hci_uart_set_baudrate(hu, speed);
>> +               if (!err) {
>> +                       if (hu->serdev)
>> +                               serdev_device_set_baudrate(hu->serdev, speed);
>> +                       else
>> +                               hci_uart_set_baudrate(hu, speed);
>> +               }
>>        }
>> 
>> finalize:
>> @@ -903,9 +928,57 @@ static int bcm_remove(struct platform_device *pdev)
>>        },
>> };
>> 
>> +static int bcm_serdev_probe(struct serdev_device *serdev)
>> +{
>> +       struct bcm_bt_device *bcmdev;
>> +       u32 speed;
>> +       int err;
>> +
>> +       bcmdev = devm_kzalloc(&serdev->dev, sizeof(*bcmdev), GFP_KERNEL);
>> +       if (!bcmdev)
>> +               return -ENOMEM;
>> +
>> +       bcmdev->hu.serdev = serdev;
>> +       serdev_device_set_drvdata(serdev, bcmdev);
>> +
>> +       err = of_property_read_u32(serdev->dev.of_node, "max-speed", &speed);
>> +       if (!err)
>> +               bcmdev->hu.oper_speed = speed;
>> +
>> +       return hci_uart_register_device(&bcmdev->hu, &bcm_proto);
>> +}
>> +
>> +static void bcm_serdev_remove(struct serdev_device *serdev)
>> +{
>> +       struct bcm_bt_device *bcmdev = serdev_device_get_drvdata(serdev);
>> +
>> +       hci_uart_unregister_device(&bcmdev->hu);
>> +}
> 
> I'm seeing the following warning when building this with Fedora-26/gcc7:
> 
> drivers/bluetooth/hci_bcm.c: In function 'bcm_serdev_remove':
> drivers/bluetooth/hci_bcm.c:953:2: error: implicit declaration of
> function 'hci_uart_unregister_device'; did you mean
> 'hci_uart_register_device'? [-Werror=implicit-function-declaration]
>  hci_uart_unregister_device(&bcmdev->hu);
>  ^~~~~~~~~~~~~~~~~~~~~~~~~~
>  hci_uart_register_device
> cc1: some warnings being treated as errors

you might be missing some patches that are already in bluetooth-next and net-next.

Regards

Marcel


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

end of thread, other threads:[~2017-08-07  9:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-31 10:03 [PATCH 1/2] ARM64: dts: bcm2837-rpi-3-b: Add bcm43438 as serial slave device Loic Poulain
2017-07-31 10:03 ` Loic Poulain
     [not found] ` <1501495414-17103-1-git-send-email-loic.poulain-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-07-31 10:03   ` [PATCH 2/2] Bluetooth: hci_bcm: Add serdev support Loic Poulain
2017-07-31 10:03     ` Loic Poulain
     [not found]     ` <1501495414-17103-2-git-send-email-loic.poulain-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-08-07  6:58       ` Peter Robinson
2017-08-07  6:58         ` Peter Robinson
     [not found]         ` <CALeDE9MWoNsiJqVhy_+FnbSKUGmikriqty5nrFd8V8ZtRYmTrA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-07  9:19           ` Marcel Holtmann
2017-08-07  9:19             ` Marcel Holtmann
2017-07-31 19:56   ` [PATCH 1/2] ARM64: dts: bcm2837-rpi-3-b: Add bcm43438 as serial slave device Stefan Wahren
2017-07-31 19:56     ` Stefan Wahren

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.