linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Add Bluetooth support to Teres A64 I
@ 2019-10-26 20:41 Hugo Grostabussiat
  2019-10-26 20:41 ` [PATCH 1/3] dt-bindings: net: bluetooth: add DT binding for rtl8723bs Hugo Grostabussiat
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Hugo Grostabussiat @ 2019-10-26 20:41 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg, Rob Herring, Mark Rutland,
	Maxime Ripard, Chen-Yu Tsai
  Cc: devicetree, Hugo Grostabussiat, linux-arm-kernel, linux-bluetooth

The Teres A64 I laptop comes equipped with a serial-attached Realtek
rtl8723bs Bluetooth controller. This series creates the DT binding for
the the Realtek vendor extension of the HCI H5 driver, for which ACPI
bindings already exist, and enable support for the Teres A64 I board.

The first patch adds the DT binding documentation.
The second one implements such binding in the HCI H5 driver.
The last patch adds the appropriate device node to the Teres A64 I dts
file to enable Bluetooth.

Hugo Grostabussiat (3):
  dt-bindings: net: bluetooth: add DT binding for rtl8723bs
  Bluetooth: hci_h5: Add DT support for rtl8723bs
  arm64: dts: allwinner: a64: Enable Bluetooth on Teres-I

 .../bindings/net/realtek,rtl8723bs-bt.txt     | 25 ++++++++++++
 .../boot/dts/allwinner/sun50i-a64-teres-i.dts | 13 ++++++
 drivers/bluetooth/hci_h5.c                    | 40 ++++++++++++++++---
 3 files changed, 73 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/realtek,rtl8723bs-bt.txt

-- 
2.23.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 1/3] dt-bindings: net: bluetooth: add DT binding for rtl8723bs
  2019-10-26 20:41 [PATCH 0/3] Add Bluetooth support to Teres A64 I Hugo Grostabussiat
@ 2019-10-26 20:41 ` Hugo Grostabussiat
  2019-10-28 19:12   ` Marcel Holtmann
  2019-10-26 20:41 ` [PATCH 2/3] Bluetooth: hci_h5: Add DT support " Hugo Grostabussiat
  2019-10-26 20:41 ` [PATCH 3/3] arm64: dts: allwinner: a64: Enable Bluetooth on Teres-I Hugo Grostabussiat
  2 siblings, 1 reply; 6+ messages in thread
From: Hugo Grostabussiat @ 2019-10-26 20:41 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg, Rob Herring, Mark Rutland,
	Maxime Ripard, Chen-Yu Tsai
  Cc: devicetree, Hugo Grostabussiat, linux-arm-kernel, linux-bluetooth

The rtl_bt driver already supports rtl8723bs devices on ACPI platforms.
This commit adds bindings for DT-only platforms.

Signed-off-by: Hugo Grostabussiat <bonstra@bonstra.fr.eu.org>
---
 .../bindings/net/realtek,rtl8723bs-bt.txt     | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/realtek,rtl8723bs-bt.txt

diff --git a/Documentation/devicetree/bindings/net/realtek,rtl8723bs-bt.txt b/Documentation/devicetree/bindings/net/realtek,rtl8723bs-bt.txt
new file mode 100644
index 000000000000..16b5cf799103
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/realtek,rtl8723bs-bt.txt
@@ -0,0 +1,25 @@
+Realtek rtl8723bs Bluetooth controller
+======================================
+
+This documents the binding structure and properties for the serial
+attached rtl8723bs Bluetooth controller.
+
+Required properties:
+- compatible: must be "realtek,rt8723bs-bt"
+
+Optional properties:
+- enable-gpio: gpio line controlling the power down (BT_DIS#) signal
+- device-wake: gpio line controlling the device wakeup (BT_WAKE) signal
+- realtek,config-name: postfix added to the name of the firmware file
+  containing the chip configuration
+
+Example:
+
+&uart1 {
+	bluetooth {
+		compatible = "realtek,rtl8723bs-bt";
+		enable-gpio = <&r_pio 0 4 GPIO_ACTIVE_HIGH>; /* PL4 */
+		device-wake-gpio = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */
+		realtek,config-name = "olimex_a64_teres_i";
+	};
+};
-- 
2.23.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/3] Bluetooth: hci_h5: Add DT support for rtl8723bs
  2019-10-26 20:41 [PATCH 0/3] Add Bluetooth support to Teres A64 I Hugo Grostabussiat
  2019-10-26 20:41 ` [PATCH 1/3] dt-bindings: net: bluetooth: add DT binding for rtl8723bs Hugo Grostabussiat
