linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] memory: tegra: Add Tegra234 support
@ 2021-12-10 16:47 Thierry Reding
  2021-12-10 16:47 ` [PATCH v2 1/6] dt-bindings: memory: tegra: Document #interconnect-cells property Thierry Reding
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Thierry Reding @ 2021-12-10 16:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Rob Herring, Thierry Reding
  Cc: Jon Hunter, linux-tegra, devicetree, linux-kernel

From: Thierry Reding <treding@nvidia.com>

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. Once the bindings are reviewed I plan to apply patches 4-6
to the Tegra tree.

Changes in v2:
- addressed all review comments on the DT schema
  - most of the conditionals weren't necessary because I found out that
    all three generations end up using the same set of interrupts for MC
    and EMC and we were assigning them wrongly
- added one patch to fix the Tegra194 EMC interrupt

Thierry

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

 .../nvidia,tegra186-mc.yaml                   | 98 ++++++++++++++++---
 arch/arm64/boot/dts/nvidia/tegra194.dtsi      |  1 +
 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 ++++++
 10 files changed, 280 insertions(+), 12 deletions(-)
 create mode 100644 drivers/memory/tegra/tegra234.c
 create mode 100644 include/dt-bindings/memory/tegra234-mc.h

-- 
2.34.1


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

* [PATCH v2 1/6] dt-bindings: memory: tegra: Document #interconnect-cells property
  2021-12-10 16:47 [PATCH v2 0/6] memory: tegra: Add Tegra234 support Thierry Reding
@ 2021-12-10 16:47 ` Thierry Reding
  2021-12-12 18:50   ` Krzysztof Kozlowski
  2021-12-10 16:47 ` [PATCH v2 2/6] dt-bindings: memory: tegra: Add Tegra234 support Thierry Reding
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Thierry Reding @ 2021-12-10 16:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Rob Herring, Thierry Reding
  Cc: Jon Hunter, linux-tegra, devicetree, linux-kernel

From: Thierry Reding <treding@nvidia.com>

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.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
Changes in v2:
- drop incomplete BPMP snippet from example
- explicitly set minItems for reg property
- describe MC and EMC general interrupts

 .../nvidia,tegra186-mc.yaml                   | 78 ++++++++++++++++---
 1 file changed, 67 insertions(+), 11 deletions(-)

diff --git a/Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml b/Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml
index 611bda38d187..b496564b1bdf 100644
--- a/Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml
+++ b/Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml
@@ -33,10 +33,12 @@ properties:
           - nvidia,tegra194-mc
 
   reg:
-    maxItems: 1
+    minItems: 1
+    maxItems: 3
 
   interrupts:
-    maxItems: 1
+    items:
+      - description: MC general interrupt
 
   "#address-cells":
     const: 2
@@ -48,6 +50,9 @@ properties:
 
   dma-ranges: true
 
+  "#interconnect-cells":
+    const: 1
+
 patternProperties:
   "^external-memory-controller@[0-9a-f]+$":
     description:
@@ -65,10 +70,12 @@ patternProperties:
               - nvidia,tegra194-emc
 
       reg:
-        maxItems: 1
+        minItems: 1
+        maxItems: 2
 
       interrupts:
-        maxItems: 1
+        items:
+          - description: EMC general interrupt
 
       clocks:
         items:
@@ -78,11 +85,65 @@ patternProperties:
         items:
           - const: emc
 
+      "#interconnect-cells":
+        const: 0
+
       nvidia,bpmp:
         $ref: /schemas/types.yaml#/definitions/phandle
         description:
           phandle of the node representing the BPMP
 
+    allOf:
+      - if:
+          properties:
+            compatible:
+              const: nvidia,tegra186-emc
+        then:
+          properties:
+            reg:
+              maxItems: 1
+
+      - if:
+          properties:
+            compatible:
+              const: nvidia,tegra194-emc
+        then:
+          properties:
+            reg:
+              minItems: 2
+
+    additionalProperties: false
+
+    required:
+      - compatible
+      - reg
+      - interrupts
+      - clocks
+      - clock-names
+      - "#interconnect-cells"
+      - nvidia,bpmp
+
+allOf:
+  - if:
+      properties:
+        compatible:
+          const: nvidia,tegra186-mc
+    then:
+      properties:
+        reg:
+          maxItems: 1
+
+  - if:
+      properties:
+        compatible:
+          const: nvidia,tegra194-mc
+    then:
+      properties:
+        reg:
+          minItems: 3
+
+additionalProperties: false
+
 required:
   - compatible
   - reg
