arm64: tegra: Add earlycon support on Tegra194
cover arm64: tegra: Add earlycon support on Tegra194
From: Thierry Reding <[email protected]>
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
Signature · 1 line
2.30.2
PATCH 1/3 dt-bindings: serial: tegra-tcu: Convert to json-schema
From: Thierry Reding <[email protected]>
Convert the Tegra TCU device tree bindings to json-schema.
--- .../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
Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.txt deleted +0 -35
@@ -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"; -};
Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCH 1/3] dt-bindings: serial: tegra-tcu: Convert to json-schema
Quoted 4 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Convert the Tegra TCU device tree bindings to json-schema.
Quoted 8 lines
Signed-off-by Thierry Reding <[email protected]>--- .../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
PATCH 2/3 dt-bindings: serial: tegra-tcu: Document "reg" property
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
In order to support early console support with the Tegra TCU, add an optional "reg" property that points to the TX mailbox.
--- .../devicetree/bindings/serial/nvidia,tegra194-tcu.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml +5 -1
@@ -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";
Signature · 1 line
2.30.2
Rob Herring
maintainerRe: [PATCH 2/3] dt-bindings: serial: tegra-tcu: Document "reg" property
Quoted 4 lines · Thierry Reding
From: Thierry Reding <[email protected]>
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.
Quoted 21 lines
Signed-off-by Thierry Reding <[email protected]>--- .../devicetree/bindings/serial/nvidia,tegra194-tcu.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml +3
-0@@ -24,6 +24,9 @@ properties: compatible: const: nvidia,tegra194-tcu + reg: + maxItems: 1 + mbox-names: items: - const: rx
Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml examples: · line 54
Quoted 5 lines
Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml +1
-1@@ -48,8 +51,9 @@ examples: - | #include <dt-bindings/mailbox/tegra186-hsp.h> - tcu: tcu { + tcu: tcu@c168000 {
While you're here:
serial@...
Quoted 8 lines
Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml +1
-0compatible = "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";Signature · 1 line
2.30.2
Re: [PATCH 2/3] dt-bindings: serial: tegra-tcu: Document "reg" property
Quoted 9 lines · Rob Herring
Quoted 4 lines · Thierry Reding
From: Thierry Reding <[email protected]>
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.
Quoted 23 lines
Quoted 23 lines
Signed-off-by Thierry Reding <[email protected]>--- .../devicetree/bindings/serial/nvidia,tegra194-tcu.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml +3
-0@@ -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>
Quoted 6 lines
Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml examples: · line 54
Quoted 2 lines
Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml +1
-1- 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
Re: [PATCH 2/3] dt-bindings: serial: tegra-tcu: Document "reg" property
In reply to Rob HerringQuoted 24 lines · Rob Herring
Quoted 4 lines · Thierry Reding
From: Thierry Reding <[email protected]>
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.
Quoted 14 lines
Signed-off-by Thierry Reding <[email protected]>--- .../devicetree/bindings/serial/nvidia,tegra194-tcu.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml +0
-0@@ -24,6 +24,9 @@ properties: compatible: const: nvidia,tegra194-tcu
Quoted 3 lines
Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml properties: · line 29
Quoted 3 lines
Documentation/devicetree/bindings/serial/nvidia,tegra194-tcu.yaml +3
-0+ reg: + maxItems: 1 +
After looking at this again, I think I may add a comment here to clarify the restrictions of this property.
Thierry
PATCH 3/3 arm64: tegra: Add "reg" property for TCU on Tegra194
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
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.
--- arch/arm64/boot/dts/nvidia/tegra194.dtsi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/nvidia/tegra194.dtsi +3 -1
@@ -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";
Signature · 1 line
2.30.2