@ 2019-10-26 20:41 ` Hugo Grostabussiat
  2019-10-28 19:09   ` Marcel Holtmann
  2019-10-26 20:41 ` [PATCH 3/3] arm64: dts: allwinner: a64: Enable Bluetooth on Teres-I Hugo Grostabussiat
  2 siblings, 1 reply; 6+ messages in thread
From: Hugo Grostabussiat @ 2019-10-26 20:41 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg, Rob Herring, Mark Rutland,
	Maxime Ripard, Chen-Yu Tsai
  Cc: devicetree, Hugo Grostabussiat, linux-arm-kernel, linux-bluetooth

The hci_h5 already supports rtl8723bs devices discovered via ACPI. This
commit adds support for discovering via device tree for ACPI-less
platforms.

Signed-off-by: Hugo Grostabussiat <bonstra@bonstra.fr.eu.org>
---
 drivers/bluetooth/hci_h5.c | 40 +++++++++++++++++++++++++++++++++-----
 1 file changed, 35 insertions(+), 5 deletions(-)

diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
index dacf297baf59..49ac03b1a7e3 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -11,6 +11,7 @@
 #include <linux/gpio/consumer.h>
 #include <linux/kernel.h>
 #include <linux/mod_devicetable.h>
+#include <linux/of_device.h>
 #include <linux/serdev.h>
 #include <linux/skbuff.h>
 
@@ -782,7 +783,9 @@ static const struct hci_uart_proto h5p = {
 
 static int h5_serdev_probe(struct serdev_device *serdev)
 {
-	const struct acpi_device_id *match;
+	const struct acpi_device_id *acpi_match;
+	const struct of_device_id *of_match;
+	const char *cfgname = NULL;
 	struct device *dev = &serdev->dev;
 	struct h5 *h5;
 
@@ -797,16 +800,27 @@ static int h5_serdev_probe(struct serdev_device *serdev)
 	serdev_device_set_drvdata(serdev, h5);
 
 	if (has_acpi_companion(dev)) {
-		match = acpi_match_device(dev->driver->acpi_match_table, dev);
-		if (!match)
+		acpi_match = acpi_match_device(
+				dev->driver->acpi_match_table, dev);
+		if (!acpi_match)
 			return -ENODEV;
 
-		h5->vnd = (const struct h5_vnd *)match->driver_data;
-		h5->id  = (char *)match->id;
+		h5->vnd = (const struct h5_vnd *)acpi_match->driver_data;
+		h5->id  = (char *)acpi_match->id;
 
 		if (h5->vnd->acpi_gpio_map)
 			devm_acpi_dev_add_driver_gpios(dev,
 						       h5->vnd->acpi_gpio_map);
+	} else if (dev->of_node) {
+		of_match = of_match_device(dev->driver->of_match_table, dev);
+		if (!of_match)
+			return -ENODEV;
+
+		of_property_read_string(dev->of_node,
+					"realtek,config-name", &cfgname);
+
+		h5->vnd = (const struct h5_vnd *)of_match->data;
+		h5->id = cfgname;
 	}
 
 	h5->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW);
@@ -996,6 +1010,19 @@ static const struct acpi_device_id h5_acpi_match[] = {
 MODULE_DEVICE_TABLE(acpi, h5_acpi_match);
 #endif
 
+#ifdef CONFIG_OF
+static const struct of_device_id h5_of_match[] = {
+#ifdef CONFIG_BT_HCIUART_RTL
+	{
+		.compatible = "realtek,rtl8723bs-bt",
+		.data = &rtl_vnd
+	},
+#endif
+	{ },
+};
+MODULE_DEVICE_TABLE(of, h5_of_match);
+#endif
+
 static const struct dev_pm_ops h5_serdev_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(h5_serdev_suspend, h5_serdev_resume)
 };
@@ -1006,6 +1033,9 @@ static struct serdev_device_driver h5_serdev_driver = {
 	.driver = {
 		.name = "hci_uart_h5",
 		.acpi_match_table = ACPI_PTR(h5_acpi_match),
+#ifdef CONFIG_OF
+		.of_match_table = h5_of_match,
+#endif
 		.pm = &h5_serdev_pm_ops,
 	},
 };
-- 
2.23.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 3/3] arm64: dts: allwinner: a64: Enable Bluetooth on Teres-I
  2019-10-26 20:41 [PATCH 0/3] Add Bluetooth support to Teres A64 I Hugo Grostabussiat
  2019-10-26 20:41 ` [PATCH 1/3] dt-bindings: net: bluetooth: add DT binding for rtl8723bs Hugo Grostabussiat
  2019-10-26 20:41 ` [PATCH 2/3] Bluetooth: hci_h5: Add DT support " Hugo Grostabussiat
@ 2019-10-26 20:41 ` Hugo Grostabussiat
  2 siblings, 0 replies; 6+ messages in thread
