Skip to contentSkip to conversation

memory: tegra: Add Tegra234 support

PATCH Superseded Thierry Reding 3 participants 9 messages Nov 12, 2021 – Nov 29, 2021

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover memory: tegra: Add Tegra234 support

From: Thierry Reding <[email protected]>

Hi,

this series adds support to the Tegra memory controller driver for the version found on the new Tegra234 SoC. It is mostly similar to that on earlier chips, except that the memory clients differ.

This also updates the device tree binding with a missing property and ensures that all versions of the memory controller device tree nodes can be properly validated.

Finally, the device trees for Tegra234 are updated and memory client nodes are hooked up to the memory controller via interconnect properties.

Thierry

Thierry Reding (5):
dt-bindings: memory: tegra: Document #interconnect-cells property
dt-bindings: memory: tegra: Add Tegra234 support
memory: tegra: Add Tegra234 support
arm64: tegra: Add memory controller on Tegra234
arm64: tegra: Hook up MMC and BPMP to memory controller

 .../nvidia,tegra186-mc.yaml                   | 14 +++-
 arch/arm64/boot/dts/nvidia/tegra234.dtsi      | 57 +++++++++++++
 drivers/memory/tegra/Makefile                 |  1 +
 drivers/memory/tegra/mc.c                     |  3 +
 drivers/memory/tegra/mc.h                     |  7 +-
 drivers/memory/tegra/tegra186-emc.c           |  3 +
 drivers/memory/tegra/tegra234.c               | 81 +++++++++++++++++++
 include/dt-bindings/clock/tegra234-clock.h    |  9 +++
 include/dt-bindings/memory/tegra234-mc.h      | 32 ++++++++
 9 files changed, 203 insertions(+), 4 deletions(-)
 create mode 100644 drivers/memory/tegra/tegra234.c
 create mode 100644 include/dt-bindings/memory/tegra234-mc.h
Signature · 1 line
2.33.1
#1 lore raw

PATCH 1/5 dt-bindings: memory: tegra: Document #interconnect-cells property

From: Thierry Reding <[email protected]>

The #interconnect-cells properties are required to hook up memory clients to the MC/EMC in interconnects properties. Add a description for these properties.

Also, allow multiple reg and interrupt entries required by Tegra194 and later.

---
 .../memory-controllers/nvidia,tegra186-mc.yaml       | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml +9 -3
index 611bda38d187..f6e4af4e86cf 100644
@@ -33,10 +33,10 @@ properties:
           - nvidia,tegra194-mc
 
   reg:
-    maxItems: 1
+    maxItems: 3
 
   interrupts:
-    maxItems: 1
+    maxItems: 2
 
   "#address-cells":
     const: 2
@@ -48,6 +48,9 @@ properties:
 
   dma-ranges: true
 
+  "#interconnect-cells":
+    const: 1
+
 patternProperties:
   "^external-memory-controller@[0-9a-f]+$":
     description:
@@ -65,7 +68,7 @@ patternProperties:
               - nvidia,tegra194-emc
 
       reg:
-        maxItems: 1
+        maxItems: 2
 
       interrupts:
         maxItems: 1
@@ -78,6 +81,9 @@ patternProperties:
         items:
           - const: emc
 
+      "#interconnect-cells":
+        const: 0
+
       nvidia,bpmp:
         $ref: /schemas/types.yaml#/definitions/phandle
         description:
Signature · 1 line
2.33.1
maintainer
#2 lore raw

Re: [PATCH 1/5] dt-bindings: memory: tegra: Document #interconnect-cells property

Quoted 6 lines · Thierry Reding

From: Thierry Reding <[email protected]>

The #interconnect-cells properties are required to hook up memory clients to the MC/EMC in interconnects properties. Add a description for these properties.

Quoted 8 lines

Also, allow multiple reg and interrupt entries required by Tegra194 and later.

