All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] arm64: tegra: Add earlycon support on Tegra194
@ 2021-03-26 17:46 Thierry Reding
  2021-03-26 17:46 ` [PATCH 1/3] dt-bindings: serial: tegra-tcu: Convert to json-schema Thierry Reding
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Thierry Reding @ 2021-03-26 17:46 UTC (permalink / raw)
  To: Rob Herring; +Cc: Jon Hunter, devicetree, linux-tegra

From: Thierry Reding <treding@nvidia.com>

Hi Rob,

I've been looking at adding support for earlycon on Tegra194 which uses
the "combined UART" as console. This isn't a real device but rather is
composed of two mailboxes that are used to communicate with a processor
that multiplexes multiple data streams before they are sent over the HW
UART.

It's possible to make this work by passing earlycon with extra options
that select the TCU and pass a TX mailbox address, but I'd prefer if we
could also make this work without any options and instead infer the TX
mailbox address to use from /chosen/stdout-path. I can make that work
with the regular OF_EARLYCON_DECLARE and just a bit of additional code
to write data to the TX mailbox if I change the device tree node to take
a "reg" property. This set of patches implements those changes (there's
a separate patch to the tegra-tcu driver that adds OF_EARLYCON_DECLARE
and a bit of code, but it's not directly relevant to this discussion).

Given that this isn't a real device and the address in the "reg"
property is also a subset of the mailbox device that will take over for
the real console later on, I'm wondering if this is acceptable, even if
it is bending the rules a tiny bit.

The only other alternative I could think of would be to obtain the node
offset to the TCU node (either by passing it to the earlycon ->setup()
callback, or looking it up manually) and then parsing the mboxes
property and find the TX mailbox provider and then compute the TX
mailbox address. But that all seems very involved for something that we
can make work out of the box by simply adding this "reg" property, even
if it may not be strictly correct.

What do you think?

Thierry

Thierry Reding (3):
  dt-bindings: serial: tegra-tcu: Convert to json-schema
  dt-bindings: serial: tegra-tcu: Document "reg" property
  arm64: tegra: Add "reg" property for TCU on Tegra194

 .../bindings/serial/nvidia,tegra194-tcu.txt   | 35 -----------
 .../bindings/serial/nvidia,tegra194-tcu.yaml  | 60 +++++++++++++++++++
 arch/arm64/boot/dts/nvidia/tegra194.dtsi      |  4 +-
 3 files changed, 63 insertions(+), 36 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.txt
 create mode 100644 Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml

-- 
2.30.2


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

* [PATCH 1/3] dt-bindings: serial: tegra-tcu: Convert to json-schema
  2021-03-26 17:46 [PATCH 0/3] arm64: tegra: Add earlycon support on Tegra194 Thierry Reding
@ 2021-03-26 17:46 ` Thierry Reding
  2021-03-27 18:41   ` Rob Herring
  2021-03-26 17:46 ` [PATCH 2/3] dt-bindings: serial: tegra-tcu: Document "reg" property Thierry Reding
  2021-03-26 17:46 ` [PATCH 3/3] arm64: tegra: Add "reg" property for TCU on Tegra194 Thierry Reding
  2 siblings, 1 reply; 8+ messages in thread
From: Thierry Reding @ 2021-03-26 17:46 UTC (permalink / raw)
  To: Rob Herring; +Cc: Jon Hunter, devicetree, linux-tegra

From: Thierry Reding <treding@nvidia.com>

Convert the Tegra TCU device tree bindings to json-schema.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 .../bindings/serial/nvidia,tegra194-tcu.txt   | 35 ------------
 .../bindings/serial/nvidia,tegra194-tcu.yaml  | 56 +++++++++++++++++++
 2 files changed, 56 insertions(+), 35 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.txt
 create mode 100644 Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml

diff --git a/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.txt b/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.txt
deleted file mode 100644
index 085a8591accd..000000000000
--- a/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-NVIDIA Tegra Combined UART (TCU)
-
-The TCU is a system for sharing a hardware UART instance among multiple
-systems within the Tegra SoC. It is implemented through a mailbox-
-based protocol where each "virtual UART" has a pair of mailboxes, one
-for transmitting and one for receiving, that is used to communicate
-with the hardware implementing the TCU.
-
-Required properties:
-- name : Should be tcu
-- compatible
-    Array of strings
-    One of:
-    - "nvidia,tegra194-tcu"
-- mbox-names:
-    "rx" - Mailbox for receiving data from hardware UART
-    "tx" - Mailbox for transmitting data to hardware UART
-- mboxes: Mailboxes corresponding to the mbox-names.
-
-This node is a mailbox consumer. See the following files for details of
-the mailbox subsystem, and the specifiers implemented by the relevant
-provider(s):
-
-- .../mailbox/mailbox.txt
-- .../mailbox/nvidia,tegra186-hsp.txt
-
-Example bindings:
------------------
-
-tcu: tcu {
-	compatible = "nvidia,tegra194-tcu";
-	mboxes = <&hsp_top0 TEGRA_HSP_MBOX_TYPE_SM 0>,
-	         <&hsp_aon TEGRA_HSP_MBOX_TYPE_SM 1>;
-	mbox-names = "rx", "tx";
-};
diff --git a/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml b/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml
new file mode 100644
index 000000000000..0a321658ccb5
--- /dev/null
+++ b/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/serial/nvidia,tegra194-tcu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVIDIA Tegra Combined UART (TCU)
+
+maintainers:
+  - Thierry Reding <thierry.reding@gmail.com>
+  - Jonathan Hunter <jonathanh@nvidia.com>
+
+description:
+  The TCU is a system for sharing a hardware UART instance among multiple
+  systems within the Tegra SoC. It is implemented through a mailbox-
+  based protocol where each "virtual UART" has a pair of mailboxes, one
+  for transmitting and one for receiving, that is used to communicate
+  with the hardware implementing the TCU.
+
+properties:
+  $nodename:
+    pattern: "^tcu(@.*)?$"
+
+  compatible:
+    const: nvidia,tegra194-tcu
+
+  mbox-names:
+    items:
+      - const: rx
+      - const: tx
+
+  mboxes:
+    description: |
+      List of phandles to mailbox channels used for receiving and
+      transmitting data from and to the hardware UART.
+    items:
+      - description: mailbox for receiving data from hardware UART
+      - description: mailbox for transmitting data to hardware UART
+
+required:
+  - compatible
+  - mbox-names
+  - mboxes
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/mailbox/tegra186-hsp.h>
+
+    tcu: tcu {
+        compatible = "nvidia,tegra194-tcu";
+        mboxes = <&hsp_top0 TEGRA_HSP_MBOX_TYPE_SM 0>,
+                 <&hsp_aon TEGRA_HSP_MBOX_TYPE_SM 1>;
+        mbox-names = "rx", "tx";
+    };
-- 
2.30.2


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

* [PATCH 2/3] dt-bindings: serial: tegra-tcu: Document "reg" property
  2021-03-26 17:46 [PATCH 0/3] arm64: tegra: Add earlycon support on Tegra194 Thierry Reding
  2021-03-26 17:46 ` [PATCH 1/3] dt-bindings: serial: tegra-tcu: Convert to json-schema Thierry Reding