@@ -90,8 +151,6 @@ required:
   - "#address-cells"
   - "#size-cells"
 
-additionalProperties: false
-
 examples:
   - |
     #include <dt-bindings/clock/tegra186-clock.h>
@@ -124,12 +183,9 @@ examples:
                 clocks = <&bpmp TEGRA186_CLK_EMC>;
                 clock-names = "emc";
 
+                #interconnect-cells = <0>;
+
                 nvidia,bpmp = <&bpmp>;
             };
         };
     };
-
-    bpmp: bpmp {
-        compatible = "nvidia,tegra186-bpmp";
-        #clock-cells = <1>;
-    };
-- 
2.34.1


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

* [PATCH v2 2/6] dt-bindings: memory: tegra: Add Tegra234 support
  2021-12-10 16:47 [PATCH v2 0/6] memory: tegra: Add Tegra234 support Thierry Reding
  2021-12-10 16:47 ` [PATCH v2 1/6] dt-bindings: memory: tegra: Document #interconnect-cells property Thierry Reding
@ 2021-12-10 16:47 ` Thierry Reding
  2021-12-12 18:46   ` Krzysztof Kozlowski
  2021-12-10 16:47 ` [PATCH v2 3/6] " Thierry Reding
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Thierry Reding @ 2021-12-10 16:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Rob Herring, Thierry Reding
  Cc: Jon Hunter, linux-tegra, devicetree, linux-kernel, Rob Herring

From: Thierry Reding <treding@nvidia.com>

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.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
Changes in v2:
- conditionally set minItems for reg properties

 .../nvidia,tegra186-mc.yaml                   | 20 ++++++++++++
 include/dt-bindings/clock/tegra234-clock.h    |  9 ++++++
 include/dt-bindings/memory/tegra234-mc.h      | 32 +++++++++++++++++++
 3 files changed, 61 insertions(+)
 create mode 100644 include/dt-bindings/memory/tegra234-mc.h

diff --git a/Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml b/Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml
index b496564b1bdf..13c4c82fd0d3 100644
--- a/Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml
+++ b/Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml
@@ -31,6 +31,7 @@ properties:
       - enum:
           - nvidia,tegra186-mc
           - nvidia,tegra194-mc
+          - nvidia,tegra234-mc
 
   reg:
     minItems: 1
@@ -68,6 +69,7 @@ patternProperties:
           - enum:
               - nvidia,tegra186-emc
               - nvidia,tegra194-emc
+              - nvidia,tegra234-emc
 
       reg:
         minItems: 1
@@ -112,6 +114,15 @@ patternProperties:
             reg:
               minItems: 2
 
+      - if:
+          properties:
+            compatible:
+              const: nvidia,tegra234-emc
+        then:
+          properties:
+            reg:
+              minItems: 2
+
     additionalProperties: false
 
     required:
@@ -142,6 +153,15 @@ allOf:
         reg:
           minItems: 3
 
+  - if:
+      properties:
+        compatible:
+          const: nvidia,tegra234-mc
+    then:
+      properties:
+        reg:
+          minItems: 3
+
 additionalProperties: false
 
 required:
diff --git a/include/dt-bindings/clock/tegra234-clock.h b/include/dt-bindings/clock/tegra234-clock.h
index 21ed0c732fb9..8d7e66e1b6ef 100644
--- a/include/dt-bindings/clock/tegra234-clock.h
+++ b/include/dt-bindings/clock/tegra234-clock.h
@@ -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 */
diff --git a/include/dt-bindings/memory/tegra234-mc.h b/include/dt-bindings/memory/tegra234-mc.h
new file mode 100644
index 000000000000..2662f70c15c6
--- /dev/null
+++ b/include/dt-bindings/memory/tegra234-mc.h
@@ -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
-- 
2.34.1


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