---
 .../memory-controllers/nvidia,tegra186-mc.yaml       | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.example.dt.yaml: memory-controller@2c00000: reg: [[0, 46137344, 0, 720896]] is too short
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.example.dt.yaml: memory-controller@2c00000: interrupts: [[0, 223, 4]] is too short
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.example.dt.yaml: memory-controller@2c00000: external-memory-controller@2c60000:reg: [[0, 46530560, 0, 327680]] is too short
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/1554376

This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

#3 lore raw

Re: [PATCH 1/5] dt-bindings: memory: tegra: Document #interconnect-cells property

In reply to Thierry Reding
Quoted 19 lines · Thierry Reding

From: Thierry Reding <[email protected]>

The #interconnect-cells properties are required to hook up memory clients to the MC/EMC in interconnects properties. Add a description for these properties.

Also, allow multiple reg and interrupt entries required by Tegra194 and later.

---
 .../memory-controllers/nvidia,tegra186-mc.yaml       | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml +0 -0
index 611bda38d187..f6e4af4e86cf 100644

Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml properties: · line 39

Quoted 9 lines
Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml +2 -2
@@ -33,10 +33,10 @@ properties:
           - nvidia,tegra194-mc
 
   reg:
-    maxItems: 1
+    maxItems: 3
 
   interrupts:
-    maxItems: 1
+    maxItems: 2

All these here and reg below might need if-else to define when one item is allowed, when not. For example - can nvidia,tegra234-mc come with only one reg?

Except this and Rob's DT-checker-bot rest of patches look ok to me.

Best regards,
Krzysztof

Quoted 23 lines
Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml +4 -1
   "#address-cells":
     const: 2
@@ -48,6 +48,9 @@ properties:
 
   dma-ranges: true
 
+  "#interconnect-cells":
+    const: 1
+
 patternProperties:
   "^external-memory-controller@[0-9a-f]+$":
     description:
@@ -65,7 +68,7 @@ patternProperties:
               - nvidia,tegra194-emc
 
       reg:
-        maxItems: 1
+        maxItems: 2
 
       interrupts:
         maxItems: 1

Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml patternProperties: · line 82

Quoted 2 lines
Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml +0 -0
@@ -78,6 +81,9 @@ patternProperties:
         items:
           - const: emc

Best regards,
Krzysztof

#4 lore raw

PATCH 2/5 dt-bindings: memory: tegra: Add Tegra234 support

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Document the variant of the memory controller and external memory controllers found on Tegra234 and add some memory client and SMMU stream ID definitions for use in device tree files.

---
 .../nvidia,tegra186-mc.yaml                   |  2 ++
 include/dt-bindings/clock/tegra234-clock.h    |  9 ++++++
 include/dt-bindings/memory/tegra234-mc.h      | 32 +++++++++++++++++++
 3 files changed, 43 insertions(+)
 create mode 100644 include/dt-bindings/memory/tegra234-mc.h
Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml +2 -0
index f6e4af4e86cf..75bad0cb9d7e 100644
@@ -31,6 +31,7 @@ properties:
       - enum:
           - nvidia,tegra186-mc
           - nvidia,tegra194-mc
+          - nvidia,tegra234-mc
 
   reg:
     maxItems: 3
@@ -66,6 +67,7 @@ patternProperties:
           - enum:
               - nvidia,tegra186-emc
               - nvidia,tegra194-emc
+              - nvidia,tegra234-emc
 
       reg:
         maxItems: 2
