Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1665571 > unrolled thread

[PATCH v5 0/4] tty/serial: meson_uart: add support for core clock handling

Started byNeil Armstrong <narmstrong@baylibre.com>
First post2017-06-14 10:30 +0200
Last post2017-06-19 10:50 +0200
Articles 6 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v5 0/4] tty/serial: meson_uart: add support for core clock handling Neil Armstrong <narmstrong@baylibre.com> - 2017-06-14 10:30 +0200
    [PATCH v5 4/4] ARM: dts: meson6: use stable UART bindings Neil Armstrong <narmstrong@baylibre.com> - 2017-06-14 10:40 +0200
    [PATCH v5 1/4] dt-bindings: serial: Add bindings for the Amlogic Meson UARTs Neil Armstrong <narmstrong@baylibre.com> - 2017-06-14 10:40 +0200
      Re: [PATCH v5 1/4] dt-bindings: serial: Add bindings for the Amlogic  Meson UARTs Rob Herring <robh@kernel.org> - 2017-06-18 16:10 +0200
    [PATCH v5 2/4] tty/serial: meson_uart: update to stable bindings Neil Armstrong <narmstrong@baylibre.com> - 2017-06-14 12:00 +0200
    Re: [PATCH v5 0/4] tty/serial: meson_uart: add support for core clock  handling Neil Armstrong <narmstrong@baylibre.com> - 2017-06-19 10:50 +0200

#1665571 — [PATCH v5 0/4] tty/serial: meson_uart: add support for core clock handling

FromNeil Armstrong <narmstrong@baylibre.com>
Date2017-06-14 10:30 +0200
Subject[PATCH v5 0/4] tty/serial: meson_uart: add support for core clock handling
Message-ID<tSbQD-2Ni-35@gated-at.bofh.it>
This patchset is a re-spin of Helmut Klein's v3 patchset at [0] and the v4 patchset at [1].

Initially, the original patchset was made to enable usage on the non-AO UARTS
not enabled by the Bootloader (uart_B and uart_C), but the patchset needed
an overall change to have clean and stable DT bindings.

The Amlogic Meson UART Driver did not have stable DT bindings and mismatched
clock handling on non-AO UARTs since these "EE" UARTs needs a clock gate to
be ungated to works correctly.
In the same way, the AO UARTs does not need gating and can be used as
Early Consoles.

In the same time, the UART Interfaces can take clock input for the baudrate
generate from either the external Xtal or the internal Bus Clock (clk81).

So new bindings was necessary to meet these requirements and the DT
maintainers requirements.

The "legacy" binding actually used in the driver is left until all the DT
files are switched to the new bindings.

The GX DT has been tested, but the last 4 Meson6/Meson8/b are only
compile-tested, and testing is welcome.
Thus only the first 3 patches can be merged until the Meson6/Meson8/b are
formally tested.

It must be noted that the meson6 cannot work today except using an early
console since the UART driver could not probe without a clocks property.

Changes since v4 at [1]:
 - Droped meson8/meson8b DT patches
 - Fixes copy/paste error in patch 2
 - Refactored clock probing in patch 2
 - merged meson6 patches together to avoid breaking bisect

[0] http://lkml.kernel.org/r/20170331165437.26227-1-hgkr.klein@gmail.com
[1] http://lkml.kernel.org/r/1497001756-942-1-git-send-email-narmstrong@baylibre.com

Helmut Klein (3):
  dt-bindings: serial: Add bindings for the Amlogic Meson UARTs
  tty/serial: meson_uart: update to stable bindings
  ARM64: dts: meson-gx: use stable UART bindings with correct gate clock

Neil Armstrong (1):
  ARM: dts: meson6: use stable UART bindings

 .../bindings/serial/amlogic,meson-uart.txt         | 38 +++++++++
 arch/arm/boot/dts/meson.dtsi                       |  8 +-
 arch/arm/boot/dts/meson6.dtsi                      | 28 +++++++
 arch/arm64/boot/dts/amlogic/meson-gx.dtsi          | 12 ++-
 arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi        | 25 ++++++
 arch/arm64/boot/dts/amlogic/meson-gxl.dtsi         | 25 ++++++
 drivers/tty/serial/meson_uart.c                    | 90 ++++++++++++++++++++--
 7 files changed, 209 insertions(+), 17 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/serial/amlogic,meson-uart.txt