@ 2021-03-26 17:46 ` Thierry Reding
  2021-03-27 18:49   ` Rob Herring
  2021-03-26 17:46 ` [PATCH 3/3] arm64: tegra: Add "reg" property for TCU on Tegra194 Thierry Reding
  2 siblings, 1 reply; 8+ messages in thread
From: Thierry Reding @ 2021-03-26 17:46 UTC (permalink / raw)
  To: Rob Herring; +Cc: Jon Hunter, devicetree, linux-tegra

From: Thierry Reding <treding@nvidia.com>

In order to support early console support with the Tegra TCU, add an
optional "reg" property that points to the TX mailbox.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 .../devicetree/bindings/serial/nvidia,tegra194-tcu.yaml     | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml b/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml
index 0a321658ccb5..8c9ed7cfaa52 100644
--- a/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml
+++ b/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml
@@ -24,6 +24,9 @@ properties:
   compatible:
     const: nvidia,tegra194-tcu
 
+  reg:
+    maxItems: 1
+
   mbox-names:
     items:
       - const: rx
@@ -48,8 +51,9 @@ examples:
   - |
     #include <dt-bindings/mailbox/tegra186-hsp.h>
 
-    tcu: tcu {
+    tcu: tcu@c168000 {
         compatible = "nvidia,tegra194-tcu";
+        reg = <0x0c168000 0x4>;
         mboxes = <&hsp_top0 TEGRA_HSP_MBOX_TYPE_SM 0>,
                  <&hsp_aon TEGRA_HSP_MBOX_TYPE_SM 1>;
         mbox-names = "rx", "tx";
-- 
2.30.2


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

* [PATCH 3/3] arm64: tegra: Add "reg" property for TCU on Tegra194
  2021-03-26 17:46 [PATCH 0/3] arm64: tegra: Add earlycon support on Tegra194 Thierry Reding
  2021-03-26 17:46 ` [PATCH 1/3] dt-bindings: serial: tegra-tcu: Convert to json-schema Thierry Reding
  2021-03-26 17:46 ` [PATCH 2/3] dt-bindings: serial: tegra-tcu: Document "reg" property Thierry Reding
@ 2021-03-26 17:46 ` Thierry Reding
  2 siblings, 0 replies; 8+ messages in thread
