Tegra114: implement EMC support
cover Tegra114: implement EMC support
Add support for External Memory Controller found in Tegra 4 SoC along with adjustments required for it to work properly.
Tested on ASUS TF701T (T40X) and Nvidia Tegratab (T40S). Both work fine.
Part of previous patchset: https://lore.kernel.org/lkml/[email protected]/
Svyatoslav Ryhel (5):
dt-bindings: memory: Document Tegra114 Memory Controller
memory: tegra: implement EMEM regs and ICC ops for Tegra114
dt-bindings: memory: Add Tegra114 memory client IDs
dt-bindings: memory: Document Tegra114 External Memory Controller
memory: tegra: Add Tegra114 EMC driver
.../nvidia,tegra124-emc.yaml | 174 +- .../nvidia,tegra124-mc.yaml | 31 +- drivers/memory/tegra/Kconfig | 12 + drivers/memory/tegra/Makefile | 1 + drivers/memory/tegra/tegra114-emc.c | 1463 +++++++++++++++++ drivers/memory/tegra/tegra114.c | 193 +++ include/dt-bindings/memory/tegra114-mc.h | 67 + 7 files changed, 1770 insertions(+), 171 deletions(-) create mode 100644 drivers/memory/tegra/tegra114-emc.c
Signature · 1 line
2.51.0
PATCH 1/5 dt-bindings: memory: Document Tegra114 Memory Controller
Add Tegra114 support into existing Tegra124 MC schema with the most notable difference in the amount of EMEM timings.
--- .../nvidia,tegra124-mc.yaml | 31 +++++-------------- 1 file changed, 8 insertions(+), 23 deletions(-)
Documentation/devicetree/bindings/memory-controllers/nvidia,tegra124-mc.yaml +8 -23
@@ -19,7 +19,9 @@ description: | properties: compatible: - const: nvidia,tegra124-mc + enum: + - nvidia,tegra114-mc + - nvidia,tegra124-mc reg: maxItems: 1
@@ -64,29 +66,12 @@ patternProperties: nvidia,emem-configuration: $ref: /schemas/types.yaml#/definitions/uint32-array - description: | + description: Values to be written to the EMEM register block. See section - "15.6.1 MC Registers" in the TRM. - items: - - description: MC_EMEM_ARB_CFG - - description: MC_EMEM_ARB_OUTSTANDING_REQ - - description: MC_EMEM_ARB_TIMING_RCD - - description: MC_EMEM_ARB_TIMING_RP - - description: MC_EMEM_ARB_TIMING_RC - - description: MC_EMEM_ARB_TIMING_RAS - - description: MC_EMEM_ARB_TIMING_FAW - - description: MC_EMEM_ARB_TIMING_RRD - - description: MC_EMEM_ARB_TIMING_RAP2PRE - - description: MC_EMEM_ARB_TIMING_WAP2PRE - - description: MC_EMEM_ARB_TIMING_R2R - - description: MC_EMEM_ARB_TIMING_W2W - - description: MC_EMEM_ARB_TIMING_R2W - - description: MC_EMEM_ARB_TIMING_W2R - - description: MC_EMEM_ARB_DA_TURNS - - description: MC_EMEM_ARB_DA_COVERS - - description: MC_EMEM_ARB_MISC0 - - description: MC_EMEM_ARB_MISC1 - - description: MC_EMEM_ARB_RING1_THROTTLE + "20.11.1 MC Registers" in the Tegea114 TRM or + "15.6.1 MC Registers" in the Tegra124 TRM. + minItems: 18 + maxItems: 19 required: - clock-frequency
Signature · 1 line
2.51.0
PATCH 2/5 memory: tegra: implement EMEM regs and ICC ops for Tegra114
In reply to Svyatoslav RyhelPrepare Internal Memory Controller for introduction of External Memory Controller.
--- drivers/memory/tegra/tegra114.c | 193 ++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+)
drivers/memory/tegra/tegra114.c +193 -0
@@ -3,6 +3,7 @@* Copyright (C) 2014 NVIDIA CORPORATION. All rights reserved. */ +#include <linux/device.h> #include <linux/of.h> #include <linux/mm.h>
@@ -1165,6 +1166,195 @@ static const struct tegra_mc_reset tegra114_mc_resets[] = { TEGRA114_MC_RESET(VI, 0x200, 0x204, 17), }; +static void tegra114_mc_tune_client_latency (struct tegra_mc *mc, +const struct tegra_mc_client *client, +unsigned int bandwidth_mbytes_sec) +{ +u32 arb_tolerance_compensation_nsec, arb_tolerance_compensation_div; +unsigned int fifo_size = client->fifo_size; +u32 arb_nsec, la_ticks, value; + +/* see 20.3.1.1 Client Configuration in Tegra4 TRM v01p */ +if (bandwidth_mbytes_sec) + arb_nsec = fifo_size *NSEC_PER_USEC / bandwidth_mbytes_sec; +else + arb_nsec =U32_MAX ; + +/* +* Latency allowness should be set with consideration for the module's +* latency tolerance and internal buffering capabilities. +* +* Display memory clients use isochronous transfers and have very low +* tolerance to a belated transfers. Hence we need to compensate the +* memory arbitration imperfection for them in order to prevent FIFO +* underflow condition when memory bus is busy. +* +* VI clients also need a stronger compensation. +*/ +switch (client->swgroup) { +case TEGRA_SWGROUP_MPCORE : +case TEGRA_SWGROUP_PTC : +/* +* We always want lower latency for these clients, hence +* don't touch them. +*/ +return ; + +case TEGRA_SWGROUP_DC : +case TEGRA_SWGROUP_DCB : + arb_tolerance_compensation_nsec =1050 ; + arb_tolerance_compensation_div =2 ; +break ; + +case TEGRA_SWGROUP_VI : + arb_tolerance_compensation_nsec =1050 ; + arb_tolerance_compensation_div =1 ; +break ; + +default : + arb_tolerance_compensation_nsec =150 ; + arb_tolerance_compensation_div =1 ; +break ; + } + +if (arb_nsec > arb_tolerance_compensation_nsec) + arb_nsec -= arb_tolerance_compensation_nsec; +else + arb_nsec =0 ; + + arb_nsec /= arb_tolerance_compensation_div; + +/* +* Latency allowance is a number of ticks a request from a particular +* client may wait in the EMEM arbiter before it becomes a high-priority +* request. +*/ + la_ticks = arb_nsec / mc->tick; + la_ticks =min (la_ticks, client->regs.la.mask); + + value =mc_readl (mc, client->regs.la.reg); + value &= ~(client->regs.la.mask << client->regs.la.shift); + value |= la_ticks << client->regs.la.shift; +mc_writel (mc, value, client->regs.la.reg); +} + +static int tegra114_mc_icc_set (struct icc_node *src,struct icc_node *dst) +{ +struct tegra_mc *mc =icc_provider_to_tegra_mc (src->provider); +const struct tegra_mc_client *client = &mc->soc->clients[src->id]; +u64 peak_bandwidth =icc_units_to_bps (src->peak_bw); + +/* +* Skip pre-initialization that is done by icc_node_add(), which sets +* bandwidth to maximum for all clients before drivers are loaded. +* +* This doesn't make sense for us because we don't have drivers for all +* clients and it's okay to keep configuration left from bootloader +* during boot, at least for today. +*/ +if (src == dst) +return 0 ; + +/* convert bytes/sec to megabytes/sec */ +do_div (peak_bandwidth,1000000 ); + +tegra114_mc_tune_client_latency (mc, client, peak_bandwidth); + +return 0 ; +} + +static int tegra114_mc_icc_aggreate (struct icc_node *node,u32 tag,u32 avg_bw, +u32 peak_bw,u32 *agg_avg,u32 *agg_peak) +{ +/* +* ISO clients need to reserve extra bandwidth up-front because +* there could be high bandwidth pressure during initial filling +* of the client's FIFO buffers. Secondly, we need to take into +* account impurities of the memory subsystem. +*/ +if (tag &TEGRA_MC_ICC_TAG_ISO ) + peak_bw =tegra_mc_scale_percents (peak_bw,400 ); + + *agg_avg += avg_bw; + *agg_peak =max (*agg_peak, peak_bw); + +return 0 ; +} + +static struct icc_node_data * +tegra114_mc_of_icc_xlate_extended (const struct of_phandle_args *spec,void *data) +{ +struct tegra_mc *mc =icc_provider_to_tegra_mc (data); +const struct tegra_mc_client *client; +unsigned int i, idx = spec->args[0 ]; +struct icc_node_data *ndata; +struct icc_node *node; + +list_for_each_entry (node, &mc->provider.nodes, node_list) { +if (node->id != idx) +continue ; + + ndata =kzalloc (sizeof (*ndata),GFP_KERNEL ); +if (!ndata) +return ERR_PTR (-ENOMEM ); + + client = &mc->soc->clients[idx]; + ndata->node = node; + +switch (client->swgroup) { +case TEGRA_SWGROUP_DC : +case TEGRA_SWGROUP_DCB : +case TEGRA_SWGROUP_PTC : +case TEGRA_SWGROUP_VI : +/* these clients are isochronous by default */ + ndata->tag =TEGRA_MC_ICC_TAG_ISO ; +break ; + +default : + ndata->tag =TEGRA_MC_ICC_TAG_DEFAULT ; +break ; + } + +return ndata; + } + +for (i =0 ; i < mc->soc->num_clients; i++) { +if (mc->soc->clients[i].id == idx) +return ERR_PTR (-EPROBE_DEFER ); + } + +dev_err (mc->dev,"invalid ICC client ID %u\n" , idx); + +return ERR_PTR (-EINVAL ); +} + +static const struct tegra_mc_icc_ops tegra114_mc_icc_ops = { + .xlate_extended = tegra114_mc_of_icc_xlate_extended, + .aggregate = tegra114_mc_icc_aggreate, + .set = tegra114_mc_icc_set, +}; + +static const unsigned long tegra114_mc_emem_regs[] = { +MC_EMEM_ARB_CFG , +MC_EMEM_ARB_OUTSTANDING_REQ , +MC_EMEM_ARB_TIMING_RCD , +MC_EMEM_ARB_TIMING_RP , +MC_EMEM_ARB_TIMING_RC , +MC_EMEM_ARB_TIMING_RAS , +MC_EMEM_ARB_TIMING_FAW , +MC_EMEM_ARB_TIMING_RRD , +MC_EMEM_ARB_TIMING_RAP2PRE , +MC_EMEM_ARB_TIMING_WAP2PRE , +MC_EMEM_ARB_TIMING_R2R , +MC_EMEM_ARB_TIMING_W2W , +MC_EMEM_ARB_TIMING_R2W , +MC_EMEM_ARB_TIMING_W2R , +MC_EMEM_ARB_DA_TURNS , +MC_EMEM_ARB_DA_COVERS , +MC_EMEM_ARB_MISC0 , +MC_EMEM_ARB_RING1_THROTTLE , +}; +const struct tegra_mc_soc tegra114_mc_soc = { .clients = tegra114_mc_clients, .num_clients =ARRAY_SIZE (tegra114_mc_clients),
@@ -1172,10 +1362,13 @@ const struct tegra_mc_soc tegra114_mc_soc = { .atom_size = 32, .client_id_mask = 0x7f, .smmu = &tegra114_smmu_soc, + .emem_regs = tegra114_mc_emem_regs, + .num_emem_regs = ARRAY_SIZE(tegra114_mc_emem_regs), .intmask =MC_INT_INVALID_SMMU_PAGE |MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM, .reset_ops = &tegra_mc_reset_ops_common, .resets = tegra114_mc_resets, .num_resets = ARRAY_SIZE(tegra114_mc_resets), + .icc_ops = &tegra114_mc_icc_ops, .ops = &tegra30_mc_ops, };
Signature · 1 line
2.51.0
PATCH 3/5 dt-bindings: memory: Add Tegra114 memory client IDs
In reply to Svyatoslav RyhelEach memory client has unique hardware ID, add these IDs.
--- include/dt-bindings/memory/tegra114-mc.h | 67 ++++++++++++++++++++++++ 1 file changed, 67 insertions(+)
include/dt-bindings/memory/tegra114-mc.h +67 -0
@@ -40,4 +40,71 @@#define TEGRA114_MC_RESET_VDE 14#define TEGRA114_MC_RESET_VI 15 +#define TEGRA114_MC_PTCR 0 +#define TEGRA114_MC_DISPLAY0A 1 +#define TEGRA114_MC_DISPLAY0AB 2 +#define TEGRA114_MC_DISPLAY0B 3 +#define TEGRA114_MC_DISPLAY0BB 4 +#define TEGRA114_MC_DISPLAY0C 5 +#define TEGRA114_MC_DISPLAY0CB 6 +#define TEGRA114_MC_DISPLAY1B 7 +#define TEGRA114_MC_DISPLAY1BB 8 +#define TEGRA114_MC_EPPUP 9 +#define TEGRA114_MC_G2PR 10 +#define TEGRA114_MC_G2SR 11 +#define TEGRA114_MC_MPEUNIFBR 12 +#define TEGRA114_MC_VIRUV 13 +#define TEGRA114_MC_AFIR 14 +#define TEGRA114_MC_AVPCARM7R 15 +#define TEGRA114_MC_DISPLAYHC 16 +#define TEGRA114_MC_DISPLAYHCB 17 +#define TEGRA114_MC_FDCDRD 18 +#define TEGRA114_MC_FDCDRD2 19 +#define TEGRA114_MC_G2DR 20 +#define TEGRA114_MC_HDAR 21 +#define TEGRA114_MC_HOST1XDMAR 22 +#define TEGRA114_MC_HOST1XR 23 +#define TEGRA114_MC_IDXSRD 24 +#define TEGRA114_MC_IDXSRD2 25 +#define TEGRA114_MC_MPE_IPRED 26 +#define TEGRA114_MC_MPEAMEMRD 27 +#define TEGRA114_MC_MPECSRD 28 +#define TEGRA114_MC_PPCSAHBDMAR 29 +#define TEGRA114_MC_PPCSAHBSLVR 30 +#define TEGRA114_MC_SATAR 31 +#define TEGRA114_MC_TEXSRD 32 +#define TEGRA114_MC_TEXSRD2 33 +#define TEGRA114_MC_VDEBSEVR 34 +#define TEGRA114_MC_VDEMBER 35 +#define TEGRA114_MC_VDEMCER 36 +#define TEGRA114_MC_VDETPER 37 +#define TEGRA114_MC_MPCORELPR 38 +#define TEGRA114_MC_MPCORER 39 +#define TEGRA114_MC_EPPU 40 +#define TEGRA114_MC_EPPV 41 +#define TEGRA114_MC_EPPY 42 +#define TEGRA114_MC_MPEUNIFBW 43 +#define TEGRA114_MC_VIWSB 44 +#define TEGRA114_MC_VIWU 45 +#define TEGRA114_MC_VIWV 46 +#define TEGRA114_MC_VIWY 47 +#define TEGRA114_MC_G2DW 48 +#define TEGRA114_MC_AFIW 49 +#define TEGRA114_MC_AVPCARM7W 50 +#define TEGRA114_MC_FDCDWR 51 +#define TEGRA114_MC_FDCDWR2 52 +#define TEGRA114_MC_HDAW 53 +#define TEGRA114_MC_HOST1XW 54 +#define TEGRA114_MC_ISPW 55 +#define TEGRA114_MC_MPCORELPW 56 +#define TEGRA114_MC_MPCOREW 57 +#define TEGRA114_MC_MPECSWR 58 +#define TEGRA114_MC_PPCSAHBDMAW 59 +#define TEGRA114_MC_PPCSAHBSLVW 60 +#define TEGRA114_MC_SATAW 61 +#define TEGRA114_MC_VDEBSEVW 62 +#define TEGRA114_MC_VDEDBGW 63 +#define TEGRA114_MC_VDEMBEW 64 +#define TEGRA114_MC_VDETPMW 65 +#endif
Signature · 1 line
2.51.0
Krzysztof Kozlowski
maintainerRe: [PATCH v1 3/5] dt-bindings: memory: Add Tegra114 memory client IDs
Quoted 7 lines · Svyatoslav Ryhel
Each memory client has unique hardware ID, add these IDs.
Signed-off-by Svyatoslav Ryhel <[email protected]>Reviewed-by Mikko Perttunen <[email protected]>--- include/dt-bindings/memory/tegra114-mc.h | 67 ++++++++++++++++++++++++
This is never a separate commit. Squash with the binding.
Best regards,
Krzysztof
Re: [PATCH v1 3/5] dt-bindings: memory: Add Tegra114 memory client IDs
вт, 17 лют. 2026 р. о 09:22 Krzysztof Kozlowski <[email protected]> пише:
Quoted 12 lines · Svyatoslav Ryhel
Quoted 7 lines
Each memory client has unique hardware ID, add these IDs.
Signed-off-by Svyatoslav Ryhel <[email protected]>Reviewed-by Mikko Perttunen <[email protected]>--- include/dt-bindings/memory/tegra114-mc.h | 67 ++++++++++++++++++++++++This is never a separate commit. Squash with the binding.
Always was and now it suddenly is not? Maybe you should consider fixing checkpatch since it complains that binding and header must be 2 separate commits.
Quoted 2 lines
Best regards,
Krzysztof
Krzysztof Kozlowski
maintainerRe: [PATCH v1 3/5] dt-bindings: memory: Add Tegra114 memory client IDs
Quoted 11 lines · Svyatoslav Ryhel
вт, 17 лют. 2026 р. о 09:22 Krzysztof Kozlowski <[email protected]> пише:
Quoted 10 lines · Svyatoslav Ryhel
Quoted 7 lines
Each memory client has unique hardware ID, add these IDs.
Signed-off-by Svyatoslav Ryhel <[email protected]>Reviewed-by Mikko Perttunen <[email protected]>--- include/dt-bindings/memory/tegra114-mc.h | 67 ++++++++++++++++++++++++
Quoted 4 lines
Quoted 2 lines
This is never a separate commit. Squash with the binding.
Always was and now it suddenly is not? Maybe you should consider
It never was, by the rules. I give this review all the time.
Quoted 2 lines
fixing checkpatch since it complains that binding and header must be 2 separate commits.
I considered, I guess many considered... but the problem is:
IT DOES NOT SAY THAT. There is no checkpatch warning, at least on recent tree.
Best regards,
Krzysztof
Re: [PATCH v1 3/5] dt-bindings: memory: Add Tegra114 memory client IDs
вт, 17 лют. 2026 р. о 10:15 Krzysztof Kozlowski <[email protected]> пише:
Quoted 13 lines · Svyatoslav Ryhel
Quoted 11 lines
вт, 17 лют. 2026 р. о 09:22 Krzysztof Kozlowski <[email protected]> пише:
Quoted 10 lines · Svyatoslav Ryhel
Quoted 7 lines
Each memory client has unique hardware ID, add these IDs.
Signed-off-by Svyatoslav Ryhel <[email protected]>Reviewed-by Mikko Perttunen <[email protected]>--- include/dt-bindings/memory/tegra114-mc.h | 67 ++++++++++++++++++++++++
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
This is never a separate commit. Squash with the binding.
Always was and now it suddenly is not? Maybe you should consider
It never was, by the rules. I give this review all the time.
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/include/dt-bindings/memory?h=next-20260216&id=96b0239bbd6153b70c14c80664ebb43cd2ddacd9
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/include/dt-bindings/memory?h=next-20260216&id=825c7f4aa2866b77c0238855e2f58d56d2f13eae
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/include/dt-bindings/memory?h=next-20260216&id=f25696bce9604dbfd8d956da6023d18a05ec8ed3
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/include/dt-bindings/memory?h=next-20260216&id=24a7eaea0a941c9e5e243ffb40073dcafecd3c11
I don't see any of these are squashed with any binding, but ok, whatever.
Quoted 8 lines
Quoted 2 lines
fixing checkpatch since it complains that binding and header must be 2 separate commits.
I considered, I guess many considered... but the problem is:
IT DOES NOT SAY THAT. There is no checkpatch warning, at least on recent tree.
Interesting, it is not now, but it definitely was. Acknowledged.
Quoted 2 lines
Best regards,
Krzysztof
Thierry Reding
maintainerRe: [PATCH v1 3/5] dt-bindings: memory: Add Tegra114 memory client IDs
In reply to Krzysztof KozlowskiQuoted 10 lines · Krzysztof Kozlowski
Quoted 7 lines · Svyatoslav Ryhel
Each memory client has unique hardware ID, add these IDs.
Signed-off-by Svyatoslav Ryhel <[email protected]>Reviewed-by Mikko Perttunen <[email protected]>--- include/dt-bindings/memory/tegra114-mc.h | 67 ++++++++++++++++++++++++This is never a separate commit. Squash with the binding.
You have previously requested that bindings and driver changes be applied together. If this header file is applied to your memory tree it means I cannot apply the corresponding DT changes until a release later because the defines are part of the header included in the DT bindings patch.
Seems a bit suboptimal. Do you have any good ideas on how to solve that particular issue? The only one that comes to mind is for you to pick up the DT changes as well, though that obviously runs a greater risk of causing merge conflicts down the road.
Thierry
Krzysztof Kozlowski
maintainerRe: [PATCH v1 3/5] dt-bindings: memory: Add Tegra114 memory client IDs
Quoted 10 lines · Thierry Reding
Quoted 9 lines · Krzysztof Kozlowski
Quoted 7 lines · Svyatoslav Ryhel
Each memory client has unique hardware ID, add these IDs.
Signed-off-by Svyatoslav Ryhel <[email protected]>Reviewed-by Mikko Perttunen <[email protected]>--- include/dt-bindings/memory/tegra114-mc.h | 67 ++++++++++++++++++++++++
Quoted 7 lines
Quoted 1 line
This is never a separate commit. Squash with the binding.
You have previously requested that bindings and driver changes be applied together. If this header file is applied to your memory tree it means I cannot apply the corresponding DT changes until a release later because the defines are part of the header included in the DT bindings patch.
I cannot apply the driver either without it, because it uses it, no? Otherwise what is it doing in bindings if the driver is not using it?
Quoted 2 lines
Seems a bit suboptimal. Do you have any good ideas on how to solve that
We listed five already in maintainer soc profile. Are they not good?
Quoted 3 lines
particular issue? The only one that comes to mind is for you to pick up the DT changes as well, though that obviously runs a greater risk of causing merge conflicts down the road.
Best regards,
Krzysztof
Krzysztof Kozlowski
maintainerRe: [PATCH v1 3/5] dt-bindings: memory: Add Tegra114 memory client IDs
Quoted 19 lines · Krzysztof Kozlowski
Quoted 10 lines · Thierry Reding
Quoted 9 lines · Krzysztof Kozlowski
Quoted 7 lines · Svyatoslav Ryhel
Each memory client has unique hardware ID, add these IDs.
Signed-off-by Svyatoslav Ryhel <[email protected]>Reviewed-by Mikko Perttunen <[email protected]>--- include/dt-bindings/memory/tegra114-mc.h | 67 ++++++++++++++++++++++++Quoted 7 lines
Quoted 1 line
This is never a separate commit. Squash with the binding.
You have previously requested that bindings and driver changes be applied together. If this header file is applied to your memory tree it means I cannot apply the corresponding DT changes until a release later because the defines are part of the header included in the DT bindings patch.
Quoted 11 lines
I cannot apply the driver either without it, because it uses it, no? Otherwise what is it doing in bindings if the driver is not using it?
Quoted 2 lines
Seems a bit suboptimal. Do you have any good ideas on how to solve that
We listed five already in maintainer soc profile. Are they not good?
Quoted 3 lines
particular issue? The only one that comes to mind is for you to pick up the DT changes as well, though that obviously runs a greater risk of causing merge conflicts down the road.
One more thing:
There is no DTS here and nothing explains (commit msgs, changelogs or cover letter) that there is any dependency and this was supposed to go other tree. So the squash-or-not-squash is absolutely irrelevant to your question/problem how DTS should deal with it.
Best regards,
Krzysztof
PATCH 4/5 dt-bindings: memory: Document Tegra114 External Memory Controller
In reply to Svyatoslav RyhelInclude Tegra114 support into existing Tegra124 EMC schema with the most notable difference being the amount of EMC timings and a few SoC unique entries.
--- .../nvidia,tegra124-emc.yaml | 174 +++--------------- 1 file changed, 26 insertions(+), 148 deletions(-)
Documentation/devicetree/bindings/memory-controllers/nvidia,tegra124-emc.yaml +26 -148
@@ -16,7 +16,9 @@ description: | properties: compatible: - const: nvidia,tegra124-emc + enum: + - nvidia,tegra114-emc + - nvidia,tegra124-emc reg: maxItems: 1
@@ -29,6 +31,9 @@ properties: items: - const: emc + interrupts: + maxItems: 1 + "#interconnect-cells": const: 0
@@ -164,153 +169,12 @@ patternProperties: nvidia,emc-configuration: description: EMC timing characterization data. These are the registers (see - section "15.6.2 EMC Registers" in the TRM) whose values need to + section "20.11.2 EMC Registers" in the Tegra114 TRM or section + "15.6.2 EMC Registers" in the Tegra124 TRM) whose values need to be specified, according to the board documentation. $ref: /schemas/types.yaml#/definitions/uint32-array - items: - - description: EMC_RC - - description: EMC_RFC - - description: EMC_RFC_SLR - - description: EMC_RAS - - description: EMC_RP - - description: EMC_R2W - - description: EMC_W2R - - description: EMC_R2P - - description: EMC_W2P - - description: EMC_RD_RCD - - description: EMC_WR_RCD - - description: EMC_RRD - - description: EMC_REXT - - description: EMC_WEXT - - description: EMC_WDV - - description: EMC_WDV_MASK - - description: EMC_QUSE - - description: EMC_QUSE_WIDTH - - description: EMC_IBDLY - - description: EMC_EINPUT - - description: EMC_EINPUT_DURATION - - description: EMC_PUTERM_EXTRA - - description: EMC_PUTERM_WIDTH - - description: EMC_PUTERM_ADJ - - description: EMC_CDB_CNTL_1 - - description: EMC_CDB_CNTL_2 - - description: EMC_CDB_CNTL_3 - - description: EMC_QRST - - description: EMC_QSAFE - - description: EMC_RDV - - description: EMC_RDV_MASK - - description: EMC_REFRESH - - description: EMC_BURST_REFRESH_NUM - - description: EMC_PRE_REFRESH_REQ_CNT - - description: EMC_PDEX2WR - - description: EMC_PDEX2RD - - description: EMC_PCHG2PDEN - - description: EMC_ACT2PDEN - - description: EMC_AR2PDEN - - description: EMC_RW2PDEN - - description: EMC_TXSR - - description: EMC_TXSRDLL - - description: EMC_TCKE - - description: EMC_TCKESR - - description: EMC_TPD - - description: EMC_TFAW - - description: EMC_TRPAB - - description: EMC_TCLKSTABLE - - description: EMC_TCLKSTOP - - description: EMC_TREFBW - - description: EMC_FBIO_CFG6 - - description: EMC_ODT_WRITE - - description: EMC_ODT_READ - - description: EMC_FBIO_CFG5 - - description: EMC_CFG_DIG_DLL - - description: EMC_CFG_DIG_DLL_PERIOD - - description: EMC_DLL_XFORM_DQS0 - - description: EMC_DLL_XFORM_DQS1 - - description: EMC_DLL_XFORM_DQS2 - - description: EMC_DLL_XFORM_DQS3 - - description: EMC_DLL_XFORM_DQS4 - - description: EMC_DLL_XFORM_DQS5 - - description: EMC_DLL_XFORM_DQS6 - - description: EMC_DLL_XFORM_DQS7 - - description: EMC_DLL_XFORM_DQS8 - - description: EMC_DLL_XFORM_DQS9 - - description: EMC_DLL_XFORM_DQS10 - - description: EMC_DLL_XFORM_DQS11 - - description: EMC_DLL_XFORM_DQS12 - - description: EMC_DLL_XFORM_DQS13 - - description: EMC_DLL_XFORM_DQS14 - - description: EMC_DLL_XFORM_DQS15 - - description: EMC_DLL_XFORM_QUSE0 - - description: EMC_DLL_XFORM_QUSE1 - - description: EMC_DLL_XFORM_QUSE2 - - description: EMC_DLL_XFORM_QUSE3 - - description: EMC_DLL_XFORM_QUSE4 - - description: EMC_DLL_XFORM_QUSE5 - - description: EMC_DLL_XFORM_QUSE6 - - description: EMC_DLL_XFORM_QUSE7 - - description: EMC_DLL_XFORM_ADDR0 - - description: EMC_DLL_XFORM_ADDR1 - - description: EMC_DLL_XFORM_ADDR2 - - description: EMC_DLL_XFORM_ADDR3 - - description: EMC_DLL_XFORM_ADDR4 - - description: EMC_DLL_XFORM_ADDR5 - - description: EMC_DLL_XFORM_QUSE8 - - description: EMC_DLL_XFORM_QUSE9 - - description: EMC_DLL_XFORM_QUSE10 - - description: EMC_DLL_XFORM_QUSE11 - - description: EMC_DLL_XFORM_QUSE12 - - description: EMC_DLL_XFORM_QUSE13 - - description: EMC_DLL_XFORM_QUSE14 - - description: EMC_DLL_XFORM_QUSE15 - - description: EMC_DLI_TRIM_TXDQS0 - - description: EMC_DLI_TRIM_TXDQS1 - - description: EMC_DLI_TRIM_TXDQS2 - - description: EMC_DLI_TRIM_TXDQS3 - - description: EMC_DLI_TRIM_TXDQS4 - - description: EMC_DLI_TRIM_TXDQS5 - - description: EMC_DLI_TRIM_TXDQS6 - - description: EMC_DLI_TRIM_TXDQS7 - - description: EMC_DLI_TRIM_TXDQS8 - - description: EMC_DLI_TRIM_TXDQS9 - - description: EMC_DLI_TRIM_TXDQS10 - - description: EMC_DLI_TRIM_TXDQS11 - - description: EMC_DLI_TRIM_TXDQS12 - - description: EMC_DLI_TRIM_TXDQS13 - - description: EMC_DLI_TRIM_TXDQS14 - - description: EMC_DLI_TRIM_TXDQS15 - - description: EMC_DLL_XFORM_DQ0 - - description: EMC_DLL_XFORM_DQ1 - - description: EMC_DLL_XFORM_DQ2 - - description: EMC_DLL_XFORM_DQ3 - - description: EMC_DLL_XFORM_DQ4 - - description: EMC_DLL_XFORM_DQ5 - - description: EMC_DLL_XFORM_DQ6 - - description: EMC_DLL_XFORM_DQ7 - - description: EMC_XM2CMDPADCTRL - - description: EMC_XM2CMDPADCTRL4 - - description: EMC_XM2CMDPADCTRL5 - - description: EMC_XM2DQPADCTRL2 - - description: EMC_XM2DQPADCTRL3 - - description: EMC_XM2CLKPADCTRL - - description: EMC_XM2CLKPADCTRL2 - - description: EMC_XM2COMPPADCTRL - - description: EMC_XM2VTTGENPADCTRL - - description: EMC_XM2VTTGENPADCTRL2 - - description: EMC_XM2VTTGENPADCTRL3 - - description: EMC_XM2DQSPADCTRL3 - - description: EMC_XM2DQSPADCTRL4 - - description: EMC_XM2DQSPADCTRL5 - - description: EMC_XM2DQSPADCTRL6 - - description: EMC_DSR_VTTGEN_DRV - - description: EMC_TXDSRVTTGEN - - description: EMC_FBIO_SPARE - - description: EMC_ZCAL_WAIT_CNT - - description: EMC_MRS_WAIT_CNT2 - - description: EMC_CTT - - description: EMC_CTT_DURATION - - description: EMC_CFG_PIPE - - description: EMC_DYN_SELF_REF_CONTROL - - description: EMC_QPOP + minItems: 97 + maxItems: 143 required: - clock-frequency
@@ -318,9 +182,7 @@ patternProperties: - nvidia,emc-auto-cal-config2 - nvidia,emc-auto-cal-config3 - nvidia,emc-auto-cal-interval - - nvidia,emc-bgbias-ctl0 - nvidia,emc-cfg - - nvidia,emc-cfg-2 - nvidia,emc-ctt-term-ctrl - nvidia,emc-mode-1 - nvidia,emc-mode-2
@@ -344,6 +206,22 @@ required: - "#interconnect-cells" - operating-points-v2 +allOf: + - if: + properties: + compatible: + contains: + enum: + - nvidia,tegra124-emc + then: + patternProperties: + "^emc-timings-[0-9]+$": + patternProperties: + "^timing-[0-9]+$": + required: + - nvidia,emc-bgbias-ctl0 + - nvidia,emc-cfg-2 + additionalProperties: false examples:
Signature · 1 line
2.51.0
PATCH 5/5 memory: tegra: Add Tegra114 EMC driver
In reply to Svyatoslav RyhelIntroduce driver for the External Memory Controller (EMC) found in Tegra114 SoC. It controls the external DRAM on the board. The purpose of this driver is to program memory timing for external memory on the EMC clock rate change.
--- drivers/memory/tegra/Kconfig | 12 + drivers/memory/tegra/Makefile | 1 + drivers/memory/tegra/tegra114-emc.c | 1463 +++++++++++++++++++++++++++ 3 files changed, 1476 insertions(+) create mode 100644 drivers/memory/tegra/tegra114-emc.c
drivers/memory/tegra/Kconfig +12 -0
@@ -35,6 +35,18 @@ config TEGRA30_EMC This driver is required to change memory timings / clock rate for external memory. +config TEGRA114_EMC + tristate "NVIDIA Tegra114 External Memory Controller driver" + default y + depends on ARCH_TEGRA_114_SOC || COMPILE_TEST + select TEGRA124_CLK_EMC if ARCH_TEGRA + select PM_OPP + help + This driver is for the External Memory Controller (EMC) found on + Tegra114 chips. The EMC controls the external DRAM on the board. + This driver is required to change memory timings / clock rate for + external memory. + config TEGRA124_EMC tristate "NVIDIA Tegra124 External Memory Controller driver" default ARCH_TEGRA_124_SOC
drivers/memory/tegra/Makefile +1 -0
@@ -16,6 +16,7 @@ obj-$(CONFIG_TEGRA_MC) += tegra-mc.o obj-$(CONFIG_TEGRA20_EMC) += tegra20-emc.o obj-$(CONFIG_TEGRA30_EMC) += tegra30-emc.o +obj-$(CONFIG_TEGRA114_EMC) += tegra114-emc.o obj-$(CONFIG_TEGRA124_EMC) += tegra124-emc.o obj-$(CONFIG_TEGRA210_EMC_TABLE) += tegra210-emc-table.o obj-$(CONFIG_TEGRA210_EMC) += tegra210-emc.o
drivers/memory/tegra/tegra114-emc.c new file +1463 -0
1,463 lines not on this page · raw message
Signature · 1 line
2.51.0
Krzysztof Kozlowski
maintainerRe: [PATCH v1 5/5] memory: tegra: Add Tegra114 EMC driver
Quoted 11 lines · Svyatoslav Ryhel
Introduce driver for the External Memory Controller (EMC) found in Tegra114 SoC. It controls the external DRAM on the board. The purpose of this driver is to program memory timing for external memory on the EMC clock rate change.
Signed-off-by Svyatoslav Ryhel <[email protected]>Reviewed-by Mikko Perttunen <[email protected]>--- drivers/memory/tegra/Kconfig | 12 + drivers/memory/tegra/Makefile | 1 + drivers/memory/tegra/tegra114-emc.c | 1463 +++++++++++++++++++++++++++
Please rebase on top of Mikko's patch removing duplicated code.
Quoted 45 lines
3 files changed, 1476 insertions(+) create mode 100644 drivers/memory/tegra/tegra114-emc.cdrivers/memory/tegra/Kconfig +12
-0@@ -35,6 +35,18 @@ config TEGRA30_EMC This driver is required to change memory timings / clock rate for external memory. +config TEGRA114_EMC + tristate "NVIDIA Tegra114 External Memory Controller driver" + default y + depends on ARCH_TEGRA_114_SOC || COMPILE_TEST + select TEGRA124_CLK_EMC if ARCH_TEGRA + select PM_OPP + help + This driver is for the External Memory Controller (EMC) found on + Tegra114 chips. The EMC controls the external DRAM on the board. + This driver is required to change memory timings / clock rate for + external memory. + config TEGRA124_EMC tristate "NVIDIA Tegra124 External Memory Controller driver" default ARCH_TEGRA_124_SOCdrivers/memory/tegra/Makefile +1
-0@@ -16,6 +16,7 @@ obj-$(CONFIG_TEGRA_MC) += tegra-mc.o obj-$(CONFIG_TEGRA20_EMC) += tegra20-emc.o obj-$(CONFIG_TEGRA30_EMC) += tegra30-emc.o +obj-$(CONFIG_TEGRA114_EMC) += tegra114-emc.o obj-$(CONFIG_TEGRA124_EMC) += tegra124-emc.o obj-$(CONFIG_TEGRA210_EMC_TABLE) += tegra210-emc-table.o obj-$(CONFIG_TEGRA210_EMC) += tegra210-emc.odrivers/memory/tegra/tegra114-emc.c new file +1
-0@@ -0,0 +1,1463 @@ +// SPDX-License-Identifier: GPL-2.0-only
drivers/memory/tegra/tegra114-emc.c line 11
Quoted 10 lines
drivers/memory/tegra/tegra114-emc.c new file +10
-0+/* +* Tegra114 External Memory Controller driver +* +* Based on downstream driver from NVIDIA and tegra124-emc.c +* Copyright (C) 2011-2014 NVIDIA Corporation +* +* Copyright (C) 2024 Svyatoslav Ryhel <[email protected]> +*/ + +#include <linux/clk-provider.h>
Where is it used?
drivers/memory/tegra/tegra114-emc.c line 13
Quoted 2 lines
drivers/memory/tegra/tegra114-emc.c new file +2
-0+#include <linux/clk.h> +#include <linux/clkdev.h>
Where is it used?
drivers/memory/tegra/tegra114-emc.c line 14
Quoted 1 line
drivers/memory/tegra/tegra114-emc.c new file +1
-0+#include <linux/clk/tegra.h>
Where is it used?
drivers/memory/tegra/tegra114-emc.c line 17
Quoted 3 lines
drivers/memory/tegra/tegra114-emc.c new file +3
-0+#include <linux/debugfs.h> +#include <linux/delay.h> +#include <linux/interconnect-provider.h>
Where is it used?
drivers/memory/tegra/tegra114-emc.c line 24
Quoted 7 lines
drivers/memory/tegra/tegra114-emc.c new file +7
-0+#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/iopoll.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/of_address.h> +#include <linux/of_platform.h>
I don't see these used. OTOH, I see you use other of_ which needs their header.
Quoted 23 lines
drivers/memory/tegra/tegra114-emc.c new file +23
-0+#include <linux/platform_device.h> +#include <linux/pm_opp.h> +#include <linux/sort.h> +#include <linux/string.h> + +#include <soc/tegra/common.h> +#include <soc/tegra/fuse.h> +#include <soc/tegra/mc.h> + +#include "mc.h" + +#define EMC_INTSTATUS 0x0 +#define EMC_INTSTATUS_REFRESH_OVERFLOW BIT(3) +#define EMC_INTSTATUS_CLKCHANGE_COMPLETE BIT(4) + +#define EMC_INTMASK 0x4 + +#define EMC_DBG 0x8 +#define EMC_DBG_READ_MUX_ASSEMBLY BIT(0) +#define EMC_DBG_WRITE_MUX_ACTIVE BIT(1) +#define EMC_DBG_FORCE_UPDATE BIT(2) +#define EMC_DBG_CFG_PRIORITY BIT(24) +
...
Quoted 9 lines
drivers/memory/tegra/tegra114-emc.c new file +9
-0+ +static int tegra_emc_debug_available_rates_show (struct seq_file *s, +void *data) +{ +struct tegra_emc *emc = s->private; +const char *prefix ="" ; +unsigned int i; + +for (i =0 ; i < emc->num_timings; i++) {
drivers/memory/tegra/tegra114-emc.c line 1128
Quoted 10 lines
drivers/memory/tegra/tegra114-emc.c new file +10
-0+seq_printf (s,"%s%lu" , prefix, emc->timings[i].rate); + prefix =" " ; + } + +seq_puts (s,"\n" ); + +return 0 ; +} + +DEFINE_SHOW_ATTRIBUTE (tegra_emc_debug_available_rates);
Where is the ABI documented for all these?
Quoted 31 lines
drivers/memory/tegra/tegra114-emc.c new file +31
-0+ +static int tegra_emc_debug_min_rate_get (void *data,u64 *rate) +{ +struct tegra_emc *emc = data; + + *rate = emc->debugfs.min_rate; + +return 0 ; +} + +static int tegra_emc_debug_min_rate_set (void *data,u64 rate) +{ +struct tegra_emc *emc = data; +int err; + +if (!tegra_emc_validate_rate (emc, rate)) +return -EINVAL ; + + err =emc_set_min_rate (emc, rate,EMC_RATE_DEBUG ); +if (err <0 ) +return err; + + emc->debugfs.min_rate = rate; + +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (tegra_emc_debug_min_rate_fops, + tegra_emc_debug_min_rate_get, + tegra_emc_debug_min_rate_set,"%llu\n" ); +
...
Quoted 61 lines
drivers/memory/tegra/tegra114-emc.c new file +61
-0+ +static int tegra_emc_probe (struct platform_device *pdev) +{ +struct tegra_core_opp_params opp_params = {}; +struct device_node *np; +struct tegra_emc *emc; +u32 ram_code; +int err; + + emc =devm_kzalloc (&pdev->dev,sizeof (*emc),GFP_KERNEL ); +if (!emc) +return -ENOMEM ; + +mutex_init (&emc->rate_lock); + emc->dev = &pdev->dev; + + emc->regs =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (emc->regs)) +return PTR_ERR (emc->regs); + + emc->mc =devm_tegra_memory_controller_get (&pdev->dev); +if (IS_ERR (emc->mc)) +return PTR_ERR (emc->mc); + + ram_code =tegra_read_ram_code (); + + np =tegra_emc_find_node_by_ram_code (pdev->dev.of_node, ram_code); +if (np) { + err =tegra_emc_load_timings_from_dt (emc, np); +of_node_put (np); +if (err) +return err; + }else { +dev_info_once (&pdev->dev, +"no memory timings for RAM code %u found in DT\n" , + ram_code); + } + + err =emc_init (emc); +if (err) { +dev_err (&pdev->dev,"EMC initialization failed: %d\n" , err); +return err; + } + +platform_set_drvdata (pdev, emc); + +tegra124_clk_set_emc_callbacks (tegra_emc_prepare_timing_change, + tegra_emc_complete_timing_change); + + err =devm_add_action_or_reset (&pdev->dev, devm_tegra_emc_unset_callback, +NULL ); +if (err) +return err; + + err =platform_get_irq (pdev,0 ); +if (err <0 ) +return err; + + emc->irq = err; + + err = devm_request_irq(&pdev->dev, emc->irq, tegra_emc_isr, 0,
drivers/memory/tegra/tegra114-emc.c line 1417
Quoted 10 lines
drivers/memory/tegra/tegra114-emc.c new file +10
-0+ dev_name(&pdev->dev), emc); +if (err) { +dev_err (&pdev->dev,"failed to request irq: %d\n" , err); +return err; + } + + emc->clk =devm_clk_get (&pdev->dev,"emc" ); +if (IS_ERR (emc->clk)) { + err =PTR_ERR (emc->clk); +dev_err (&pdev->dev,"failed to get EMC clock: %d\n" , err);
Syntax is return dev_err_probe. Since some years and all the existing code was already fixed, no?
Quoted 36 lines
drivers/memory/tegra/tegra114-emc.c new file +36
-0+return err; + } + + opp_params.init_state = true; + + err =devm_tegra_core_dev_init_opp_table (&pdev->dev, &opp_params); +if (err) +return err; + +tegra_emc_rate_requests_init (emc); + +if (IS_ENABLED (CONFIG_DEBUG_FS )) +emc_debugfs_init (&pdev->dev, emc); + +tegra_emc_interconnect_init (emc); + +/* +* Don't allow the kernel module to be unloaded. Unloading adds some +* extra complexity which doesn't really worth the effort in a case of +* this driver. +*/ +try_module_get (THIS_MODULE ); + +return 0 ; +}; + +static const struct of_device_id tegra_emc_of_match[] = { + { .compatible ="nvidia,tegra114-emc" }, + {} +}; +MODULE_DEVICE_TABLE (of, tegra_emc_of_match); + +static struct platform_driver tegra_emc_driver = { + .probe = tegra_emc_probe, + .driver = { + .name ="tegra114-emc" ,
drivers/memory/tegra/tegra114-emc.c line 1463
Quoted 10 lines
drivers/memory/tegra/tegra114-emc.c new file +10
-0+ .of_match_table = tegra_emc_of_match, + .suppress_bind_attrs = true, + .sync_state = icc_sync_state, + }, +}; +module_platform_driver (tegra_emc_driver); + +MODULE_AUTHOR ("Svyatoslav Ryhel <[email protected]>" ); +MODULE_DESCRIPTION ("NVIDIA Tegra114 EMC driver" ); +MODULE_LICENSE ("GPL" );
Best regards,
Krzysztof
Re: [PATCH v1 5/5] memory: tegra: Add Tegra114 EMC driver
вт, 17 лют. 2026 р. о 09:21 Krzysztof Kozlowski <[email protected]> пише:
Quoted 74 lines · Svyatoslav Ryhel
Quoted 11 lines
Introduce driver for the External Memory Controller (EMC) found in Tegra114 SoC. It controls the external DRAM on the board. The purpose of this driver is to program memory timing for external memory on the EMC clock rate change.
Signed-off-by Svyatoslav Ryhel <[email protected]>Reviewed-by Mikko Perttunen <[email protected]>--- drivers/memory/tegra/Kconfig | 12 + drivers/memory/tegra/Makefile | 1 + drivers/memory/tegra/tegra114-emc.c | 1463 +++++++++++++++++++++++++++Please rebase on top of Mikko's patch removing duplicated code.
Quoted 45 lines
3 files changed, 1476 insertions(+) create mode 100644 drivers/memory/tegra/tegra114-emc.cdrivers/memory/tegra/Kconfig +12
-0@@ -35,6 +35,18 @@ config TEGRA30_EMC This driver is required to change memory timings / clock rate for external memory. +config TEGRA114_EMC + tristate "NVIDIA Tegra114 External Memory Controller driver" + default y + depends on ARCH_TEGRA_114_SOC || COMPILE_TEST + select TEGRA124_CLK_EMC if ARCH_TEGRA + select PM_OPP + help + This driver is for the External Memory Controller (EMC) found on + Tegra114 chips. The EMC controls the external DRAM on the board. + This driver is required to change memory timings / clock rate for + external memory. + config TEGRA124_EMC tristate "NVIDIA Tegra124 External Memory Controller driver" default ARCH_TEGRA_124_SOCdrivers/memory/tegra/Makefile +1
-0@@ -16,6 +16,7 @@ obj-$(CONFIG_TEGRA_MC) += tegra-mc.o obj-$(CONFIG_TEGRA20_EMC) += tegra20-emc.o obj-$(CONFIG_TEGRA30_EMC) += tegra30-emc.o +obj-$(CONFIG_TEGRA114_EMC) += tegra114-emc.o obj-$(CONFIG_TEGRA124_EMC) += tegra124-emc.o obj-$(CONFIG_TEGRA210_EMC_TABLE) += tegra210-emc-table.o obj-$(CONFIG_TEGRA210_EMC) += tegra210-emc.odrivers/memory/tegra/tegra114-emc.c new file +1
-0@@ -0,0 +1,1463 @@ +// SPDX-License-Identifier: GPL-2.0-only drivers/memory/tegra/tegra114-emc.c line 11
Quoted 10 lines
drivers/memory/tegra/tegra114-emc.c new file +10
-0+/* +* Tegra114 External Memory Controller driver +* +* Based on downstream driver from NVIDIA and tegra124-emc.c +* Copyright (C) 2011-2014 NVIDIA Corporation +* +* Copyright (C) 2024 Svyatoslav Ryhel <[email protected]> +*/ + +#include <linux/clk-provider.h> Where is it used?
Quoted 9 lines
drivers/memory/tegra/tegra114-emc.c line 13
Quoted 2 lines
drivers/memory/tegra/tegra114-emc.c new file +2
-0+#include <linux/clk.h> +#include <linux/clkdev.h> Where is it used?
drivers/memory/tegra/tegra114-emc.c line 14
Quoted 1 line
drivers/memory/tegra/tegra114-emc.c new file +1
-0+#include <linux/clk/tegra.h> Where is it used?
All 4 by tegra124_clk_set_emc_callbacks
Quoted 6 lines
drivers/memory/tegra/tegra114-emc.c line 17
Quoted 3 lines
drivers/memory/tegra/tegra114-emc.c new file +3
-0+#include <linux/debugfs.h> +#include <linux/delay.h> +#include <linux/interconnect-provider.h> Where is it used?
tegra_emc_interconnect_init
Quoted 11 lines
drivers/memory/tegra/tegra114-emc.c line 24
Quoted 7 lines
drivers/memory/tegra/tegra114-emc.c new file +7
-0+#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/iopoll.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/of_address.h> +#include <linux/of_platform.h> I don't see these used. OTOH, I see you use other
of_which needs their header.
fair
Quoted 39 lines
Quoted 23 lines
drivers/memory/tegra/tegra114-emc.c new file +23
-0+#include <linux/platform_device.h> +#include <linux/pm_opp.h> +#include <linux/sort.h> +#include <linux/string.h> + +#include <soc/tegra/common.h> +#include <soc/tegra/fuse.h> +#include <soc/tegra/mc.h> + +#include "mc.h" + +#define EMC_INTSTATUS 0x0 +#define EMC_INTSTATUS_REFRESH_OVERFLOW BIT(3) +#define EMC_INTSTATUS_CLKCHANGE_COMPLETE BIT(4) + +#define EMC_INTMASK 0x4 + +#define EMC_DBG 0x8 +#define EMC_DBG_READ_MUX_ASSEMBLY BIT(0) +#define EMC_DBG_WRITE_MUX_ACTIVE BIT(1) +#define EMC_DBG_FORCE_UPDATE BIT(2) +#define EMC_DBG_CFG_PRIORITY BIT(24) +...
Quoted 13 lines
drivers/memory/tegra/tegra114-emc.c new file +13
-0+ +static int tegra_emc_debug_available_rates_show (struct seq_file *s, +void *data) +{ +struct tegra_emc *emc = s->private; +const char *prefix ="" ; +unsigned int i; + +for (i =0 ; i < emc->num_timings; i++) { +seq_printf (s,"%s%lu" , prefix, emc->timings[i].rate); + prefix =" " ; + } +
Quoted 9 lines
drivers/memory/tegra/tegra114-emc.c line 1128
Quoted 6 lines
drivers/memory/tegra/tegra114-emc.c new file +6
-0+seq_puts (s,"\n" ); + +return 0 ; +} + +DEFINE_SHOW_ATTRIBUTE (tegra_emc_debug_available_rates);Where is the ABI documented for all these?
Debugfs does not require ABI documentation, provided comment in the driver is sufficient.
Quoted 100 lines
Quoted 31 lines
drivers/memory/tegra/tegra114-emc.c new file +31
-0+ +static int tegra_emc_debug_min_rate_get (void *data,u64 *rate) +{ +struct tegra_emc *emc = data; + + *rate = emc->debugfs.min_rate; + +return 0 ; +} + +static int tegra_emc_debug_min_rate_set (void *data,u64 rate) +{ +struct tegra_emc *emc = data; +int err; + +if (!tegra_emc_validate_rate (emc, rate)) +return -EINVAL ; + + err =emc_set_min_rate (emc, rate,EMC_RATE_DEBUG ); +if (err <0 ) +return err; + + emc->debugfs.min_rate = rate; + +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (tegra_emc_debug_min_rate_fops, + tegra_emc_debug_min_rate_get, + tegra_emc_debug_min_rate_set,"%llu\n" ); +...
Quoted 66 lines
drivers/memory/tegra/tegra114-emc.c new file +66
-0+ +static int tegra_emc_probe (struct platform_device *pdev) +{ +struct tegra_core_opp_params opp_params = {}; +struct device_node *np; +struct tegra_emc *emc; +u32 ram_code; +int err; + + emc =devm_kzalloc (&pdev->dev,sizeof (*emc),GFP_KERNEL ); +if (!emc) +return -ENOMEM ; + +mutex_init (&emc->rate_lock); + emc->dev = &pdev->dev; + + emc->regs =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (emc->regs)) +return PTR_ERR (emc->regs); + + emc->mc =devm_tegra_memory_controller_get (&pdev->dev); +if (IS_ERR (emc->mc)) +return PTR_ERR (emc->mc); + + ram_code =tegra_read_ram_code (); + + np =tegra_emc_find_node_by_ram_code (pdev->dev.of_node, ram_code); +if (np) { + err =tegra_emc_load_timings_from_dt (emc, np); +of_node_put (np); +if (err) +return err; + }else { +dev_info_once (&pdev->dev, +"no memory timings for RAM code %u found in DT\n" , + ram_code); + } + + err =emc_init (emc); +if (err) { +dev_err (&pdev->dev,"EMC initialization failed: %d\n" , err); +return err; + } + +platform_set_drvdata (pdev, emc); + +tegra124_clk_set_emc_callbacks (tegra_emc_prepare_timing_change, + tegra_emc_complete_timing_change); + + err =devm_add_action_or_reset (&pdev->dev, devm_tegra_emc_unset_callback, +NULL ); +if (err) +return err; + + err =platform_get_irq (pdev,0 ); +if (err <0 ) +return err; + + emc->irq = err; + + err =devm_request_irq (&pdev->dev, emc->irq, tegra_emc_isr,0 , +dev_name (&pdev->dev), emc); +if (err) { +dev_err (&pdev->dev,"failed to request irq: %d\n" , err); +return err; + }
Quoted 9 lines
drivers/memory/tegra/tegra114-emc.c line 1417
Quoted 5 lines
drivers/memory/tegra/tegra114-emc.c new file +5
-0+ + emc->clk =devm_clk_get (&pdev->dev,"emc" ); +if (IS_ERR (emc->clk)) { + err =PTR_ERR (emc->clk); +dev_err (&pdev->dev,"failed to get EMC clock: %d\n" , err);Syntax is return
dev_err_probe. Since some years and all the existing code was already fixed, no?
fair
Quoted 50 lines
Quoted 36 lines
drivers/memory/tegra/tegra114-emc.c new file +36
-0+return err; + } + + opp_params.init_state = true; + + err =devm_tegra_core_dev_init_opp_table (&pdev->dev, &opp_params); +if (err) +return err; + +tegra_emc_rate_requests_init (emc); + +if (IS_ENABLED (CONFIG_DEBUG_FS )) +emc_debugfs_init (&pdev->dev, emc); + +tegra_emc_interconnect_init (emc); + +/* +* Don't allow the kernel module to be unloaded. Unloading adds some +* extra complexity which doesn't really worth the effort in a case of +* this driver. +*/ +try_module_get (THIS_MODULE ); + +return 0 ; +}; + +static const struct of_device_id tegra_emc_of_match[] = { + { .compatible ="nvidia,tegra114-emc" }, + {} +}; +MODULE_DEVICE_TABLE (of, tegra_emc_of_match); + +static struct platform_driver tegra_emc_driver = { + .probe = tegra_emc_probe, + .driver = { + .name ="tegra114-emc" ,drivers/memory/tegra/tegra114-emc.c line 1463
Quoted 10 lines
drivers/memory/tegra/tegra114-emc.c new file +10
-0+ .of_match_table = tegra_emc_of_match, + .suppress_bind_attrs = true, + .sync_state = icc_sync_state, + }, +}; +module_platform_driver (tegra_emc_driver); + +MODULE_AUTHOR ("Svyatoslav Ryhel <[email protected]>" ); +MODULE_DESCRIPTION ("NVIDIA Tegra114 EMC driver" ); +MODULE_LICENSE ("GPL" );Best regards,
Krzysztof
Krzysztof Kozlowski
maintainerRe: [PATCH v1 5/5] memory: tegra: Add Tegra114 EMC driver
Quoted 80 lines · Svyatoslav Ryhel
вт, 17 лют. 2026 р. о 09:21 Krzysztof Kozlowski <[email protected]> пише:
Quoted 79 lines · Svyatoslav Ryhel
Quoted 11 lines
Introduce driver for the External Memory Controller (EMC) found in Tegra114 SoC. It controls the external DRAM on the board. The purpose of this driver is to program memory timing for external memory on the EMC clock rate change.
Signed-off-by Svyatoslav Ryhel <[email protected]>Reviewed-by Mikko Perttunen <[email protected]>--- drivers/memory/tegra/Kconfig | 12 + drivers/memory/tegra/Makefile | 1 + drivers/memory/tegra/tegra114-emc.c | 1463 +++++++++++++++++++++++++++Please rebase on top of Mikko's patch removing duplicated code.
Quoted 45 lines
3 files changed, 1476 insertions(+) create mode 100644 drivers/memory/tegra/tegra114-emc.cdrivers/memory/tegra/Kconfig +12
-0@@ -35,6 +35,18 @@ config TEGRA30_EMC This driver is required to change memory timings / clock rate for external memory. +config TEGRA114_EMC + tristate "NVIDIA Tegra114 External Memory Controller driver" + default y + depends on ARCH_TEGRA_114_SOC || COMPILE_TEST + select TEGRA124_CLK_EMC if ARCH_TEGRA + select PM_OPP + help + This driver is for the External Memory Controller (EMC) found on + Tegra114 chips. The EMC controls the external DRAM on the board. + This driver is required to change memory timings / clock rate for + external memory. + config TEGRA124_EMC tristate "NVIDIA Tegra124 External Memory Controller driver" default ARCH_TEGRA_124_SOCdrivers/memory/tegra/Makefile +1
-0@@ -16,6 +16,7 @@ obj-$(CONFIG_TEGRA_MC) += tegra-mc.o obj-$(CONFIG_TEGRA20_EMC) += tegra20-emc.o obj-$(CONFIG_TEGRA30_EMC) += tegra30-emc.o +obj-$(CONFIG_TEGRA114_EMC) += tegra114-emc.o obj-$(CONFIG_TEGRA124_EMC) += tegra124-emc.o obj-$(CONFIG_TEGRA210_EMC_TABLE) += tegra210-emc-table.o obj-$(CONFIG_TEGRA210_EMC) += tegra210-emc.odrivers/memory/tegra/tegra114-emc.c new file +1
-0@@ -0,0 +1,1463 @@ +// SPDX-License-Identifier: GPL-2.0-only drivers/memory/tegra/tegra114-emc.c line 11
Quoted 10 lines
drivers/memory/tegra/tegra114-emc.c new file +10
-0+/* +* Tegra114 External Memory Controller driver +* +* Based on downstream driver from NVIDIA and tegra124-emc.c +* Copyright (C) 2011-2014 NVIDIA Corporation +* +* Copyright (C) 2024 Svyatoslav Ryhel <[email protected]> +*/ + +#include <linux/clk-provider.h> Where is it used?
drivers/memory/tegra/tegra114-emc.c line 13
Quoted 2 lines
drivers/memory/tegra/tegra114-emc.c new file +2
-0+#include <linux/clk.h> +#include <linux/clkdev.h> Where is it used?
Quoted 6 lines
Quoted 4 lines
drivers/memory/tegra/tegra114-emc.c line 14
Quoted 1 line
drivers/memory/tegra/tegra114-emc.c new file +1
-0+#include <linux/clk/tegra.h> Where is it used?
All 4 by
tegra124_clk_set_emc_callbacks
What? That's not how C works.
There is no definition of tegra124_clk_set_emc_callbacks here in this patch, so the headers are not used. Point me to any symbols from these headers being used in this patch.
Best regards,
Krzysztof
Re: [PATCH v1 5/5] memory: tegra: Add Tegra114 EMC driver
вт, 17 лют. 2026 р. о 10:18 Krzysztof Kozlowski <[email protected]> пише:
Quoted 87 lines · Svyatoslav Ryhel
Quoted 85 lines
вт, 17 лют. 2026 р. о 09:21 Krzysztof Kozlowski <[email protected]> пише:
Quoted 83 lines · Svyatoslav Ryhel
Quoted 11 lines
Introduce driver for the External Memory Controller (EMC) found in Tegra114 SoC. It controls the external DRAM on the board. The purpose of this driver is to program memory timing for external memory on the EMC clock rate change.
Signed-off-by Svyatoslav Ryhel <[email protected]>Reviewed-by Mikko Perttunen <[email protected]>--- drivers/memory/tegra/Kconfig | 12 + drivers/memory/tegra/Makefile | 1 + drivers/memory/tegra/tegra114-emc.c | 1463 +++++++++++++++++++++++++++Please rebase on top of Mikko's patch removing duplicated code.
Quoted 45 lines
3 files changed, 1476 insertions(+) create mode 100644 drivers/memory/tegra/tegra114-emc.cdrivers/memory/tegra/Kconfig +12
-0@@ -35,6 +35,18 @@ config TEGRA30_EMC This driver is required to change memory timings / clock rate for external memory. +config TEGRA114_EMC + tristate "NVIDIA Tegra114 External Memory Controller driver" + default y + depends on ARCH_TEGRA_114_SOC || COMPILE_TEST + select TEGRA124_CLK_EMC if ARCH_TEGRA + select PM_OPP + help + This driver is for the External Memory Controller (EMC) found on + Tegra114 chips. The EMC controls the external DRAM on the board. + This driver is required to change memory timings / clock rate for + external memory. + config TEGRA124_EMC tristate "NVIDIA Tegra124 External Memory Controller driver" default ARCH_TEGRA_124_SOCdrivers/memory/tegra/Makefile +1
-0@@ -16,6 +16,7 @@ obj-$(CONFIG_TEGRA_MC) += tegra-mc.o obj-$(CONFIG_TEGRA20_EMC) += tegra20-emc.o obj-$(CONFIG_TEGRA30_EMC) += tegra30-emc.o +obj-$(CONFIG_TEGRA114_EMC) += tegra114-emc.o obj-$(CONFIG_TEGRA124_EMC) += tegra124-emc.o obj-$(CONFIG_TEGRA210_EMC_TABLE) += tegra210-emc-table.o obj-$(CONFIG_TEGRA210_EMC) += tegra210-emc.odrivers/memory/tegra/tegra114-emc.c new file +1
-0@@ -0,0 +1,1463 @@ +// SPDX-License-Identifier: GPL-2.0-only drivers/memory/tegra/tegra114-emc.c line 11
Quoted 10 lines
drivers/memory/tegra/tegra114-emc.c new file +10
-0+/* +* Tegra114 External Memory Controller driver +* +* Based on downstream driver from NVIDIA and tegra124-emc.c +* Copyright (C) 2011-2014 NVIDIA Corporation +* +* Copyright (C) 2024 Svyatoslav Ryhel <[email protected]> +*/ + +#include <linux/clk-provider.h> Where is it used?
drivers/memory/tegra/tegra114-emc.c line 13
Quoted 2 lines
drivers/memory/tegra/tegra114-emc.c new file +2
-0+#include <linux/clk.h> +#include <linux/clkdev.h> Where is it used?
drivers/memory/tegra/tegra114-emc.c line 14
Quoted 1 line
drivers/memory/tegra/tegra114-emc.c new file +1
-0+#include <linux/clk/tegra.h> Where is it used?
Quoted 8 lines
Quoted 1 line
All 4 by
tegra124_clk_set_emc_callbacksWhat? That's not how C works.
There is no definition of
tegra124_clk_set_emc_callbackshere in this patch, so the headers are not used. Point me to any symbols from these headers being used in this patch.
Quoted 2 lines
Best regards,
Krzysztof
Krzysztof Kozlowski
maintainerRe: [PATCH v1 5/5] memory: tegra: Add Tegra114 EMC driver
Quoted 39 lines · Svyatoslav Ryhel
Quoted 39 lines
Quoted 38 lines
Quoted 27 lines
Quoted 14 lines
obj-$(CONFIG_TEGRA20_EMC) += tegra20-emc.o
obj-$(CONFIG_TEGRA30_EMC) += tegra30-emc.odrivers/memory/tegra/Makefile +1
-0+obj-$(CONFIG_TEGRA114_EMC) += tegra114-emc.o obj-$(CONFIG_TEGRA124_EMC) += tegra124-emc.o obj-$(CONFIG_TEGRA210_EMC_TABLE) += tegra210-emc-table.o obj-$(CONFIG_TEGRA210_EMC) += tegra210-emc.odrivers/memory/tegra/tegra114-emc.c new file +1
-0@@ -0,0 +1,1463 @@ +// SPDX-License-Identifier: GPL-2.0-only drivers/memory/tegra/tegra114-emc.c line 11
Quoted 10 lines
drivers/memory/tegra/tegra114-emc.c new file +10
-0+/* +* Tegra114 External Memory Controller driver +* +* Based on downstream driver from NVIDIA and tegra124-emc.c +* Copyright (C) 2011-2014 NVIDIA Corporation +* +* Copyright (C) 2024 Svyatoslav Ryhel <[email protected]> +*/ + +#include <linux/clk-provider.h> Where is it used?
Quoted 9 lines
drivers/memory/tegra/tegra114-emc.c line 13
Quoted 2 lines
drivers/memory/tegra/tegra114-emc.c new file +2
-0+#include <linux/clk.h> +#include <linux/clkdev.h> Where is it used?
drivers/memory/tegra/tegra114-emc.c line 14
Quoted 1 line
drivers/memory/tegra/tegra114-emc.c new file +1
-0+#include <linux/clk/tegra.h> Where is it used?
All 4 by
tegra124_clk_set_emc_callbacks
Quoted 9 lines
Quoted 6 lines
What? That's not how C works.
There is no definition of
tegra124_clk_set_emc_callbackshere in this patch, so the headers are not used. Point me to any symbols from these headers being used in this patch.
This is different header, I asked for using in this patch (or rather this C unit). Plus that header does not even use things I asked above - no clkdev, no interconnect, no clk provider.
Best regards,
Krzysztof