-- 
1.9.1

[toc] | [next] | [standalone]


#1665576 — [PATCH v5 4/4] ARM: dts: meson6: use stable UART bindings

FromNeil Armstrong <narmstrong@baylibre.com>
Date2017-06-14 10:40 +0200
Subject[PATCH v5 4/4] ARM: dts: meson6: use stable UART bindings
Message-ID<tSc0h-2S1-9@gated-at.bofh.it>
In reply to#1665571
The UART bindings needs specifying a SoC family, use the meson6 family
for the UART nodes like the other nodes.
Switch to the stable UART bindings for meson6 by adding a XTAL node and
using the proper compatible strings.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 arch/arm/boot/dts/meson.dtsi  |  8 ++++----
 arch/arm/boot/dts/meson6.dtsi | 28 ++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/meson.dtsi b/arch/arm/boot/dts/meson.dtsi
index 8d9c369..ecc9330 100644
--- a/arch/arm/boot/dts/meson.dtsi
+++ b/arch/arm/boot/dts/meson.dtsi
@@ -79,14 +79,14 @@
 			ranges = <0x0 0xc1100000 0x200000>;
 
 			uart_A: serial@84c0 {
-				compatible = "amlogic,meson-uart";
+				compatible = "amlogic,meson6-uart";
 				reg = <0x84c0 0x18>;
 				interrupts = <0 26 1>;
 				status = "disabled";
 			};
 
 			uart_B: serial@84dc {
-				compatible = "amlogic,meson-uart";
+				compatible = "amlogic,meson6-uart";
 				reg = <0x84dc 0x18>;
 				interrupts = <0 75 1>;
 				status = "disabled";
@@ -102,7 +102,7 @@
 			};
 
 			uart_C: serial@8700 {
-				compatible = "amlogic,meson-uart";
+				compatible = "amlogic,meson6-uart";
 				reg = <0x8700 0x18>;
 				interrupts = <0 93 1>;
 				status = "disabled";
@@ -153,7 +153,7 @@
 			};
 
 			uart_AO: serial@4c0 {
-				compatible = "amlogic,meson-uart";
+				compatible = "amlogic,meson6-uart", "amlogic,meson-ao-uart";
 				reg = <0x4c0 0x18>;
 				interrupts = <0 90 1>;
 				status = "disabled";
diff --git a/arch/arm/boot/dts/meson6.dtsi b/arch/arm/boot/dts/meson6.dtsi
index b0fc91f..a334fbe 100644
--- a/arch/arm/boot/dts/meson6.dtsi
+++ b/arch/arm/boot/dts/meson6.dtsi
@@ -70,9 +70,37 @@
 		};
 	};
 
+	xtal: xtal-clk {
+		compatible = "fixed-clock";
+		clock-frequency = <24000000>;
+		clock-output-names = "xtal";
+		#clock-cells = <0>;
+	};
+
 	clk81: clk@0 {
 		#clock-cells = <0>;
 		compatible = "fixed-clock";
 		clock-frequency = <200000000>;
 	};
 }; /* end of / */
+
+
+&uart_AO {
+	clocks = <&xtal>, <&clk81>, <&clk81>;
+	clock-names = "xtal", "pclk", "baud";
+};
+
+&uart_A {
+	clocks = <&xtal>, <&clk81>, <&clk81>;
+	clock-names = "xtal", "pclk", "baud";
+};
+
+&uart_B {
+	clocks = <&xtal>, <&clk81>, <&clk81>;
+	clock-names = "xtal", "pclk", "baud";
+};
+
+&uart_C {
+	clocks = <&xtal>, <&clk81>, <&clk81>;
+	clock-names = "xtal", "pclk", "baud";
+};
-- 
1.9.1

[toc] | [prev] | [next] | [standalone]


#1665579 — [PATCH v5 1/4] dt-bindings: serial: Add bindings for the Amlogic Meson UARTs

