Tegra20 External Memory Controller driver
Subsystems (5)
cover Tegra20 External Memory Controller driver
Hello,
Couple years ago the Tegra20 EMC driver was removed from the kernel due to incompatible changes in the Tegra's clock driver. This patchset introduces a modernized EMC driver. Currently the sole purpose of the driver is to initialize DRAM frequency to maximum rate during of the kernels boot-up. Later we may consider implementing dynamic memory frequency scaling, utilizing functionality provided by this driver.
Dmitry Osipenko (4):
dt: bindings: tegra20-emc: Document interrupt property
ARM: dts: tegra20: Add interrupt to External Memory Controller
clk: tegra20: Turn EMC clock gate into divider
memory: tegra: Introduce Tegra20 EMC driver
.../bindings/arm/tegra/nvidia,tegra20-emc.txt | 2 + arch/arm/boot/dts/tegra20.dtsi | 1 + drivers/clk/tegra/clk-tegra20.c | 39 +- drivers/memory/tegra/Kconfig | 10 + drivers/memory/tegra/Makefile | 1 + drivers/memory/tegra/tegra20-emc.c | 573 ++++++++++++++++++ 6 files changed, 616 insertions(+), 10 deletions(-) create mode 100644 drivers/memory/tegra/tegra20-emc.c
Signature · 1 line
2.17.0
PATCH 1/4 dt: bindings: tegra20-emc: Document interrupt property
EMC has a dedicated interrupt that is used to notify about completion of HW operations. Document the interrupt property.
--- .../devicetree/bindings/arm/tegra/nvidia,tegra20-emc.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-emc.txt +2 -0
@@ -10,6 +10,7 @@ Properties: and chosen using the ramcode board selector. If omitted, only one set of tables can be present and said tables will be used irrespective of ram-code configuration. +- interrupts : Should contain EMC General interrupt. Child device nodes describe the memory settings for different configurations and clock rates.
@@ -20,6 +21,7 @@ Example: #size-cells = < 0 >; compatible = "nvidia,tegra20-emc"; reg = <0x7000f4000 0x200>; + interrupts = <0 78 0x04>; }
Signature · 1 line
2.17.0
PATCH 2/4 ARM: dts: tegra20: Add interrupt to External Memory Controller
In reply to Dmitry OsipenkoAdd interrupt entry into the EMC DT node.
--- arch/arm/boot/dts/tegra20.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/tegra20.dtsi +1 -0
@@ -609,6 +609,7 @@ memory-controller@7000f400 { compatible = "nvidia,tegra20-emc"; reg = <0x7000f400 0x200>; + interrupts = <GIC_SPI 78 IRQ_TYPE_LEVEL_HIGH>; #address-cells = <1>; #size-cells = <0>; };
Signature · 1 line
2.17.0
PATCH 3/4 clk: tegra20: Turn EMC clock gate into divider
In reply to Dmitry OsipenkoKernel should never gate the EMC clock as it causes immediate lockup, so removing clk-gate functionality doesn't affect anything. Turning EMC clk gate into divider allows to implement glitch-less EMC scaling, avoiding reparenting to a backup clock.
--- drivers/clk/tegra/clk-tegra20.c | 39 ++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 10 deletions(-)
drivers/clk/tegra/clk-tegra20.c +29 -10
@@ -578,7 +578,6 @@ static struct tegra_clk tegra20_clks[tegra_clk_max] __initdata = { [tegra_clk_afi] = { .dt_id = TEGRA20_CLK_AFI, .present = true }, [tegra_clk_fuse] = { .dt_id = TEGRA20_CLK_FUSE, .present = true }, [tegra_clk_kfuse] = { .dt_id = TEGRA20_CLK_KFUSE, .present = true }, - [tegra_clk_emc] = { .dt_id = TEGRA20_CLK_EMC, .present = true }, };static unsigned long tegra20_clk_measure_input_freq (void )
@@ -799,19 +798,18 @@ static struct tegra_periph_init_data tegra_periph_nodiv_clk_list[] = { TEGRA_INIT_DATA_NODIV("disp2", mux_pllpdc_clkm, CLK_SOURCE_DISP2, 30, 2, 26, 0, TEGRA20_CLK_DISP2), }; -static void __init tegra20_periph_clk_init (void ) +static void __init tegra20_emc_clk_init (void ) { -struct tegra_periph_init_data *data; +u32 emc_reg =readl_relaxed (clk_base +CLK_SOURCE_EMC ); +u32 use_pllm_ud =BIT (29 );struct clk *clk; -unsigned int i; -/* ac97 */ - clk =tegra_clk_register_periph_gate ("ac97" ,"pll_a_out0" , -TEGRA_PERIPH_ON_APB , - clk_base,0 ,3 , periph_clk_enb_refcnt); - clks[TEGRA20_CLK_AC97 ] = clk; +if (emc_reg & use_pllm_ud) { +pr_err ("%s: un-divided PllM_out0 used as clock source\n" , + __func__); +return ; + } -/* emc */ clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm, ARRAY_SIZE(mux_pllmcp_clkm), CLK_SET_RATE_NO_REPARENT,
@@ -822,6 +820,27 @@ static void __init tegra20_periph_clk_init(void) &emc_lock); clks[TEGRA20_CLK_MC ] = clk; + clk =clk_register_divider (NULL ,"emc" ,"emc_mux" ,CLK_IS_CRITICAL , + clk_base +CLK_SOURCE_EMC ,0 ,7 , +0 , &emc_lock); + clks[TEGRA20_CLK_EMC ] = clk; +} + +static void __init tegra20_periph_clk_init (void ) +{ +struct tegra_periph_init_data *data; +struct clk *clk; +unsigned int i; + +/* ac97 */ + clk =tegra_clk_register_periph_gate ("ac97" ,"pll_a_out0" , +TEGRA_PERIPH_ON_APB , + clk_base,0 ,3 , periph_clk_enb_refcnt); + clks[TEGRA20_CLK_AC97 ] = clk; + +/* emc */ +tegra20_emc_clk_init (); +/* dsi */ clk =tegra_clk_register_periph_gate ("dsi" ,"pll_d" ,0 , clk_base,0 ,48 , periph_clk_enb_refcnt);
Signature · 1 line
2.17.0
Stephen Boyd
maintainerRe: [PATCH v1 3/4] clk: tegra20: Turn EMC clock gate into divider
Quoting Dmitry Osipenko (2018-05-30 08:06:45)
Quoted 7 lines
Kernel should never gate the EMC clock as it causes immediate lockup, so removing clk-gate functionality doesn't affect anything. Turning EMC clk gate into divider allows to implement glitch-less EMC scaling, avoiding reparenting to a backup clock.
=Signed-off-by Dmitry Osipenko <[email protected]>
Looks ok to me, but I'm waiting for someone from Tegra side to ack it or review it.
Re: [PATCH v1 3/4] clk: tegra20: Turn EMC clock gate into divider
Quoted 11 lines · Stephen Boyd
Quoting Dmitry Osipenko (2018-05-30 08:06:45)
Quoted 6 lines
Kernel should never gate the EMC clock as it causes immediate lockup, so removing clk-gate functionality doesn't affect anything. Turning EMC clk gate into divider allows to implement glitch-less EMC scaling, avoiding reparenting to a backup clock.
Signed-off-by Dmitry Osipenko <[email protected]>Looks ok to me, but I'm waiting for someone from Tegra side to ack it or review it.
I've already prepared v2 with some minor cleanups and additional clk patch. For now waiting for Peter's review comments to v1.
PATCH 4/4 memory: tegra: Introduce Tegra20 EMC driver
In reply to Dmitry OsipenkoIntroduce driver for the External Memory Controller (EMC) found on Tegra20 chips, which controls the external DRAM on the board. The purpose of this driver is to program memory timings for external memory on the EMC clock rate change.
--- drivers/memory/tegra/Kconfig | 10 + drivers/memory/tegra/Makefile | 1 + drivers/memory/tegra/tegra20-emc.c | 573 +++++++++++++++++++++++++++++ 3 files changed, 584 insertions(+) create mode 100644 drivers/memory/tegra/tegra20-emc.c
drivers/memory/tegra/Kconfig +10 -0
@@ -6,6 +6,16 @@ config TEGRA_MC This driver supports the Memory Controller (MC) hardware found on NVIDIA Tegra SoCs. +config TEGRA20_EMC + bool "NVIDIA Tegra20 External Memory Controller driver" + default y + depends on ARCH_TEGRA_2x_SOC + help + This driver is for the External Memory Controller (EMC) found on + Tegra20 chips. The EMC controls the external DRAM on the board. + This driver is required to change memory timings / clock rate for + external memory. + config TEGRA124_EMC bool "NVIDIA Tegra124 External Memory Controller driver" default y
drivers/memory/tegra/Makefile +1 -0
@@ -10,5 +10,6 @@ tegra-mc-$(CONFIG_ARCH_TEGRA_210_SOC) += tegra210.o obj-$(CONFIG_TEGRA_MC) += tegra-mc.o +obj-$(CONFIG_TEGRA20_EMC) += tegra20-emc.o obj-$(CONFIG_TEGRA124_EMC) += tegra124-emc.o obj-$(CONFIG_ARCH_TEGRA_186_SOC) += tegra186.o
drivers/memory/tegra/tegra20-emc.c new file +573 -0
573 lines not on this page · raw message
Signature · 1 line
2.17.0