memory: tegra: Add Tegra234 support
v3 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. Once the bindings are reviewed I plan to apply patches 4-6 to the Tegra tree.
Changes in v3:
- update commit message of patch 1
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
*** BLURB HERE ***
Thierry Reding (6):
dt-bindings: memory: tegra: Update for Tegra194
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
Signature · 1 line
2.34.1
PATCH v3 1/6 dt-bindings: memory: tegra: Update for Tegra194
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.
For the nested EMC controller, the list of required properties was missing. Add it so that the validation can be more strict.
Also, allow multiple reg entries required by Tegra194 and later.
While at it, also remove the dummy BPMP node from the example because it is incomplete and fails validation. It's also not necessary for this file and the BPMP DT schema already has a full example.
---
Changes in v3:
- reword commit message to reflect changes in v2
Changes in v2:
- drop incomplete BPMP snippet from example
- explicitly set minItems for reg property
- describe MC and EMC general interrupts
- add required properties for EMC
.../nvidia,tegra186-mc.yaml | 78 ++++++++++++++++--- 1 file changed, 67 insertions(+), 11 deletions(-)
Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml +67 -11
@@ -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>; - };
Signature · 1 line
2.34.1
Re: [PATCH v3 1/6] dt-bindings: memory: tegra: Update for Tegra194
Quoted 20 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.
For the nested EMC controller, the list of required properties was missing. Add it so that the validation can be more strict.
Also, allow multiple reg entries required by Tegra194 and later.
While at it, also remove the dummy BPMP node from the example because it is incomplete and fails validation. It's also not necessary for this file and the BPMP DT schema already has a full example.
Signed-off-by Thierry Reding <[email protected]>---
Changes in v3:
- reword commit message to reflect changes in v2
Quoted 9 lines
Changes in v2:
- drop incomplete BPMP snippet from example
- explicitly set minItems for reg property
- describe MC and EMC general interrupts
- add required properties for EMC.../nvidia,tegra186-mc.yaml | 78 ++++++++++++++++--- 1 file changed, 67 insertions(+), 11 deletions(-)
Best regards,
Krzysztof
Re: [PATCH v3 1/6] dt-bindings: memory: tegra: Update for Tegra194
In reply to Thierry RedingQuoted 20 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.
For the nested EMC controller, the list of required properties was missing. Add it so that the validation can be more strict.
Also, allow multiple reg entries required by Tegra194 and later.
While at it, also remove the dummy BPMP node from the example because it is incomplete and fails validation. It's also not necessary for this file and the BPMP DT schema already has a full example.
Signed-off-by Thierry Reding <[email protected]>---
Changes in v3:
- reword commit message to reflect changes in v2
Quoted 9 lines
Changes in v2:
- drop incomplete BPMP snippet from example
- explicitly set minItems for reg property
- describe MC and EMC general interrupts
- add required properties for EMC.../nvidia,tegra186-mc.yaml | 78 ++++++++++++++++--- 1 file changed, 67 insertions(+), 11 deletions(-)
PATCH v3 2/6 dt-bindings: memory: tegra: Add Tegra234 support
In reply to Thierry RedingFrom: 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.
---
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
Documentation/devicetree/bindings/memory-controllers/nvidia,tegra186-mc.yaml +20 -0
@@ -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:
include/dt-bindings/clock/tegra234-clock.h +9 -0
@@ -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
@@ -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.34.1
Re: [PATCH v3 2/6] dt-bindings: memory: tegra: Add Tegra234 support
Quoted 12 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.
Reviewed-by Rob Herring <[email protected]>Signed-off-by Thierry Reding <[email protected]>---
Changes in v2:
- conditionally set minItems for reg properties
Quoted 6 lines
.../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
Provide me a stable tag with the headers, please.
Best regards,
Krzysztof
PATCH v3 3/6 memory: tegra: Add Tegra234 support
In reply to Thierry RedingFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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.34.1
PATCH v3 4/6 arm64: tegra: Add EMC general interrupt on Tegra194
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Add the missing EMC general interrupt for the external memory controller on Tegra194.
--- arch/arm64/boot/dts/nvidia/tegra194.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/nvidia/tegra194.dtsi +1 -0
@@ -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";
Signature · 1 line
2.34.1
PATCH v3 5/6 arm64: tegra: Add memory controller on Tegra234
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
This adds the memory controller and the embedded external memory controller found on the Tegra234 SoC.
---
Changes in v2:
- move EMC general interrupt from MC to EMC
arch/arm64/boot/dts/nvidia/tegra234.dtsi | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
arch/arm64/boot/dts/nvidia/tegra234.dtsi +49 -0
@@ -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>;
Signature · 1 line
2.34.1
PATCH v3 6/6 arm64: tegra: Hook up MMC and BPMP to memory controller
In reply to Thierry RedingFrom: 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
@@ -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.34.1