* [PATCH v2 3/6] memory: tegra: Add Tegra234 support
  2021-12-10 16:47 [PATCH v2 0/6] memory: tegra: Add Tegra234 support Thierry Reding
  2021-12-10 16:47 ` [PATCH v2 1/6] dt-bindings: memory: tegra: Document #interconnect-cells property Thierry Reding
  2021-12-10 16:47 ` [PATCH v2 2/6] dt-bindings: memory: tegra: Add Tegra234 support Thierry Reding
@ 2021-12-10 16:47 ` Thierry Reding
  2021-12-10 16:47 ` [PATCH v2 4/6] arm64: tegra: Add EMC general interrupt on Tegra194 Thierry Reding
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Thierry Reding @ 2021-12-10 16:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Rob Herring, Thierry Reding
  Cc: Jon Hunter, linux-tegra, devicetree, linux-kernel

From: Thierry Reding <treding@nvidia.com>

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.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 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

diff --git a/drivers/memory/tegra/Makefile b/drivers/memory/tegra/Makefile
index c992e87782d2..1df0b43e40b1 100644
--- a/drivers/memory/tegra/Makefile
+++ b/drivers/memory/tegra/Makefile
@@ -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
 
diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c
index 44b4a4080920..bf3abb6d8354 100644
--- a/drivers/memory/tegra/mc.c
+++ b/drivers/memory/tegra/mc.c
@@ -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 */ }
 };
diff --git a/drivers/memory/tegra/mc.h b/drivers/memory/tegra/mc.h
index 1e492989c363..062886e94c04 100644
--- a/drivers/memory/tegra/mc.h
+++ b/drivers/memory/tegra/mc.h
@@ -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
 
diff --git a/drivers/memory/tegra/tegra186-emc.c b/drivers/memory/tegra/tegra186-emc.c
index 746c4ef2c0af..54b47ca33483 100644
--- a/drivers/memory/tegra/tegra186-emc.c
+++ b/drivers/memory/tegra/tegra186-emc.c
@@ -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 */ }
 };
diff --git a/drivers/memory/tegra/tegra234.c b/drivers/memory/tegra/tegra234.c
new file mode 100644
index 000000000000..45efc5139960
--- /dev/null
+++ b/drivers/memory/tegra/tegra234.c
@@ -0,0 +1,81 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2021 NVIDIA CORPORATION.  All rights reserved.
+ */
+
+#include <soc/tegra/mc.h>
+
+#include <dt-bindings/memory/tegra234-mc.h>
+
+#include "mc.h"
+
+static const struct tegra_mc_client tegra234_mc_clients[] = {
+	{
+		.id = TEGRA234_MEMORY_CLIENT_SDMMCRAB,
+		.name = "sdmmcrab",
+		.sid = TEGRA234_SID_SDMMC4,
+		.regs = {
+			.sid = {
+				.override = 0x318,
+				.security = 0x31c,
+			},
+		},
+	}, {
+		.id = TEGRA234_MEMORY_CLIENT_SDMMCWAB,
+		.name = "sdmmcwab",
+		.sid = TEGRA234_SID_SDMMC4,
+		.regs = {
+			.sid = {
+				.override = 0x338,
+				.security = 0x33c,
+			},
+		},
+	}, {
+		.id = TEGRA234_MEMORY_CLIENT_BPMPR,
+		.name = "bpmpr",
+		.sid = TEGRA234_SID_BPMP,
+		.regs = {
+			.sid = {
+				.override = 0x498,
+				.security = 0x49c,
+			},
+		},
+	}, {
+		.id = TEGRA234_MEMORY_CLIENT_BPMPW,
+		.name = "bpmpw",
+		.sid = TEGRA234_SID_BPMP,
+		.regs = {
+			.sid = {
+				.override = 0x4a0,
+				.security = 0x4a4,
+			},
+		},
+	}, {
+		.id = TEGRA234_MEMORY_CLIENT_BPMPDMAR,
+		.name = "bpmpdmar",
+		.sid = TEGRA234_SID_BPMP,
+		.regs = {
+			.sid = {
+				.override = 0x4a8,
+				.security = 0x4ac,
+			},
+		},
+	}, {
+		.id = TEGRA234_MEMORY_CLIENT_BPMPDMAW,
+		.name = "bpmpdmaw",
+		.sid = TEGRA234_SID_BPMP,
+		.regs = {
+			.sid = {
+				.override = 0x4b0,
+				.security = 0x4b4,
+			},
+		},
+	},
+};
+
+const struct tegra_mc_soc tegra234_mc_soc = {
+	.num_clients = ARRAY_SIZE(tegra234_mc_clients),
+	.clients = tegra234_mc_clients,
+	.num_address_bits = 40,
+	.ops = &tegra186_mc_ops,
+};
-- 
2.34.1


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

