[U-Boot] [PATCH 1/4] rockchip: arm64: rk3399: revise timeout-handling for DRAM PHY lock

Revise the loop watching for a timeout on obtaining a DRAM PHY lock to clearly state a timeout in milliseconds and use get_timer (based on the ARMv8 architected timer) to detect a timeout.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com ---
arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c b/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c index 216a26c..4dd84e2 100644 --- a/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c +++ b/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c @@ -5,6 +5,7 @@ * * Adapted from coreboot. */ + #include <common.h> #include <clk.h> #include <dm.h> @@ -19,6 +20,7 @@ #include <asm/arch/grf_rk3399.h> #include <asm/arch/hardware.h> #include <linux/err.h> +#include <time.h>
DECLARE_GLOBAL_DATA_PTR; struct chan_info { @@ -506,6 +508,7 @@ static int pctl_cfg(const struct chan_info *chan, u32 channel, u32 tmp, tmp1, tmp2; u32 pwrup_srefresh_exit; int ret; + const ulong timeout_ms = 200;
/* * work around controller bug: @@ -588,13 +591,15 @@ static int pctl_cfg(const struct chan_info *chan, u32 channel, clrsetbits_le32(&denali_phy[957], 0x3 << 24, 0x2 << 24);
/* Wating for PHY and DRAM init complete */ - tmp = 0; - while (!(readl(&denali_ctl[203]) & (1 << 3))) { - mdelay(10); - tmp++; - if (tmp > 10) + tmp = get_timer(0); + do { + if (get_timer(tmp) > timeout_ms) { + error("DRAM (%s): phy failed to lock within %ld ms\n", + __func__, timeout_ms); return -ETIME; - } + } + } while (!(readl(&denali_ctl[203]) & (1 << 3))); + debug("DRAM (%s): phy locked after %ld ms\n", __func__, get_timer(tmp));
clrsetbits_le32(&denali_ctl[68], PWRUP_SREFRESH_EXIT, pwrup_srefresh_exit);

The RK3399 is capable of driving DDR3 at 933MHz (i.e. DDR3-1866), if the PCB layout permits and appropriate memory timings are used.
This changes the sanity checks to allow a DTS to request DDR3-1866 operation.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Tested-by: Klaus Goger klaus.goger@theobroma-systems.com ---
arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c b/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c index 4dd84e2..0b87fcf 100644 --- a/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c +++ b/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c @@ -1090,7 +1090,7 @@ static int sdram_init(struct dram_info *dram,
debug("Starting SDRAM initialization...\n");
- if ((dramtype == DDR3 && ddr_freq > 800) || + if ((dramtype == DDR3 && ddr_freq > 933) || (dramtype == LPDDR3 && ddr_freq > 933) || (dramtype == LPDDR4 && ddr_freq > 800)) { debug("SDRAM frequency is to high!");

On 31 May 2017 at 10:16, Philipp Tomsich philipp.tomsich@theobroma-systems.com wrote:
The RK3399 is capable of driving DDR3 at 933MHz (i.e. DDR3-1866), if the PCB layout permits and appropriate memory timings are used.
This changes the sanity checks to allow a DTS to request DDR3-1866 operation.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Tested-by: Klaus Goger klaus.goger@theobroma-systems.com
arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org

Philipp,
On 06/01/2017 12:16 AM, Philipp Tomsich wrote:
The RK3399 is capable of driving DDR3 at 933MHz (i.e. DDR3-1866), if the PCB layout permits and appropriate memory timings are used.
This changes the sanity checks to allow a DTS to request DDR3-1866 operation.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Tested-by: Klaus Goger klaus.goger@theobroma-systems.com
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks, - Kever
arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c b/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c index 4dd84e2..0b87fcf 100644 --- a/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c +++ b/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c @@ -1090,7 +1090,7 @@ static int sdram_init(struct dram_info *dram,
debug("Starting SDRAM initialization...\n");
- if ((dramtype == DDR3 && ddr_freq > 800) ||
- if ((dramtype == DDR3 && ddr_freq > 933) || (dramtype == LPDDR3 && ddr_freq > 933) || (dramtype == LPDDR4 && ddr_freq > 800)) { debug("SDRAM frequency is to high!");

Philipp,
On 06/01/2017 12:16 AM, Philipp Tomsich wrote:
The RK3399 is capable of driving DDR3 at 933MHz (i.e. DDR3-1866), if the PCB layout permits and appropriate memory timings are used.
This changes the sanity checks to allow a DTS to request DDR3-1866 operation.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com Tested-by: Klaus Goger klaus.goger@theobroma-systems.com
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks, - Kever
arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-rockchip, thanks!

With the validation done for DDR3-1866 (i.e. 933 MHz bus clock), we can now add the timings (rk3399-sdram-ddr3-1866.dtsi) for boards built with the DDR3-1866 option.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com ---
arch/arm/dts/rk3399-sdram-ddr3-1866.dtsi | 1537 ++++++++++++++++++++++++++++++ 1 file changed, 1537 insertions(+) create mode 100644 arch/arm/dts/rk3399-sdram-ddr3-1866.dtsi
diff --git a/arch/arm/dts/rk3399-sdram-ddr3-1866.dtsi b/arch/arm/dts/rk3399-sdram-ddr3-1866.dtsi new file mode 100644 index 0000000..80e946e --- /dev/null +++ b/arch/arm/dts/rk3399-sdram-ddr3-1866.dtsi @@ -0,0 +1,1537 @@ +/* + * (C) 2017 Theobroma Systems Design und Consulting GmbH + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +&dmc { + rockchip,sdram-params = < + 0x1 + 0xa + 0x3 + 0x2 + 0x1 + 0x0 + 0xf + 0xf + 1 + 0x80181219 + 0x17050a03 + 0x00000002 + 0x00006456 + 0x0000004c + 0x00000000 + 0x1 + 0xa + 0x3 + 0x2 + 0x1 + 0x0 + 0xf + 0xf + 1 + 0x80181219 + 0x17050a03 + 0x00000002 + 0x00006456 + 0x0000004c + 0x00000000 + 933 + 3 + 2 + 9 + 1 + 0x00000600 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x0000000a + 0x00000000 + 0x00000000 + 0x00000000 + 0x0000000a + 0x00000000 + 0x00000000 + 0x00000000 + 0x0000000a + 0x00000000 + 0x00000000 + 0x01000000 + 0x00000000 + 0x00000101 + 0x00020100 + 0x0002d976 + 0x00071fa6 + 0x02000200 + 0x091a0200 + 0x00091a00 + 0x0400091a + 0x2c060004 + 0x210c0820 + 0x202c0600 + 0x00210c08 + 0x08202c06 + 0x0800210c + 0x00000f04 + 0x0501000a + 0x0f040805 + 0x0501000a + 0x0f040805 + 0x0501000a + 0x02030005 + 0x0c0f0c00 + 0x000f0c0f + 0x14000a0a + 0x00000a0a + 0x00010000 + 0x031c1c1c + 0x000c0c0c + 0x00000000 + 0x03010000 + 0x1c6a0147 + 0x1c6a0147 + 0x1c6a0147 + 0x00000000 + 0x00060006 + 0x00170006 + 0x00170017 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x02000000 + 0x02000151 + 0x02000151 + 0x00000151 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000301 + 0x00000001 + 0x00000000 + 0x00000000 + 0x01000000 + 0x80104002 + 0x00040003 + 0x00040005 + 0x00030000 + 0x00050004 + 0x00000004 + 0x00040003 + 0x00040005 + 0x71a80000 + 0x000038d4 + 0x38d471a8 + 0x71a80000 + 0x000038d4 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x0a0a0a00 + 0x000a0a0a + 0x00030200 + 0x00040700 + 0x00000302 + 0x02000407 + 0x00000003 + 0x00030f04 + 0x00070004 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00010000 + 0x00010000 + 0x20040020 + 0x00200400 + 0x01000400 + 0x00000b80 + 0x00000000 + 0x00000001 + 0x00000002 + 0x0000000e + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00bb0000 + 0x00ea005e + 0x00ea0000 + 0x005e00bb + 0x000000ea + 0x00bb00ea + 0x00ea005e + 0x00ea0000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00420014 + 0x00140020 + 0x00200042 + 0x00420014 + 0x00000020 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00420014 + 0x00140020 + 0x00200042 + 0x00420014 + 0x00000020 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x01000000 + 0x00000000 + 0x00000000 + 0x18151100 + 0x0000000c + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00025603 + 0x004b012b + 0x00000000 + 0x012b0256 + 0x0000004b + 0x00025600 + 0x004b012b + 0x00000000 + 0x00000000 + 0x00000000 + 0x01010100 + 0x00000202 + 0x0a000001 + 0x01000f0f + 0x00000000 + 0x00000000 + 0x00010003 + 0x00000c03 + 0x00000000 + 0x00000000 + 0x01000000 + 0x00010000 + 0x00000001 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00010000 + 0x08080802 + 0x01010606 + 0x00000001 + 0x04040400 + 0x03080808 + 0x03050303 + 0x03050303 + 0x00050303 + 0x00020202 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x0d000001 + 0x00010028 + 0x00010000 + 0x00000003 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00010100 + 0x01000000 + 0x00000001 + 0x00000303 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x000556aa + 0x000aaaaa + 0x000aa955 + 0x00055555 + 0x000b3133 + 0x0004cd33 + 0x0004cecc + 0x000b32cc + 0x00010300 + 0x03000100 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00ffff00 + 0x15150000 + 0x08000015 + 0x000038d4 + 0x00000200 + 0x00000200 + 0x00000200 + 0x00000200 + 0x000038d4 + 0x00023848 + 0x38d4080b + 0x00000200 + 0x00000200 + 0x00000200 + 0x00000200 + 0x000038d4 + 0x00023848 + 0x38d4080b + 0x00000200 + 0x00000200 + 0x00000200 + 0x00000200 + 0x000038d4 + 0x00023848 + 0x0202080b + 0x03030202 + 0x00000014 + 0x00000000 + 0x00000000 + 0x00001403 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00030000 + 0x00060018 + 0x00060018 + 0x00060018 + 0x00000000 + 0x00000000 + 0x01000000 + 0x03080308 + 0x00050308 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x01000100 + 0x01010101 + 0x01000101 + 0x01000100 + 0x00010001 + 0x00010002 + 0x00020100 + 0x00000002 + 0x00000600 + 0x00000000 + 0x000071a8 + 0x000038d4 + 0x000071a8 + 0x000038d4 + 0x000071a8 + 0x38d438d4 + 0x00000200 + 0x00000200 + 0x00000200 + 0x00000200 + 0x000038d4 + 0x00000200 + 0x00000200 + 0x00000200 + 0x00000200 + 0x000038d4 + 0x00000200 + 0x00000200 + 0x00000200 + 0x00000200 + 0x00010000 + 0x00000007 + 0x110f0001 + 0x3c020000 + 0x3fffffff + 0x3c030000 + 0x1dc0ffff + 0x3c010000 + 0x1dc0ffff + 0x3c000000 + 0x1dc0ffff + 0x3c300400 + 0x1dc7ffff + 0x3c000000 + 0x00000000 + 0x3c000000 + 0x00000000 + 0x3c000000 + 0x00000000 + 0x03000101 + 0x00262626 + 0x091a0009 + 0x00091a00 + 0x0000001a + 0x1c6a0147 + 0x1c6a0147 + 0x1c6a0147 + 0x00000500 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x04040000 + 0x0d000004 + 0x00000128 + 0x00000000 + 0x00030003 + 0x00000014 + 0x00000000 + 0x00000000 + 0x08060002 + 0x08010801 + 0x00060601 + 0x00020001 + 0x00080004 + 0x00000000 + 0x00000000 + 0x04040400 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00030300 + 0x00000014 + 0x00000000 + 0x01010300 + 0x00000000 + 0x00000000 + 0x01000000 + 0x00000101 + 0x55555a5a + 0x55555a5a + 0x55555a5a + 0x55555a5a + 0x0b0b0001 + 0x0808000b + 0x03030008 + 0x00000103 + 0x00030000 + 0x17030000 + 0x00060018 + 0x00060018 + 0x00060018 + 0x00000000 + 0x00000000 + 0x00000000 + 0x140a0000 + 0x000a000a + 0x00000a00 + 0x010a000a + 0x00000100 + 0x01000000 + 0x00000000 + 0x00000100 + 0x1e1a0000 + 0x10010204 + 0x07070705 + 0x20000202 + 0x00201000 + 0x00201000 + 0x04041000 + 0x12120100 + 0x00010112 + 0x004b004a + 0x1a030000 + 0x0102041e + 0x34000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00004200 + 0x00000020 + 0x004d4d00 + 0x00200042 + 0x4d000000 + 0x0000424d + 0x00000020 + 0x004d4d00 + 0x00200042 + 0x4d000000 + 0x0000424d + 0x00000020 + 0x004d4d00 + 0x00200042 + 0x4d000000 + 0x0042004d + 0x00000020 + 0x004d4d00 + 0x00200042 + 0x4d000000 + 0x0000424d + 0x00000020 + 0x004d4d00 + 0x00200042 + 0x4d000000 + 0x0000424d + 0x00000020 + 0x004d4d00 + 0x00200042 + 0x4d000000 + 0x0000004d + 0x00ea00ea + 0x080400ea + 0x0f080c0c + 0x2000fd7a + 0x0a042000 + 0x0c0c080f + 0x00000f08 + 0x2000fd7a + 0x0a042000 + 0x0c0c080f + 0x00000f08 + 0x2000fd7a + 0x0a042000 + 0x0200020f + 0x02000200 + 0x02000200 + 0x02000200 + 0x02000200 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x01000300 + 0x0038d400 + 0x00023848 + 0x000038d4 + 0x00023848 + 0x000038d4 + 0x00023848 + 0x08000000 + 0x00000100 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000001 + 0x76543210 + 0x0004c008 + 0x000000de + 0x00000000 + 0x00000000 + 0x00010000 + 0x01665555 + 0x00665555 + 0x00010f00 + 0x06010200 + 0x00000001 + 0x001700c0 + 0x00cc0001 + 0x00000066 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x04080000 + 0x04080400 + 0x08000000 + 0x0c00c007 + 0x00000100 + 0x00000100 + 0x55555555 + 0xaaaaaaaa + 0x55555555 + 0xaaaaaaaa + 0x00005555 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00200000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x02800280 + 0x02800280 + 0x02800280 + 0x02800280 + 0x00000280 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00800000 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00de0080 + 0x00000001 + 0x00000000 + 0x00000000 + 0x00000200 + 0x00000000 + 0x51313152 + 0x80013130 + 0x02000080 + 0x00100001 + 0x07064208 + 0x000f0c0f + 0x01000140 + 0x00000c20 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x76543210 + 0x0004c008 + 0x000000de + 0x00000000 + 0x00000000 + 0x00010000 + 0x01665555 + 0x00665555 + 0x00010f00 + 0x06010200 + 0x00000001 + 0x001700c0 + 0x00cc0001 + 0x00000066 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x04080000 + 0x04080400 + 0x08000000 + 0x0c00c007 + 0x00000100 + 0x00000100 + 0x55555555 + 0xaaaaaaaa + 0x55555555 + 0xaaaaaaaa + 0x00005555 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00200000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x02800280 + 0x02800280 + 0x02800280 + 0x02800280 + 0x00000280 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00800000 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00de0080 + 0x00000001 + 0x00000000 + 0x00000000 + 0x00000200 + 0x00000000 + 0x51313152 + 0x80013130 + 0x02000080 + 0x00100001 + 0x07064208 + 0x000f0c0f + 0x01000140 + 0x00000c20 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x76543210 + 0x0004c008 + 0x000000de + 0x00000000 + 0x00000000 + 0x00010000 + 0x01665555 + 0x00665555 + 0x00010f00 + 0x06010200 + 0x00000001 + 0x001700c0 + 0x00cc0001 + 0x00000066 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x04080000 + 0x04080400 + 0x08000000 + 0x0c00c007 + 0x00000100 + 0x00000100 + 0x55555555 + 0xaaaaaaaa + 0x55555555 + 0xaaaaaaaa + 0x00005555 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00200000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x02800280 + 0x02800280 + 0x02800280 + 0x02800280 + 0x00000280 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00800000 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00de0080 + 0x00000001 + 0x00000000 + 0x00000000 + 0x00000200 + 0x00000000 + 0x51313152 + 0x80013130 + 0x02000080 + 0x00100001 + 0x07064208 + 0x000f0c0f + 0x01000140 + 0x00000c20 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x76543210 + 0x0004c008 + 0x000000de + 0x00000000 + 0x00000000 + 0x00010000 + 0x01665555 + 0x00665555 + 0x00010f00 + 0x06010200 + 0x00000001 + 0x001700c0 + 0x00cc0001 + 0x00000066 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x04080000 + 0x04080400 + 0x08000000 + 0x0c00c007 + 0x00000100 + 0x00000100 + 0x55555555 + 0xaaaaaaaa + 0x55555555 + 0xaaaaaaaa + 0x00005555 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00200000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x02800280 + 0x02800280 + 0x02800280 + 0x02800280 + 0x00000280 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00800000 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00800080 + 0x00de0080 + 0x00000001 + 0x00000000 + 0x00000000 + 0x00000200 + 0x00000000 + 0x51313152 + 0x80013130 + 0x02000080 + 0x00100001 + 0x07064208 + 0x000f0c0f + 0x01000140 + 0x00000c20 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00800000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00400320 + 0x00000040 + 0x00dcba98 + 0x00000000 + 0x00dcba98 + 0x01000000 + 0x00020003 + 0x00000000 + 0x00000000 + 0x00000000 + 0x0000002a + 0x00000015 + 0x00000015 + 0x0000002a + 0x00000033 + 0x0000000c + 0x0000000c + 0x00000033 + 0x0a418820 + 0x103f0000 + 0x0000003f + 0x00030055 + 0x03000300 + 0x03000300 + 0x00000300 + 0x42080010 + 0x00000003 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00800000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00400320 + 0x00000040 + 0x00000000 + 0x00000000 + 0x00000000 + 0x01000000 + 0x00020003 + 0x00000000 + 0x00000000 + 0x00000000 + 0x0000002a + 0x00000015 + 0x00000015 + 0x0000002a + 0x00000033 + 0x0000000c + 0x0000000c + 0x00000033 + 0x16a4a0e6 + 0x103f0000 + 0x0000003f + 0x00030055 + 0x03000300 + 0x03000300 + 0x00000300 + 0x42080010 + 0x00000003 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00800000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00400320 + 0x00000040 + 0x00000000 + 0x00000000 + 0x00000000 + 0x01000000 + 0x00020003 + 0x00000000 + 0x00000000 + 0x00000000 + 0x0000002a + 0x00000015 + 0x00000015 + 0x0000002a + 0x00000033 + 0x0000000c + 0x0000000c + 0x00000033 + 0x1ee6b16a + 0x103f0000 + 0x0000003f + 0x00030055 + 0x03000300 + 0x03000300 + 0x00000300 + 0x42080010 + 0x00000003 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000001 + 0x00000000 + 0x01000005 + 0x04000f00 + 0x00020040 + 0x00020055 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00010100 + 0x00000601 + 0x00000000 + 0x00006400 + 0x01221102 + 0x00000000 + 0x00031f00 + 0x031f031f + 0x031f031f + 0x00030003 + 0x03000300 + 0x00000300 + 0x01221102 + 0x00000000 + 0x00000000 + 0x04020000 + 0x00000001 + 0x00008011 + 0x00000011 + 0x00000440 + 0x00000040 + 0x00004011 + 0x00004011 + 0x00004410 + 0x00004410 + 0x00004410 + 0x00004410 + 0x00004410 + 0x00004011 + 0x00004410 + 0x00004011 + 0x00004410 + 0x00004011 + 0x00004410 + 0x00000000 + 0x00000000 + 0x00000000 + 0x04000000 + 0x00000000 + 0x00000000 + 0x00000508 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0x00000000 + 0xe4000000 + 0x00000000 + 0x00000000 + 0x01010000 + 0x00000000 + >; +}; +

On 31 May 2017 at 10:16, Philipp Tomsich philipp.tomsich@theobroma-systems.com wrote:
With the validation done for DDR3-1866 (i.e. 933 MHz bus clock), we can now add the timings (rk3399-sdram-ddr3-1866.dtsi) for boards built with the DDR3-1866 option.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
arch/arm/dts/rk3399-sdram-ddr3-1866.dtsi | 1537 ++++++++++++++++++++++++++++++ 1 file changed, 1537 insertions(+) create mode 100644 arch/arm/dts/rk3399-sdram-ddr3-1866.dtsi
Reviewed-by: Simon Glass sjg@chromium.org

On 31 May 2017 at 10:16, Philipp Tomsich philipp.tomsich@theobroma-systems.com wrote:
With the validation done for DDR3-1866 (i.e. 933 MHz bus clock), we can now add the timings (rk3399-sdram-ddr3-1866.dtsi) for boards built with the DDR3-1866 option.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
arch/arm/dts/rk3399-sdram-ddr3-1866.dtsi | 1537 ++++++++++++++++++++++++++++++ 1 file changed, 1537 insertions(+) create mode 100644 arch/arm/dts/rk3399-sdram-ddr3-1866.dtsi
Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot-rockchip, thanks!

The RK3399-Q7 has multiple build-options for its DRAM configuration, including the timing of the DRAM components populated.
While DDR3-1600 is the standard configuration, custom-configurations are available with DDR3-1333 (for a further cost-optimisation) and with DDR3-1866 (as a premium option).
To simplify our test automation (without the need to maintain 3 different defconfigs) and customer evaluation, we make this selectable via Kconfig.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com ---
arch/arm/dts/rk3399-puma.dts | 8 +++++++ board/theobroma-systems/puma_rk3399/Kconfig | 37 +++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
diff --git a/arch/arm/dts/rk3399-puma.dts b/arch/arm/dts/rk3399-puma.dts index fca14d3..41d32eb 100644 --- a/arch/arm/dts/rk3399-puma.dts +++ b/arch/arm/dts/rk3399-puma.dts @@ -8,7 +8,15 @@
#include <dt-bindings/pwm/pwm.h> #include "rk3399.dtsi" +#if defined(CONFIG_SYS_TSD_PUMA_DDR3_1333) +#include "rk3399-sdram-ddr3-1333.dtsi" +#elif defined(CONFIG_SYS_TSD_PUMA_DDR3_1600) #include "rk3399-sdram-ddr3-1600.dtsi" +#elif defined(CONFIG_SYS_TSD_PUMA_DDR3_1866) +#include "rk3399-sdram-ddr3-1866.dtsi" +#else +#error "Unknown memory timing configuration for the RK3399-Q7" +#endif
/ { model = "Theobroma Systems RK3399-Q7 SoM"; diff --git a/board/theobroma-systems/puma_rk3399/Kconfig b/board/theobroma-systems/puma_rk3399/Kconfig index a645590..1773648 100644 --- a/board/theobroma-systems/puma_rk3399/Kconfig +++ b/board/theobroma-systems/puma_rk3399/Kconfig @@ -12,4 +12,41 @@ config SYS_CONFIG_NAME config BOARD_SPECIFIC_OPTIONS # dummy def_bool y
+if SPL + +choice + prompt "RK3399-Q7 DRAM timings" + default SYS_TSD_PUMA_DDR3_1600 + help + The RK3399-Q7 module is orderable in multiple memory + configurations, which may also differ in the timings used. + + DDR3-1600 is the standard configuration, but both DDR3-1333 + (for potential cost-optimisation) and DDR3-1866 (as a + premium option) are fully validated in the design. + + The setting of this option is used to select the appropriate + timings for inclusion in the device tree controlling DRAM + initialisation during the board-initialisation performed by + the SPL stage. + +config SYS_TSD_PUMA_DDR3_1333 + bool "DDR3-1333 timings" + help + Use DDR3-1333 timings for the DRAM setup of the RK3399-Q7. + +config SYS_TSD_PUMA_DDR3_1600 + bool "DDR3-1600 timings" + help + Use DDR3-1600 timings for the DRAM setup of the RK3399-Q7. + +config SYS_TSD_PUMA_DDR3_1866 + bool "DDR3-1866 timings" + help + Use DDR3-1866 timings for the DRAM setup of the RK3399-Q7. + +endchoice + +endif + endif

On 31 May 2017 at 10:16, Philipp Tomsich philipp.tomsich@theobroma-systems.com wrote:
The RK3399-Q7 has multiple build-options for its DRAM configuration, including the timing of the DRAM components populated.
While DDR3-1600 is the standard configuration, custom-configurations are available with DDR3-1333 (for a further cost-optimisation) and with DDR3-1866 (as a premium option).
To simplify our test automation (without the need to maintain 3 different defconfigs) and customer evaluation, we make this selectable via Kconfig.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
arch/arm/dts/rk3399-puma.dts | 8 +++++++ board/theobroma-systems/puma_rk3399/Kconfig | 37 +++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org

Hi Philipp,
On 1 June 2017 at 20:55, Simon Glass sjg@chromium.org wrote:
On 31 May 2017 at 10:16, Philipp Tomsich philipp.tomsich@theobroma-systems.com wrote:
The RK3399-Q7 has multiple build-options for its DRAM configuration, including the timing of the DRAM components populated.
While DDR3-1600 is the standard configuration, custom-configurations are available with DDR3-1333 (for a further cost-optimisation) and with DDR3-1866 (as a premium option).
To simplify our test automation (without the need to maintain 3 different defconfigs) and customer evaluation, we make this selectable via Kconfig.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
arch/arm/dts/rk3399-puma.dts | 8 +++++++ board/theobroma-systems/puma_rk3399/Kconfig | 37 +++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org
Unfortunately this break various boards including firefly-rk3288.
Instead of the #ifdef can you please add a separate .dts for each variant, with each including a .dtsi with the rest of it?
Regards, Simon

Philipp,
On 06/01/2017 12:16 AM, Philipp Tomsich wrote:
Revise the loop watching for a timeout on obtaining a DRAM PHY lock to clearly state a timeout in milliseconds and use get_timer (based on the ARMv8 architected timer) to detect a timeout.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks, - Kever
arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c b/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c index 216a26c..4dd84e2 100644 --- a/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c +++ b/arch/arm/mach-rockchip/rk3399/sdram_rk3399.c @@ -5,6 +5,7 @@
- Adapted from coreboot.
*/
- #include <common.h> #include <clk.h> #include <dm.h>
@@ -19,6 +20,7 @@ #include <asm/arch/grf_rk3399.h> #include <asm/arch/hardware.h> #include <linux/err.h> +#include <time.h>
DECLARE_GLOBAL_DATA_PTR; struct chan_info { @@ -506,6 +508,7 @@ static int pctl_cfg(const struct chan_info *chan, u32 channel, u32 tmp, tmp1, tmp2; u32 pwrup_srefresh_exit; int ret;
const ulong timeout_ms = 200;
/*
- work around controller bug:
@@ -588,13 +591,15 @@ static int pctl_cfg(const struct chan_info *chan, u32 channel, clrsetbits_le32(&denali_phy[957], 0x3 << 24, 0x2 << 24);
/* Wating for PHY and DRAM init complete */
- tmp = 0;
- while (!(readl(&denali_ctl[203]) & (1 << 3))) {
mdelay(10);
tmp++;
if (tmp > 10)
- tmp = get_timer(0);
- do {
if (get_timer(tmp) > timeout_ms) {
error("DRAM (%s): phy failed to lock within %ld ms\n",
__func__, timeout_ms); return -ETIME;
- }
}
} while (!(readl(&denali_ctl[203]) & (1 << 3)));
debug("DRAM (%s): phy locked after %ld ms\n", __func__, get_timer(tmp));
clrsetbits_le32(&denali_ctl[68], PWRUP_SREFRESH_EXIT, pwrup_srefresh_exit);

On 31 May 2017 at 10:16, Philipp Tomsich philipp.tomsich@theobroma-systems.com wrote:
Revise the loop watching for a timeout on obtaining a DRAM PHY lock to clearly state a timeout in milliseconds and use get_timer (based on the ARMv8 architected timer) to detect a timeout.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

On 31 May 2017 at 10:16, Philipp Tomsich philipp.tomsich@theobroma-systems.com wrote:
Revise the loop watching for a timeout on obtaining a DRAM PHY lock to clearly state a timeout in milliseconds and use get_timer (based on the ARMv8 architected timer) to detect a timeout.
Signed-off-by: Philipp Tomsich philipp.tomsich@theobroma-systems.com
arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot-rockchip, thanks!
participants (4)
-
Kever Yang
-
Philipp Tomsich
-
Simon Glass
-
sjg@google.com