From: Hugo Grostabussiat @ 2019-10-26 20:41 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg, Rob Herring, Mark Rutland,
	Maxime Ripard, Chen-Yu Tsai
  Cc: devicetree, Hugo Grostabussiat, linux-arm-kernel, linux-bluetooth

The UART1 on the Teres-A64-I is connected to a rtl8723bs combo
WLAN/Bluetooth controller, with three GPIOs used for device reset,
host wake up and device wake up.

Currently, the host wake up feature is not supported by the HCI H5
driver.

Signed-off-by: Hugo Grostabussiat <bonstra@bonstra.fr.eu.org>
---
 .../arm64/boot/dts/allwinner/sun50i-a64-teres-i.dts | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-teres-i.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-teres-i.dts
index 1069e7012c9c..c7db2f1650d4 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-teres-i.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-teres-i.dts
@@ -325,6 +325,19 @@
 	status = "okay";
 };
 
+&uart1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart1_pins>, <&uart1_rts_cts_pins>;
+	status = "okay";
+
+	bluetooth {
+		compatible = "realtek,rtl8723bs-bt";
+		enable-gpio = <&r_pio 0 4 GPIO_ACTIVE_HIGH>; /* PL4 */
+		device-wake-gpio = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */
+		realtek,config-name = "teres_a64_i";
+	};
+};
+
 &usbphy {
 	usb1_vbus-supply = <&reg_usb1_vbus>;
 	status = "okay";
-- 
2.23.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/3] Bluetooth: hci_h5: Add DT support for rtl8723bs
  2019-10-26 20:41 ` [PATCH 2/3] Bluetooth: hci_h5: Add DT support " Hugo Grostabussiat
@ 2019-10-28 19:09   ` Marcel Holtmann
  0 siblings, 0 replies; 6+ messages in thread
From: Marcel Holtmann @ 2019-10-28 19:09 UTC (permalink / raw)
  To: Hugo Grostabussiat
  Cc: Mark Rutland, devicetree, Johan Hedberg, Maxime Ripard,
	linux-bluetooth, Chen-Yu Tsai, Rob Herring, linux-arm-kernel

Hi Hugo,