* [PATCH v2 4/6] arm64: tegra: Add EMC general interrupt on Tegra194
  2021-12-10 16:47 [PATCH v2 0/6] memory: tegra: Add Tegra234 support Thierry Reding
                   ` (2 preceding siblings ...)
  2021-12-10 16:47 ` [PATCH v2 3/6] " Thierry Reding
@ 2021-12-10 16:47 ` Thierry Reding
  2021-12-10 16:47 ` [PATCH v2 5/6] arm64: tegra: Add memory controller on Tegra234 Thierry Reding
  2021-12-10 16:47 ` [PATCH v2 6/6] arm64: tegra: Hook up MMC and BPMP to memory controller Thierry Reding
  5 siblings, 0 replies; 11+ messages in thread
From: Thierry Reding @ 2021-12-10 16:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Rob Herring, Thierry Reding
  Cc: Jon Hunter, linux-tegra, devicetree, linux-kernel

From: Thierry Reding <treding@nvidia.com>

Add the missing EMC general interrupt for the external memory controller
on Tegra194.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
Changes in v2:
- new patch to add the missing EMC general interrupt on Tegra194

 arch/arm64/boot/dts/nvidia/tegra194.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/boot/dts/nvidia/tegra194.dtsi b/arch/arm64/boot/dts/nvidia/tegra194.dtsi
index 8d29b7fdb044..ee668902dd6c 100644
--- a/arch/arm64/boot/dts/nvidia/tegra194.dtsi
+++ b/arch/arm64/boot/dts/nvidia/tegra194.dtsi
@@ -593,6 +593,7 @@ emc: external-memory-controller@2c60000 {
 				compatible = "nvidia,tegra194-emc";
 				reg = <0x0 0x02c60000 0x0 0x90000>,
 				      <0x0 0x01780000 0x0 0x80000>;
+				interrupts = <GIC_SPI 224 IRQ_TYPE_LEVEL_HIGH>;
 				clocks = <&bpmp TEGRA194_CLK_EMC>;
 				clock-names = "emc";
 
-- 
2.34.1


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

* [PATCH v2 5/6] arm64: tegra: Add memory controller on Tegra234
  2021-12-10 16:47 [PATCH v2 0/6] memory: tegra: Add Tegra234 support Thierry Reding
                   ` (3 preceding siblings ...)
  2021-12-10 16:47 ` [PATCH v2 4/6] arm64: tegra: Add EMC general interrupt on Tegra194 Thierry Reding
@ 2021-12-10 16:47 ` Thierry Reding
  2021-12-10 16:47 ` [PATCH v2 6/6] arm64: tegra: Hook up MMC and BPMP to memory controller Thierry Reding
  5 siblings, 0 replies; 11+ messages in thread
From: Thierry Reding @ 2021-12-10 16:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Rob Herring, Thierry Reding
  Cc: Jon Hunter, linux-tegra, devicetree, linux-kernel

From: Thierry Reding <treding@nvidia.com>

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

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
Changes in v2:
- move EMC general interrupt from MC to EMC

 arch/arm64/boot/dts/nvidia/tegra234.dtsi | 49 ++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/arch/arm64/boot/dts/nvidia/tegra234.dtsi b/arch/arm64/boot/dts/nvidia/tegra234.dtsi
index f8061b452046..a75b21c6a521 100644
--- a/arch/arm64/boot/dts/nvidia/tegra234.dtsi
+++ b/arch/arm64/boot/dts/nvidia/tegra234.dtsi
@@ -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>;
+			#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>;
+				interrupts = <GIC_SPI 224 IRQ_TYPE_LEVEL_HIGH>;
+				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>;
-- 
2.34.1


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

* [PATCH v2 6/6] arm64: tegra: Hook up MMC and BPMP to memory controller
  2021-12-10 16:47 [PATCH v2 0/6] memory: tegra: Add Tegra234 support Thierry Reding
                   ` (4 preceding siblings ...)
  2021-12-10 16:47 ` [PATCH v2 5/6] arm64: tegra: Add memory controller on Tegra234 Thierry Reding
@ 2021-12-10 16:47 ` Thierry Reding
  5 siblings, 0 replies; 11+ messages in thread