From: Thierry Reding @ 2021-03-26 17:46 UTC (permalink / raw)
  To: Rob Herring; +Cc: Jon Hunter, devicetree, linux-tegra

From: Thierry Reding <treding@nvidia.com>

Technically the TCU doesn't have any registers but works with two
mailboxes that serve as RX and TX FIFOs. However, if used as early
console via /chosen/stdout-path, the earlycon code will want to use
the "reg" property to initialize the I/O memory base address that
will in turn be used to access the TX FIFO.

Add the "reg" property to the TCU device tree node to make earlycon
support work out of the box.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 arch/arm64/boot/dts/nvidia/tegra194.dtsi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/nvidia/tegra194.dtsi b/arch/arm64/boot/dts/nvidia/tegra194.dtsi
index db68d53f5de0..f9fc481f90c7 100644
--- a/arch/arm64/boot/dts/nvidia/tegra194.dtsi
+++ b/arch/arm64/boot/dts/nvidia/tegra194.dtsi
@@ -2537,8 +2537,10 @@ sound {
 		assigned-clock-rates = <258000000>;
 	};
 
-	tcu: tcu {
+	tcu: tcu@c168000 {
 		compatible = "nvidia,tegra194-tcu";
+		/* TX mailbox for use with earlycon */
+		reg = <0x0 0x0c168000 0x0 0x4>;
 		mboxes = <&hsp_top0 TEGRA_HSP_MBOX_TYPE_SM TEGRA_HSP_SM_RX(0)>,
 		         <&hsp_aon TEGRA_HSP_MBOX_TYPE_SM TEGRA_HSP_SM_TX(1)>;
 		mbox-names = "rx", "tx";
-- 
2.30.2


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

* Re: [PATCH 1/3] dt-bindings: serial: tegra-tcu: Convert to json-schema
  2021-03-26 17:46 ` [PATCH 1/3] dt-bindings: serial: tegra-tcu: Convert to json-schema Thierry Reding
@ 2021-03-27 18:41   ` Rob Herring
  0 siblings, 0 replies; 8+ messages in thread
From: Rob Herring @ 2021-03-27 18:41 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-tegra, Rob Herring, Jon Hunter, devicetree

On Fri, 26 Mar 2021 18:46:39 +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> Convert the Tegra TCU device tree bindings to json-schema.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  .../bindings/serial/nvidia,tegra194-tcu.txt   | 35 ------------
>  .../bindings/serial/nvidia,tegra194-tcu.yaml  | 56 +++++++++++++++++++
>  2 files changed, 56 insertions(+), 35 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.txt
>  create mode 100644 Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml
> 

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

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

* Re: [PATCH 2/3] dt-bindings: serial: tegra-tcu: Document "reg" property
  2021-03-26 17:46 ` [PATCH 2/3] dt-bindings: serial: tegra-tcu: Document "reg" property Thierry Reding
@ 2021-03-27 18:49   ` Rob Herring
  2021-03-29  7:23     ` Thierry Reding
  2021-03-29  7:26     ` Thierry Reding
  0 siblings, 2 replies; 8+ messages in thread
From: Rob Herring @ 2021-03-27 18:49 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Jon Hunter, devicetree, linux-tegra

On Fri, Mar 26, 2021 at 06:46:40PM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> In order to support early console support with the Tegra TCU, add an
> optional "reg" property that points to the TX mailbox.

This will mean the same address in in DT twice which we try to avoid, 
right? I guess it's fine, we could drop it if we ever enforce that. I'm 
sure there's worse abuses with duplicates than this.

> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  .../devicetree/bindings/serial/nvidia,tegra194-tcu.yaml     | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml b/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml
> index 0a321658ccb5..8c9ed7cfaa52 100644
> --- a/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml
> +++ b/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml
> @@ -24,6 +24,9 @@ properties:
>    compatible:
>      const: nvidia,tegra194-tcu
>  
> +  reg:
> +    maxItems: 1
> +
>    mbox-names:
>      items:
>        - const: rx
> @@ -48,8 +51,9 @@ examples:
>    - |
>      #include <dt-bindings/mailbox/tegra186-hsp.h>
>  
> -    tcu: tcu {
> +    tcu: tcu@c168000 {

While you're here:

serial@...

>          compatible = "nvidia,tegra194-tcu";
> +        reg = <0x0c168000 0x4>;
>          mboxes = <&hsp_top0 TEGRA_HSP_MBOX_TYPE_SM 0>,
>                   <&hsp_aon TEGRA_HSP_MBOX_TYPE_SM 1>;
>          mbox-names = "rx", "tx";
> -- 
> 2.30.2
> 

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

* Re: [PATCH 2/3] dt-bindings: serial: tegra-tcu: Document "reg" property
  2021-03-27 18:49   ` Rob Herring
@ 2021-03-29  7:23     ` Thierry Reding
  2021-03-29  7:26     ` Thierry Reding
  1 sibling, 0 replies; 8+ messages in thread
From: Thierry Reding @ 2021-03-29  7:23 UTC (permalink / raw)
  To: Rob Herring; +Cc: Jon Hunter, devicetree, linux-tegra

[-- Attachment #1: Type: text/plain, Size: 2788 bytes --]

On Sat, Mar 27, 2021 at 12:49:25PM -0600, Rob Herring wrote:
> On Fri, Mar 26, 2021 at 06:46:40PM +0100, Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> > 
> > In order to support early console support with the Tegra TCU, add an
> > optional "reg" property that points to the TX mailbox.
> 
> This will mean the same address in in DT twice which we try to avoid, 
> right? I guess it's fine, we could drop it if we ever enforce that. I'm 
> sure there's worse abuses with duplicates than this.

It doesn't end up being the exact same address, but it'll be an address
that is part of the I/O memory region defined by the HSP block that
provides the mailbox. In practice this isn't going to cause a problem
because by the time the mailbox address is being used, the early console
will have been replaced by the proper TCU console. But yeah, I'm not
particularly thrilled by this, either.

I had spent a bit of time trying to code up a setup function that would
parse the necessary information from DT, but this unfortunately required
a bunch of ->setup() callbacks to be changed because we don't currently
pass in the FDT node offset, which we'd need in order for this to work.
An additional negative side-effect is that we'd need to duplicate a
bunch of logic to determine the offset to add onto the HSP base address
and that's something that depends on the particular configuration of the
HSP instance, which means lots of hard-coded conditionals.

All of that added up and at some point this slight abuse seemed like the
lesser evil.

> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> > ---
> >  .../devicetree/bindings/serial/nvidia,tegra194-tcu.yaml     | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml b/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml
> > index 0a321658ccb5..8c9ed7cfaa52 100644
> > --- a/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml
> > +++ b/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml
> > @@ -24,6 +24,9 @@ properties:
> >    compatible:
> >      const: nvidia,tegra194-tcu
> >  
> > +  reg:
> > +    maxItems: 1
> > +
> >    mbox-names:
> >      items:
> >        - const: rx
> > @@ -48,8 +51,9 @@ examples:
> >    - |
> >      #include <dt-bindings/mailbox/tegra186-hsp.h>
> >  
> > -    tcu: tcu {
> > +    tcu: tcu@c168000 {
> 
> While you're here:
> 
> serial@...

Okay, will do. It's not a very traditional serial port, so that might
perhaps be confusing, but we're using it like a serial port, so for all
intents and purposes this really is a serial port, so renaming makes
sense, I think.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 2/3] dt-bindings: serial: tegra-tcu: Document "reg" property
  2021-03-27 18:49   ` Rob Herring
  2021-03-29  7:23     ` Thierry Reding
@ 2021-03-29  7:26     ` Thierry Reding
  1 sibling, 0 replies; 8+ messages in thread
From: Thierry Reding @ 2021-03-29  7:26 UTC (permalink / raw)
  To: Rob Herring; +Cc: Jon Hunter, devicetree, linux-tegra

[-- Attachment #1: Type: text/plain, Size: 1352 bytes --]

On Sat, Mar 27, 2021 at 12:49:25PM -0600, Rob Herring wrote:
> On Fri, Mar 26, 2021 at 06:46:40PM +0100, Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> > 
> > In order to support early console support with the Tegra TCU, add an
> > optional "reg" property that points to the TX mailbox.
> 
> This will mean the same address in in DT twice which we try to avoid, 
> right? I guess it's fine, we could drop it if we ever enforce that. I'm 
> sure there's worse abuses with duplicates than this.
> 
> > 
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> > ---
> >  .../devicetree/bindings/serial/nvidia,tegra194-tcu.yaml     | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml b/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml
> > index 0a321658ccb5..8c9ed7cfaa52 100644
> > --- a/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml
> > +++ b/Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml
> > @@ -24,6 +24,9 @@ properties:
> >    compatible:
> >      const: nvidia,tegra194-tcu
> >  
> > +  reg:
> > +    maxItems: 1
> > +

After looking at this again, I think I may add a comment here to clarify
the restrictions of this property.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2021-03-29  7:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-26 17:46 [PATCH 0/3] arm64: tegra: Add earlycon support on Tegra194 Thierry Reding
2021-03-26 17:46 ` [PATCH 1/3] dt-bindings: serial: tegra-tcu: Convert to json-schema Thierry Reding
2021-03-27 18:41   ` Rob Herring
2021-03-26 17:46 ` [PATCH 2/3] dt-bindings: serial: tegra-tcu: Document "reg" property Thierry Reding
2021-03-27 18:49   ` Rob Herring
2021-03-29  7:23     ` Thierry Reding
2021-03-29  7:26     ` Thierry Reding
2021-03-26 17:46 ` [PATCH 3/3] arm64: tegra: Add "reg" property for TCU on Tegra194 Thierry Reding

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.