> The hci_h5 already supports rtl8723bs devices discovered via ACPI. This
> commit adds support for discovering via device tree for ACPI-less
> platforms.
> 
> Signed-off-by: Hugo Grostabussiat <bonstra@bonstra.fr.eu.org>
> ---
> drivers/bluetooth/hci_h5.c | 40 +++++++++++++++++++++++++++++++++-----
> 1 file changed, 35 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
> index dacf297baf59..49ac03b1a7e3 100644
> --- a/drivers/bluetooth/hci_h5.c
> +++ b/drivers/bluetooth/hci_h5.c
> @@ -11,6 +11,7 @@
> #include <linux/gpio/consumer.h>
> #include <linux/kernel.h>
> #include <linux/mod_devicetable.h>
> +#include <linux/of_device.h>
> #include <linux/serdev.h>
> #include <linux/skbuff.h>
> 
> @@ -782,7 +783,9 @@ static const struct hci_uart_proto h5p = {
> 
> static int h5_serdev_probe(struct serdev_device *serdev)
> {
> -	const struct acpi_device_id *match;
> +	const struct acpi_device_id *acpi_match;
> +	const struct of_device_id *of_match;
> +	const char *cfgname = NULL;
> 	struct device *dev = &serdev->dev;
> 	struct h5 *h5;
> 
> @@ -797,16 +800,27 @@ static int h5_serdev_probe(struct serdev_device *serdev)
> 	serdev_device_set_drvdata(serdev, h5);
> 
> 	if (has_acpi_companion(dev)) {

then move const struct acpi_device_id *match here in the local focus.

> -		match = acpi_match_device(dev->driver->acpi_match_table, dev);
> -		if (!match)
> +		acpi_match = acpi_match_device(
> +				dev->driver->acpi_match_table, dev);
> +		if (!acpi_match)
> 			return -ENODEV;
> 
> -		h5->vnd = (const struct h5_vnd *)match->driver_data;
> -		h5->id  = (char *)match->id;
> +		h5->vnd = (const struct h5_vnd *)acpi_match->driver_data;
> +		h5->id  = (char *)acpi_match->id;
> 
> 		if (h5->vnd->acpi_gpio_map)
> 			devm_acpi_dev_add_driver_gpios(dev,
> 						       h5->vnd->acpi_gpio_map);
> +	} else if (dev->of_node) {

And have struct of_device_id *match here.

> +		of_match = of_match_device(dev->driver->of_match_table, dev);
> +		if (!of_match)
> +			return -ENODEV;
> +
> +		of_property_read_string(dev->of_node,
> +					"realtek,config-name", &cfgname);
> +
> +		h5->vnd = (const struct h5_vnd *)of_match->data;
> +		h5->id = cfgname;

So we can not just read a realtek specific variable here. This is still generic code for 3-Wire UART protocol and needs to be available to other vendors as well.

> 	}
> 
> 	h5->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW);
> @@ -996,6 +1010,19 @@ static const struct acpi_device_id h5_acpi_match[] = {
> MODULE_DEVICE_TABLE(acpi, h5_acpi_match);
> #endif
> 
> +#ifdef CONFIG_OF
> +static const struct of_device_id h5_of_match[] = {
> +#ifdef CONFIG_BT_HCIUART_RTL
> +	{
> +		.compatible = "realtek,rtl8723bs-bt",
> +		.data = &rtl_vnd
> +	},
> +#endif
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, h5_of_match);
> +#endif
> +
> static const struct dev_pm_ops h5_serdev_pm_ops = {
> 	SET_SYSTEM_SLEEP_PM_OPS(h5_serdev_suspend, h5_serdev_resume)
> };
> @@ -1006,6 +1033,9 @@ static struct serdev_device_driver h5_serdev_driver = {
> 	.driver = {
> 		.name = "hci_uart_h5",
> 		.acpi_match_table = ACPI_PTR(h5_acpi_match),
> +#ifdef CONFIG_OF
> +		.of_match_table = h5_of_match,
> +#endif

Use of_match_ptr here instead of the ifdef.

> 		.pm = &h5_serdev_pm_ops,
> 	},
> };

Regards

Marcel


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/3] dt-bindings: net: bluetooth: add DT binding for rtl8723bs
  2019-10-26 20:41 ` [PATCH 1/3] dt-bindings: net: bluetooth: add DT binding for rtl8723bs Hugo Grostabussiat
@ 2019-10-28 19:12   ` Marcel Holtmann
  0 siblings, 0 replies; 6+ messages in thread
From: Marcel Holtmann @ 2019-10-28 19:12 UTC (permalink / raw)
  To: Hugo Grostabussiat
  Cc: Mark Rutland, devicetree, Johan Hedberg, Maxime Ripard,
	linux-bluetooth, Chen-Yu Tsai, Rob Herring, linux-arm-kernel

Hi Hugo,

> The rtl_bt driver already supports rtl8723bs devices on ACPI platforms.
> This commit adds bindings for DT-only platforms.
> 
> Signed-off-by: Hugo Grostabussiat <bonstra@bonstra.fr.eu.org>
> ---
> .../bindings/net/realtek,rtl8723bs-bt.txt     | 25 +++++++++++++++++++
> 1 file changed, 25 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/net/realtek,rtl8723bs-bt.txt

please document this in net/realtek-bluetooth.txt in a generic fashion for potentially all Realtek devices. Similar to what has been done for Broadcom etc.

> 
> diff --git a/Documentation/devicetree/bindings/net/realtek,rtl8723bs-bt.txt b/Documentation/devicetree/bindings/net/realtek,rtl8723bs-bt.txt
> new file mode 100644
> index 000000000000..16b5cf799103
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/realtek,rtl8723bs-bt.txt
> @@ -0,0 +1,25 @@
> +Realtek rtl8723bs Bluetooth controller
> +======================================
> +
> +This documents the binding structure and properties for the serial
> +attached rtl8723bs Bluetooth controller.
> +
> +Required properties:
> +- compatible: must be "realtek,rt8723bs-bt"
> +
> +Optional properties:
> +- enable-gpio: gpio line controlling the power down (BT_DIS#) signal
> +- device-wake: gpio line controlling the device wakeup (BT_WAKE) signal
> +- realtek,config-name: postfix added to the name of the firmware file
> +  containing the chip configuration

This needs an ACK from Rob before I consider applying it.

Regards

Marcel


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-10-28 19:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-26 20:41 [PATCH 0/3] Add Bluetooth support to Teres A64 I Hugo Grostabussiat
2019-10-26 20:41 ` [PATCH 1/3] dt-bindings: net: bluetooth: add DT binding for rtl8723bs Hugo Grostabussiat
2019-10-28 19:12   ` Marcel Holtmann
2019-10-26 20:41 ` [PATCH 2/3] Bluetooth: hci_h5: Add DT support " Hugo Grostabussiat
2019-10-28 19:09   ` Marcel Holtmann
2019-10-26 20:41 ` [PATCH 3/3] arm64: dts: allwinner: a64: Enable Bluetooth on Teres-I Hugo Grostabussiat

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