From: Thierry Reding @ 2021-12-10 16:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Rob Herring, Thierry Reding
  Cc: Jon Hunter, linux-tegra, devicetree, linux-kernel

From: Thierry Reding <treding@nvidia.com>

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.

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

diff --git a/arch/arm64/boot/dts/nvidia/tegra234.dtsi b/arch/arm64/boot/dts/nvidia/tegra234.dtsi
index a75b21c6a521..fafbd9a819a4 100644
--- a/arch/arm64/boot/dts/nvidia/tegra234.dtsi
+++ b/arch/arm64/boot/dts/nvidia/tegra234.dtsi
@@ -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";
-- 
2.34.1


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

* Re: [PATCH v2 2/6] dt-bindings: memory: tegra: Add Tegra234 support
  2021-12-10 16:47 ` [PATCH v2 2/6] dt-bindings: memory: tegra: Add Tegra234 support Thierry Reding
@ 2021-12-12 18:46   ` Krzysztof Kozlowski
  2021-12-13 16:21     ` Thierry Reding
  0 siblings, 1 reply; 11+ messages in thread
From: Krzysztof Kozlowski @ 2021-12-12 18:46 UTC (permalink / raw)
  To: Thierry Reding, Rob Herring
  Cc: Jon Hunter, linux-tegra, devicetree, linux-kernel, Rob Herring

On 10/12/2021 17:47, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> 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.
> 
> Reviewed-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
> Changes in v2:
> - conditionally set minItems for reg properties
> 
>  .../nvidia,tegra186-mc.yaml                   | 20 ++++++++++++
>  include/dt-bindings/clock/tegra234-clock.h    |  9 ++++++
>  include/dt-bindings/memory/tegra234-mc.h      | 32 +++++++++++++++++++
>  3 files changed, 61 insertions(+)
>  create mode 100644 include/dt-bindings/memory/tegra234-mc.h
> 

(...)

>  /** @brief output of mux controlled by CLK_RST_CONTROLLER_CLK_SOURCE_SDMMC4 */
> diff --git a/include/dt-bindings/memory/tegra234-mc.h b/include/dt-bindings/memory/tegra234-mc.h
> new file mode 100644
> index 000000000000..2662f70c15c6
> --- /dev/null
> +++ b/include/dt-bindings/memory/tegra234-mc.h
> @@ -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
> +

This header is needed by the driver and DTS patches. One of us can apply
it and provide to the other via stable-tag. I think Arnd and Olof prefer
if headers are coming with DTS and are provided to other trees, so maybe
you will take the bindings and provide a tag for me for the driver?

Best regards,
Krzysztof

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

* Re: [PATCH v2 1/6] dt-bindings: memory: tegra: Document #interconnect-cells property
  2021-12-10 16:47 ` [PATCH v2 1/6] dt-bindings: memory: tegra: Document #interconnect-cells property Thierry Reding
@ 2021-12-12 18:50   ` Krzysztof Kozlowski
  2021-12-13 16:18     ` Thierry Reding
  0 siblings, 1 reply; 11+ messages in thread
From: Krzysztof Kozlowski @ 2021-12-12 18:50 UTC (permalink / raw)
  To: Thierry Reding, Rob Herring
  Cc: Jon Hunter, linux-tegra, devicetree, linux-kernel

On 10/12/2021 17:47, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> 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.

I think number of interrupts is fixed and you do not change them for
newer SoC, so the message is a little bit not precise. Also the subject
does not it the patch - maybe something like - "adjust properties for
Tegra196"?

> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
> Changes in v2:
> - drop incomplete BPMP snippet from example
> - explicitly set minItems for reg property
> - describe MC and EMC general interrupts
> 
>  .../nvidia,tegra186-mc.yaml                   | 78 ++++++++++++++++---
>  1 file changed, 67 insertions(+), 11 deletions(-)
> 



Best regards,
Krzysztof

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