FromNeil Armstrong <narmstrong@baylibre.com>
Date2017-06-14 10:40 +0200
Subject[PATCH v5 1/4] dt-bindings: serial: Add bindings for the Amlogic Meson UARTs
Message-ID<tSc0i-2S1-19@gated-at.bofh.it>
In reply to#1665571
From: Helmut Klein <hgkr.klein@gmail.com>

Add the documentation for the device tree binding of Amlogic Meson Serial UART.

Signed-off-by: Helmut Klein <hgkr.klein@gmail.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 .../bindings/serial/amlogic,meson-uart.txt         | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/serial/amlogic,meson-uart.txt

diff --git a/Documentation/devicetree/bindings/serial/amlogic,meson-uart.txt b/Documentation/devicetree/bindings/serial/amlogic,meson-uart.txt
new file mode 100644
index 0000000..8ff65fa
--- /dev/null
+++ b/Documentation/devicetree/bindings/serial/amlogic,meson-uart.txt
@@ -0,0 +1,38 @@
+Amlogic Meson SoC UART Serial Interface
+=======================================
+
+The Amlogic Meson SoC UART Serial Interface is present on a large range
+of SoCs, and can be present either in the "Always-On" power domain or the
+"Everything-Else" power domain.
+
+The particularity of the "Always-On" Serial Interface is that the hardware
+is active since power-on and does not need any clock gating and is usable
+as very early serial console.
+
+Required properties:
+- compatible : compatible: value should be different for each SoC family as :
+	- Meson6 : "amlogic,meson6-uart"
+	- Meson8 : "amlogic,meson8-uart"
+	- Meson8b : "amlogic,meson8b-uart"
+	- GX (GXBB, GXL, GXM) : "amlogic,meson-gx-uart"
+	eventually followed by : "amlogic,meson-ao-uart" if this UART interface
+	is in the "Always-On" power domain.
+- reg : offset and length of the register set for the device.
+- interrupts : identifier to the device interrupt
+- clocks : a list of phandle + clock-specifier pairs, one for each
+	   entry in clock names.
+- clocks-names :
+   * "xtal" for external xtal clock identifier
+   * "pclk" for the bus core clock, either the clk81 clock or the gate clock
+   * "baud" for the source of the baudrate generator, can be either the xtal
+	or the pclk.
+
+e.g.
+uart_A: serial@84c0 {
+	compatible = "amlogic,meson-gx-uart";
+	reg = <0x0 0x84c0 0x0 0x14>;
+	interrupts = <GIC_SPI 26 IRQ_TYPE_EDGE_RISING>;
+	/* Use xtal as baud rate clock source */
+	clocks = <&xtal>, <&clkc CLKID_UART0>, <&xtal>;
+	clock-names = "xtal", "pclk", "baud";
+};
-- 
1.9.1

[toc] | [prev] | [next] | [standalone]


#1668614 — Re: [PATCH v5 1/4] dt-bindings: serial: Add bindings for the Amlogic Meson UARTs

FromRob Herring <robh@kernel.org>
Date2017-06-18 16:10 +0200
SubjectRe: [PATCH v5 1/4] dt-bindings: serial: Add bindings for the Amlogic Meson UARTs
Message-ID<tTJ3R-670-39@gated-at.bofh.it>
In reply to#1665579
On Wed, Jun 14, 2017 at 10:29:14AM +0200, Neil Armstrong wrote:
> From: Helmut Klein <hgkr.klein@gmail.com>
> 
> Add the documentation for the device tree binding of Amlogic Meson Serial UART.
> 
> Signed-off-by: Helmut Klein <hgkr.klein@gmail.com>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>  .../bindings/serial/amlogic,meson-uart.txt         | 38 ++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/serial/amlogic,meson-uart.txt

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

[toc] | [prev] | [next] | [standalone]


#1665663 — [PATCH v5 2/4] tty/serial: meson_uart: update to stable bindings

FromNeil Armstrong <narmstrong@baylibre.com>
Date2017-06-14 12:00 +0200
Subject[PATCH v5 2/4] tty/serial: meson_uart: update to stable bindings
Message-ID<tSdfI-3xZ-23@gated-at.bofh.it>
In reply to#1665571
From: Helmut Klein <hgkr.klein@gmail.com>

