Add EMC scaling support for Tegra210
Subsystems (5)
v4 cover Add EMC scaling support for Tegra210
This series introduces the EMC clock scaling support for Tegra210. The new version has a significant change, which drops the EMC table bindings and replaces by memory region node of EMC table.
And most of the comments in V1 have been addressed. Thanks.
v4:
* make sure the behavior is compatible with the case if the kernel uses the older DTB which doesn't have EMC node.
* remove the EMC clock statistic data in EMC debug fs.
Joseph Lo (8):
dt-bindings: memory: tegra: Add external memory controller binding for
Tegra210
clk: tegra: Add PLLP_UD and PLLMB_UD for Tegra210
clk: tegra: Export functions for EMC clock scaling
memory: tegra: Add Tegra210 EMC clock driver
memory: tegra: Add EMC scaling support code for Tegra210
memory: tegra: Add EMC scaling sequence code for Tegra210
clk: tegra: Remove the old emc_mux clock for Tegra210
arm64: tegra: Add external memory controller node for Tegra210
.../nvidia,tegra210-emc.txt | 55 + arch/arm64/boot/dts/nvidia/tegra210.dtsi | 33 + drivers/clk/tegra/clk-tegra210.c | 89 +- drivers/memory/tegra/Kconfig | 10 + drivers/memory/tegra/Makefile | 1 + drivers/memory/tegra/tegra210-emc-cc-r21021.c | 1953 ++++++++++++++++ drivers/memory/tegra/tegra210-emc.c | 2041 +++++++++++++++++ drivers/memory/tegra/tegra210-emc.h | 1031 +++++++++ include/dt-bindings/clock/tegra210-car.h | 4 +- include/linux/clk/tegra.h | 5 + include/soc/tegra/emc.h | 2 + 11 files changed, 5207 insertions(+), 17 deletions(-) create mode 100644 Documentation/devicetree/bindings/memory-controllers/nvidia,tegra210-emc.txt create mode 100644 drivers/memory/tegra/tegra210-emc-cc-r21021.c create mode 100644 drivers/memory/tegra/tegra210-emc.c create mode 100644 drivers/memory/tegra/tegra210-emc.h
Signature · 1 line
2.21.0
PATCH v4 1/8 dt-bindings: memory: tegra: Add external memory controller binding for Tegra210
Add the binding document for the external memory controller (EMC) which communicates with external LPDDR4 devices. It includes the bindings of the EMC node and a sub-node of EMC table which under the reserved memory node. The EMC table contains the data of the rates that EMC supported.
---
v4:
- no change
v3:
- drop the bindings of EMC table
- add memory-region and reserved-memory node for EMC table
--- .../nvidia,tegra210-emc.txt | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Documentation/devicetree/bindings/memory-controllers/nvidia,tegra210-emc.txt
Documentation/devicetree/bindings/memory-controllers/nvidia,tegra210-emc.txt new file +55 -0
@@ -0,0 +1,55 @@ +NVIDIA Tegra210 SoC EMC (external memory controller) +==================================================== + +Device node +=========== +Required properties : +- compatible : should be "nvidia,tegra210-emc". +- reg : physical base address and length of the controller's registers. +- clocks : phandles of the possible source clocks. +- clock-names : names of the possible source clocks. +- interrupts : Should contain the EMC general interrupt. +- memory-region : phandle to the reserved memory (see + Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt) which + contains a sub-node of EMC table. +- nvidia,memory-controller : phandle of the memory controller. + +Reserved memory node +==================== +Should contain a sub-node of EMC table with required properties: +- compatible : should be "nvidia,tegra210-emc-table". +- reg : physical address and length of the location of EMC table. + +Example: + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + emc_table: emc-table@8be00000 { + compatible = "nvidia,tegra210-emc-table"; + reg = <0x0 0x8be00000 0x0 0x10000>; + status = "okay"; + }; + }; + + external-memory-controller@7001b000 { + compatible = "nvidia,tegra210-emc"; + reg = <0x0 0x7001b000 0x0 0x1000>, + <0x0 0x7001e000 0x0 0x1000>, + <0x0 0x7001f000 0x0 0x1000>; + clocks = <&tegra_car TEGRA210_CLK_EMC>, + <&tegra_car TEGRA210_CLK_PLL_M>, + <&tegra_car TEGRA210_CLK_PLL_C>, + <&tegra_car TEGRA210_CLK_PLL_P>, + <&tegra_car TEGRA210_CLK_CLK_M>, + <&tegra_car TEGRA210_CLK_PLL_M_UD>, + <&tegra_car TEGRA210_CLK_PLL_MB_UD>, + <&tegra_car TEGRA210_CLK_PLL_MB>, + <&tegra_car TEGRA210_CLK_PLL_P_UD>; + clock-names = "emc", "pll_m", "pll_c", "pll_p", "clk_m", + "pll_m_ud", "pll_mb_ud", "pll_mb", "pll_p_ud"; + interrupts = <GIC_SPI 78 IRQ_TYPE_LEVEL_HIGH>; + memory-region = <&emc_table>; + nvidia,memory-controller = <&mc>; + };
Signature · 1 line
2.21.0
PATCH v4 2/8 clk: tegra: Add PLLP_UD and PLLMB_UD for Tegra210
In reply to Joseph LoIntroduce the low jitter path of PLLP and PLLMB which can be used as EMC clock source.
---
v4:
- no change
v3:
- split to 3 patches from the previous version
--- drivers/clk/tegra/clk-tegra210.c | 11 +++++++++++ include/dt-bindings/clock/tegra210-car.h | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-)
drivers/clk/tegra/clk-tegra210.c +11 -0
@@ -3116,6 +3116,17 @@ static void __init tegra210_pll_init(void __iomem *clk_base,clk_register_clkdev (clk,"pll_m_ud" ,NULL ); clks[TEGRA210_CLK_PLL_M_UD ] = clk; +/* PLLMB_UD */ + clk =clk_register_fixed_factor (NULL ,"pll_mb_ud" ,"pll_mb" , +CLK_SET_RATE_PARENT ,1 ,1 ); +clk_register_clkdev (clk,"pll_mb_ud" ,NULL ); + clks[TEGRA210_CLK_PLL_MB_UD ] = clk; + +/* PLLP_UD */ + clk =clk_register_fixed_factor (NULL ,"pll_p_ud" ,"pll_p" , +0 ,1 ,1 ); + clks[TEGRA210_CLK_PLL_P_UD ] = clk; +/* PLLU_VCO */ if (!tegra210_init_pllu ()) { clk = clk_register_fixed_rate(NULL, "pll_u_vco", "pll_ref", 0,
include/dt-bindings/clock/tegra210-car.h +2 -2
@@ -349,8 +349,8 @@#define TEGRA210_CLK_PLL_P_OUT_XUSB 317#define TEGRA210_CLK_XUSB_SSP_SRC 318#define TEGRA210_CLK_PLL_RE_OUT1 319 -/* 320 */ -/* 321 */ +#define TEGRA210_CLK_PLL_MB_UD 320 +#define TEGRA210_CLK_PLL_P_UD 321#define TEGRA210_CLK_ISP 322#define TEGRA210_CLK_PLL_A_OUT_ADSP 323#define TEGRA210_CLK_PLL_A_OUT0_OUT_ADSP 324
Signature · 1 line
2.21.0
PATCH v4 3/8 clk: tegra: Export functions for EMC clock scaling
In reply to Joseph LoExport functions to allow accessing the CAR register required by EMC clock scaling. These functions will be used to access the CAR register as part of the scaling sequence.
---
v4:
- no change
v3:
- split to 3 patches from the previous version
--- drivers/clk/tegra/clk-tegra210.c | 36 ++++++++++++++++++++++++++++++++ include/linux/clk/tegra.h | 5 +++++ 2 files changed, 41 insertions(+)
drivers/clk/tegra/clk-tegra210.c +36 -0
@@ -47,6 +47,7 @@#define CLK_SOURCE_LA 0x1f8#define CLK_SOURCE_SDMMC2 0x154#define CLK_SOURCE_SDMMC4 0x164 +#define CLK_SOURCE_EMC_DLL 0x664#define PLLC_BASE 0x80#define PLLC_OUT 0x84
@@ -234,6 +235,10 @@#define RST_DFLL_DVCO 0x2f4#define DVFS_DFLL_RESET_SHIFT 0 +#define CLK_RST_CONTROLLER_CLK_OUT_ENB_X_SET 0x284 +#define CLK_RST_CONTROLLER_CLK_OUT_ENB_X_CLR 0x288 +#define CLK_OUT_ENB_X_CLK_ENB_EMC_DLL BIT(14) +#define CLK_RST_CONTROLLER_RST_DEV_Y_SET 0x2a8#define CLK_RST_CONTROLLER_RST_DEV_Y_CLR 0x2ac
@@ -560,6 +565,37 @@ void tegra210_set_sata_pll_seq_sw(bool state) }EXPORT_SYMBOL_GPL (tegra210_set_sata_pll_seq_sw); +void tegra210_clk_emc_dll_enable (bool flag) +{ +u32 offset = flag ?CLK_RST_CONTROLLER_CLK_OUT_ENB_X_SET : +CLK_RST_CONTROLLER_CLK_OUT_ENB_X_CLR ; + +writel_relaxed (CLK_OUT_ENB_X_CLK_ENB_EMC_DLL , clk_base + offset); +} +EXPORT_SYMBOL_GPL (tegra210_clk_emc_dll_enable); + +void tegra210_clk_emc_dll_update_setting (u32 emc_dll_src_value) +{ +writel_relaxed (emc_dll_src_value, clk_base +CLK_SOURCE_EMC_DLL ); +} +EXPORT_SYMBOL_GPL (tegra210_clk_emc_dll_update_setting); + +void tegra210_clk_emc_update_setting (u32 emc_src_value) +{ +writel_relaxed (emc_src_value, clk_base +CLK_SOURCE_EMC ); +} +EXPORT_SYMBOL_GPL (tegra210_clk_emc_update_setting); + +u32 tegra210_clk_emc_get_setting (void ) +{ +u32 val; + + val =readl_relaxed (clk_base +CLK_SOURCE_EMC ); + +return val; +} +EXPORT_SYMBOL_GPL (tegra210_clk_emc_get_setting); +static void tegra210_generic_mbist_war (struct tegra210_domain_mbist_war *mbist) {u32 val;
include/linux/clk/tegra.h +5 -0
@@ -129,5 +129,10 @@ extern void tegra210_set_sata_pll_seq_sw(bool state);extern void tegra210_put_utmipll_in_iddq (void );extern void tegra210_put_utmipll_out_iddq (void );extern int tegra210_clk_handle_mbist_war (unsigned int id); +extern void tegra210_clk_emc_dll_enable (bool flag); +extern void tegra210_clk_emc_dll_update_setting (u32 emc_dll_src_value); +extern void tegra210_clk_emc_update_setting (u32 emc_src_value); +extern u32 tegra210_clk_emc_get_setting (void ); +#endif /* __LINUX_CLK_TEGRA_H_ */
Signature · 1 line
2.21.0
PATCH v4 4/8 memory: tegra: Add Tegra210 EMC clock driver
In reply to Joseph LoThis is the initial patch for Tegra210 EMC clock driver, which doesn't include the support code and detail sequence for clock scaling yet.
The driver is designed to support LPDDR4 SDRAM. Because of the LPDDR4 devices need to do initial time training before it can be used, the firmware will help to do that at early boot stage. Then, the trained table of the rates we support will pass to the kernel via DT. So the driver can get the trained table for clock scaling support.
For the higher rate support (above 800MHz), the periodic training is needed for the timing compensation. So basically, two methodologies for clock scaling are supported, one is following the clock changing sequence to update the EMC table to EMC registers and another is if the rate needs periodic training, then we will start a timer to do that periodically until it scales to the lower rate.
Based on the work of Peter De Schrijver <[email protected]>.
---
v4:
- remove the statistic data in debugfs
- add tegra210_clk_register_emc API to make it compatible with the case if the kernel still uses the older DTB which doesn't have EMC node. And the MC and EMC clock can still be registered successfully.
v3:
- address almost all the comments from the previous version
- remove the DT parser of EMC table
- The EMC table is passing as a binary blob now.
--- drivers/memory/tegra/Kconfig | 10 + drivers/memory/tegra/Makefile | 1 + drivers/memory/tegra/tegra210-emc.c | 671 ++++++++++++++++++++++++++++ drivers/memory/tegra/tegra210-emc.h | 156 +++++++ include/soc/tegra/emc.h | 2 + 5 files changed, 840 insertions(+) create mode 100644 drivers/memory/tegra/tegra210-emc.c create mode 100644 drivers/memory/tegra/tegra210-emc.h
drivers/memory/tegra/Kconfig +10 -0
@@ -26,3 +26,13 @@ config TEGRA124_EMC Tegra124 chips. The EMC controls the external DRAM on the board. This driver is required to change memory timings / clock rate for external memory. + +config TEGRA210_EMC + bool "NVIDIA Tegra210 External Memory Controller driver" + default y + depends on TEGRA_MC && ARCH_TEGRA_210_SOC + help + This driver is for the External Memory Controller (EMC) found on + Tegra210 chips. The EMC controls the external DRAM on the board. + This driver is required to change memory timings / clock rate for + external memory.
drivers/memory/tegra/Makefile +1 -0
@@ -12,4 +12,5 @@ obj-$(CONFIG_TEGRA_MC) += tegra-mc.o obj-$(CONFIG_TEGRA20_EMC) += tegra20-emc.o obj-$(CONFIG_TEGRA124_EMC) += tegra124-emc.o +obj-$(CONFIG_TEGRA210_EMC) += tegra210-emc.o obj-$(CONFIG_ARCH_TEGRA_186_SOC) += tegra186.o
drivers/memory/tegra/tegra210-emc.c new file +671 -0
671 lines not on this page · raw message
drivers/memory/tegra/tegra210-emc.h new file +156 -0
156 lines not on this page · raw message
include/soc/tegra/emc.h +2 -0
@@ -16,4 +16,6 @@ int tegra_emc_prepare_timing_change(struct tegra_emc *emc,void tegra_emc_complete_timing_change (struct tegra_emc *emc,unsigned long rate); +struct clk *tegra210_clk_register_emc (void ); +#endif /* __SOC_TEGRA_EMC_H__ */
Signature · 1 line
2.21.0
PATCH v4 5/8 memory: tegra: Add EMC scaling support code for Tegra210
In reply to Joseph LoThis patch adds the required APIs and variables for the EMC scaling sequence code on Tegra210.
Based on the work of Peter De Schrijver <[email protected]>.
---
v4:
- fix the API with generic naming
- use 'u16' in 'struct emc_table_register_offset'
--- drivers/memory/tegra/tegra210-emc.c | 1365 +++++++++++++++++++++++++++ drivers/memory/tegra/tegra210-emc.h | 718 ++++++++++++++ 2 files changed, 2083 insertions(+)
drivers/memory/tegra/tegra210-emc.c +1365 -0
@@ -22,11 +22,27 @@#define EMC_CLK_EMC_2X_CLK_SRC_SHIFT 29#define EMC_CLK_EMC_2X_CLK_SRC_MASK \ (0x7 << EMC_CLK_EMC_2X_CLK_SRC_SHIFT) +#define EMC_CLK_SOURCE_PLLM_LJ 0x4 +#define EMC_CLK_SOURCE_PLLMB_LJ 0x5#define EMC_CLK_MC_EMC_SAME_FREQ BIT(16)#define EMC_CLK_EMC_2X_CLK_DIVISOR_SHIFT 0#define EMC_CLK_EMC_2X_CLK_DIVISOR_MASK \ (0xff << EMC_CLK_EMC_2X_CLK_DIVISOR_SHIFT) +#define CLK_RST_CONTROLLER_CLK_SOURCE_EMC_DLL 0x664 +#define DLL_CLK_EMC_DLL_CLK_SRC_SHIFT 29 +#define DLL_CLK_EMC_DLL_CLK_SRC_MASK \ + (0x7 << DLL_CLK_EMC_DLL_CLK_SRC_SHIFT) +#define DLL_CLK_EMC_DLL_DDLL_CLK_SEL_SHIFT 10 +#define DLL_CLK_EMC_DLL_DDLL_CLK_SEL_MASK \ + (0x3 << DLL_CLK_EMC_DLL_DDLL_CLK_SEL_SHIFT) +#define PLLM_VCOA 0 +#define PLLM_VCOB 1 +#define EMC_DLL_SWITCH_OUT 2 +#define DLL_CLK_EMC_DLL_CLK_DIVISOR_SHIFT 0 +#define DLL_CLK_EMC_DLL_CLK_DIVISOR_MASK \ + (0xff << DLL_CLK_EMC_DLL_CLK_DIVISOR_SHIFT) +#define MC_EMEM_ARB_MISC0_EMC_SAME_FREQ BIT(27)#define TEGRA_EMC_MAX_FREQS 16
@@ -35,7 +51,46 @@#define CLK_CHANGE_DELAY 100#define TRAINING_TIME 100 +#define EMC0_EMC_DATA_BRLSHFT_0_INDEX 2 +#define EMC1_EMC_DATA_BRLSHFT_0_INDEX 3 +#define EMC0_EMC_DATA_BRLSHFT_1_INDEX 4 +#define EMC1_EMC_DATA_BRLSHFT_1_INDEX 5 + +#define TRIM_REG (chan, rank, reg, byte) \ + (((EMC_PMACRO_OB_DDLL_LONG_DQ_RANK ## rank ## _ ## reg ## \ + _OB_DDLL_LONG_DQ_RANK ## rank ## _BYTE ## byte ## _MASK & \ + next_timing->trim_regs[EMC_PMACRO_OB_DDLL_LONG_DQ_RANK ## \ + rank ## _ ## reg ## _INDEX]) >> \ + EMC_PMACRO_OB_DDLL_LONG_DQ_RANK ## rank ## _ ## reg ## \ + _OB_DDLL_LONG_DQ_RANK ## rank ## _BYTE ## byte ## _SHIFT) \ + + \ + (((EMC_DATA_BRLSHFT_ ## rank ## _RANK ## rank ## _BYTE ## \ + byte ## _DATA_BRLSHFT_MASK & \ + next_timing->trim_perch_regs[EMC ## chan ## \ + _EMC_DATA_BRLSHFT_ ## rank ## _INDEX]) >> \ + EMC_DATA_BRLSHFT_ ## rank ## _RANK ## rank ## _BYTE ## \ + byte ## _DATA_BRLSHFT_SHIFT) * 64)) + +#define CALC_TEMP (rank, reg, byte1, byte2, n) \ + (((new[n] << EMC_PMACRO_OB_DDLL_LONG_DQ_RANK ## rank ## _ ## \ + reg ## _OB_DDLL_LONG_DQ_RANK ## rank ## _BYTE ## byte1 ## _SHIFT) & \ + EMC_PMACRO_OB_DDLL_LONG_DQ_RANK ## rank ## _ ## reg ## \ + _OB_DDLL_LONG_DQ_RANK ## rank ## _BYTE ## byte1 ## _MASK) \ + | \ + ((new[n + 1] << EMC_PMACRO_OB_DDLL_LONG_DQ_RANK ## rank ## _ ##\ + reg ## _OB_DDLL_LONG_DQ_RANK ## rank ## _BYTE ## byte2 ## _SHIFT) & \ + EMC_PMACRO_OB_DDLL_LONG_DQ_RANK ## rank ## _ ## reg ## \ + _OB_DDLL_LONG_DQ_RANK ## rank ## _BYTE ## byte2 ## _MASK)) +enum { +TEGRA_DRAM_OVER_TEMP_NONE =0 , +TEGRA_DRAM_OVER_TEMP_REFRESH_X2 , +TEGRA_DRAM_OVER_TEMP_REFRESH_X4 , +TEGRA_DRAM_OVER_TEMP_THROTTLE ,/* 4x Refresh + derating. */ +TEGRA_DRAM_OVER_TEMP_MAX , +}; + +enum TEGRA_EMC_SOURCE {TEGRA_EMC_SRC_PLLM ,TEGRA_EMC_SRC_PLLC ,TEGRA_EMC_SRC_PLLP ,
@@ -80,17 +135,499 @@ static const struct supported_sequence supported_seqs[] = { };static const struct supported_sequence *seq = supported_seqs;static DEFINE_SPINLOCK (emc_access_lock); +unsigned long dram_over_temp_state =TEGRA_DRAM_OVER_TEMP_NONE ; + +const struct emc_table_register_offset reg_off = { + .burst_regs_off = { +EMC_RC , +EMC_RFC , +EMC_RFCPB , +EMC_REFCTRL2 , +EMC_RFC_SLR , +EMC_RAS , +EMC_RP , +EMC_R2W , +EMC_W2R , +EMC_R2P , +EMC_W2P , +EMC_R2R , +EMC_TPPD , +EMC_CCDMW , +EMC_RD_RCD , +EMC_WR_RCD , +EMC_RRD , +EMC_REXT , +EMC_WEXT , +EMC_WDV_CHK , +EMC_WDV , +EMC_WSV , +EMC_WEV , +EMC_WDV_MASK , +EMC_WS_DURATION , +EMC_WE_DURATION , +EMC_QUSE , +EMC_QUSE_WIDTH , +EMC_IBDLY , +EMC_OBDLY , +EMC_EINPUT , +EMC_MRW6 , +EMC_EINPUT_DURATION , +EMC_PUTERM_EXTRA , +EMC_PUTERM_WIDTH , +EMC_QRST , +EMC_QSAFE , +EMC_RDV , +EMC_RDV_MASK , +EMC_RDV_EARLY , +EMC_RDV_EARLY_MASK , +EMC_REFRESH , +EMC_BURST_REFRESH_NUM , +EMC_PRE_REFRESH_REQ_CNT , +EMC_PDEX2WR , +EMC_PDEX2RD , +EMC_PCHG2PDEN , +EMC_ACT2PDEN , +EMC_AR2PDEN , +EMC_RW2PDEN , +EMC_CKE2PDEN , +EMC_PDEX2CKE , +EMC_PDEX2MRR , +EMC_TXSR , +EMC_TXSRDLL , +EMC_TCKE , +EMC_TCKESR , +EMC_TPD , +EMC_TFAW , +EMC_TRPAB , +EMC_TCLKSTABLE , +EMC_TCLKSTOP , +EMC_MRW7 , +EMC_TREFBW , +EMC_ODT_WRITE , +EMC_FBIO_CFG5 , +EMC_FBIO_CFG7 , +EMC_CFG_DIG_DLL , +EMC_CFG_DIG_DLL_PERIOD , +EMC_PMACRO_IB_RXRT , +EMC_CFG_PIPE_1 , +EMC_CFG_PIPE_2 , +EMC_PMACRO_QUSE_DDLL_RANK0_4 , +EMC_PMACRO_QUSE_DDLL_RANK0_5 , +EMC_PMACRO_QUSE_DDLL_RANK1_4 , +EMC_PMACRO_QUSE_DDLL_RANK1_5 , +EMC_MRW8 , +EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_4 , +EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_5 , +EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_0 , +EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_1 , +EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_2 , +EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_3 , +EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_4 , +EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_5 , +EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_0 , +EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_1 , +EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_2 , +EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_3 , +EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_4 , +EMC_PMACRO_OB_DDLL_LONG_DQS_RANK1_5 , +EMC_PMACRO_DDLL_LONG_CMD_0 , +EMC_PMACRO_DDLL_LONG_CMD_1 , +EMC_PMACRO_DDLL_LONG_CMD_2 , +EMC_PMACRO_DDLL_LONG_CMD_3 , +EMC_PMACRO_DDLL_LONG_CMD_4 , +EMC_PMACRO_DDLL_SHORT_CMD_0 , +EMC_PMACRO_DDLL_SHORT_CMD_1 , +EMC_PMACRO_DDLL_SHORT_CMD_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE0_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE1_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE2_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE3_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE4_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE5_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE6_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE7_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD0_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD1_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD2_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD3_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE0_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE1_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE2_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE3_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE4_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE5_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE6_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE7_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD0_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD0_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD0_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD0_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD1_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD1_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD1_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD1_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD2_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD2_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD2_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD2_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD3_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD3_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD3_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_CMD3_3 , +EMC_TXDSRVTTGEN , +EMC_FDPD_CTRL_DQ , +EMC_FDPD_CTRL_CMD , +EMC_FBIO_SPARE , +EMC_ZCAL_INTERVAL , +EMC_ZCAL_WAIT_CNT , +EMC_MRS_WAIT_CNT , +EMC_MRS_WAIT_CNT2 , +EMC_AUTO_CAL_CHANNEL , +EMC_DLL_CFG_0 , +EMC_DLL_CFG_1 , +EMC_PMACRO_AUTOCAL_CFG_COMMON , +EMC_PMACRO_ZCTRL , +EMC_CFG , +EMC_CFG_PIPE , +EMC_DYN_SELF_REF_CONTROL , +EMC_QPOP , +EMC_DQS_BRLSHFT_0 , +EMC_DQS_BRLSHFT_1 , +EMC_CMD_BRLSHFT_2 , +EMC_CMD_BRLSHFT_3 , +EMC_PMACRO_PAD_CFG_CTRL , +EMC_PMACRO_DATA_PAD_RX_CTRL , +EMC_PMACRO_CMD_PAD_RX_CTRL , +EMC_PMACRO_DATA_RX_TERM_MODE , +EMC_PMACRO_CMD_RX_TERM_MODE , +EMC_PMACRO_CMD_PAD_TX_CTRL , +EMC_PMACRO_DATA_PAD_TX_CTRL , +EMC_PMACRO_COMMON_PAD_TX_CTRL , +EMC_PMACRO_VTTGEN_CTRL_0 , +EMC_PMACRO_VTTGEN_CTRL_1 , +EMC_PMACRO_VTTGEN_CTRL_2 , +EMC_PMACRO_BRICK_CTRL_RFU1 , +EMC_PMACRO_CMD_BRICK_CTRL_FDPD , +EMC_PMACRO_BRICK_CTRL_RFU2 , +EMC_PMACRO_DATA_BRICK_CTRL_FDPD , +EMC_PMACRO_BG_BIAS_CTRL_0 , +EMC_CFG_3 , +EMC_PMACRO_TX_PWRD_0 , +EMC_PMACRO_TX_PWRD_1 , +EMC_PMACRO_TX_PWRD_2 , +EMC_PMACRO_TX_PWRD_3 , +EMC_PMACRO_TX_PWRD_4 , +EMC_PMACRO_TX_PWRD_5 , +EMC_CONFIG_SAMPLE_DELAY , +EMC_PMACRO_TX_SEL_CLK_SRC_0 , +EMC_PMACRO_TX_SEL_CLK_SRC_1 , +EMC_PMACRO_TX_SEL_CLK_SRC_2 , +EMC_PMACRO_TX_SEL_CLK_SRC_3 , +EMC_PMACRO_TX_SEL_CLK_SRC_4 , +EMC_PMACRO_TX_SEL_CLK_SRC_5 , +EMC_PMACRO_DDLL_BYPASS , +EMC_PMACRO_DDLL_PWRD_0 , +EMC_PMACRO_DDLL_PWRD_1 , +EMC_PMACRO_DDLL_PWRD_2 , +EMC_PMACRO_CMD_CTRL_0 , +EMC_PMACRO_CMD_CTRL_1 , +EMC_PMACRO_CMD_CTRL_2 , +EMC_TR_TIMING_0 , +EMC_TR_DVFS , +EMC_TR_CTRL_1 , +EMC_TR_RDV , +EMC_TR_QPOP , +EMC_TR_RDV_MASK , +EMC_MRW14 , +EMC_TR_QSAFE , +EMC_TR_QRST , +EMC_TRAINING_CTRL , +EMC_TRAINING_SETTLE , +EMC_TRAINING_VREF_SETTLE , +EMC_TRAINING_CA_FINE_CTRL , +EMC_TRAINING_CA_CTRL_MISC , +EMC_TRAINING_CA_CTRL_MISC1 , +EMC_TRAINING_CA_VREF_CTRL , +EMC_TRAINING_QUSE_CORS_CTRL , +EMC_TRAINING_QUSE_FINE_CTRL , +EMC_TRAINING_QUSE_CTRL_MISC , +EMC_TRAINING_QUSE_VREF_CTRL , +EMC_TRAINING_READ_FINE_CTRL , +EMC_TRAINING_READ_CTRL_MISC , +EMC_TRAINING_READ_VREF_CTRL , +EMC_TRAINING_WRITE_FINE_CTRL , +EMC_TRAINING_WRITE_CTRL_MISC , +EMC_TRAINING_WRITE_VREF_CTRL , +EMC_TRAINING_MPC , +EMC_MRW15 , + }, + .trim_regs_off = { +EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_0 , +EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_1 , +EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_2 , +EMC_PMACRO_IB_DDLL_LONG_DQS_RANK0_3 , +EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_0 , +EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_1 , +EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_2 , +EMC_PMACRO_IB_DDLL_LONG_DQS_RANK1_3 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE0_0 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE0_1 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE0_2 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE1_0 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE1_1 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE1_2 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE2_0 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE2_1 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE2_2 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE3_0 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE3_1 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE3_2 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE4_0 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE4_1 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE4_2 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE5_0 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE5_1 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE5_2 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE6_0 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE6_1 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE6_2 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE7_0 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE7_1 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK0_BYTE7_2 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE0_0 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE0_1 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE0_2 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE1_0 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE1_1 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE1_2 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE2_0 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE2_1 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE2_2 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE3_0 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE3_1 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE3_2 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE4_0 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE4_1 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE4_2 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE5_0 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE5_1 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE5_2 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE6_0 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE6_1 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE6_2 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE7_0 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE7_1 , +EMC_PMACRO_IB_DDLL_SHORT_DQ_RANK1_BYTE7_2 , +EMC_PMACRO_IB_VREF_DQS_0 , +EMC_PMACRO_IB_VREF_DQS_1 , +EMC_PMACRO_IB_VREF_DQ_0 , +EMC_PMACRO_IB_VREF_DQ_1 , +EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_0 , +EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_1 , +EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_2 , +EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_3 , +EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_4 , +EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_5 , +EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_0 , +EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_1 , +EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_2 , +EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_3 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE0_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE0_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE0_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE1_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE1_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE1_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE2_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE2_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE2_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE3_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE3_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE3_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE4_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE4_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE4_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE5_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE5_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE5_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE6_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE6_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE6_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE7_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE7_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_BYTE7_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD0_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD0_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD0_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD1_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD1_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD1_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD2_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD2_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD2_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD3_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD3_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK0_CMD3_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE0_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE0_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE0_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE1_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE1_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE1_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE2_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE2_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE2_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE3_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE3_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE3_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE4_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE4_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE4_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE5_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE5_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE5_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE6_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE6_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE6_2 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE7_0 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE7_1 , +EMC_PMACRO_OB_DDLL_SHORT_DQ_RANK1_BYTE7_2 , +EMC_PMACRO_QUSE_DDLL_RANK0_0 , +EMC_PMACRO_QUSE_DDLL_RANK0_1 , +EMC_PMACRO_QUSE_DDLL_RANK0_2 , +EMC_PMACRO_QUSE_DDLL_RANK0_3 , +EMC_PMACRO_QUSE_DDLL_RANK1_0 , +EMC_PMACRO_QUSE_DDLL_RANK1_1 , +EMC_PMACRO_QUSE_DDLL_RANK1_2 , +EMC_PMACRO_QUSE_DDLL_RANK1_3 + }, + .burst_mc_regs_off = { +MC_EMEM_ARB_CFG , +MC_EMEM_ARB_OUTSTANDING_REQ , +MC_EMEM_ARB_REFPB_HP_CTRL , +MC_EMEM_ARB_REFPB_BANK_CTRL , +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_CCDMW , +MC_EMEM_ARB_TIMING_W2R , +MC_EMEM_ARB_TIMING_RFCPB , +MC_EMEM_ARB_DA_TURNS , +MC_EMEM_ARB_DA_COVERS , +MC_EMEM_ARB_MISC0 , +MC_EMEM_ARB_MISC1 , +MC_EMEM_ARB_MISC2 , +MC_EMEM_ARB_RING1_THROTTLE , +MC_EMEM_ARB_DHYST_CTRL , +MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_0 , +MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_1 , +MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_2 , +MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_3 , +MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_4 , +MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_5 , +MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_6 , +MC_EMEM_ARB_DHYST_TIMEOUT_UTIL_7 , + }, + .la_scale_regs_off = { +MC_MLL_MPCORER_PTSA_RATE , +MC_FTOP_PTSA_RATE , +MC_PTSA_GRANT_DECREMENT , +MC_LATENCY_ALLOWANCE_XUSB_0 , +MC_LATENCY_ALLOWANCE_XUSB_1 , +MC_LATENCY_ALLOWANCE_TSEC_0 , +MC_LATENCY_ALLOWANCE_SDMMCA_0 , +MC_LATENCY_ALLOWANCE_SDMMCAA_0 , +MC_LATENCY_ALLOWANCE_SDMMC_0 , +MC_LATENCY_ALLOWANCE_SDMMCAB_0 , +MC_LATENCY_ALLOWANCE_PPCS_0 , +MC_LATENCY_ALLOWANCE_PPCS_1 , +MC_LATENCY_ALLOWANCE_MPCORE_0 , +MC_LATENCY_ALLOWANCE_HC_0 , +MC_LATENCY_ALLOWANCE_HC_1 , +MC_LATENCY_ALLOWANCE_AVPC_0 , +MC_LATENCY_ALLOWANCE_GPU_0 , +MC_LATENCY_ALLOWANCE_GPU2_0 , +MC_LATENCY_ALLOWANCE_NVENC_0 , +MC_LATENCY_ALLOWANCE_NVDEC_0 , +MC_LATENCY_ALLOWANCE_VIC_0 , +MC_LATENCY_ALLOWANCE_VI2_0 , +MC_LATENCY_ALLOWANCE_ISP2_0 , +MC_LATENCY_ALLOWANCE_ISP2_1 , + }, + .burst_regs_per_ch_off = { + { .bank =REG_EMC0 , .offset =EMC_MRW10 , }, + { .bank =REG_EMC1 , .offset =EMC_MRW10 , }, + { .bank =REG_EMC0 , .offset =EMC_MRW11 , }, + { .bank =REG_EMC1 , .offset =EMC_MRW11 , }, + { .bank =REG_EMC0 , .offset =EMC_MRW12 , }, + { .bank =REG_EMC1 , .offset =EMC_MRW12 , }, + { .bank =REG_EMC0 , .offset =EMC_MRW13 , }, + { .bank =REG_EMC1 , .offset =EMC_MRW13 , }, + }, + .trim_regs_per_ch_off = { + { .bank =REG_EMC0 , .offset =EMC_CMD_BRLSHFT_0 , }, + { .bank =REG_EMC1 , .offset =EMC_CMD_BRLSHFT_1 , }, + { .bank =REG_EMC0 , .offset =EMC_DATA_BRLSHFT_0 , }, + { .bank =REG_EMC1 , .offset =EMC_DATA_BRLSHFT_0 , }, + { .bank =REG_EMC0 , .offset =EMC_DATA_BRLSHFT_1 , }, + { .bank =REG_EMC1 , .offset =EMC_DATA_BRLSHFT_1 , }, + { .bank =REG_EMC0 , .offset =EMC_QUSE_BRLSHFT_0 , }, + { .bank =REG_EMC1 , .offset =EMC_QUSE_BRLSHFT_1 , }, + { .bank =REG_EMC0 , .offset =EMC_QUSE_BRLSHFT_2 , }, + { .bank =REG_EMC1 , .offset =EMC_QUSE_BRLSHFT_3 , }, + }, + .vref_regs_per_ch_off = { + { .bank =REG_EMC0 , + .offset =EMC_TRAINING_OPT_DQS_IB_VREF_RANK0 , }, + { .bank =REG_EMC1 , + .offset =EMC_TRAINING_OPT_DQS_IB_VREF_RANK0 , }, + { .bank =REG_EMC0 , + .offset =EMC_TRAINING_OPT_DQS_IB_VREF_RANK1 , }, + { .bank =REG_EMC1 , + .offset =EMC_TRAINING_OPT_DQS_IB_VREF_RANK1 , }, + }, +};static inline struct tegra_emc *clk_hw_to_emc (struct clk_hw *hw) { return container_of(hw, struct tegra_emc, hw); } +void emc_writel (struct tegra_emc *emc,u32 val,unsigned long offset) +{ +writel_relaxed (val, emc->emc_base[REG_EMC ] + offset); +} +u32 emc_readl (struct tegra_emc *emc,unsigned long offset) {return readl_relaxed (emc->emc_base[REG_EMC ] + offset); } +u32 emc1_readl (struct tegra_emc *emc,unsigned long offset) +{ +return readl_relaxed (emc->emc_base[REG_EMC1 ] + offset); +} + +void emc_writel_per_ch (struct tegra_emc *emc,u32 val,int type, +unsigned long offset) +{ +switch (type) { +case REG_EMC : +case REG_EMC0 : +return writel_relaxed (val, emc->emc_base[REG_EMC ] + offset); +case REG_EMC1 : +return writel_relaxed (val, emc->emc_base[REG_EMC1 ] + offset); + } +} +u32 emc_readl_per_ch (struct tegra_emc *emc,int type,unsigned long offset) {
@@ -109,6 +646,14 @@ u32 emc_readl_per_ch(struct tegra_emc *emc, int type,return val; } +void ccfifo_writel (struct tegra_emc *emc,u32 val,unsigned long addr, +u32 delay) +{ +writel_relaxed (val, emc->emc_base[REG_EMC ] +EMC_CCFIFO_DATA ); +writel_relaxed ((addr &0xffff ) | ((delay &0x7fff ) <<16 ) | (1 <<31 ), + emc->emc_base[REG_EMC ] +EMC_CCFIFO_ADDR ); +} +static inline u32 emc_src_val (u32 val) { return (val & EMC_CLK_EMC_2X_CLK_SRC_MASK) >>
@@ -176,6 +721,826 @@ static inline unsigned long emc_get_src_clk_rate(void)return rate; } +static void tegra210_change_dll_src (struct tegra_emc *emc, +u32 clksrc) +{ +u32 out_enb_x; +u32 dll_setting = emc->next_timing->dll_clk_src; +u32 emc_clk_src; +u32 emc_clk_div; + + out_enb_x =0 ; + emc_clk_src = (clksrc &EMC_CLK_EMC_2X_CLK_SRC_MASK ) >> +EMC_CLK_EMC_2X_CLK_SRC_SHIFT ; + emc_clk_div = (clksrc &EMC_CLK_EMC_2X_CLK_DIVISOR_MASK ) >> +EMC_CLK_EMC_2X_CLK_DIVISOR_SHIFT ; + + dll_setting &= ~(DLL_CLK_EMC_DLL_CLK_SRC_MASK | +DLL_CLK_EMC_DLL_CLK_DIVISOR_MASK ); + dll_setting |= emc_clk_src <<DLL_CLK_EMC_DLL_CLK_SRC_SHIFT ; + dll_setting |= emc_clk_div <<DLL_CLK_EMC_DLL_CLK_DIVISOR_SHIFT ; + + dll_setting &= ~DLL_CLK_EMC_DLL_DDLL_CLK_SEL_MASK ; +if (emc_clk_src ==EMC_CLK_SOURCE_PLLMB_LJ ) + dll_setting |= (PLLM_VCOB << +DLL_CLK_EMC_DLL_DDLL_CLK_SEL_SHIFT ); +else if (emc_clk_src ==EMC_CLK_SOURCE_PLLM_LJ ) + dll_setting |= (PLLM_VCOA << +DLL_CLK_EMC_DLL_DDLL_CLK_SEL_SHIFT ); +else + dll_setting |= (EMC_DLL_SWITCH_OUT << +DLL_CLK_EMC_DLL_DDLL_CLK_SEL_SHIFT ); + +tegra210_clk_emc_dll_update_setting (dll_setting); + +if (emc->next_timing->clk_out_enb_x_0_clk_enb_emc_dll) +tegra210_clk_emc_dll_enable (true); +else +tegra210_clk_emc_dll_enable (false); +} + +void emc_do_clock_change (struct tegra_emc *emc,u32 clksrc) +{ +int err; + +mc_readl (emc->mc,MC_EMEM_ADR_CFG ); +emc_readl (emc,EMC_INTSTATUS ); + +tegra210_clk_emc_update_setting (clksrc); + + err =emc_wait_for_update (emc,EMC_INTSTATUS , +EMC_INTSTATUS_CLKCHANGE_COMPLETE , true, +REG_EMC ); +if (err) +pr_warn ("%s: clock change completion error: %d" , __func__, err); +} + +struct emc_table *emc_get_timing_from_freq (struct tegra_emc *emc, +unsigned long rate) +{ +int i; + +for (i =0 ; i < emc->emc_table_size; i++) +if (emc->emc_table[i].rate == rate) +return &emc->emc_table[i]; + +return NULL ; +} + +int emc_wait_for_update (struct tegra_emc *emc,u32 status_reg,u32 bit_mask, +bool updated_state,int chan) +{ +int i, err = -ETIMEDOUT ; +u32 reg; + +for (i =0 ; i <EMC_STATUS_UPDATE_TIMEOUT ; i++) { + reg =emc_readl_per_ch (emc, chan, status_reg); +if (!!(reg & bit_mask) == updated_state) { + err =0 ; + goto done; + } +udelay (1 ); + } + +done: +return err; +} + +void emc_set_shadow_bypass (struct tegra_emc *emc,int set) +{ +u32 emc_dbg =emc_readl (emc,EMC_DBG ); + +if (set) +emc_writel (emc, emc_dbg |EMC_DBG_WRITE_MUX_ACTIVE ,EMC_DBG ); +else +emc_writel (emc, emc_dbg & ~EMC_DBG_WRITE_MUX_ACTIVE ,EMC_DBG ); +} + +u32 emc_get_dll_state (struct emc_table *next_timing) +{ +bool next_dll_enabled; + + next_dll_enabled = !(next_timing->emc_emrs &0x1 ); +if (next_dll_enabled) +return DLL_ON ; +else +return DLL_OFF ; +} + +u32 div_o3 (u32 a,u32 b) +{ +u32 result = a / b; + +if ((b * result) < a) +return result +1 ; +else +return result; +} + +void emc_timing_update (struct tegra_emc *emc,int dual_chan) +{ +int err =0 ; + +emc_writel (emc,0x1 ,EMC_TIMING_CONTROL ); + err |=emc_wait_for_update (emc,EMC_EMC_STATUS , +EMC_EMC_STATUS_TIMING_UPDATE_STALLED , + false,REG_EMC ); +if (dual_chan) + err |=emc_wait_for_update (emc,EMC_EMC_STATUS , +EMC_EMC_STATUS_TIMING_UPDATE_STALLED , + false,REG_EMC1 ); +if (err) +pr_warn ("%s: timing update error: %d" , __func__, err); +} + +u32 tegra210_actual_osc_clocks (u32 in) +{ +if (in <0x40 ) +return in *16 ; +else if (in <0x80 ) +return 2048 ; +else if (in <0xc0 ) +return 4096 ; +else +return 8192 ; +} + +void tegra210_start_periodic_compensation (struct tegra_emc *emc) +{ +u32 mpc_req =0x4b ; + +emc_writel (emc, mpc_req,EMC_MPC ); + mpc_req =emc_readl (emc,EMC_MPC ); +} + +u32 tegra210_apply_periodic_compensation_trimmer (struct emc_table *next_timing, +u32 offset) +{ +u32 i, temp =0 ; +u32 next_timing_rate_mhz = next_timing->rate /1000 ; +s32 tree_delta[4 ]; +s32 tree_delta_taps[4 ]; +s32 new[] = { +TRIM_REG (0 ,0 ,0 ,0 ), +TRIM_REG (0 ,0 ,0 ,1 ), +TRIM_REG (0 ,0 ,1 ,2 ), +TRIM_REG (0 ,0 ,1 ,3 ), + +TRIM_REG (1 ,0 ,2 ,4 ), +TRIM_REG (1 ,0 ,2 ,5 ), +TRIM_REG (1 ,0 ,3 ,6 ), +TRIM_REG (1 ,0 ,3 ,7 ), + +TRIM_REG (0 ,1 ,0 ,0 ), +TRIM_REG (0 ,1 ,0 ,1 ), +TRIM_REG (0 ,1 ,1 ,2 ), +TRIM_REG (0 ,1 ,1 ,3 ), + +TRIM_REG (1 ,1 ,2 ,4 ), +TRIM_REG (1 ,1 ,2 ,5 ), +TRIM_REG (1 ,1 ,3 ,6 ), +TRIM_REG (1 ,1 ,3 ,7 ) + }; + +switch (offset) { +case EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_0 : +case EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_1 : +case EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_2 : +case EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_3 : +case EMC_DATA_BRLSHFT_0 : + tree_delta[0 ] =128 * + (next_timing->current_dram_clktree[C0D0U0 ] - + next_timing->trained_dram_clktree[C0D0U0 ]); + tree_delta[1 ] =128 * + (next_timing->current_dram_clktree[C0D0U1 ] - + next_timing->trained_dram_clktree[C0D0U1 ]); + tree_delta[2 ] =128 * + (next_timing->current_dram_clktree[C1D0U0 ] - + next_timing->trained_dram_clktree[C1D0U0 ]); + tree_delta[3 ] =128 * + (next_timing->current_dram_clktree[C1D0U1 ] - + next_timing->trained_dram_clktree[C1D0U1 ]); + + tree_delta_taps[0 ] = (tree_delta[0 ] * + (s32 )next_timing_rate_mhz) /1000000 ; + tree_delta_taps[1 ] = (tree_delta[1 ] * + (s32 )next_timing_rate_mhz) /1000000 ; + tree_delta_taps[2 ] = (tree_delta[2 ] * + (s32 )next_timing_rate_mhz) /1000000 ; + tree_delta_taps[3 ] = (tree_delta[3 ] * + (s32 )next_timing_rate_mhz) /1000000 ; + +for (i =0 ; i <4 ; i++) { +if ((tree_delta_taps[i] > next_timing->tree_margin) || + (tree_delta_taps[i] < + (-1 * next_timing->tree_margin))) { + new[i *2 ] = new[i *2 ] + tree_delta_taps[i]; + new[i *2 +1 ] = new[i *2 +1 ] + + tree_delta_taps[i]; + } + } + +if (offset ==EMC_DATA_BRLSHFT_0 ) { +for (i =0 ; i <8 ; i++) + new[i] = new[i] /64 ; + }else { +for (i =0 ; i <8 ; i++) + new[i] = new[i] %64 ; + } +break ; + +case EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_0 : +case EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_1 : +case EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_2 : +case EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_3 : +case EMC_DATA_BRLSHFT_1 : + tree_delta[0 ] =128 * + (next_timing->current_dram_clktree[C0D1U0 ] - + next_timing->trained_dram_clktree[C0D1U0 ]); + tree_delta[1 ] =128 * + (next_timing->current_dram_clktree[C0D1U1 ] - + next_timing->trained_dram_clktree[C0D1U1 ]); + tree_delta[2 ] =128 * + (next_timing->current_dram_clktree[C1D1U0 ] - + next_timing->trained_dram_clktree[C1D1U0 ]); + tree_delta[3 ] =128 * + (next_timing->current_dram_clktree[C1D1U1 ] - + next_timing->trained_dram_clktree[C1D1U1 ]); + + tree_delta_taps[0 ] = (tree_delta[0 ] * + (s32 )next_timing_rate_mhz) /1000000 ; + tree_delta_taps[1 ] = (tree_delta[1 ] * + (s32 )next_timing_rate_mhz) /1000000 ; + tree_delta_taps[2 ] = (tree_delta[2 ] * + (s32 )next_timing_rate_mhz) /1000000 ; + tree_delta_taps[3 ] = (tree_delta[3 ] * + (s32 )next_timing_rate_mhz) /1000000 ; + +for (i =0 ; i <4 ; i++) { +if ((tree_delta_taps[i] > next_timing->tree_margin) || + (tree_delta_taps[i] < + (-1 * next_timing->tree_margin))) { + new[8 + i *2 ] = new[8 + i *2 ] + + tree_delta_taps[i]; + new[8 + i *2 +1 ] = new[8 + i *2 +1 ] + + tree_delta_taps[i]; + } + } + +if (offset ==EMC_DATA_BRLSHFT_1 ) { +for (i =0 ; i <8 ; i++) + new[i +8 ] = new[i +8 ] /64 ; + }else { +for (i =0 ; i <8 ; i++) + new[i +8 ] = new[i +8 ] %64 ; + } +break ; + } + +switch (offset) { +case EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_0 : + temp =CALC_TEMP (0 ,0 ,0 ,1 ,0 ); +break ; +case EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_1 : + temp =CALC_TEMP (0 ,1 ,2 ,3 ,2 ); +break ; +case EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_2 : + temp =CALC_TEMP (0 ,2 ,4 ,5 ,4 ); +break ; +case EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_3 : + temp =CALC_TEMP (0 ,3 ,6 ,7 ,6 ); +break ; +case EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_0 : + temp =CALC_TEMP (1 ,0 ,0 ,1 ,8 ); +break ; +case EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_1 : + temp =CALC_TEMP (1 ,1 ,2 ,3 ,10 ); +break ; +case EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_2 : + temp =CALC_TEMP (1 ,2 ,4 ,5 ,12 ); +break ; +case EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_3 : + temp =CALC_TEMP (1 ,3 ,6 ,7 ,14 ); +break ; +case EMC_DATA_BRLSHFT_0 : + temp = ((new[0 ] << +EMC_DATA_BRLSHFT_0_RANK0_BYTE0_DATA_BRLSHFT_SHIFT ) & +EMC_DATA_BRLSHFT_0_RANK0_BYTE0_DATA_BRLSHFT_MASK ) | + ((new[1 ] << +EMC_DATA_BRLSHFT_0_RANK0_BYTE1_DATA_BRLSHFT_SHIFT ) & +EMC_DATA_BRLSHFT_0_RANK0_BYTE1_DATA_BRLSHFT_MASK ) | + ((new[2 ] << +EMC_DATA_BRLSHFT_0_RANK0_BYTE2_DATA_BRLSHFT_SHIFT ) & +EMC_DATA_BRLSHFT_0_RANK0_BYTE2_DATA_BRLSHFT_MASK ) | + ((new[3 ] << +EMC_DATA_BRLSHFT_0_RANK0_BYTE3_DATA_BRLSHFT_SHIFT ) & +EMC_DATA_BRLSHFT_0_RANK0_BYTE3_DATA_BRLSHFT_MASK ) | + ((new[4 ] << +EMC_DATA_BRLSHFT_0_RANK0_BYTE4_DATA_BRLSHFT_SHIFT ) & +EMC_DATA_BRLSHFT_0_RANK0_BYTE4_DATA_BRLSHFT_MASK ) | + ((new[5 ] << +EMC_DATA_BRLSHFT_0_RANK0_BYTE5_DATA_BRLSHFT_SHIFT ) & +EMC_DATA_BRLSHFT_0_RANK0_BYTE5_DATA_BRLSHFT_MASK ) | + ((new[6 ] << +EMC_DATA_BRLSHFT_0_RANK0_BYTE6_DATA_BRLSHFT_SHIFT ) & +EMC_DATA_BRLSHFT_0_RANK0_BYTE6_DATA_BRLSHFT_MASK ) | + ((new[7 ] << +EMC_DATA_BRLSHFT_0_RANK0_BYTE7_DATA_BRLSHFT_SHIFT ) & +EMC_DATA_BRLSHFT_0_RANK0_BYTE7_DATA_BRLSHFT_MASK ); +break ; +case EMC_DATA_BRLSHFT_1 : + temp = ((new[8 ] << +EMC_DATA_BRLSHFT_1_RANK1_BYTE0_DATA_BRLSHFT_SHIFT ) & +EMC_DATA_BRLSHFT_1_RANK1_BYTE0_DATA_BRLSHFT_MASK ) | + ((new[9 ] << +EMC_DATA_BRLSHFT_1_RANK1_BYTE1_DATA_BRLSHFT_SHIFT ) & +EMC_DATA_BRLSHFT_1_RANK1_BYTE1_DATA_BRLSHFT_MASK ) | + ((new[10 ] << +EMC_DATA_BRLSHFT_1_RANK1_BYTE2_DATA_BRLSHFT_SHIFT ) & +EMC_DATA_BRLSHFT_1_RANK1_BYTE2_DATA_BRLSHFT_MASK ) | + ((new[11 ] << +EMC_DATA_BRLSHFT_1_RANK1_BYTE3_DATA_BRLSHFT_SHIFT ) & +EMC_DATA_BRLSHFT_1_RANK1_BYTE3_DATA_BRLSHFT_MASK ) | + ((new[12 ] << +EMC_DATA_BRLSHFT_1_RANK1_BYTE4_DATA_BRLSHFT_SHIFT ) & +EMC_DATA_BRLSHFT_1_RANK1_BYTE4_DATA_BRLSHFT_MASK ) | + ((new[13 ] << +EMC_DATA_BRLSHFT_1_RANK1_BYTE5_DATA_BRLSHFT_SHIFT ) & +EMC_DATA_BRLSHFT_1_RANK1_BYTE5_DATA_BRLSHFT_MASK ) | + ((new[14 ] << +EMC_DATA_BRLSHFT_1_RANK1_BYTE6_DATA_BRLSHFT_SHIFT ) & +EMC_DATA_BRLSHFT_1_RANK1_BYTE6_DATA_BRLSHFT_MASK ) | + ((new[15 ] << +EMC_DATA_BRLSHFT_1_RANK1_BYTE7_DATA_BRLSHFT_SHIFT ) & +EMC_DATA_BRLSHFT_1_RANK1_BYTE7_DATA_BRLSHFT_MASK ); +break ; +default : +break ; + } + +return temp; +} + +u32 tegra210_dll_prelock (struct tegra_emc *emc,int dvfs_with_training, +u32 clksrc) +{ +u32 emc_dig_dll_status; +u32 dll_locked; +u32 dll_out; +u32 emc_cfg_dig_dll; +u32 emc_dll_cfg_0; +u32 emc_dll_cfg_1; +u32 ddllcal_ctrl_start_trim_val; +u32 dll_en; +u32 dual_channel_lpddr4_case; +u32 dll_priv_updated; + + dual_channel_lpddr4_case = + !!(emc_readl (emc,EMC_FBIO_CFG7 ) &EMC_FBIO_CFG7_CH1_ENABLE ) & + !!(emc_readl (emc,EMC_FBIO_CFG7 ) &EMC_FBIO_CFG7_CH0_ENABLE ); + + emc_dig_dll_status =0 ; + dll_locked =0 ; + dll_out =0 ; + emc_cfg_dig_dll =0 ; + emc_dll_cfg_0 =0 ; + emc_dll_cfg_1 =0 ; + ddllcal_ctrl_start_trim_val =0 ; + dll_en =0 ; + + emc_cfg_dig_dll =emc_readl (emc,EMC_CFG_DIG_DLL ) & + ~EMC_CFG_DIG_DLL_CFG_DLL_LOCK_LIMIT_MASK ; + emc_cfg_dig_dll |= (3 <<EMC_CFG_DIG_DLL_CFG_DLL_LOCK_LIMIT_SHIFT ); + emc_cfg_dig_dll &= ~EMC_CFG_DIG_DLL_CFG_DLL_EN ; + emc_cfg_dig_dll &= ~EMC_CFG_DIG_DLL_CFG_DLL_MODE_MASK ; + emc_cfg_dig_dll |= (3 <<EMC_CFG_DIG_DLL_CFG_DLL_MODE_SHIFT ); + emc_cfg_dig_dll |=EMC_CFG_DIG_DLL_CFG_DLL_STALL_ALL_TRAFFIC ; + emc_cfg_dig_dll &= ~EMC_CFG_DIG_DLL_CFG_DLL_STALL_RW_UNTIL_LOCK ; + emc_cfg_dig_dll &= ~EMC_CFG_DIG_DLL_CFG_DLL_STALL_ALL_UNTIL_LOCK ; + +emc_writel (emc, emc_cfg_dig_dll,EMC_CFG_DIG_DLL ); +emc_writel (emc,1 ,EMC_TIMING_CONTROL ); + +emc_wait_for_update (emc,EMC_EMC_STATUS , +EMC_EMC_STATUS_TIMING_UPDATE_STALLED , +0 ,REG_EMC ); +if (dual_channel_lpddr4_case) +emc_wait_for_update (emc,EMC_EMC_STATUS , +EMC_EMC_STATUS_TIMING_UPDATE_STALLED , +0 ,REG_EMC1 ); + +do { + emc_cfg_dig_dll =emc_readl (emc,EMC_CFG_DIG_DLL ); + dll_en = emc_cfg_dig_dll &EMC_CFG_DIG_DLL_CFG_DLL_EN ; + }while (dll_en ==1 ); + +if (dual_channel_lpddr4_case) { +do { + emc_cfg_dig_dll =emc1_readl (emc,EMC_CFG_DIG_DLL ); + dll_en = emc_cfg_dig_dll &EMC_CFG_DIG_DLL_CFG_DLL_EN ; + }while (dll_en ==1 ); + } + + emc_dll_cfg_0 = emc->next_timing->burst_regs[EMC_DLL_CFG_0_INDEX ]; + +emc_writel (emc, emc_dll_cfg_0,EMC_DLL_CFG_0 ); + +if (emc->next_timing->rate >=400000 + && emc->next_timing->rate <600000 ) + ddllcal_ctrl_start_trim_val =150 ; +else if (emc->next_timing->rate >=600000 + && emc->next_timing->rate <800000 ) + ddllcal_ctrl_start_trim_val =100 ; +else if (emc->next_timing->rate >=800000 + && emc->next_timing->rate <1000000 ) + ddllcal_ctrl_start_trim_val =70 ; +else if (emc->next_timing->rate >=1000000 + && emc->next_timing->rate <1200000 ) + ddllcal_ctrl_start_trim_val =30 ; +else + ddllcal_ctrl_start_trim_val =20 ; + + emc_dll_cfg_1 =emc_readl (emc,EMC_DLL_CFG_1 ); + emc_dll_cfg_1 &=EMC_DLL_CFG_1_DDLLCAL_CTRL_START_TRIM_MASK ; + emc_dll_cfg_1 |= ddllcal_ctrl_start_trim_val; +emc_writel (emc, emc_dll_cfg_1,EMC_DLL_CFG_1 ); + +tegra210_change_dll_src (emc, clksrc); + + emc_cfg_dig_dll =emc_readl (emc,EMC_CFG_DIG_DLL ); + emc_cfg_dig_dll |=EMC_CFG_DIG_DLL_CFG_DLL_EN ; +emc_writel (emc, emc_cfg_dig_dll,EMC_CFG_DIG_DLL ); + +emc_timing_update (emc, dual_channel_lpddr4_case ? +DUAL_CHANNEL :SINGLE_CHANNEL ); + +do { + emc_cfg_dig_dll =emc_readl (emc,EMC_CFG_DIG_DLL ); + dll_en = emc_cfg_dig_dll &EMC_CFG_DIG_DLL_CFG_DLL_EN ; + }while (dll_en ==0 ); + +if (dual_channel_lpddr4_case) { +do { + emc_cfg_dig_dll =emc1_readl (emc,EMC_CFG_DIG_DLL ); + dll_en = emc_cfg_dig_dll &EMC_CFG_DIG_DLL_CFG_DLL_EN ; + }while (dll_en ==0 ); + } + +do { + emc_dig_dll_status =emc_readl (emc,EMC_DIG_DLL_STATUS ); + dll_locked = emc_dig_dll_status &EMC_DIG_DLL_STATUS_DLL_LOCK ; + dll_priv_updated = emc_dig_dll_status & +EMC_DIG_DLL_STATUS_DLL_PRIV_UPDATED ; + }while (!dll_locked || !dll_priv_updated); + + emc_dig_dll_status =emc_readl (emc,EMC_DIG_DLL_STATUS ); +return emc_dig_dll_status &EMC_DIG_DLL_STATUS_DLL_OUT_MASK ; +} + +u32 tegra210_dvfs_power_ramp_up (struct tegra_emc *emc,u32 clk, +int flip_backward) +{ +u32 pmacro_cmd_pad; +u32 pmacro_dq_pad; +u32 pmacro_rfu1; +u32 pmacro_cfg5; +u32 pmacro_common_tx; +u32 ramp_up_wait =0 ; + +if (flip_backward) { + pmacro_cmd_pad = emc->current_timing->burst_regs[ +EMC_PMACRO_CMD_PAD_TX_CTRL_INDEX ]; + pmacro_dq_pad = emc->current_timing->burst_regs[ +EMC_PMACRO_DATA_PAD_TX_CTRL_INDEX ]; + pmacro_rfu1 = emc->current_timing->burst_regs[ +EMC_PMACRO_BRICK_CTRL_RFU1_INDEX ]; + pmacro_cfg5 = emc->current_timing->burst_regs[ +EMC_FBIO_CFG5_INDEX ]; + pmacro_common_tx = emc->current_timing->burst_regs[ +EMC_PMACRO_COMMON_PAD_TX_CTRL_INDEX ]; + }else { + pmacro_cmd_pad = emc->next_timing->burst_regs[ +EMC_PMACRO_CMD_PAD_TX_CTRL_INDEX ]; + pmacro_dq_pad = emc->next_timing->burst_regs[ +EMC_PMACRO_DATA_PAD_TX_CTRL_INDEX ]; + pmacro_rfu1 = emc->next_timing->burst_regs[ +EMC_PMACRO_BRICK_CTRL_RFU1_INDEX ]; + pmacro_cfg5 = emc->next_timing->burst_regs[ +EMC_FBIO_CFG5_INDEX ]; + pmacro_common_tx = emc->next_timing->burst_regs[ +EMC_PMACRO_COMMON_PAD_TX_CTRL_INDEX ]; + } + pmacro_cmd_pad |=EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQ_TX_DRVFORCEON ; + +if (clk <1000000 /DVFS_FGCG_MID_SPEED_THRESHOLD ) { +ccfifo_writel (emc, pmacro_common_tx &0xa , +EMC_PMACRO_COMMON_PAD_TX_CTRL ,0 ); +ccfifo_writel (emc, pmacro_common_tx &0xf , +EMC_PMACRO_COMMON_PAD_TX_CTRL , + (100000 / clk) +1 ); + ramp_up_wait +=100000 ; + }else { +ccfifo_writel (emc, pmacro_common_tx |0x8 , +EMC_PMACRO_COMMON_PAD_TX_CTRL ,0 ); + } + +if (clk <1000000 /DVFS_FGCG_HIGH_SPEED_THRESHOLD ) { +if (clk <1000000 /IOBRICK_DCC_THRESHOLD ) { + pmacro_cmd_pad |= +EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQSP_TX_E_DCC | +EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQSN_TX_E_DCC ; + pmacro_cmd_pad &= + ~(EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQ_TX_E_DCC | +EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_CMD_TX_E_DCC ); +ccfifo_writel (emc, pmacro_cmd_pad, +EMC_PMACRO_CMD_PAD_TX_CTRL , + (100000 / clk) +1 ); + ramp_up_wait +=100000 ; + + pmacro_dq_pad |= +EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQSP_TX_E_DCC | +EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQSN_TX_E_DCC ; + pmacro_dq_pad &= + ~(EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQ_TX_E_DCC | +EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_CMD_TX_E_DCC ); +ccfifo_writel (emc, pmacro_dq_pad, +EMC_PMACRO_DATA_PAD_TX_CTRL ,0 ); +ccfifo_writel (emc, pmacro_rfu1 &0xfe40fe40 , +EMC_PMACRO_BRICK_CTRL_RFU1 ,0 ); + }else { +ccfifo_writel (emc, pmacro_rfu1 &0xfe40fe40 , +EMC_PMACRO_BRICK_CTRL_RFU1 , + (100000 / clk) +1 ); + ramp_up_wait +=100000 ; + } + +ccfifo_writel (emc, pmacro_rfu1 &0xfeedfeed , +EMC_PMACRO_BRICK_CTRL_RFU1 , (100000 / clk) +1 ); + ramp_up_wait +=100000 ; + +if (clk <1000000 /IOBRICK_DCC_THRESHOLD ) { + pmacro_cmd_pad |= +EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQSP_TX_E_DCC | +EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQSN_TX_E_DCC | +EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQ_TX_E_DCC | +EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_CMD_TX_E_DCC ; +ccfifo_writel (emc, pmacro_cmd_pad, +EMC_PMACRO_CMD_PAD_TX_CTRL , + (100000 / clk) +1 ); + ramp_up_wait +=100000 ; + + pmacro_dq_pad |= +EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQSP_TX_E_DCC | +EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQSN_TX_E_DCC | +EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQ_TX_E_DCC | +EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_CMD_TX_E_DCC ; +ccfifo_writel (emc, pmacro_dq_pad, +EMC_PMACRO_DATA_PAD_TX_CTRL ,0 ); +ccfifo_writel (emc, pmacro_rfu1, +EMC_PMACRO_BRICK_CTRL_RFU1 ,0 ); + }else { +ccfifo_writel (emc, pmacro_rfu1, +EMC_PMACRO_BRICK_CTRL_RFU1 , + (100000 / clk) +1 ); + ramp_up_wait +=100000 ; + } + +ccfifo_writel (emc, pmacro_cfg5 & ~EMC_FBIO_CFG5_CMD_TX_DIS , +EMC_FBIO_CFG5 , (100000 / clk) +10 ); + ramp_up_wait +=100000 + (10 * clk); + }else if (clk <1000000 /DVFS_FGCG_MID_SPEED_THRESHOLD ) { +ccfifo_writel (emc, pmacro_rfu1 |0x06000600 , +EMC_PMACRO_BRICK_CTRL_RFU1 , (100000 / clk) +1 ); +ccfifo_writel (emc, pmacro_cfg5 & ~EMC_FBIO_CFG5_CMD_TX_DIS , +EMC_FBIO_CFG5 , (100000 / clk) +10 ); + ramp_up_wait +=100000 +10 * clk; + }else { +ccfifo_writel (emc, pmacro_rfu1 |0x00000600 , +EMC_PMACRO_BRICK_CTRL_RFU1 ,0 ); +ccfifo_writel (emc, pmacro_cfg5 & ~EMC_FBIO_CFG5_CMD_TX_DIS , +EMC_FBIO_CFG5 ,12 ); + ramp_up_wait +=12 * clk; + } + + pmacro_cmd_pad &= ~EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQ_TX_DRVFORCEON ; +ccfifo_writel (emc, pmacro_cmd_pad,EMC_PMACRO_CMD_PAD_TX_CTRL ,5 ); + +return ramp_up_wait; +} + +u32 tegra210_dvfs_power_ramp_down (struct tegra_emc *emc,u32 clk, +int flip_backward) +{ +u32 ramp_down_wait =0 ; +u32 pmacro_cmd_pad; +u32 pmacro_dq_pad; +u32 pmacro_rfu1; +u32 pmacro_cfg5; +u32 pmacro_common_tx; +u32 seq_wait; + +if (flip_backward) { + pmacro_cmd_pad = emc->next_timing->burst_regs[ +EMC_PMACRO_CMD_PAD_TX_CTRL_INDEX ]; + pmacro_dq_pad = emc->next_timing->burst_regs[ +EMC_PMACRO_DATA_PAD_TX_CTRL_INDEX ]; + pmacro_rfu1 = emc->next_timing->burst_regs[ +EMC_PMACRO_BRICK_CTRL_RFU1_INDEX ]; + pmacro_cfg5 = emc->next_timing->burst_regs[ +EMC_FBIO_CFG5_INDEX ]; + pmacro_common_tx = emc->next_timing->burst_regs[ +EMC_PMACRO_COMMON_PAD_TX_CTRL_INDEX ]; + }else { + pmacro_cmd_pad = emc->current_timing->burst_regs[ +EMC_PMACRO_CMD_PAD_TX_CTRL_INDEX ]; + pmacro_dq_pad = emc->current_timing->burst_regs[ +EMC_PMACRO_DATA_PAD_TX_CTRL_INDEX ]; + pmacro_rfu1 = emc->current_timing->burst_regs[ +EMC_PMACRO_BRICK_CTRL_RFU1_INDEX ]; + pmacro_cfg5 = emc->current_timing->burst_regs[ +EMC_FBIO_CFG5_INDEX ]; + pmacro_common_tx = emc->current_timing->burst_regs[ +EMC_PMACRO_COMMON_PAD_TX_CTRL_INDEX ]; + } + + pmacro_cmd_pad |=EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQ_TX_DRVFORCEON ; + +ccfifo_writel (emc, pmacro_cmd_pad,EMC_PMACRO_CMD_PAD_TX_CTRL ,0 ); +ccfifo_writel (emc, pmacro_cfg5 |EMC_FBIO_CFG5_CMD_TX_DIS , +EMC_FBIO_CFG5 ,12 ); + ramp_down_wait =12 * clk; + + seq_wait = (100000 / clk) +1 ; + +if (clk < (1000000 /DVFS_FGCG_HIGH_SPEED_THRESHOLD )) { +if (clk < (1000000 /IOBRICK_DCC_THRESHOLD )) { + pmacro_cmd_pad &= + ~(EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQ_TX_E_DCC | +EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_CMD_TX_E_DCC ); + pmacro_cmd_pad |= +EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQSP_TX_E_DCC | +EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQSN_TX_E_DCC ; +ccfifo_writel (emc, pmacro_cmd_pad, +EMC_PMACRO_CMD_PAD_TX_CTRL , seq_wait); + ramp_down_wait +=100000 ; + + pmacro_dq_pad &= + ~(EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQ_TX_E_DCC | +EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_CMD_TX_E_DCC ); + pmacro_dq_pad |= +EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQSP_TX_E_DCC | +EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQSN_TX_E_DCC ; +ccfifo_writel (emc, pmacro_dq_pad, +EMC_PMACRO_DATA_PAD_TX_CTRL ,0 ); +ccfifo_writel (emc, pmacro_rfu1 & ~0x01120112 , +EMC_PMACRO_BRICK_CTRL_RFU1 ,0 ); + }else { +ccfifo_writel (emc, pmacro_rfu1 & ~0x01120112 , +EMC_PMACRO_BRICK_CTRL_RFU1 , seq_wait); + ramp_down_wait +=100000 ; + } + +ccfifo_writel (emc, pmacro_rfu1 & ~0x01bf01bf , +EMC_PMACRO_BRICK_CTRL_RFU1 , seq_wait); + ramp_down_wait +=100000 ; + +if (clk < (1000000 /IOBRICK_DCC_THRESHOLD )) { + pmacro_cmd_pad &= + ~(EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQ_TX_E_DCC | +EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_CMD_TX_E_DCC | +EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQSP_TX_E_DCC | +EMC_PMACRO_CMD_PAD_TX_CTRL_CMD_DQSN_TX_E_DCC ); +ccfifo_writel (emc, pmacro_cmd_pad, +EMC_PMACRO_CMD_PAD_TX_CTRL , seq_wait); + ramp_down_wait +=100000 ; + + pmacro_dq_pad &= + ~(EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQ_TX_E_DCC | +EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_CMD_TX_E_DCC | +EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQSP_TX_E_DCC | +EMC_PMACRO_DATA_PAD_TX_CTRL_DATA_DQSN_TX_E_DCC ); +ccfifo_writel (emc, pmacro_dq_pad, +EMC_PMACRO_DATA_PAD_TX_CTRL ,0 ); +ccfifo_writel (emc, pmacro_rfu1 & ~0x07ff07ff , +EMC_PMACRO_BRICK_CTRL_RFU1 ,0 ); + }else { +ccfifo_writel (emc, pmacro_rfu1 & ~0x07ff07ff , +EMC_PMACRO_BRICK_CTRL_RFU1 , seq_wait); + ramp_down_wait +=100000 ; + } + }else { +ccfifo_writel (emc, pmacro_rfu1 & ~0xffff07ff , +EMC_PMACRO_BRICK_CTRL_RFU1 , seq_wait +19 ); + ramp_down_wait +=100000 + (20 * clk); + } + +if (clk < (1000000 /DVFS_FGCG_MID_SPEED_THRESHOLD )) { + ramp_down_wait +=100000 ; +ccfifo_writel (emc, pmacro_common_tx & ~0x5 , +EMC_PMACRO_COMMON_PAD_TX_CTRL , seq_wait); + ramp_down_wait +=100000 ; +ccfifo_writel (emc, pmacro_common_tx & ~0xf , +EMC_PMACRO_COMMON_PAD_TX_CTRL , seq_wait); + ramp_down_wait +=100000 ; +ccfifo_writel (emc,0 ,0 , seq_wait); + ramp_down_wait +=100000 ; + }else { +ccfifo_writel (emc, pmacro_common_tx & ~0xf , +EMC_PMACRO_COMMON_PAD_TX_CTRL , seq_wait); + } + +return ramp_down_wait; +} + +void tegra210_reset_dram_clktree_values (struct emc_table *table) +{ + table->current_dram_clktree[C0D0U0 ] = + table->trained_dram_clktree[C0D0U0 ]; + table->current_dram_clktree[C0D0U1 ] = + table->trained_dram_clktree[C0D0U1 ]; + table->current_dram_clktree[C1D0U0 ] = + table->trained_dram_clktree[C1D0U0 ]; + table->current_dram_clktree[C1D0U1 ] = + table->trained_dram_clktree[C1D0U1 ]; + table->current_dram_clktree[C1D1U0 ] = + table->trained_dram_clktree[C1D1U0 ]; + table->current_dram_clktree[C1D1U1 ] = + table->trained_dram_clktree[C1D1U1 ]; +} + +static void update_dll_control (struct tegra_emc *emc,u32 emc_cfg_dig_dll, +int channel_mode,bool updated_state) +{ +emc_writel (emc, emc_cfg_dig_dll,EMC_CFG_DIG_DLL ); +emc_timing_update (emc, channel_mode); + +emc_wait_for_update (emc,EMC_CFG_DIG_DLL ,EMC_CFG_DIG_DLL_CFG_DLL_EN , + updated_state,REG_EMC ); +if (channel_mode ==DUAL_CHANNEL ) +emc_wait_for_update (emc,EMC_CFG_DIG_DLL , +EMC_CFG_DIG_DLL_CFG_DLL_EN , + updated_state,REG_EMC1 ); +} + +void tegra210_dll_disable (struct tegra_emc *emc,int channel_mode) +{ +u32 emc_cfg_dig_dll; + + emc_cfg_dig_dll =emc_readl (emc,EMC_CFG_DIG_DLL ); + emc_cfg_dig_dll &= ~EMC_CFG_DIG_DLL_CFG_DLL_EN ; + +update_dll_control (emc, emc_cfg_dig_dll, channel_mode, false); +} + +void tegra210_dll_enable (struct tegra_emc *emc,int channel_mode) +{ +u32 emc_cfg_dig_dll; + + emc_cfg_dig_dll =emc_readl (emc,EMC_CFG_DIG_DLL ); + emc_cfg_dig_dll |=EMC_CFG_DIG_DLL_CFG_DLL_EN ; + +update_dll_control (emc, emc_cfg_dig_dll, channel_mode, true); +} + +void emc_set_over_temp_timing (struct tegra_emc *emc,struct emc_table *timing, +unsigned long state) +{ +#define REFRESH_X2 1 +#define REFRESH_X4 2 +#define REFRESH_SPEEDUP (val, speedup) \ + (val = ((val) & 0xFFFF0000) | (((val) & 0xFFFF) >> (speedup))) + +u32 ref = timing->burst_regs[EMC_REFRESH_INDEX ]; +u32 pre_ref = timing->burst_regs[EMC_PRE_REFRESH_REQ_CNT_INDEX ]; +u32 dsr_cntrl = timing->burst_regs[EMC_DYN_SELF_REF_CONTROL_INDEX ]; + +switch (state) { +case TEGRA_DRAM_OVER_TEMP_NONE : +case TEGRA_DRAM_OVER_TEMP_THROTTLE : +break ; +case TEGRA_DRAM_OVER_TEMP_REFRESH_X2 : +REFRESH_SPEEDUP (ref,REFRESH_X2 ); +REFRESH_SPEEDUP (pre_ref,REFRESH_X2 ); +REFRESH_SPEEDUP (dsr_cntrl,REFRESH_X2 ); +break ; +case TEGRA_DRAM_OVER_TEMP_REFRESH_X4 : +REFRESH_SPEEDUP (ref,REFRESH_X4 ); +REFRESH_SPEEDUP (pre_ref,REFRESH_X4 ); +REFRESH_SPEEDUP (dsr_cntrl,REFRESH_X4 ); +break ; +default : +pr_warn ("%s: Failed to set dram over temp state %lu\n" , + __func__, state); +return ; + } + +emc_writel (emc, ref, reg_off.burst_regs_off[EMC_REFRESH_INDEX ]); +emc_writel (emc, pre_ref, + reg_off.burst_regs_off[EMC_PRE_REFRESH_REQ_CNT_INDEX ]); +emc_writel (emc, dsr_cntrl, + reg_off.burst_regs_off[EMC_DYN_SELF_REF_CONTROL_INDEX ]); +} +static int emc_table_lookup (struct tegra_emc *emc,unsigned long rate) {int i;
drivers/memory/tegra/tegra210-emc.h +718 -0
738 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v4 6/8 memory: tegra: Add EMC scaling sequence code for Tegra210
In reply to Joseph LoThis patch includes the sequence for clock tuning and the dynamic training mechanism for the clock above 800MHz.
And historically there have been different sequences to change the EMC clock. The sequence to be used is specified in the EMC table. However, for the currently supported upstreaming platform, only the most recent sequence is used. So only support that in this patch.
Based on the work of Peter De Schrijver <[email protected]>.
---
v4:
- no change
--- drivers/memory/tegra/Makefile | 2 +- drivers/memory/tegra/tegra210-emc-cc-r21021.c | 1953 +++++++++++++++++ drivers/memory/tegra/tegra210-emc.c | 5 + drivers/memory/tegra/tegra210-emc.h | 157 ++ 4 files changed, 2116 insertions(+), 1 deletion(-) create mode 100644 drivers/memory/tegra/tegra210-emc-cc-r21021.c
drivers/memory/tegra/Makefile +1 -1
@@ -12,5 +12,5 @@ obj-$(CONFIG_TEGRA_MC) += tegra-mc.o obj-$(CONFIG_TEGRA20_EMC) += tegra20-emc.o obj-$(CONFIG_TEGRA124_EMC) += tegra124-emc.o -obj-$(CONFIG_TEGRA210_EMC) += tegra210-emc.o +obj-$(CONFIG_TEGRA210_EMC) += tegra210-emc.o tegra210-emc-cc-r21021.o obj-$(CONFIG_ARCH_TEGRA_186_SOC) += tegra186.o
drivers/memory/tegra/tegra210-emc-cc-r21021.c new file +1953 -0
1,953 lines not on this page · raw message
drivers/memory/tegra/tegra210-emc.c +5 -0
@@ -126,6 +126,11 @@ static const char *emc_src_names[TEGRA_EMC_SRC_COUNT] = { };static const struct supported_sequence supported_seqs[] = { + { +0x7 , + emc_set_clock_r21021, + __do_periodic_emc_compensation_r21021, + }, {0 ,NULL ,
drivers/memory/tegra/tegra210-emc.h +157 -0
292 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v4 7/8 clk: tegra: Remove the old emc_mux clock for Tegra210
In reply to Joseph LoRemove the old emc_mux clock and don't use the common EMC clock definition. This will be replaced by a new clock defined in the EMC driver.
---
v4:
- make sure the behavior is compatible with case if the kernel still uses the older DTB which doesn't have EMC node. And the MC and EMC clock can still be registered successuflly.
v3:
- split to 3 patches from the previous version
--- drivers/clk/tegra/clk-tegra210.c | 42 ++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 15 deletions(-)
drivers/clk/tegra/clk-tegra210.c +27 -15
@@ -28,6 +28,7 @@#include <dt-bindings/reset/tegra210-car.h> #include <linux/iopoll.h> #include <linux/sizes.h> +#include <soc/tegra/emc.h> #include <soc/tegra/pmc.h> #include "clk.h"
@@ -324,12 +325,6 @@ static unsigned long tegra210_input_freq[] = { [8] = 12000000, }; -static const char *mux_pllmcp_clkm[] = { -"pll_m" ,"pll_c" ,"pll_p" ,"clk_m" ,"pll_m_ud" ,"pll_mb" ,"pll_mb" , -"pll_p" , -}; -#define mux_pllmcp_clkm_idx NULL -#define PLL_ENABLE (1 << 30)#define PLLCX_MISC1_IDDQ (1 << 27)
@@ -2346,7 +2341,6 @@ static struct tegra_clk tegra210_clks[tegra_clk_max] __initdata = { [tegra_clk_i2c2] = { .dt_id = TEGRA210_CLK_I2C2, .present = true }, [tegra_clk_uartc_8] = { .dt_id = TEGRA210_CLK_UARTC, .present = true }, [tegra_clk_mipi_cal] = { .dt_id = TEGRA210_CLK_MIPI_CAL, .present = true }, - [tegra_clk_emc] = { .dt_id = TEGRA210_CLK_EMC, .present = true }, [tegra_clk_usb2] = { .dt_id = TEGRA210_CLK_USB2, .present = true }, [tegra_clk_bsev] = { .dt_id = TEGRA210_CLK_BSEV, .present = true }, [tegra_clk_uartd_8] = { .dt_id = TEGRA210_CLK_UARTD, .present = true },
@@ -2957,6 +2951,27 @@ static int tegra210_init_pllu(void)return 0 ; } +static const struct clk_div_table mc_div_table_tegra210[] = { + { .val =0 , .div =2 }, + { .val =1 , .div =4 }, + { .val =2 , .div =1 }, + { .val =3 , .div =2 }, + { .val =0 , .div =0 }, +}; + +static void tegra210_clk_register_mc (const char *name, +const char *parent_name) +{ +struct clk *clk; + + clk =clk_register_divider_table (NULL , name, parent_name, +CLK_IS_CRITICAL , + clk_base +CLK_SOURCE_EMC , +15 ,2 ,CLK_DIVIDER_READ_ONLY , + mc_div_table_tegra210, &emc_lock); + clks[TEGRA210_CLK_MC ] = clk; +} +static const char *const sor1_out_parents[] = {/* * Bit 0 of the mux selects sor1_pad_clkout, irrespective of bit 1, so
@@ -3040,15 +3055,12 @@ static __init void tegra210_periph_clk_init(void __iomem *clk_base, CLK_SOURCE_LA, 0); clks[TEGRA210_CLK_LA ] = clk; -/* emc mux */ - clk =clk_register_mux (NULL ,"emc_mux" , mux_pllmcp_clkm, -ARRAY_SIZE (mux_pllmcp_clkm),0 , - clk_base +CLK_SOURCE_EMC , -29 ,3 ,0 , &emc_lock); +/* emc */ + clk =tegra210_clk_register_emc (); + clks[TEGRA210_CLK_EMC ] = clk; - clk =tegra_clk_register_mc ("mc" ,"emc_mux" , clk_base +CLK_SOURCE_EMC , - &emc_lock); - clks[TEGRA210_CLK_MC ] = clk; +/* mc */ +tegra210_clk_register_mc ("mc" ,"emc" );/* cml0 */ clk = clk_register_gate(NULL, "cml0", "pll_e", 0, clk_base + PLLE_AUX,
Signature · 1 line
2.21.0
PATCH v4 8/8 arm64: tegra: Add external memory controller node for Tegra210
In reply to Joseph LoAdd external memory controller (EMC) node for Tegra210
---
v4:
- no change.
v3:
- apply memory-region for emc_table. And add reserved-memory node with it.
--- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
arch/arm64/boot/dts/nvidia/tegra210.dtsi +33 -0
@@ -872,6 +872,27 @@ #iommu-cells = <1>; }; + external-memory-controller@7001b000 { + compatible = "nvidia,tegra210-emc"; + reg = <0x0 0x7001b000 0x0 0x1000>, + <0x0 0x7001e000 0x0 0x1000>, + <0x0 0x7001f000 0x0 0x1000>; + clocks = <&tegra_car TEGRA210_CLK_EMC>, + <&tegra_car TEGRA210_CLK_PLL_M>, + <&tegra_car TEGRA210_CLK_PLL_C>, + <&tegra_car TEGRA210_CLK_PLL_P>, + <&tegra_car TEGRA210_CLK_CLK_M>, + <&tegra_car TEGRA210_CLK_PLL_M_UD>, + <&tegra_car TEGRA210_CLK_PLL_MB_UD>, + <&tegra_car TEGRA210_CLK_PLL_MB>, + <&tegra_car TEGRA210_CLK_PLL_P_UD>; + clock-names = "emc", "pll_m", "pll_c", "pll_p", "clk_m", + "pll_m_ud", "pll_mb_ud", "pll_mb", "pll_p_ud"; + interrupts = <GIC_SPI 78 IRQ_TYPE_LEVEL_HIGH>; + memory-region = <&emc_table>; + nvidia,memory-controller = <&mc>; + }; + sata@70020000 { compatible = "nvidia,tegra210-ahci"; reg = <0x0 0x70027000 0x0 0x2000>, /* AHCI */
@@ -1431,6 +1452,18 @@ }; }; + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + emc_table: emc-table@8be00000 { + compatible = "nvidia,tegra210-emc-table"; + reg = <0x0 0x8be00000 0x0 0x10000>; + status = "disabled"; + }; + }; + timer { compatible = "arm,armv8-timer"; interrupts = <GIC_PPI 13
Signature · 1 line
2.21.0
Re: [PATCH V4 7/8] clk: tegra: Remove the old emc_mux clock for Tegra210
In reply to Joseph Lo29.05.2019 11:21, Joseph Lo пишет:
Quoted 61 lines
Remove the old
emc_muxclock and don't use the common EMC clock definition. This will be replaced by a new clock defined in the EMC driver.Signed-off-by Joseph Lo <[email protected]>---
v4:
- make sure the behavior is compatible with case if the kernel still uses the older DTB which doesn't have EMC node. And the MC and EMC clock can still be registered successuflly.
v3:
- split to 3 patches from the previous version--- drivers/clk/tegra/clk-tegra210.c | 42 ++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 15 deletions(-)drivers/clk/tegra/clk-tegra210.c +9
-7@@ -28,6 +28,7 @@#include <dt-bindings/reset/tegra210-car.h> #include <linux/iopoll.h> #include <linux/sizes.h> +#include <soc/tegra/emc.h> #include <soc/tegra/pmc.h> #include "clk.h" @@ -324,12 +325,6 @@ static unsigned long tegra210_input_freq[] = { [8] = 12000000, }; -static const char *mux_pllmcp_clkm[] = { -"pll_m" ,"pll_c" ,"pll_p" ,"clk_m" ,"pll_m_ud" ,"pll_mb" ,"pll_mb" , -"pll_p" , -}; -#define mux_pllmcp_clkm_idx NULL -#define PLL_ENABLE (1 << 30)#define PLLCX_MISC1_IDDQ (1 << 27)@@ -2346,7 +2341,6 @@ static struct tegra_clk tegra210_clks[tegra_clk_max] __initdata = { [tegra_clk_i2c2] = { .dt_id = TEGRA210_CLK_I2C2, .present = true }, [tegra_clk_uartc_8] = { .dt_id = TEGRA210_CLK_UARTC, .present = true }, [tegra_clk_mipi_cal] = { .dt_id = TEGRA210_CLK_MIPI_CAL, .present = true }, - [tegra_clk_emc] = { .dt_id = TEGRA210_CLK_EMC, .present = true }, [tegra_clk_usb2] = { .dt_id = TEGRA210_CLK_USB2, .present = true }, [tegra_clk_bsev] = { .dt_id = TEGRA210_CLK_BSEV, .present = true }, [tegra_clk_uartd_8] = { .dt_id = TEGRA210_CLK_UARTD, .present = true },@@ -2957,6 +2951,27 @@ static int tegra210_init_pllu(void)return 0 ; } +static const struct clk_div_table mc_div_table_tegra210[] = { + { .val =0 , .div =2 }, + { .val =1 , .div =4 }, + { .val =2 , .div =1 }, + { .val =3 , .div =2 }, + { .val =0 , .div =0 }, +}; +
drivers/clk/tegra/clk-tegra210.c static int tegra210_init_pllu(void) · line 2971
Quoted 10 lines
drivers/clk/tegra/clk-tegra210.c +10
-0+static void tegra210_clk_register_mc (const char *name, +const char *parent_name) +{ +struct clk *clk; + + clk =clk_register_divider_table (NULL , name, parent_name, +CLK_IS_CRITICAL , + clk_base +CLK_SOURCE_EMC , +15 ,2 ,CLK_DIVIDER_READ_ONLY , + mc_div_table_tegra210, &emc_lock);
This doesn't look right, you're mixing up the MC divider with the EMC divider here. The MC clock is always sourced from EMC and there is only one bit for the MC divider, the bit 16 MC_EMC_SAME_FREQ.
When EMC clock is divided down by 2 (bit 15 EMC_CLK_DIV2_EN), then the clk-framework will take care of it by calculating the MC rate based on the actual parent EMC rate.
Quoted 18 lines
drivers/clk/tegra/clk-tegra210.c +5
-5+ clks[TEGRA210_CLK_MC ] = clk; +} +static const char *const sor1_out_parents[] = {/* * Bit 0 of the mux selects sor1_pad_clkout, irrespective of bit 1, so @@ -3040,15 +3055,12 @@ static __init void tegra210_periph_clk_init(void __iomem *clk_base, CLK_SOURCE_LA, 0); clks[TEGRA210_CLK_LA ] = clk; -/* emc mux */ - clk =clk_register_mux (NULL ,"emc_mux" , mux_pllmcp_clkm, -ARRAY_SIZE (mux_pllmcp_clkm),0 , - clk_base +CLK_SOURCE_EMC , -29 ,3 ,0 , &emc_lock); +/* emc */ + clk =tegra210_clk_register_emc ();
drivers/clk/tegra/clk-tegra210.c static __init void tegra210_periph_clk_init(void __iomem *clk_base, · line 3066
Quoted 10 lines
drivers/clk/tegra/clk-tegra210.c +3
-3+ clks[TEGRA210_CLK_EMC ] = clk; - clk =tegra_clk_register_mc ("mc" ,"emc_mux" , clk_base +CLK_SOURCE_EMC , - &emc_lock); - clks[TEGRA210_CLK_MC ] = clk; +/* mc */ +tegra210_clk_register_mc ("mc" ,"emc" );/* cml0 */ clk = clk_register_gate(NULL, "cml0", "pll_e", 0, clk_base + PLLE_AUX,
You should leave the common tegra_clk_register_mc() usage as-is and only s/emc_mux/emc/ in the argument.
Signature · 6 lines
Dmitry _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH V4 4/8] memory: tegra: Add Tegra210 EMC clock driver
In reply to Joseph Lo29.05.2019 11:21, Joseph Lo пишет:
Quoted 44 lines
This is the initial patch for Tegra210 EMC clock driver, which doesn't include the support code and detail sequence for clock scaling yet.
The driver is designed to support LPDDR4 SDRAM. Because of the LPDDR4 devices need to do initial time training before it can be used, the firmware will help to do that at early boot stage. Then, the trained table of the rates we support will pass to the kernel via DT. So the driver can get the trained table for clock scaling support.
For the higher rate support (above 800MHz), the periodic training is needed for the timing compensation. So basically, two methodologies for clock scaling are supported, one is following the clock changing sequence to update the EMC table to EMC registers and another is if the rate needs periodic training, then we will start a timer to do that periodically until it scales to the lower rate.
Based on the work of Peter De Schrijver <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>---
v4:
- remove the statistic data in debugfs
- addtegra210_clk_register_emcAPI to make it compatible with the case if the kernel still uses the older DTB which doesn't have EMC node. And the MC and EMC clock can still be registered successfully.
v3:
- address almost all the comments from the previous version
- remove the DT parser of EMC table
- The EMC table is passing as a binary blob now.--- drivers/memory/tegra/Kconfig | 10 + drivers/memory/tegra/Makefile | 1 + drivers/memory/tegra/tegra210-emc.c | 671 ++++++++++++++++++++++++++++ drivers/memory/tegra/tegra210-emc.h | 156 +++++++ include/soc/tegra/emc.h | 2 + 5 files changed, 840 insertions(+) create mode 100644 drivers/memory/tegra/tegra210-emc.c create mode 100644 drivers/memory/tegra/tegra210-emc.hdrivers/memory/tegra/Kconfig +0
-0
drivers/memory/tegra/Kconfig config TEGRA124_EMC · line 32
Quoted 7 lines
drivers/memory/tegra/Kconfig +4
-0@@ -26,3 +26,13 @@ config TEGRA124_EMC Tegra124 chips. The EMC controls the external DRAM on the board. This driver is required to change memory timings / clock rate for external memory. + +config TEGRA210_EMC + bool "NVIDIA Tegra210 External Memory Controller driver" + default y
This is not enough since you're leaving possibility to disable compilation of the driver, but the compilation will fail because of the unresolved symbol (tegra210_clk_register_emc).
drivers/memory/tegra/Kconfig config TEGRA124_EMC · line 38
Quoted 6 lines
drivers/memory/tegra/Kconfig +6
-0+ depends on TEGRA_MC && ARCH_TEGRA_210_SOC + help + This driver is for the External Memory Controller (EMC) found on + Tegra210 chips. The EMC controls the external DRAM on the board. + This driver is required to change memory timings / clock rate for + external memory.
Either TEGRA210_EMC Kconfig option shall be always force-selected for T210 or you should move all the clk-related code into drivers/clk/tegra/.
Could you please give a rationale for having EMC clock code within the EMC driver?
[snip]
Quoted 5 lines
drivers/memory/tegra/Kconfig +5
-0+static int tegra210_emc_probe(struct platform_device *pdev) +{ + int i; + unsigned long table_rate; + unsigned long current_rate;
drivers/memory/tegra/Kconfig
Quoted 10 lines
drivers/memory/tegra/Kconfig +10
-0+ struct clk *emc_clk; + struct device_node *np; + struct platform_device *mc; + struct resource res; + struct tegra_emc *emc; + void *table_addr; + + emc_clk = devm_clk_get(&pdev->dev, "emc"); + if (IS_ERR(emc_clk)) + return PTR_ERR(emc_clk);
Please add newline in a such places in the code to make it more readable.
Quoted 42 lines
drivers/memory/tegra/Kconfig +42
-0+ emc = clk_hw_to_emc(__clk_get_hw(emc_clk)); + + np = of_parse_phandle(pdev->dev.of_node, "nvidia,memory-controller", 0); + if (!np) { + dev_err(&pdev->dev, "could not get memory controller\n"); + return -ENOENT; + } + + mc = of_find_device_by_node(np); + of_node_put(np); + if (!mc) + return -ENOENT; + + emc->mc = platform_get_drvdata(mc); + if (!emc->mc) + return -EPROBE_DEFER; + + emc->emc_base[REG_EMC] = devm_platform_ioremap_resource(pdev, 0); + emc->emc_base[REG_EMC0] = devm_platform_ioremap_resource(pdev, 1); + emc->emc_base[REG_EMC1] = devm_platform_ioremap_resource(pdev, 2); + + for (i = 0; i < TEGRA_EMC_SRC_COUNT; i++) { + if (!IS_ERR(emc_src[i])) + clk_put(emc_src[i]); + + emc_src[i] = devm_clk_get(&pdev->dev, emc_src_names[i]); + if (IS_ERR(emc_src[i])) { + dev_err(&pdev->dev, "Can not find EMC source clock\n"); + return -ENODATA; + } + } + + np = of_parse_phandle(pdev->dev.of_node, "memory-region", 0); + if (!np) { + dev_err(&pdev->dev, "could not find EMC table\n"); + return -ENODATA; + } + + if (!of_device_is_compatible(np, "nvidia,tegra210-emc-table") || + !of_device_is_available(np)) { + dev_err(&pdev->dev, "EMC table is invalid\n"); + return -ENODATA;
drivers/memory/tegra/Kconfig
Quoted 10 lines
drivers/memory/tegra/Kconfig +10
-0+ } + + of_address_to_resource(np, 0, &res); + table_addr = memremap(res.start, resource_size(&res), MEMREMAP_WB); + of_node_put(np); + if (!table_addr) { + dev_err(&pdev->dev, "could not map EMC table\n"); + return -ENOMEM; + } + emc->emc_table = (struct emc_table *)table_addr;
There is no need to cast a void. Please make sure that you don't have any non-upstream patches applied that are changing compiler flags, also make sure that you're using proper compiler (GCC) if you're getting a warning here.
Quoted 38 lines
drivers/memory/tegra/Kconfig +38
-0+ + for (i = 0; i < TEGRA_EMC_MAX_FREQS; i++) + if (emc->emc_table[i].rev != 0) + emc->emc_table_size++; + else + break; + + /* check the supported sequence */ + while (seq->table_rev) { + if (seq->table_rev == emc->emc_table[0].rev) + break; + seq++; + } + if (!seq->set_clock) { + seq = NULL; + dev_err(&pdev->dev, "Invalid EMC sequence for table Rev. %d\n", + emc->emc_table[0].rev); + return -ENODATA; + } + + emc_clk_sel = devm_kcalloc(&pdev->dev, + emc->emc_table_size, + sizeof(struct emc_sel), + GFP_KERNEL); + + /* calculate the rate from source clock */ + current_rate = emc_get_src_clk_rate() / 1000; + + /* validate the table */ + for (i = 0; i < emc->emc_table_size; i++) { + table_rate = emc->emc_table[i].rate; + if (!table_rate) + continue; + + if (i && ((table_rate <= emc->emc_table[i-1].rate) || + (emc->emc_table[i].min_volt < + emc->emc_table[i-1].min_volt))) + continue;
drivers/memory/tegra/Kconfig
Quoted 10 lines
drivers/memory/tegra/Kconfig +10
-0+ + if (emc->emc_table[i].rev != emc->emc_table[0].rev) + continue; + + if (find_matching_input(&emc->emc_table[i], &emc_clk_sel[i])) + continue; + + if (table_rate == current_rate) + emc->current_timing = &emc->emc_table[i]; + }
I'm suggesting to factor out all the validations into a separate function for clarity.
Signature · 6 lines
Dmitry _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH V4 5/8] memory: tegra: Add EMC scaling support code for Tegra210
In reply to Joseph Lo29.05.2019 11:21, Joseph Lo пишет:
Quoted 11 lines
This patch adds the required APIs and variables for the EMC scaling sequence code on Tegra210.
Based on the work of Peter De Schrijver <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>---
v4:
- fix the API with generic naming
- use 'u16' in 'structemc_table_register_offset'
---
[snip]
Quoted 4 lines
drivers/memory/tegra/tegra210-emc.c +4
-0+void emc_writel (struct tegra_emc *emc,u32 val,unsigned long offset) +{ +writel_relaxed (val, emc->emc_base[REG_EMC ] + offset); +}
drivers/memory/tegra/tegra210-emc.c static const struct supported_sequence supported_seqs[] = { · line 617
Quoted 10 lines
drivers/memory/tegra/tegra210-emc.c +5
-0+u32 emc_readl (struct tegra_emc *emc,unsigned long offset) {return readl_relaxed (emc->emc_base[REG_EMC ] + offset); } +u32 emc1_readl (struct tegra_emc *emc,unsigned long offset) +{ +return readl_relaxed (emc->emc_base[REG_EMC1 ] + offset); +}
Please make all the global one-line functions static and inlined, then move them out into the header. This will allow compiler to optimize code better and also will hide these generic-looking global symbol names from unrelated parties in the multiplatform kernel build.
Signature · 6 lines
Dmitry _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH V4 7/8] clk: tegra: Remove the old emc_mux clock for Tegra210
In reply to Dmitry OsipenkoQuoted 106 lines · Dmitry Osipenko
29.05.2019 11:21, Joseph Lo пишет:
Quoted 61 lines
Remove the old
emc_muxclock and don't use the common EMC clock definition. This will be replaced by a new clock defined in the EMC driver.Signed-off-by Joseph Lo <[email protected]>---
v4:
- make sure the behavior is compatible with case if the kernel still uses the older DTB which doesn't have EMC node. And the MC and EMC clock can still be registered successuflly.
v3:
- split to 3 patches from the previous version--- drivers/clk/tegra/clk-tegra210.c | 42 ++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 15 deletions(-)drivers/clk/tegra/clk-tegra210.c +9
-7@@ -28,6 +28,7 @@#include <dt-bindings/reset/tegra210-car.h> #include <linux/iopoll.h> #include <linux/sizes.h> +#include <soc/tegra/emc.h> #include <soc/tegra/pmc.h> #include "clk.h" @@ -324,12 +325,6 @@ static unsigned long tegra210_input_freq[] = { [8] = 12000000, }; -static const char *mux_pllmcp_clkm[] = { -"pll_m" ,"pll_c" ,"pll_p" ,"clk_m" ,"pll_m_ud" ,"pll_mb" ,"pll_mb" , -"pll_p" , -}; -#define mux_pllmcp_clkm_idx NULL -#define PLL_ENABLE (1 << 30)#define PLLCX_MISC1_IDDQ (1 << 27)@@ -2346,7 +2341,6 @@ static struct tegra_clk tegra210_clks[tegra_clk_max] __initdata = { [tegra_clk_i2c2] = { .dt_id = TEGRA210_CLK_I2C2, .present = true }, [tegra_clk_uartc_8] = { .dt_id = TEGRA210_CLK_UARTC, .present = true }, [tegra_clk_mipi_cal] = { .dt_id = TEGRA210_CLK_MIPI_CAL, .present = true }, - [tegra_clk_emc] = { .dt_id = TEGRA210_CLK_EMC, .present = true }, [tegra_clk_usb2] = { .dt_id = TEGRA210_CLK_USB2, .present = true }, [tegra_clk_bsev] = { .dt_id = TEGRA210_CLK_BSEV, .present = true }, [tegra_clk_uartd_8] = { .dt_id = TEGRA210_CLK_UARTD, .present = true },@@ -2957,6 +2951,27 @@ static int tegra210_init_pllu(void)return 0 ; } +static const struct clk_div_table mc_div_table_tegra210[] = { + { .val =0 , .div =2 }, + { .val =1 , .div =4 }, + { .val =2 , .div =1 }, + { .val =3 , .div =2 }, + { .val =0 , .div =0 }, +}; +drivers/clk/tegra/clk-tegra210.c static int tegra210_init_pllu(void) · line 2971
Quoted 10 lines
drivers/clk/tegra/clk-tegra210.c +10
-0+static void tegra210_clk_register_mc (const char *name, +const char *parent_name) +{ +struct clk *clk; + + clk =clk_register_divider_table (NULL , name, parent_name, +CLK_IS_CRITICAL , + clk_base +CLK_SOURCE_EMC , +15 ,2 ,CLK_DIVIDER_READ_ONLY , + mc_div_table_tegra210, &emc_lock);This doesn't look right, you're mixing up the MC divider with the EMC divider here. The MC clock is always sourced from EMC and there is only one bit for the MC divider, the bit 16
MC_EMC_SAME_FREQ.When EMC clock is divided down by 2 (bit 15
EMC_CLK_DIV2_EN), then the clk-framework will take care of it by calculating the MC rate based on the actual parent EMC rate.Quoted 25 lines
drivers/clk/tegra/clk-tegra210.c +8
-8+ clks[TEGRA210_CLK_MC ] = clk; +} +static const char *const sor1_out_parents[] = {/* * Bit 0 of the mux selects sor1_pad_clkout, irrespective of bit 1, so @@ -3040,15 +3055,12 @@ static __init void tegra210_periph_clk_init(void __iomem *clk_base, CLK_SOURCE_LA, 0); clks[TEGRA210_CLK_LA ] = clk; -/* emc mux */ - clk =clk_register_mux (NULL ,"emc_mux" , mux_pllmcp_clkm, -ARRAY_SIZE (mux_pllmcp_clkm),0 , - clk_base +CLK_SOURCE_EMC , -29 ,3 ,0 , &emc_lock); +/* emc */ + clk =tegra210_clk_register_emc (); + clks[TEGRA210_CLK_EMC ] = clk; - clk =tegra_clk_register_mc ("mc" ,"emc_mux" , clk_base +CLK_SOURCE_EMC , - &emc_lock); - clks[TEGRA210_CLK_MC ] = clk; +/* mc */ +tegra210_clk_register_mc ("mc" ,"emc" );
Quoted 6 lines
drivers/clk/tegra/clk-tegra210.c static __init void tegra210_periph_clk_init(void __iomem *clk_base, · line 3066
Quoted 3 lines
drivers/clk/tegra/clk-tegra210.c +0
-0/* cml0 */ clk = clk_register_gate(NULL, "cml0", "pll_e", 0, clk_base + PLLE_AUX,You should leave the common
tegra_clk_register_mc()usage as-is and only s/emc_mux/emc/ in the argument.
Ah, yes, that was wrong mixing up with two irrelevant bits. Fixed in my local patch.
Thanks,
Joseph
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH V4 4/8] memory: tegra: Add Tegra210 EMC clock driver
In reply to Dmitry OsipenkoQuoted 67 lines · Dmitry Osipenko
29.05.2019 11:21, Joseph Lo пишет:
Quoted 44 lines
This is the initial patch for Tegra210 EMC clock driver, which doesn't include the support code and detail sequence for clock scaling yet.
The driver is designed to support LPDDR4 SDRAM. Because of the LPDDR4 devices need to do initial time training before it can be used, the firmware will help to do that at early boot stage. Then, the trained table of the rates we support will pass to the kernel via DT. So the driver can get the trained table for clock scaling support.
For the higher rate support (above 800MHz), the periodic training is needed for the timing compensation. So basically, two methodologies for clock scaling are supported, one is following the clock changing sequence to update the EMC table to EMC registers and another is if the rate needs periodic training, then we will start a timer to do that periodically until it scales to the lower rate.
Based on the work of Peter De Schrijver <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>---
v4:
- remove the statistic data in debugfs
- addtegra210_clk_register_emcAPI to make it compatible with the case if the kernel still uses the older DTB which doesn't have EMC node. And the MC and EMC clock can still be registered successfully.
v3:
- address almost all the comments from the previous version
- remove the DT parser of EMC table
- The EMC table is passing as a binary blob now.--- drivers/memory/tegra/Kconfig | 10 + drivers/memory/tegra/Makefile | 1 + drivers/memory/tegra/tegra210-emc.c | 671 ++++++++++++++++++++++++++++ drivers/memory/tegra/tegra210-emc.h | 156 +++++++ include/soc/tegra/emc.h | 2 + 5 files changed, 840 insertions(+)create mode 100644
drivers/memory/tegra/tegra210-emc.ccreate mode 100644drivers/memory/tegra/tegra210-emc.hdrivers/memory/tegra/Kconfig +0
-0drivers/memory/tegra/Kconfig config TEGRA124_EMC · line 32
Quoted 7 lines
drivers/memory/tegra/Kconfig +4
-0@@ -26,3 +26,13 @@ config TEGRA124_EMC Tegra124 chips. The EMC controls the external DRAM on the board. This driver is required to change memory timings / clock rate for external memory. + +config TEGRA210_EMC + bool "NVIDIA Tegra210 External Memory Controller driver" + default yThis is not enough since you're leaving possibility to disable compilation of the driver, but the compilation will fail because of the unresolved symbol (
tegra210_clk_register_emc).drivers/memory/tegra/Kconfig config TEGRA124_EMC · line 38
Quoted 6 lines
drivers/memory/tegra/Kconfig +6
-0+ depends on TEGRA_MC && ARCH_TEGRA_210_SOC + help + This driver is for the External Memory Controller (EMC) found on + Tegra210 chips. The EMC controls the external DRAM on the board. + This driver is required to change memory timings / clock rate for + external memory.Either
TEGRA210_EMCKconfigoption shall be always force-selected for T210 or you should move all the clk-related code intodrivers/clk/tegra/.
Quoted 2 lines
Could you please give a rationale for having EMC clock code within the EMC driver?
I didn't have a specific reason for that initially, just wanted the clock code and EMC driver together for easier maintenance.
But considering the fix in v4, that makes it backward compatible with the case if the kernel uses the older DT without EMC node, I think it's better to move the clock code into the clk folder now.
Quoted 122 lines
[snip]
Quoted 5 lines
drivers/memory/tegra/Kconfig +5
-0+static int tegra210_emc_probe(struct platform_device *pdev) +{ + int i; + unsigned long table_rate; + unsigned long current_rate;drivers/memory/tegra/Kconfig
Quoted 10 lines
drivers/memory/tegra/Kconfig +10
-0+ struct clk *emc_clk; + struct device_node *np; + struct platform_device *mc; + struct resource res; + struct tegra_emc *emc; + void *table_addr; + + emc_clk = devm_clk_get(&pdev->dev, "emc"); + if (IS_ERR(emc_clk)) + return PTR_ERR(emc_clk);Please add newline in a such places in the code to make it more readable.
Quoted 42 lines
drivers/memory/tegra/Kconfig +42
-0+ emc = clk_hw_to_emc(__clk_get_hw(emc_clk)); + + np = of_parse_phandle(pdev->dev.of_node, "nvidia,memory-controller", 0); + if (!np) { + dev_err(&pdev->dev, "could not get memory controller\n"); + return -ENOENT; + } + + mc = of_find_device_by_node(np); + of_node_put(np); + if (!mc) + return -ENOENT; + + emc->mc = platform_get_drvdata(mc); + if (!emc->mc) + return -EPROBE_DEFER; + + emc->emc_base[REG_EMC] = devm_platform_ioremap_resource(pdev, 0); + emc->emc_base[REG_EMC0] = devm_platform_ioremap_resource(pdev, 1); + emc->emc_base[REG_EMC1] = devm_platform_ioremap_resource(pdev, 2); + + for (i = 0; i < TEGRA_EMC_SRC_COUNT; i++) { + if (!IS_ERR(emc_src[i])) + clk_put(emc_src[i]); + + emc_src[i] = devm_clk_get(&pdev->dev, emc_src_names[i]); + if (IS_ERR(emc_src[i])) { + dev_err(&pdev->dev, "Can not find EMC source clock\n"); + return -ENODATA; + } + } + + np = of_parse_phandle(pdev->dev.of_node, "memory-region", 0); + if (!np) { + dev_err(&pdev->dev, "could not find EMC table\n"); + return -ENODATA; + } + + if (!of_device_is_compatible(np, "nvidia,tegra210-emc-table") || + !of_device_is_available(np)) { + dev_err(&pdev->dev, "EMC table is invalid\n"); + return -ENODATA;drivers/memory/tegra/Kconfig
Quoted 10 lines
drivers/memory/tegra/Kconfig +10
-0+ } + + of_address_to_resource(np, 0, &res); + table_addr = memremap(res.start, resource_size(&res), MEMREMAP_WB); + of_node_put(np); + if (!table_addr) { + dev_err(&pdev->dev, "could not map EMC table\n"); + return -ENOMEM; + } + emc->emc_table = (struct emc_table *)table_addr;There is no need to cast a void. Please make sure that you don't have any non-upstream patches applied that are changing compiler flags, also make sure that you're using proper compiler (GCC) if you're getting a warning here.
Quoted 43 lines
drivers/memory/tegra/Kconfig +43
-0+ + for (i = 0; i < TEGRA_EMC_MAX_FREQS; i++) + if (emc->emc_table[i].rev != 0) + emc->emc_table_size++; + else + break; + + /* check the supported sequence */ + while (seq->table_rev) { + if (seq->table_rev == emc->emc_table[0].rev) + break; + seq++; + } + if (!seq->set_clock) { + seq = NULL; + dev_err(&pdev->dev, "Invalid EMC sequence for table Rev. %d\n", + emc->emc_table[0].rev); + return -ENODATA; + } + + emc_clk_sel = devm_kcalloc(&pdev->dev, + emc->emc_table_size, + sizeof(struct emc_sel), + GFP_KERNEL); + + /* calculate the rate from source clock */ + current_rate = emc_get_src_clk_rate() / 1000; + + /* validate the table */ + for (i = 0; i < emc->emc_table_size; i++) { + table_rate = emc->emc_table[i].rate; + if (!table_rate) + continue; + + if (i && ((table_rate <= emc->emc_table[i-1].rate) || + (emc->emc_table[i].min_volt < + emc->emc_table[i-1].min_volt))) + continue; + + if (emc->emc_table[i].rev != emc->emc_table[0].rev) + continue; + + if (find_matching_input(&emc->emc_table[i], &emc_clk_sel[i]))
Quoted 9 lines
drivers/memory/tegra/Kconfig
Quoted 5 lines
drivers/memory/tegra/Kconfig +5
-0+ continue; + + if (table_rate == current_rate) + emc->current_timing = &emc->emc_table[i]; + }I'm suggesting to factor out all the validations into a separate function for clarity.
Okay, will fix.
Thanks,
Joseph
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH V4 5/8] memory: tegra: Add EMC scaling support code for Tegra210
In reply to Dmitry OsipenkoQuoted 25 lines · Dmitry Osipenko
29.05.2019 11:21, Joseph Lo пишет:
Quoted 11 lines
This patch adds the required APIs and variables for the EMC scaling sequence code on Tegra210.
Based on the work of Peter De Schrijver <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>---
v4:
- fix the API with generic naming
- use 'u16' in 'structemc_table_register_offset'
---[snip]
Quoted 10 lines
drivers/memory/tegra/tegra210-emc.c +5
-0+void emc_writel (struct tegra_emc *emc,u32 val,unsigned long offset) +{ +writel_relaxed (val, emc->emc_base[REG_EMC ] + offset); +} +u32 emc_readl (struct tegra_emc *emc,unsigned long offset) {return readl_relaxed (emc->emc_base[REG_EMC ] + offset); }
Quoted 9 lines
drivers/memory/tegra/tegra210-emc.c static const struct supported_sequence supported_seqs[] = { · line 617
Quoted 4 lines
drivers/memory/tegra/tegra210-emc.c +4
-0+u32 emc1_readl (struct tegra_emc *emc,unsigned long offset) +{ +return readl_relaxed (emc->emc_base[REG_EMC1 ] + offset); +}Please make all the global one-line functions static and inlined, then move them out into the header. This will allow compiler to optimize code better and also will hide these generic-looking global symbol names from unrelated parties in the multiplatform kernel build.
Okay, will do.
Thanks,
Joseph
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH V4 5/8] memory: tegra: Add EMC scaling support code for Tegra210
In reply to Joseph Lo29.05.2019 11:21, Joseph Lo пишет:
Quoted 22 lines
This patch adds the required APIs and variables for the EMC scaling sequence code on Tegra210.
Based on the work of Peter De Schrijver <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>---
v4:
- fix the API with generic namingdrivers/memory/tegra/tegra210-emc.h +12
-0+extern const struct emc_table_register_offset reg_off; +extern unsigned long dram_over_temp_state; + +void ccfifo_writel (struct tegra_emc *emc,u32 val,unsigned long addr, +u32 delay); +u32 div_o3 (u32 a,u32 b); +void emc_writel (struct tegra_emc *emc,u32 val,unsigned long offset); +u32 emc_readl (struct tegra_emc *emc,unsigned long offset); +void emc_writel_per_ch (struct tegra_emc *emc,u32 val,int type, +unsigned long offset); +u32 emc1_readl (struct tegra_emc *emc,unsigned long offset); +
drivers/memory/tegra/tegra210-emc.h struct supported_sequence { · line 859
Quoted 10 lines
drivers/memory/tegra/tegra210-emc.h +10
-0+void emc_do_clock_change (struct tegra_emc *emc,u32 clksrc); +void emc_set_shadow_bypass (struct tegra_emc *emc,int set); +void emc_timing_update (struct tegra_emc *emc,int dual_chan); +u32 emc_get_dll_state (struct emc_table *next_timing); +struct emc_table *emc_get_timing_from_freq (struct tegra_emc *emc, +unsigned long rate); +void emc_set_over_temp_timing (struct tegra_emc *emc,struct emc_table *timing, +unsigned long state); +int emc_wait_for_update (struct tegra_emc *emc,u32 status_reg,u32 bit_mask, +bool updated_state,int chan);
It wouldn't hurt to prepend these all with "tegra210_".
Signature · 6 lines
Dmitry _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH V4 6/8] memory: tegra: Add EMC scaling sequence code for Tegra210
In reply to Joseph Lo29.05.2019 11:21, Joseph Lo пишет:
Quoted 40 lines
This patch includes the sequence for clock tuning and the dynamic training mechanism for the clock above 800MHz.
And historically there have been different sequences to change the EMC clock. The sequence to be used is specified in the EMC table. However, for the currently supported upstreaming platform, only the most recent sequence is used. So only support that in this patch.
Based on the work of Peter De Schrijver <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>---
v4:
- no change--- drivers/memory/tegra/Makefile | 2 +- drivers/memory/tegra/tegra210-emc-cc-r21021.c | 1953 +++++++++++++++++ drivers/memory/tegra/tegra210-emc.c | 5 + drivers/memory/tegra/tegra210-emc.h | 157 ++ 4 files changed, 2116 insertions(+), 1 deletion(-) create mode 100644 drivers/memory/tegra/tegra210-emc-cc-r21021.cdrivers/memory/tegra/Makefile +1
-1@@ -12,5 +12,5 @@ obj-$(CONFIG_TEGRA_MC) += tegra-mc.o obj-$(CONFIG_TEGRA20_EMC) += tegra20-emc.o obj-$(CONFIG_TEGRA124_EMC) += tegra124-emc.o -obj-$(CONFIG_TEGRA210_EMC) += tegra210-emc.o +obj-$(CONFIG_TEGRA210_EMC) += tegra210-emc.o tegra210-emc-cc-r21021.o obj-$(CONFIG_ARCH_TEGRA_186_SOC) += tegra186.odrivers/memory/tegra/tegra210-emc-cc-r21021.c new file +1
-0@@ -0,0 +1,1953 @@ +// SPDX-License-Identifier: GPL-2.0
drivers/memory/tegra/tegra210-emc-cc-r21021.c line 11
Quoted 10 lines
drivers/memory/tegra/tegra210-emc-cc-r21021.c new file +10
-0+/* +* Copyright (c) 2014-2019, NVIDIA CORPORATION. All rights reserved. +*/ + +#include <linux/kernel.h> +#include <linux/io.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/of.h> +#include <soc/tegra/mc.h>
Minor nit: please keep all the includes sorted in alphabet order.
Signature · 6 lines
Dmitry _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH V4 5/8] memory: tegra: Add EMC scaling support code for Tegra210
In reply to Joseph Lo29.05.2019 11:21, Joseph Lo пишет:
Quoted 13 lines
This patch adds the required APIs and variables for the EMC scaling sequence code on Tegra210.
Based on the work of Peter De Schrijver <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>---
v4:
- fix the API with generic naming
- use 'u16' in 'structemc_table_register_offset'
---
drivers/memory/tegra/tegra210-emc.h struct supported_sequence { · line 839
Quoted 2 lines
drivers/memory/tegra/tegra210-emc.h +2
-0+extern const struct emc_table_register_offset reg_off; +extern unsigned long dram_over_temp_state;
Please avoid global variables where they are not really needed.
Add reg_off pointer to tegra_emc.
Remove dram_over_temp_state variable entirely and replace it with TEGRA_DRAM_OVER_TEMP_NONE in the code since nothing changes the variable.
Again, prepend all global symbols with tegra210_.
Alternatively you could simply include tegra210-emc-cc-r21021.c into tegra210-emc.c, I don't see anything wrong with that variant.
#include "tegra210-emc-cc-r21021.c"
Or you could squash it all into a single source file if variants other than "r21021" are not planned to be supported. This will help to reduce messiness of the code and will allow compiler to better optimize it all.
Signature · 6 lines
Dmitry _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH V4 4/8] memory: tegra: Add Tegra210 EMC clock driver
In reply to Joseph LoQuoted 71 lines · Joseph Lo
Quoted 67 lines · Dmitry Osipenko
29.05.2019 11:21, Joseph Lo пишет:
Quoted 44 lines
This is the initial patch for Tegra210 EMC clock driver, which doesn't include the support code and detail sequence for clock scaling yet.
The driver is designed to support LPDDR4 SDRAM. Because of the LPDDR4 devices need to do initial time training before it can be used, the firmware will help to do that at early boot stage. Then, the trained table of the rates we support will pass to the kernel via DT. So the driver can get the trained table for clock scaling support.
For the higher rate support (above 800MHz), the periodic training is needed for the timing compensation. So basically, two methodologies for clock scaling are supported, one is following the clock changing sequence to update the EMC table to EMC registers and another is if the rate needs periodic training, then we will start a timer to do that periodically until it scales to the lower rate.
Based on the work of Peter De Schrijver <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>---
v4:
- remove the statistic data in debugfs
- addtegra210_clk_register_emcAPI to make it compatible with the case if the kernel still uses the older DTB which doesn't have EMC node. And the MC and EMC clock can still be registered successfully.
v3:
- address almost all the comments from the previous version
- remove the DT parser of EMC table
- The EMC table is passing as a binary blob now.--- drivers/memory/tegra/Kconfig | 10 + drivers/memory/tegra/Makefile | 1 + drivers/memory/tegra/tegra210-emc.c | 671 ++++++++++++++++++++++++++++ drivers/memory/tegra/tegra210-emc.h | 156 +++++++ include/soc/tegra/emc.h | 2 + 5 files changed, 840 insertions(+)create mode 100644
drivers/memory/tegra/tegra210-emc.ccreate mode 100644drivers/memory/tegra/tegra210-emc.hdrivers/memory/tegra/Kconfig +0
-0drivers/memory/tegra/Kconfig config TEGRA124_EMC · line 32
Quoted 7 lines
drivers/memory/tegra/Kconfig +4
-0@@ -26,3 +26,13 @@ config TEGRA124_EMC Tegra124 chips. The EMC controls the external DRAM on the board. This driver is required to change memory timings / clock rate for external memory. + +config TEGRA210_EMC + bool "NVIDIA Tegra210 External Memory Controller driver" + default yThis is not enough since you're leaving possibility to disable compilation of the driver, but the compilation will fail because of the unresolved symbol (
tegra210_clk_register_emc).drivers/memory/tegra/Kconfig config TEGRA124_EMC · line 38
Quoted 6 lines
drivers/memory/tegra/Kconfig +6
-0+ depends on TEGRA_MC && ARCH_TEGRA_210_SOC + help + This driver is for the External Memory Controller (EMC) found on + Tegra210 chips. The EMC controls the external DRAM on the board. + This driver is required to change memory timings / clock rate for + external memory.Either
TEGRA210_EMCKconfigoption shall be always force-selected for T210 or you should move all the clk-related code intodrivers/clk/tegra/.Quoted 2 lines
Could you please give a rationale for having EMC clock code within the EMC driver?
Quoted 6 lines
I didn't have a specific reason for that initially, just wanted the clock code and EMC driver together for easier maintenance.
But considering the fix in v4, that makes it backward compatible with the case if the kernel uses the older DT without EMC node, I think it's better to move the clock code into the clk folder now.
I looked into this a bit and I don't think this is actually worth it. The problem is that, as opposed to Tegra124 and earlier, the sequence for changing the EMC frequency is much more entangled. The bulk of the programming will be on the EMC side, with the code occasionally calling into CAR code to set the parent clock and some other flags.
So there's going to be some interdependencies regardless of where the clock code actually lives. I can try to split this apart, but I don't have very high hopes that the end result will be any cleaner than the version here.
Thierry
Re: [PATCH V4 4/8] memory: tegra: Add Tegra210 EMC clock driver
26.02.2020 19:57, Thierry Reding пишет:
Quoted 85 lines · Joseph Lo
Quoted 71 lines · Dmitry Osipenko
Quoted 67 lines
29.05.2019 11:21, Joseph Lo пишет:
Quoted 44 lines
This is the initial patch for Tegra210 EMC clock driver, which doesn't include the support code and detail sequence for clock scaling yet.
The driver is designed to support LPDDR4 SDRAM. Because of the LPDDR4 devices need to do initial time training before it can be used, the firmware will help to do that at early boot stage. Then, the trained table of the rates we support will pass to the kernel via DT. So the driver can get the trained table for clock scaling support.
For the higher rate support (above 800MHz), the periodic training is needed for the timing compensation. So basically, two methodologies for clock scaling are supported, one is following the clock changing sequence to update the EMC table to EMC registers and another is if the rate needs periodic training, then we will start a timer to do that periodically until it scales to the lower rate.
Based on the work of Peter De Schrijver <[email protected]>.
Signed-off-by Joseph Lo <[email protected]>---
v4:
- remove the statistic data in debugfs
- addtegra210_clk_register_emcAPI to make it compatible with the case if the kernel still uses the older DTB which doesn't have EMC node. And the MC and EMC clock can still be registered successfully.
v3:
- address almost all the comments from the previous version
- remove the DT parser of EMC table
- The EMC table is passing as a binary blob now.--- drivers/memory/tegra/Kconfig | 10 + drivers/memory/tegra/Makefile | 1 + drivers/memory/tegra/tegra210-emc.c | 671 ++++++++++++++++++++++++++++ drivers/memory/tegra/tegra210-emc.h | 156 +++++++ include/soc/tegra/emc.h | 2 + 5 files changed, 840 insertions(+)create mode 100644
drivers/memory/tegra/tegra210-emc.ccreate mode 100644drivers/memory/tegra/tegra210-emc.hdrivers/memory/tegra/Kconfig +0
-0drivers/memory/tegra/Kconfig config TEGRA124_EMC · line 32
Quoted 7 lines
drivers/memory/tegra/Kconfig +4
-0@@ -26,3 +26,13 @@ config TEGRA124_EMC Tegra124 chips. The EMC controls the external DRAM on the board. This driver is required to change memory timings / clock rate for external memory. + +config TEGRA210_EMC + bool "NVIDIA Tegra210 External Memory Controller driver" + default yThis is not enough since you're leaving possibility to disable compilation of the driver, but the compilation will fail because of the unresolved symbol (
tegra210_clk_register_emc).drivers/memory/tegra/Kconfig config TEGRA124_EMC · line 38
Quoted 6 lines
drivers/memory/tegra/Kconfig +6
-0+ depends on TEGRA_MC && ARCH_TEGRA_210_SOC + help + This driver is for the External Memory Controller (EMC) found on + Tegra210 chips. The EMC controls the external DRAM on the board. + This driver is required to change memory timings / clock rate for + external memory.Either
TEGRA210_EMCKconfigoption shall be always force-selected for T210 or you should move all the clk-related code intodrivers/clk/tegra/.Quoted 2 lines
Could you please give a rationale for having EMC clock code within the EMC driver?
Quoted 6 lines
I didn't have a specific reason for that initially, just wanted the clock code and EMC driver together for easier maintenance.
But considering the fix in v4, that makes it backward compatible with the case if the kernel uses the older DT without EMC node, I think it's better to move the clock code into the clk folder now.
I looked into this a bit and I don't think this is actually worth it. The problem is that, as opposed to Tegra124 and earlier, the sequence for changing the EMC frequency is much more entangled. The bulk of the programming will be on the EMC side, with the code occasionally calling into CAR code to set the parent clock and some other flags.
Quoted 4 lines
So there's going to be some interdependencies regardless of where the clock code actually lives. I can try to split this apart, but I don't have very high hopes that the end result will be any cleaner than the version here.
I'm vaguely recalling that there was another reason than just to "make things cleaner"..
https://patchwork.kernel.org/patch/10938389/#22641053
Secondly, if you're going to use the CCF API for the clock changes, then I'm not sure that having couple custom clock-API functions sounds too bad.
Lastly, in regards to the cleanup.. at minimum you should strip out all the unused parts from this code, make a generic cleanup to make it all look better, address previous comments.