* Re: [PATCH v2 1/6] dt-bindings: memory: tegra: Document #interconnect-cells property
  2021-12-12 18:50   ` Krzysztof Kozlowski
@ 2021-12-13 16:18     ` Thierry Reding
  0 siblings, 0 replies; 11+ messages in thread
From: Thierry Reding @ 2021-12-13 16:18 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Rob Herring, Jon Hunter, linux-tegra, devicetree, linux-kernel

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

On Sun, Dec 12, 2021 at 07:50:25PM +0100, Krzysztof Kozlowski wrote:
> On 10/12/2021 17:47, Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> > 
> > 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.
> 
> I think number of interrupts is fixed and you do not change them for
> newer SoC, so the message is a little bit not precise. Also the subject
> does not it the patch - maybe something like - "adjust properties for
> Tegra196"?

Yeah, I forgot to update the commit message after making the changes in
v2. I'll send out v3 with an updated commit message.

Thanks,
Thierry

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

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

* Re: [PATCH v2 2/6] dt-bindings: memory: tegra: Add Tegra234 support
  2021-12-12 18:46   ` Krzysztof Kozlowski
@ 2021-12-13 16:21     ` Thierry Reding
  0 siblings, 0 replies; 11+ messages in thread
From: Thierry Reding @ 2021-12-13 16:21 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Rob Herring, Jon Hunter, linux-tegra, devicetree, linux-kernel,
	Rob Herring

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

On Sun, Dec 12, 2021 at 07:46:06PM +0100, Krzysztof Kozlowski wrote:
> On 10/12/2021 17:47, Thierry Reding wrote:
> > From: Thierry Reding <treding@nvidia.com>
> > 
> > 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.
> > 
> > Reviewed-by: Rob Herring <robh@kernel.org>
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> > ---
> > Changes in v2:
> > - conditionally set minItems for reg properties
> > 
> >  .../nvidia,tegra186-mc.yaml                   | 20 ++++++++++++
> >  include/dt-bindings/clock/tegra234-clock.h    |  9 ++++++
> >  include/dt-bindings/memory/tegra234-mc.h      | 32 +++++++++++++++++++
> >  3 files changed, 61 insertions(+)
> >  create mode 100644 include/dt-bindings/memory/tegra234-mc.h
> > 
> 
> (...)
> 
> >  /** @brief output of mux controlled by CLK_RST_CONTROLLER_CLK_SOURCE_SDMMC4 */
> > diff --git a/include/dt-bindings/memory/tegra234-mc.h b/include/dt-bindings/memory/tegra234-mc.h
> > new file mode 100644
> > index 000000000000..2662f70c15c6
> > --- /dev/null
> > +++ b/include/dt-bindings/memory/tegra234-mc.h
> > @@ -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
> > +
> 
> This header is needed by the driver and DTS patches. One of us can apply
> it and provide to the other via stable-tag. I think Arnd and Olof prefer
> if headers are coming with DTS and are provided to other trees, so maybe
> you will take the bindings and provide a tag for me for the driver?

Yeah, once you're happy with the series (I've just sent out an updated
v3) I can apply this to the Tegra tree and send you a stable tag to pull
into your tree.

Thierry

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

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

end of thread, other threads:[~2021-12-13 16:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-10 16:47 [PATCH v2 0/6] memory: tegra: Add Tegra234 support Thierry Reding
2021-12-10 16:47 ` [PATCH v2 1/6] dt-bindings: memory: tegra: Document #interconnect-cells property Thierry Reding
2021-12-12 18:50   ` Krzysztof Kozlowski
2021-12-13 16:18     ` Thierry Reding
2021-12-10 16:47 ` [PATCH v2 2/6] dt-bindings: memory: tegra: Add Tegra234 support Thierry Reding
2021-12-12 18:46   ` Krzysztof Kozlowski
2021-12-13 16:21     ` Thierry Reding
2021-12-10 16:47 ` [PATCH v2 3/6] " Thierry Reding
2021-12-10 16:47 ` [PATCH v2 4/6] arm64: tegra: Add EMC general interrupt on Tegra194 Thierry Reding
2021-12-10 16:47 ` [PATCH v2 5/6] arm64: tegra: Add memory controller on Tegra234 Thierry Reding
2021-12-10 16:47 ` [PATCH v2 6/6] arm64: tegra: Hook up MMC and BPMP to memory controller Thierry Reding

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