This patch handle the stable UART bindings but also keeps compatibility
with the legacy non-stable bindings until all boards uses them.

Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Helmut Klein <hgkr.klein@gmail.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/tty/serial/meson_uart.c | 90 ++++++++++++++++++++++++++++++++++++++---
 1 file changed, 84 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
index 60f1679..82e0709 100644
--- a/drivers/tty/serial/meson_uart.c
+++ b/drivers/tty/serial/meson_uart.c
@@ -579,8 +579,12 @@ static void meson_serial_early_console_write(struct console *co,
 	device->con->write = meson_serial_early_console_write;
 	return 0;
 }
+/* Legacy bindings, should be removed when no more used */
 OF_EARLYCON_DECLARE(meson, "amlogic,meson-uart",
 		    meson_serial_early_console_setup);
+/* Stable bindings */
+OF_EARLYCON_DECLARE(meson, "amlogic,meson-ao-uart",
+		    meson_serial_early_console_setup);
 
 #define MESON_SERIAL_CONSOLE	(&meson_serial_console)
 #else
@@ -595,11 +599,76 @@ static void meson_serial_early_console_write(struct console *co,
 	.cons		= MESON_SERIAL_CONSOLE,
 };
 
+static inline struct clk *meson_uart_probe_clock(struct device *dev,
+						 const char *id)
+{
+	struct clk *clk = NULL;
+	int ret;
+
+	clk = devm_clk_get(dev, id);
+	if (IS_ERR(clk))
+		return clk;
+
+	ret = clk_prepare_enable(clk);
+	if (ret) {
+		dev_err(dev, "couldn't enable clk\n");
+		return ERR_PTR(ret);
+	}
+
+	devm_add_action_or_reset(dev,
+			(void(*)(void *))clk_disable_unprepare,
+			clk);
+
+	return clk;
+}
+
+/*
+ * This function gets clocks in the legacy non-stable DT bindings.
+ * This code will be remove once all the platforms switch to the
+ * new DT bindings.
+ */
+static int meson_uart_probe_clocks_legacy(struct platform_device *pdev,
+					  struct uart_port *port)
+{
+	struct clk *clk = NULL;
+
+	clk = meson_uart_probe_clock(&pdev->dev, NULL);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+
+	port->uartclk = clk_get_rate(clk);
+
+	return 0;
+}
+
+static int meson_uart_probe_clocks(struct platform_device *pdev,
+				   struct uart_port *port)
+{
+	struct clk *clk_xtal = NULL;
+	struct clk *clk_pclk = NULL;
+	struct clk *clk_baud = NULL;
+
+	clk_pclk = meson_uart_probe_clock(&pdev->dev, "pclk");
+	if (IS_ERR(clk_pclk))
+		return PTR_ERR(clk_pclk);
+
+	clk_xtal = meson_uart_probe_clock(&pdev->dev, "xtal");
+	if (IS_ERR(clk_xtal))
+		return PTR_ERR(clk_xtal);
+
+	clk_baud = meson_uart_probe_clock(&pdev->dev, "baud");
+	if (IS_ERR(clk_baud))
+		return PTR_ERR(clk_baud);
+
+	port->uartclk = clk_get_rate(clk_baud);
+
+	return 0;
+}
+
 static int meson_uart_probe(struct platform_device *pdev)
 {
 	struct resource *res_mem, *res_irq;
 	struct uart_port *port;
-	struct clk *clk;
 	int ret = 0;
 
 	if (pdev->dev.of_node)
@@ -625,11 +694,15 @@ static int meson_uart_probe(struct platform_device *pdev)
 	if (!port)
 		return -ENOMEM;
 
-	clk = clk_get(&pdev->dev, NULL);
-	if (IS_ERR(clk))
-		return PTR_ERR(clk);
+	/* Use legacy way until all platforms switch to new bindings */
+	if (of_device_is_compatible(pdev->dev.of_node, "amlogic,meson-uart"))
+		ret = meson_uart_probe_clocks_legacy(pdev, port);
+	else
+		ret = meson_uart_probe_clocks(pdev, port);
+
+	if (ret)
+		return ret;
 
-	port->uartclk = clk_get_rate(clk);
 	port->iotype = UPIO_MEM;
 	port->mapbase = res_mem->start;
 	port->irq = res_irq->start;
@@ -668,9 +741,14 @@ static int meson_uart_remove(struct platform_device *pdev)
 	return 0;
 }
 