include/dt-bindings/clock/tegra234-clock.h +9 -0
index 21ed0c732fb9..8d7e66e1b6ef 100644
@@ -9,6 +9,15 @@
  * @defgroup bpmp_clock_ids Clock ID's
  * @{
  */
+/**
+ * @brief controls the EMC clock frequency.
+ * @details Doing a clk_set_rate on this clock will select the
+ * appropriate clock source, program the source rate and execute a
+ * specific sequence to switch to the new clock source for both memory
+ * controllers. This can be used to control the balance between memory
+ * throughput and memory controller power.
+ */
+#define TEGRA234_CLK_EMC			31U
 /** @brief output of gate CLK_ENB_FUSE */
 #define TEGRA234_CLK_FUSE			40U
 /** @brief output of mux controlled by CLK_RST_CONTROLLER_CLK_SOURCE_SDMMC4 */
include/dt-bindings/memory/tegra234-mc.h new file +32 -0
new file mode 100644
index 000000000000..2662f70c15c6
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
+
+#ifndef DT_BINDINGS_MEMORY_TEGRA234_MC_H
+#define DT_BINDINGS_MEMORY_TEGRA234_MC_H
+
+/* special clients */
+#define TEGRA234_SID_INVALID		0x00
+#define TEGRA234_SID_PASSTHROUGH	0x7f
+
+
+/* NISO1 stream IDs */
+#define TEGRA234_SID_SDMMC4	0x02
+#define TEGRA234_SID_BPMP	0x10
+
+/*
+ * memory client IDs
+ */
+
+/* sdmmcd memory read client */
+#define TEGRA234_MEMORY_CLIENT_SDMMCRAB 0x63
+/* sdmmcd memory write client */
+#define TEGRA234_MEMORY_CLIENT_SDMMCWAB 0x67
+/* BPMP read client */
+#define TEGRA234_MEMORY_CLIENT_BPMPR 0x93
+/* BPMP write client */
+#define TEGRA234_MEMORY_CLIENT_BPMPW 0x94
+/* BPMPDMA read client */
+#define TEGRA234_MEMORY_CLIENT_BPMPDMAR 0x95
+/* BPMPDMA write client */
+#define TEGRA234_MEMORY_CLIENT_BPMPDMAW 0x96
+
+#endif
Signature · 1 line
2.33.1
maintainer Reviewed-by on v1 2/5
#5 lore raw

Re: [PATCH 2/5] dt-bindings: memory: tegra: Add Tegra234 support

Quoted 6 lines · Thierry Reding

From: Thierry Reding <[email protected]>

Document the variant of the memory controller and external memory controllers found on Tegra234 and add some memory client and SMMU stream ID definitions for use in device tree files.

Quoted 8 lines
---
 .../nvidia,tegra186-mc.yaml                   |  2 ++
 include/dt-bindings/clock/tegra234-clock.h    |  9 ++++++
 include/dt-bindings/memory/tegra234-mc.h      | 32 +++++++++++++++++++
 3 files changed, 43 insertions(+)
 create mode 100644 include/dt-bindings/memory/tegra234-mc.h
#6 lore raw

PATCH 3/5 memory: tegra: Add Tegra234 support

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

The memory controller and external memory controller found on Tegra234 is similar to the version found on earlier SoCs but supports a number of new memory clients.

Add initial memory client definitions for the Tegra234 so that the SMMU stream ID override registers can be properly programmed at boot time.

---
 drivers/memory/tegra/Makefile       |  1 +
 drivers/memory/tegra/mc.c           |  3 ++
 drivers/memory/tegra/mc.h           |  7 ++-
 drivers/memory/tegra/tegra186-emc.c |  3 ++
 drivers/memory/tegra/tegra234.c     | 81 +++++++++++++++++++++++++++++
 5 files changed, 94 insertions(+), 1 deletion(-)
 create mode 100644 drivers/memory/tegra/tegra234.c
drivers/memory/tegra/Makefile +1 -0
index c992e87782d2..1df0b43e40b1 100644
@@ -9,6 +9,7 @@ tegra-mc-$(CONFIG_ARCH_TEGRA_132_SOC) += tegra124.o
 tegra-mc-$(CONFIG_ARCH_TEGRA_210_SOC) += tegra210.o
 tegra-mc-$(CONFIG_ARCH_TEGRA_186_SOC) += tegra186.o
 tegra-mc-$(CONFIG_ARCH_TEGRA_194_SOC) += tegra186.o tegra194.o
+tegra-mc-$(CONFIG_ARCH_TEGRA_194_SOC) += tegra186.o tegra234.o
 
 obj-$(CONFIG_TEGRA_MC) += tegra-mc.o
 
drivers/memory/tegra/mc.c +3 -0
index 44b4a4080920..bf3abb6d8354 100644
@@ -44,6 +44,9 @@ static const struct of_device_id tegra_mc_of_match[] = {
 #endif
 #ifdef CONFIG_ARCH_TEGRA_194_SOC
 	{ .compatible = "nvidia,tegra194-mc", .data = &tegra194_mc_soc },
+#endif
+#ifdef CONFIG_ARCH_TEGRA_234_SOC
+	{ .compatible = "nvidia,tegra234-mc", .data = &tegra234_mc_soc },
 #endif
 	{ /* sentinel */ }
 };
drivers/memory/tegra/mc.h +6 -1
index 1e492989c363..062886e94c04 100644
@@ -137,6 +137,10 @@ extern const struct tegra_mc_soc tegra186_mc_soc;
 extern const struct tegra_mc_soc tegra194_mc_soc;
 #endif
 
+#ifdef CONFIG_ARCH_TEGRA_234_SOC
+extern const struct tegra_mc_soc tegra234_mc_soc;
+#endif
+
 #if defined(CONFIG_ARCH_TEGRA_3x_SOC) || \
     defined(CONFIG_ARCH_TEGRA_114_SOC) || \
     defined(CONFIG_ARCH_TEGRA_124_SOC) || \
@@ -147,7 +151,8 @@ extern const struct tegra_mc_ops tegra30_mc_ops;
 #endif
 
 #if defined(CONFIG_ARCH_TEGRA_186_SOC) || \
-    defined(CONFIG_ARCH_TEGRA_194_SOC)
+    defined(CONFIG_ARCH_TEGRA_194_SOC) || \
+    defined(CONFIG_ARCH_TEGRA_234_SOC)
 extern const struct tegra_mc_ops tegra186_mc_ops;
 #endif
 
drivers/memory/tegra/tegra186-emc.c +3 -0
index 746c4ef2c0af..54b47ca33483 100644
@@ -272,6 +272,9 @@ static const struct of_device_id tegra186_emc_of_match[] = {
 #endif
 #if defined(CONFIG_ARCH_TEGRA_194_SOC)
 	{ .compatible = "nvidia,tegra194-emc" },
+#endif
+#if defined(CONFIG_ARCH_TEGRA_234_SOC)
+	{ .compatible = "nvidia,tegra234-emc" },
 #endif
 	{ /* sentinel */ }
 };
drivers/memory/tegra/tegra234.c new file +81 -0

81 lines not on this page · raw message

Signature · 1 line
2.33.1
#7 lore raw

PATCH 4/5 arm64: tegra: Add memory controller on Tegra234

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

This adds the memory controller and the embedded external memory controller found on the Tegra234 SoC.

---
 arch/arm64/boot/dts/nvidia/tegra234.dtsi | 49 ++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
arch/arm64/boot/dts/nvidia/tegra234.dtsi +49 -0
index ad6978ca7162..8893d110a0ae 100644
@@ -4,6 +4,7 @@
 #include <dt-bindings/gpio/tegra234-gpio.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/mailbox/tegra186-hsp.h>
+#include <dt-bindings/memory/tegra234-mc.h>
 #include <dt-bindings/reset/tegra234-reset.h>
 
 / {
@@ -85,6 +86,54 @@ gpio: gpio@2200000 {
 			gpio-controller;
 		};
 
+		mc: memory-controller@2c00000 {
+			compatible = "nvidia,tegra234-mc";
+			reg = <0x02c00000 0x100000>,
+			      <0x02b80000 0x040000>,
+			      <0x01700000 0x100000>;
+			interrupts = <GIC_SPI 223 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 224 IRQ_TYPE_LEVEL_HIGH>;
+			#interconnect-cells = <1>;
+			status = "okay";
+
+			#address-cells = <2>;
+			#size-cells = <2>;
+
+			ranges = <0x01700000 0x0 0x01700000 0x0 0x100000>,
+				 <0x02b80000 0x0 0x02b80000 0x0 0x040000>,
+				 <0x02c00000 0x0 0x02c00000 0x0 0x100000>;
+
+			/*
+			 * Bit 39 of addresses passing through the memory
+			 * controller selects the XBAR format used when memory
+			 * is accessed. This is used to transparently access
+			 * memory in the XBAR format used by the discrete GPU
+			 * (bit 39 set) or Tegra (bit 39 clear).
+			 *
+			 * As a consequence, the operating system must ensure
+			 * that bit 39 is never used implicitly, for example
+			 * via an I/O virtual address mapping of an IOMMU. If
+			 * devices require access to the XBAR switch, their
+			 * drivers must set this bit explicitly.
+			 *
+			 * Limit the DMA range for memory clients to [38:0].
+			 */
+			dma-ranges = <0x0 0x0 0x0 0x80 0x0>;
+
+			emc: external-memory-controller@2c60000 {
+				compatible = "nvidia,tegra234-emc";
+				reg = <0x0 0x02c60000 0x0 0x90000>,
+				      <0x0 0x01780000 0x0 0x80000>;
+				clocks = <&bpmp TEGRA234_CLK_EMC>;
+				clock-names = "emc";
+				status = "okay";
+
+				#interconnect-cells = <0>;
+
+				nvidia,bpmp = <&bpmp>;
+			};
+		};
+
 		uarta: serial@3100000 {
 			compatible = "nvidia,tegra234-uart", "nvidia,tegra20-uart";
 			reg = <0x03100000 0x10000>;
Signature · 1 line
2.33.1
#8 lore raw

PATCH 5/5 arm64: tegra: Hook up MMC and BPMP to memory controller

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Use the interconnects property to hook up the MMC and BPMP to the memory controller. This is needed to set the correct bus-level DMA mask, which is a prerequisite for adding IOMMU support.

---
 arch/arm64/boot/dts/nvidia/tegra234.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm64/boot/dts/nvidia/tegra234.dtsi +8 -0
index 8893d110a0ae..07ab9137f681 100644
@@ -157,6 +157,9 @@ mmc@3460000 {
 			assigned-clock-parents = <&bpmp TEGRA234_CLK_PLLC4>;
 			resets = <&bpmp TEGRA234_RESET_SDMMC4>;
 			reset-names = "sdhci";
+			interconnects = <&mc TEGRA234_MEMORY_CLIENT_SDMMCRAB &emc>,
+					<&mc TEGRA234_MEMORY_CLIENT_SDMMCWAB &emc>;
+			interconnect-names = "dma-mem", "write";
 			nvidia,pad-autocal-pull-up-offset-hs400 = <0x00>;
 			nvidia,pad-autocal-pull-down-offset-hs400 = <0x00>;
 			nvidia,pad-autocal-pull-up-offset-1v8-timeout = <0x0a>;
@@ -289,6 +292,11 @@ bpmp: bpmp {
 		#clock-cells = <1>;
 		#reset-cells = <1>;
 		#power-domain-cells = <1>;
+		interconnects = <&mc TEGRA234_MEMORY_CLIENT_BPMPR &emc>,
+				<&mc TEGRA234_MEMORY_CLIENT_BPMPW &emc>,
+				<&mc TEGRA234_MEMORY_CLIENT_BPMPDMAR &emc>,
+				<&mc TEGRA234_MEMORY_CLIENT_BPMPDMAW &emc>;
+		interconnect-names = "read", "write", "dma-mem", "dma-write";
 
 		bpmp_i2c: i2c {
 			compatible = "nvidia,tegra186-bpmp-i2c";
Signature · 1 line
2.33.1