-
 static const struct of_device_id meson_uart_dt_match[] = {
+	/* Legacy bindings, should be removed when no more used */
 	{ .compatible = "amlogic,meson-uart" },
+	/* Stable bindings */
+	{ .compatible = "amlogic,meson6-uart" },
+	{ .compatible = "amlogic,meson8-uart" },
+	{ .compatible = "amlogic,meson8b-uart" },
+	{ .compatible = "amlogic,meson-gx-uart" },
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, meson_uart_dt_match);
-- 
1.9.1

[toc] | [prev] | [next] | [standalone]


#1668897 — Re: [PATCH v5 0/4] tty/serial: meson_uart: add support for core clock handling

FromNeil Armstrong <narmstrong@baylibre.com>
Date2017-06-19 10:50 +0200
SubjectRe: [PATCH v5 0/4] tty/serial: meson_uart: add support for core clock handling
Message-ID<tU0xH-jE-7@gated-at.bofh.it>
In reply to#1665571
On 06/14/2017 10:29 AM, Neil Armstrong wrote:
> This patchset is a re-spin of Helmut Klein's v3 patchset at [0] and the v4 patchset at [1].
> 
> Initially, the original patchset was made to enable usage on the non-AO UARTS
> not enabled by the Bootloader (uart_B and uart_C), but the patchset needed
> an overall change to have clean and stable DT bindings.
> 
> The Amlogic Meson UART Driver did not have stable DT bindings and mismatched
> clock handling on non-AO UARTs since these "EE" UARTs needs a clock gate to
> be ungated to works correctly.
> In the same way, the AO UARTs does not need gating and can be used as
> Early Consoles.
> 
> In the same time, the UART Interfaces can take clock input for the baudrate
> generate from either the external Xtal or the internal Bus Clock (clk81).
> 
> So new bindings was necessary to meet these requirements and the DT
> maintainers requirements.
> 
> The "legacy" binding actually used in the driver is left until all the DT
> files are switched to the new bindings.
> 
> The GX DT has been tested, but the last 4 Meson6/Meson8/b are only
> compile-tested, and testing is welcome.
> Thus only the first 3 patches can be merged until the Meson6/Meson8/b are
> formally tested.
> 
> It must be noted that the meson6 cannot work today except using an early
> console since the UART driver could not probe without a clocks property.
> 
> Changes since v4 at [1]:
>  - Droped meson8/meson8b DT patches
>  - Fixes copy/paste error in patch 2
>  - Refactored clock probing in patch 2
>  - merged meson6 patches together to avoid breaking bisect
> 
> [0] http://lkml.kernel.org/r/20170331165437.26227-1-hgkr.klein@gmail.com
> [1] http://lkml.kernel.org/r/1497001756-942-1-git-send-email-narmstrong@baylibre.com
> 
> Helmut Klein (3):
>   dt-bindings: serial: Add bindings for the Amlogic Meson UARTs
>   tty/serial: meson_uart: update to stable bindings
>   ARM64: dts: meson-gx: use stable UART bindings with correct gate clock
> 
> Neil Armstrong (1):
>   ARM: dts: meson6: use stable UART bindings
> 
>  .../bindings/serial/amlogic,meson-uart.txt         | 38 +++++++++
>  arch/arm/boot/dts/meson.dtsi                       |  8 +-
>  arch/arm/boot/dts/meson6.dtsi                      | 28 +++++++
>  arch/arm64/boot/dts/amlogic/meson-gx.dtsi          | 12 ++-
>  arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi        | 25 ++++++
>  arch/arm64/boot/dts/amlogic/meson-gxl.dtsi         | 25 ++++++
>  drivers/tty/serial/meson_uart.c                    | 90 ++++++++++++++++++++--
>  7 files changed, 209 insertions(+), 17 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/serial/amlogic,meson-uart.txt
> 


Hi Greg,

Patches 3 & 4 will need a respin to avoid breaking compatibility with old kernel
like the tty patch does by keeping the legacy compatible string.
I will re-send then in a separate thread and Kevin will handle them.

Patches 1 & 2 can be taken if they are OK for you.

Thanks,
Neil

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web