rockchip: Split sdram common function into sdram_common.c
Subsystems (3)
cover rockchip: Split sdram common function into sdram_common.c
Some function like the dram capability decode and dram_init() are the same for all Rockchip SoCs, maybe alaso cap detect function later, add sdram_common.c for all SoC driver.
Kever Yang (7):
rockchip: add sdram_common for common functions
rockchip: use common sdram function
rockchip: rk3328: add sdram driver in U-Boot
rockchip: rk3368: add sdram driver for U-Boot
rockchip: dts: rk3328: add dmc node
rockchip: dts: rk3368: add dmc node
rockchip: correct the bank0 ram size
arch/arm/dts/rk3328.dtsi | 7 ++ arch/arm/dts/rk3368.dtsi | 7 ++ arch/arm/include/asm/arch-rockchip/ddr_rk3288.h | 48 ----------- arch/arm/include/asm/arch-rockchip/grf_rk3368.h | 4 +- arch/arm/include/asm/arch-rockchip/sdram_common.h | 58 ++++++++++++++ arch/arm/mach-rockchip/Makefile | 3 + arch/arm/mach-rockchip/rk3188-board.c | 22 ----- arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 61 +++----------- arch/arm/mach-rockchip/rk3288-board.c | 22 ----- arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 74 +++++------------ arch/arm/mach-rockchip/rk3328/Makefile | 1 + arch/arm/mach-rockchip/rk3328/sdram_rk3328.c | 66 +++++++++++++++ arch/arm/mach-rockchip/rk3368/Makefile | 1 + arch/arm/mach-rockchip/rk3368/sdram_rk3368.c | 66 +++++++++++++++ arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 97 ++--------------------- arch/arm/mach-rockchip/sdram_common.c | 71 +++++++++++++++++ board/rockchip/evb_rk3328/evb-rk3328.c | 8 +- board/rockchip/evb_rk3399/evb-rk3399.c | 24 +----- board/rockchip/sheep_rk3368/sheep_rk3368.c | 9 +-- board/theobroma-systems/puma_rk3399/puma-rk3399.c | 24 +----- 20 files changed, 324 insertions(+), 349 deletions(-) create mode 100644 arch/arm/include/asm/arch-rockchip/sdram_common.h create mode 100644 arch/arm/mach-rockchip/rk3328/sdram_rk3328.c create mode 100644 arch/arm/mach-rockchip/rk3368/sdram_rk3368.c create mode 100644 arch/arm/mach-rockchip/sdram_common.c
Signature · 1 line
1.9.1
PATCH 1/7 rockchip: add sdram_common for common functions
There are some functions like sdram_size_mb can be re-used for different rockchip SoCs, just put them into common file.
---
arch/arm/include/asm/arch-rockchip/sdram_common.h | 58 ++++++++++++++++++ arch/arm/mach-rockchip/Makefile | 3 + arch/arm/mach-rockchip/sdram_common.c | 71 +++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 arch/arm/include/asm/arch-rockchip/sdram_common.h create mode 100644 arch/arm/mach-rockchip/sdram_common.c
arch/arm/include/asm/arch-rockchip/sdram_common.h new file +58 -0
@@ -0,0 +1,58 @@ +/* +* Copyright (C) 2017 Rockchip Electronics Co., Ltd. +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef _ASM_ARCH_SDRAM_COMMON_H +#define _ASM_ARCH_SDRAM_COMMON_H +/* +* sys_reg bitfield struct +* [31] row_3_4_ch1 +* [30] row_3_4_ch0 +* [29:28] chinfo +* [27] rank_ch1 +* [26:25] col_ch1 +* [24] bk_ch1 +* [23:22] cs0_row_ch1 +* [21:20] cs1_row_ch1 +* [19:18] bw_ch1 +* [17:16] dbw_ch1; +* [15:13] ddrtype +* [12] channelnum +* [11] rank_ch0 +* [10:9] col_ch0 +* [8] bk_ch0 +* [7:6] cs0_row_ch0 +* [5:4] cs1_row_ch0 +* [3:2] bw_ch0 +* [1:0] dbw_ch0 +*/ +#define SYS_REG_DDRTYPE_SHIFT 13 +#define SYS_REG_DDRTYPE_MASK 7 +#define SYS_REG_NUM_CH_SHIFT 12 +#define SYS_REG_NUM_CH_MASK 1 +#define SYS_REG_ROW_3_4_SHIFT (ch) (30 + (ch)) +#define SYS_REG_ROW_3_4_MASK 1 +#define SYS_REG_CHINFO_SHIFT (ch) (28 + (ch)) +#define SYS_REG_RANK_SHIFT (ch) (11 + (ch) * 16) +#define SYS_REG_RANK_MASK 1 +#define SYS_REG_COL_SHIFT (ch) (9 + (ch) * 16) +#define SYS_REG_COL_MASK 3 +#define SYS_REG_BK_SHIFT (ch) (8 + (ch) * 16) +#define SYS_REG_BK_MASK 1 +#define SYS_REG_CS0_ROW_SHIFT (ch) (6 + (ch) * 16) +#define SYS_REG_CS0_ROW_MASK 3 +#define SYS_REG_CS1_ROW_SHIFT (ch) (4 + (ch) * 16) +#define SYS_REG_CS1_ROW_MASK 3 +#define SYS_REG_BW_SHIFT (ch) (2 + (ch) * 16) +#define SYS_REG_BW_MASK 3 +#define SYS_REG_DBW_SHIFT (ch) ((ch) * 16) +#define SYS_REG_DBW_MASK 3 + +/* Get sdram size decode from reg */ +size_t rockchip_sdram_size (phys_addr_t reg); + +/* Called by U-Boot board_init_r for Rockchip SoCs */ +int dram_init (void ); +#endif
arch/arm/mach-rockchip/Makefile +3 -0
@@ -21,6 +21,9 @@ obj-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board.o obj-$(CONFIG_ROCKCHIP_RK322X) += rk322x-board.o obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board.o obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board.o +ifdef CONFIG_RAM +obj-y += sdram_common.o +endif endif ifndef CONFIG_ARM64 obj-y += rk_timer.o
arch/arm/mach-rockchip/sdram_common.c new file +71 -0
71 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 1/7 rockchip: add sdram_common for common functions
Hi Kever,
Quoted 4 lines · Kever Yang
There are some functions like
sdram_size_mbcan be re-used for different rockchip SoCs, just put them into common file.Signed-off-by Kever Yang <[email protected]>
Quoted 8 lines
---
arch/arm/include/asm/arch-rockchip/sdram_common.h | 58 ++++++++++++++++++ arch/arm/mach-rockchip/Makefile | 3 + arch/arm/mach-rockchip/sdram_common.c | 71 +++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 arch/arm/include/asm/arch-rockchip/sdram_common.h create mode 100644 arch/arm/mach-rockchip/sdram_common.c
As a follow-up patch, do you think we could change to shifted masks in this area?
PATCH 2/7 rockchip: use common sdram function
In reply to Kever YangReplace the sdram_init() in board init and rockchip_sdram_size() in sdram driver for all the Rockchip SoCs which enable CONFIG_RAM.
---
arch/arm/include/asm/arch-rockchip/ddr_rk3288.h | 48 ----------- arch/arm/mach-rockchip/rk3188-board.c | 22 ----- arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 61 +++----------- arch/arm/mach-rockchip/rk3288-board.c | 22 ----- arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 74 +++++------------ arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 97 ++--------------------- board/rockchip/evb_rk3328/evb-rk3328.c | 6 -- board/rockchip/evb_rk3399/evb-rk3399.c | 22 ----- board/rockchip/sheep_rk3368/sheep_rk3368.c | 7 -- board/theobroma-systems/puma_rk3399/puma-rk3399.c | 22 ----- 10 files changed, 37 insertions(+), 344 deletions(-)
arch/arm/include/asm/arch-rockchip/ddr_rk3288.h +0 -48
@@ -441,52 +441,4 @@ enum {/* mr1 for ddr3 */ #define DDR3_DLL_DISABLE 1 -/* -*TODO(sjg at chromium.org): We use a PMU register to store SDRAM information for -* passing from SPL to U-Boot. It would probably be better to use a normal C -* structure in SRAM. -* -* sys_reg bitfield struct -* [31] row_3_4_ch1 -* [30] row_3_4_ch0 -* [29:28] chinfo -* [27] rank_ch1 -* [26:25] col_ch1 -* [24] bk_ch1 -* [23:22] cs0_row_ch1 -* [21:20] cs1_row_ch1 -* [19:18] bw_ch1 -* [17:16] dbw_ch1; -* [15:13] ddrtype -* [12] channelnum -* [11] rank_ch0 -* [10:9] col_ch0 -* [8] bk_ch0 -* [7:6] cs0_row_ch0 -* [5:4] cs1_row_ch0 -* [3:2] bw_ch0 -* [1:0] dbw_ch0 -*/ -#define SYS_REG_DDRTYPE_SHIFT 13 -#define SYS_REG_DDRTYPE_MASK 7 -#define SYS_REG_NUM_CH_SHIFT 12 -#define SYS_REG_NUM_CH_MASK 1 -#define SYS_REG_ROW_3_4_SHIFT (ch) (30 + (ch)) -#define SYS_REG_ROW_3_4_MASK 1 -#define SYS_REG_CHINFO_SHIFT (ch) (28 + (ch)) -#define SYS_REG_RANK_SHIFT (ch) (11 + (ch) * 16) -#define SYS_REG_RANK_MASK 1 -#define SYS_REG_COL_SHIFT (ch) (9 + (ch) * 16) -#define SYS_REG_COL_MASK 3 -#define SYS_REG_BK_SHIFT (ch) (8 + (ch) * 16) -#define SYS_REG_BK_MASK 1 -#define SYS_REG_CS0_ROW_SHIFT (ch) (6 + (ch) * 16) -#define SYS_REG_CS0_ROW_MASK 3 -#define SYS_REG_CS1_ROW_SHIFT (ch) (4 + (ch) * 16) -#define SYS_REG_CS1_ROW_MASK 3 -#define SYS_REG_BW_SHIFT (ch) (2 + (ch) * 16) -#define SYS_REG_BW_MASK 3 -#define SYS_REG_DBW_SHIFT (ch) ((ch) * 16) -#define SYS_REG_DBW_MASK 3 -#endif
arch/arm/mach-rockchip/rk3188-board.c +0 -22
@@ -72,28 +72,6 @@ err:#endif } -int dram_init (void ) -{ -struct ram_info ram; -struct udevice *dev; -int ret; - - ret =uclass_get_device (UCLASS_RAM ,0 , &dev); -if (ret) { -debug ("DRAM init failed: %d\n" , ret); -return ret; - } - ret =ram_get_info (dev, &ram); -if (ret) { -debug ("Cannot get DRAM size: %d\n" , ret); -return ret; - } -debug ("SDRAM base=%lx, size=%x\n" , ram.base, ram.size); - gd->ram_size = ram.size; - -return 0 ; -} -#ifndef CONFIG_SYS_DCACHE_OFF void enable_caches (void ) {
arch/arm/mach-rockchip/rk3188/sdram_rk3188.c +10 -51
102 lines not on this page · raw message
arch/arm/mach-rockchip/rk3288-board.c +0 -22
@@ -155,28 +155,6 @@ err:#endif } -int dram_init (void ) -{ -struct ram_info ram; -struct udevice *dev; -int ret; - - ret =uclass_get_device (UCLASS_RAM ,0 , &dev); -if (ret) { -debug ("DRAM init failed: %d\n" , ret); -return ret; - } - ret =ram_get_info (dev, &ram); -if (ret) { -debug ("Cannot get DRAM size: %d\n" , ret); -return ret; - } -debug ("SDRAM base=%lx, size=%x\n" , ram.base, ram.size); - gd->ram_size = ram.size; - -return 0 ; -} -#ifndef CONFIG_SYS_DCACHE_OFF void enable_caches (void ) {
arch/arm/mach-rockchip/rk3288/sdram_rk3288.c +19 -55
117 lines not on this page · raw message
arch/arm/mach-rockchip/rk3399/sdram_rk3399.c +8 -89
121 lines not on this page · raw message
board/rockchip/evb_rk3328/evb-rk3328.c +0 -6
@@ -16,12 +16,6 @@ int board_init(void)return 0 ; } -int dram_init (void ) -{ - gd->ram_size =0x80000000 ; -return 0 ; -} -int dram_init_banksize (void ) {/* Reserve 0x200000 for ATF bl31 */
board/rockchip/evb_rk3399/evb-rk3399.c +0 -22
@@ -68,28 +68,6 @@ out:return 0 ; } -int dram_init (void ) -{ -struct ram_info ram; -struct udevice *dev; -int ret; - - ret =uclass_get_device (UCLASS_RAM ,0 , &dev); -if (ret) { -debug ("DRAM init failed: %d\n" , ret); -return ret; - } - ret =ram_get_info (dev, &ram); -if (ret) { -debug ("Cannot get DRAM size: %d\n" , ret); -return ret; - } -debug ("SDRAM base=%llx, size=%x\n" , ram.base, (unsigned int )ram.size); - gd->ram_size = ram.size; - -return 0 ; -} -int dram_init_banksize (void ) {/* Reserve 0x200000 for ATF bl31 */
board/rockchip/sheep_rk3368/sheep_rk3368.c +0 -7
@@ -21,13 +21,6 @@ int board_init(void)return 0 ; } -int dram_init (void ) -{ - gd->ram_size =0x80000000 ; - -return 0 ; -} -int dram_init_banksize (void ) { gd->bd->bi_dram[0 ].start =0x200000 ;
board/theobroma-systems/puma_rk3399/puma-rk3399.c +0 -22
@@ -181,28 +181,6 @@ void get_board_serial(struct tag_serialnr *serialnr) }#endif -int dram_init (void ) -{ -struct ram_info ram; -struct udevice *dev; -int ret; - - ret =uclass_get_device (UCLASS_RAM ,0 , &dev); -if (ret) { -debug ("DRAM init failed: %d\n" , ret); -return ret; - } - ret =ram_get_info (dev, &ram); -if (ret) { -debug ("Cannot get DRAM size: %d\n" , ret); -return ret; - } -debug ("SDRAM base=%llx, size=%x\n" , ram.base, (unsigned int )ram.size); - gd->ram_size = ram.size; - -return 0 ; -} -int dram_init_banksize (void ) {/* Reserve 0x200000 for ATF bl31 */
Signature · 1 line
1.9.1
PATCH 2/7 rockchip: use common sdram function
Quoted 6 lines · Kever Yang
Replace the
sdram_init()in board init androckchip_sdram_size()in sdram driver for all the Rockchip SoCs which enableCONFIG_RAM.Signed-off-by Kever Yang <[email protected]>---
Quoted 11 lines
arch/arm/include/asm/arch-rockchip/ddr_rk3288.h | 48 ----------- arch/arm/mach-rockchip/rk3188-board.c | 22 ----- arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 61 +++----------- arch/arm/mach-rockchip/rk3288-board.c | 22 ----- arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 74 +++++------------ arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 97 ++--------------------- board/rockchip/evb_rk3328/evb-rk3328.c | 6 -- board/rockchip/evb_rk3399/evb-rk3399.c | 22 ----- board/rockchip/sheep_rk3368/sheep_rk3368.c | 7 -- board/theobroma-systems/puma_rk3399/puma-rk3399.c | 22 ----- 10 files changed, 37 insertions(+), 344 deletions(-)
Quite a few changes here but it looks sane.
PATCH 3/7 rockchip: rk3328: add sdram driver in U-Boot
In reply to Kever YangAdd sdram driver in U-Boot for get the correct sdram size from sys_reg, so that U-Boot can co-work with Rockchip loader or SPL to get different dram capability and then tell the kernel.
---
arch/arm/mach-rockchip/rk3328/Makefile | 1 + arch/arm/mach-rockchip/rk3328/sdram_rk3328.c | 66 ++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 arch/arm/mach-rockchip/rk3328/sdram_rk3328.c
arch/arm/mach-rockchip/rk3328/Makefile +1 -0
@@ -6,4 +6,5 @@ obj-y += clk_rk3328.o obj-y += rk3328.o +obj-y += sdram_rk3328.o obj-y += syscon_rk3328.o
arch/arm/mach-rockchip/rk3328/sdram_rk3328.c new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 3/7 rockchip: rk3328: add sdram driver in U-Boot
Quoted 3 lines · Kever Yang
Add sdram driver in U-Boot for get the correct sdram size from
sys_reg, so that U-Boot can co-work with Rockchip loader or SPL to get different dram capability and then tell the kernel.
Do you think we might be able to retire the Rockchip loader one day?
Quoted 8 lines
Signed-off-by Kever Yang <[email protected]>---
arch/arm/mach-rockchip/rk3328/Makefile | 1 + arch/arm/mach-rockchip/rk3328/sdram_rk3328.c | 66 ++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 arch/arm/mach-rockchip/rk3328/sdram_rk3328.c
PATCH 3/7 rockchip: rk3328: add sdram driver in U-Boot
Hi Simon,
Quoted 5 lines · Simon Glass
Quoted 3 lines · Kever Yang
Add sdram driver in U-Boot for get the correct sdram size from
sys_reg, so that U-Boot can co-work with Rockchip loader or SPL to get different dram capability and then tell the kernel.Do you think we might be able to retire the Rockchip loader one day?
If the feature and performance is almost the same, then Rockchip loader is no need any more, and that's what I'm try to do.
- rockcusb & fastboot gadget performance, as I have comment in Eddie's patch long
time ago, the dfu in U-Boot is using single buffer, which is very
slow compare
to mass storage gadget.
- Android boot, it's still not have full support for Android image like recovery in U-Boot now.
- Secure boot, I have not verify this part on upstream U-Boot, but rockchip needs it.
- some other feature used by our product
Thanks,
- Kever
Quoted 10 lines
Quoted 8 lines
Signed-off-by Kever Yang <[email protected]>---
arch/arm/mach-rockchip/rk3328/Makefile | 1 + arch/arm/mach-rockchip/rk3328/sdram_rk3328.c | 66 ++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)create mode 100644
arch/arm/mach-rockchip/rk3328/sdram_rk3328.cReviewed-by Simon Glass <[email protected]>
PATCH 3/7 rockchip: rk3328: add sdram driver in U-Boot
Hi Kever,
Quoted 14 lines · Kever Yang
Hi Simon,
Quoted 8 lines · Simon Glass
Quoted 4 lines · Kever Yang
Add sdram driver in U-Boot for get the correct sdram size from
sys_reg, so that U-Boot can co-work with Rockchip loader or SPL to get different dram capability and then tell the kernel.Do you think we might be able to retire the Rockchip loader one day?
Quoted 12 lines
If the feature and performance is almost the same, then Rockchip loader is no need any more, and that's what I'm try to do.
- rockcusb & fastboot gadget performance, as I have comment in Eddie's patch long
time ago, the dfu in U-Boot is using single buffer, which is very slow
compare
to mass storage gadget.
- Android boot, it's still not have full support for Android image like recovery in U-Boot now.
- Secure boot, I have not verify this part on upstream U-Boot, but rockchip needs it.
- some other feature used by our product
OK, good to know the plan, thank you. Hopefully there are no obstacles to getting all the above features into mainline.
Regards,
Simon
PATCH 4/7 rockchip: rk3368: add sdram driver for U-Boot
In reply to Kever YangAdd sdram driver in U-Boot for get the correct sdram size from sys_reg, so that U-Boot can co-work with Rockchip loader or SPL to get different dram capability and then tell the kernel.
---
arch/arm/include/asm/arch-rockchip/grf_rk3368.h | 4 +- arch/arm/mach-rockchip/rk3368/Makefile | 1 + arch/arm/mach-rockchip/rk3368/sdram_rk3368.c | 66 +++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-rockchip/rk3368/sdram_rk3368.c
arch/arm/include/asm/arch-rockchip/grf_rk3368.h +3 -1
@@ -92,8 +92,10 @@ struct rk3368_pmu_grf {u32 gpio0d_drv;u32 gpio0l_sr;u32 gpio0h_sr; +u32 reserved[(0x200 -0x34 ) /4 -1 ]; +u32 os_reg[4 ]; }; -check_member (rk3368_pmu_grf, gpio0h_sr,0x34 ); +check_member (rk3368_pmu_grf, os_reg[3 ],0x20c );/*GRF_GPIO0C_IOMUX*/ enum {
arch/arm/mach-rockchip/rk3368/Makefile +1 -0
@@ -5,4 +5,5 @@ # obj-y += clk_rk3368.o obj-y += rk3368.o +obj-y += sdram_rk3368.o obj-y += syscon_rk3368.o
arch/arm/mach-rockchip/rk3368/sdram_rk3368.c new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 4/7 rockchip: rk3368: add sdram driver for U-Boot
Quoted 4 lines · Kever Yang
Add sdram driver in U-Boot for get the correct sdram size from
sys_reg, so that U-Boot can co-work with Rockchip loader or SPL to get different dram capability and then tell the kernel.
Quoted 8 lines
Signed-off-by Kever Yang <[email protected]>---
arch/arm/include/asm/arch-rockchip/grf_rk3368.h | 4 +- arch/arm/mach-rockchip/rk3368/Makefile | 1 + arch/arm/mach-rockchip/rk3368/sdram_rk3368.c | 66 +++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-rockchip/rk3368/sdram_rk3368.c
PATCH 5/7 rockchip: dts: rk3328: add dmc node
In reply to Kever YangAdd a dmc node for sdram driver.
---
arch/arm/dts/rk3328.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/dts/rk3328.dtsi +7 -0
@@ -184,6 +184,7 @@ }; grf: syscon at ff100000 { + u-boot,dm-pre-reloc; compatible = "rockchip,rk3328-grf", "syscon", "simple-mfd"; reg = <0x0 0xff100000 0x0 0x1000>; #address-cells = <1>;
@@ -350,6 +351,12 @@ status = "disabled"; }; + dmc: dmc at ff400000 { + u-boot,dm-pre-reloc; + compatible = "rockchip,rk3328-dmc", "syscon"; + reg = <0x0 0xff400000 0x0 0x1000>; + }; + cru: clock-controller at ff440000 { compatible = "rockchip,rk3328-cru", "rockchip,cru", "syscon"; reg = <0x0 0xff440000 0x0 0x1000>;
Signature · 1 line
1.9.1
PATCH 5/7 rockchip: dts: rk3328: add dmc node
Quoted 7 lines · Kever Yang
Add a dmc node for sdram driver.
Signed-off-by Kever Yang <[email protected]>---
arch/arm/dts/rk3328.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
PATCH 6/7 rockchip: dts: rk3368: add dmc node
In reply to Kever YangAdd dmc node to enable sdram driver.
---
arch/arm/dts/rk3368.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/dts/rk3368.dtsi +7 -0
@@ -546,6 +546,12 @@ status = "disabled"; }; + dmc: dmc at ff610000 { + u-boot,dm-pre-reloc; + compatible = "rockchip,rk3368-dmc", "syscon"; + reg = <0x0 0xff610000 0x0 0x1000>; + }; + i2c0: i2c at ff650000 { compatible = "rockchip,rk3368-i2c", "rockchip,rk3288-i2c"; reg = <0x0 0xff650000 0x0 0x1000>;
@@ -641,6 +647,7 @@ }; pmugrf: syscon at ff738000 { + u-boot,dm-pre-reloc; compatible = "rockchip,rk3368-pmugrf", "syscon"; reg = <0x0 0xff738000 0x0 0x1000>; };
Signature · 1 line
1.9.1
PATCH 6/7 rockchip: dts: rk3368: add dmc node
Quoted 7 lines · Kever Yang
Add dmc node to enable sdram driver.
Signed-off-by Kever Yang <[email protected]>---
arch/arm/dts/rk3368.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
PATCH 7/7 rockchip: correct the bank0 ram size
In reply to Kever YangThe bank0 ram size should be the DRAM size minus reserved size, the DRAM size may be 1GB, 2GB, 4GB, we can not hard code it.
---
board/rockchip/evb_rk3328/evb-rk3328.c | 2 +- board/rockchip/evb_rk3399/evb-rk3399.c | 2 +- board/rockchip/sheep_rk3368/sheep_rk3368.c | 2 +- board/theobroma-systems/puma_rk3399/puma-rk3399.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
board/rockchip/evb_rk3328/evb-rk3328.c +1 -1
@@ -20,7 +20,7 @@ int dram_init_banksize(void) {/* Reserve 0x200000 for ATF bl31 */ gd->bd->bi_dram[0 ].start =0x200000 ; - gd->bd->bi_dram[0 ].size =0x7e000000 ; + gd->bd->bi_dram[0 ].size = gd->ram_size - gd->bd->bi_dram[0 ].start;return 0 ; }
board/rockchip/evb_rk3399/evb-rk3399.c +1 -1
@@ -72,7 +72,7 @@ int dram_init_banksize(void) {/* Reserve 0x200000 for ATF bl31 */ gd->bd->bi_dram[0 ].start =0x200000 ; - gd->bd->bi_dram[0 ].size =0x7e000000 ; + gd->bd->bi_dram[0 ].size = gd->ram_size - gd->bd->bi_dram[0 ].start;return 0 ; }
board/rockchip/sheep_rk3368/sheep_rk3368.c +1 -1
@@ -24,7 +24,7 @@ int board_init(void)int dram_init_banksize (void ) { gd->bd->bi_dram[0 ].start =0x200000 ; - gd->bd->bi_dram[0 ].size =0x7fe00000 ; + gd->bd->bi_dram[0 ].size = gd->ram_size - gd->bd->bi_dram[0 ].start;return 0 ; }
board/theobroma-systems/puma_rk3399/puma-rk3399.c +1 -1
@@ -185,7 +185,7 @@ int dram_init_banksize(void) {/* Reserve 0x200000 for ATF bl31 */ gd->bd->bi_dram[0 ].start =0x200000 ; - gd->bd->bi_dram[0 ].size =0x7e000000 ; + gd->bd->bi_dram[0 ].size = gd->ram_size - gd->bd->bi_dram[0 ].start;return 0 ; }
Signature · 1 line
1.9.1
PATCH 7/7 rockchip: correct the bank0 ram size
Quoted 11 lines · Kever Yang
The bank0 ram size should be the DRAM size minus reserved size, the DRAM size may be 1GB, 2GB, 4GB, we can not hard code it.
Signed-off-by Kever Yang <[email protected]>---
board/rockchip/evb_rk3328/evb-rk3328.c | 2 +- board/rockchip/evb_rk3399/evb-rk3399.c | 2 +- board/rockchip/sheep_rk3368/sheep_rk3368.c | 2 +- board/theobroma-systems/puma_rk3399/puma-rk3399.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
cover rockchip: Split sdram common function into sdram_common.c
In reply to Kever YangKever,
thanks a lot! I had just started to work on RK3368 SPL code and the DDR controller would have been next on the list…
You saved me quite a bit of work there.
Regards,
Philipp.
Quoted 47 lines · Kever Yang
Some function like the dram capability decode and
dram_init()are the same for all Rockchip SoCs, maybe alaso cap detect function later, addsdram_common.cfor all SoC driver.Kever Yang (7):
rockchip: addsdram_commonfor common functions
rockchip: use common sdram function
rockchip: rk3328: add sdram driver in U-Boot
rockchip: rk3368: add sdram driver for U-Boot
rockchip: dts: rk3328: add dmc node
rockchip: dts: rk3368: add dmc node
rockchip: correct the bank0 ram sizearch/arm/dts/rk3328.dtsi | 7 ++ arch/arm/dts/rk3368.dtsi | 7 ++ arch/arm/include/asm/arch-rockchip/ddr_rk3288.h | 48 ----------- arch/arm/include/asm/arch-rockchip/grf_rk3368.h | 4 +- arch/arm/include/asm/arch-rockchip/sdram_common.h | 58 ++++++++++++++ arch/arm/mach-rockchip/Makefile | 3 + arch/arm/mach-rockchip/rk3188-board.c | 22 ----- arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 61 +++----------- arch/arm/mach-rockchip/rk3288-board.c | 22 ----- arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 74 +++++------------ arch/arm/mach-rockchip/rk3328/Makefile | 1 + arch/arm/mach-rockchip/rk3328/sdram_rk3328.c | 66 +++++++++++++++ arch/arm/mach-rockchip/rk3368/Makefile | 1 + arch/arm/mach-rockchip/rk3368/sdram_rk3368.c | 66 +++++++++++++++ arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 97 ++--------------------- arch/arm/mach-rockchip/sdram_common.c | 71 +++++++++++++++++ board/rockchip/evb_rk3328/evb-rk3328.c | 8 +- board/rockchip/evb_rk3399/evb-rk3399.c | 24 +----- board/rockchip/sheep_rk3368/sheep_rk3368.c | 9 +-- board/theobroma-systems/puma_rk3399/puma-rk3399.c | 24 +----- 20 files changed, 324 insertions(+), 349 deletions(-)create mode 100644
arch/arm/include/asm/arch-rockchip/sdram_common.hcreate mode 100644arch/arm/mach-rockchip/rk3328/sdram_rk3328.ccreate mode 100644arch/arm/mach-rockchip/rk3368/sdram_rk3368.ccreate mode 100644arch/arm/mach-rockchip/sdram_common.cSignature · 1 line
1.9.1
Heiko Stübner
maintainercover rockchip: Split sdram common function into sdram_common.c
Am Dienstag, 13. Juni 2017, 11:31:53 CEST schrieb Dr. Philipp Tomsich:
Quoted 5 lines
Kever,
thanks a lot! I had just started to work on RK3368 SPL code and the DDR controller would have been next on the list…
You saved me quite a bit of work there.
Although the sdram drivers for rk3328 and rk3368 only seem to provide the non-spl portions for now.
Kever, is there a rough time estimate for spl support for these socs? (Got a rk3328-rock64 sample yesterday, so would be interested on getting a mainline u-boot to run on it)
Thanks
Heiko
Quoted 46 lines
Regards,
Philipp.Quoted 42 lines · Kever Yang
Some function like the dram capability decode and
dram_init()are the same for all Rockchip SoCs, maybe alaso cap detect function later, addsdram_common.cfor all SoC driver.Kever Yang (7):
rockchip: addsdram_commonfor common functions
rockchip: use common sdram function
rockchip: rk3328: add sdram driver in U-Boot
rockchip: rk3368: add sdram driver for U-Boot
rockchip: dts: rk3328: add dmc node
rockchip: dts: rk3368: add dmc node
rockchip: correct the bank0 ram sizearch/arm/dts/rk3328.dtsi | 7 ++ arch/arm/dts/rk3368.dtsi | 7 ++ arch/arm/include/asm/arch-rockchip/ddr_rk3288.h | 48 ----------- arch/arm/include/asm/arch-rockchip/grf_rk3368.h | 4 +- arch/arm/include/asm/arch-rockchip/sdram_common.h | 58 ++++++++++++++ arch/arm/mach-rockchip/Makefile | 3 + arch/arm/mach-rockchip/rk3188-board.c | 22 ----- arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 61 +++----------- arch/arm/mach-rockchip/rk3288-board.c | 22 ----- arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 74 +++++------------ arch/arm/mach-rockchip/rk3328/Makefile | 1 + arch/arm/mach-rockchip/rk3328/sdram_rk3328.c | 66 +++++++++++++++ arch/arm/mach-rockchip/rk3368/Makefile | 1 + arch/arm/mach-rockchip/rk3368/sdram_rk3368.c | 66 +++++++++++++++ arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 97 ++--------------------- arch/arm/mach-rockchip/sdram_common.c | 71 +++++++++++++++++ board/rockchip/evb_rk3328/evb-rk3328.c | 8 +- board/rockchip/evb_rk3399/evb-rk3399.c | 24 +----- board/rockchip/sheep_rk3368/sheep_rk3368.c | 9 +-- board/theobroma-systems/puma_rk3399/puma-rk3399.c | 24 +----- 20 files changed, 324 insertions(+), 349 deletions(-)create mode 100644
arch/arm/include/asm/arch-rockchip/sdram_common.hcreate mode 100644arch/arm/mach-rockchip/rk3328/sdram_rk3328.ccreate mode 100644arch/arm/mach-rockchip/rk3368/sdram_rk3368.ccreate mode 100644arch/arm/mach-rockchip/sdram_common.c
cover rockchip: Split sdram common function into sdram_common.c
I just realised this myself after pulling it into my tree to take a closer look and possibly give it a spin… my euphoria was gone rather quickly.
Since I have SPL set up for the 3368 and have all the "necessary notes” (which usually leads into the realisation that there’s necessary and sufficient are two very distinct concepts) on my desk to write the DRAM init code for it, I might as well sit down and continue down this path.
We have quite a few RK3368-uQ7 modules in the lab—so having mainline U-Boot support is becoming a priority.
Quoted 68 lines · Heiko Stübner
Am Dienstag, 13. Juni 2017, 11:31:53 CEST schrieb Dr. Philipp Tomsich:
Quoted 5 lines
Kever,
thanks a lot! I had just started to work on RK3368 SPL code and the DDR controller would have been next on the list…
You saved me quite a bit of work there.Although the sdram drivers for rk3328 and rk3368 only seem to provide the non-spl portions for now.
Kever, is there a rough time estimate for spl support for these socs? (Got a rk3328-rock64 sample yesterday, so would be interested on getting a mainline u-boot to run on it)
Thanks
HeikoQuoted 46 lines
Regards,
Philipp.Quoted 42 lines · Kever Yang
Some function like the dram capability decode and
dram_init()are the same for all Rockchip SoCs, maybe alaso cap detect function later, addsdram_common.cfor all SoC driver.Kever Yang (7):
rockchip: addsdram_commonfor common functions
rockchip: use common sdram function
rockchip: rk3328: add sdram driver in U-Boot
rockchip: rk3368: add sdram driver for U-Boot
rockchip: dts: rk3328: add dmc node
rockchip: dts: rk3368: add dmc node
rockchip: correct the bank0 ram sizearch/arm/dts/rk3328.dtsi | 7 ++ arch/arm/dts/rk3368.dtsi | 7 ++ arch/arm/include/asm/arch-rockchip/ddr_rk3288.h | 48 ----------- arch/arm/include/asm/arch-rockchip/grf_rk3368.h | 4 +- arch/arm/include/asm/arch-rockchip/sdram_common.h | 58 ++++++++++++++ arch/arm/mach-rockchip/Makefile | 3 + arch/arm/mach-rockchip/rk3188-board.c | 22 ----- arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 61 +++----------- arch/arm/mach-rockchip/rk3288-board.c | 22 ----- arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 74 +++++------------ arch/arm/mach-rockchip/rk3328/Makefile | 1 + arch/arm/mach-rockchip/rk3328/sdram_rk3328.c | 66 +++++++++++++++ arch/arm/mach-rockchip/rk3368/Makefile | 1 + arch/arm/mach-rockchip/rk3368/sdram_rk3368.c | 66 +++++++++++++++ arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 97 ++--------------------- arch/arm/mach-rockchip/sdram_common.c | 71 +++++++++++++++++ board/rockchip/evb_rk3328/evb-rk3328.c | 8 +- board/rockchip/evb_rk3399/evb-rk3399.c | 24 +----- board/rockchip/sheep_rk3368/sheep_rk3368.c | 9 +-- board/theobroma-systems/puma_rk3399/puma-rk3399.c | 24 +----- 20 files changed, 324 insertions(+), 349 deletions(-)create mode 100644
arch/arm/include/asm/arch-rockchip/sdram_common.hcreate mode 100644arch/arm/mach-rockchip/rk3328/sdram_rk3328.ccreate mode 100644arch/arm/mach-rockchip/rk3368/sdram_rk3368.ccreate mode 100644arch/arm/mach-rockchip/sdram_common.c
cover rockchip: Split sdram common function into sdram_common.c
In reply to Heiko StübnerHeiko,
Quoted 10 lines · Heiko Stübner
Am Dienstag, 13. Juni 2017, 11:31:53 CEST schrieb Dr. Philipp Tomsich:
Quoted 5 lines
Kever,
thanks a lot! I had just started to work on RK3368 SPL code and the DDR controller would have been next on the list…
You saved me quite a bit of work there.Although the sdram drivers for rk3328 and rk3368 only seem to provide the non-spl portions for now.
Kever, is there a rough time estimate for spl support for these socs?
No, I would like to provide them ASAP, but I don't get enough hands now :( so I decide to make the U-Boot recognize correct DRAM size first which is the
most important.
Quoted 2 lines
(Got a rk3328-rock64 sample yesterday, so would be interested on getting a mainline u-boot to run on it)
You can run mainline u-boot now already, just need to using Rockchip loader instead of SPL before U-Boot.
Thanks,
- Kever
Quoted 52 lines
Thanks
HeikoQuoted 45 lines
Regards,
Philipp.Quoted 42 lines · Kever Yang
Some function like the dram capability decode and
dram_init()are the same for all Rockchip SoCs, maybe alaso cap detect function later, addsdram_common.cfor all SoC driver.Kever Yang (7):
rockchip: addsdram_commonfor common functions
rockchip: use common sdram function
rockchip: rk3328: add sdram driver in U-Boot
rockchip: rk3368: add sdram driver for U-Boot
rockchip: dts: rk3328: add dmc node
rockchip: dts: rk3368: add dmc node
rockchip: correct the bank0 ram sizearch/arm/dts/rk3328.dtsi | 7 ++ arch/arm/dts/rk3368.dtsi | 7 ++ arch/arm/include/asm/arch-rockchip/ddr_rk3288.h | 48 ----------- arch/arm/include/asm/arch-rockchip/grf_rk3368.h | 4 +- arch/arm/include/asm/arch-rockchip/sdram_common.h | 58 ++++++++++++++ arch/arm/mach-rockchip/Makefile | 3 + arch/arm/mach-rockchip/rk3188-board.c | 22 ----- arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 61 +++----------- arch/arm/mach-rockchip/rk3288-board.c | 22 ----- arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 74 +++++------------ arch/arm/mach-rockchip/rk3328/Makefile | 1 + arch/arm/mach-rockchip/rk3328/sdram_rk3328.c | 66 +++++++++++++++ arch/arm/mach-rockchip/rk3368/Makefile | 1 + arch/arm/mach-rockchip/rk3368/sdram_rk3368.c | 66 +++++++++++++++ arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 97 ++--------------------- arch/arm/mach-rockchip/sdram_common.c | 71 +++++++++++++++++ board/rockchip/evb_rk3328/evb-rk3328.c | 8 +- board/rockchip/evb_rk3399/evb-rk3399.c | 24 +----- board/rockchip/sheep_rk3368/sheep_rk3368.c | 9 +-- board/theobroma-systems/puma_rk3399/puma-rk3399.c | 24 +----- 20 files changed, 324 insertions(+), 349 deletions(-)create mode 100644
arch/arm/include/asm/arch-rockchip/sdram_common.hcreate mode 100644arch/arm/mach-rockchip/rk3328/sdram_rk3328.ccreate mode 100644arch/arm/mach-rockchip/rk3368/sdram_rk3368.ccreate mode 100644arch/arm/mach-rockchip/sdram_common.c
cover rockchip: Split sdram common function into sdram_common.c
Heiko & Kever,
just a quick update (to avoid any duplication of effort)…
We have implemented DRAM initialisation in UBoot/SPL for the RK3368-uQ7 already, but it will be a few more days before we can provide patches (the SPL stage is hopelessly large once we MMC support in SPL is enabled … so this first needs back-to-bootrom working).
The first drop from our side will be 32bits, dual-rank — auto-detection of ranks and width will come in later, once I receive modified hardware (i.e. (a) with CS1 held high; (b) with half the memory removed for 16bit mode) from my colleagues.
Regards,
Philipp.
Quoted 29 lines · Kever Yang
Heiko,
Quoted 10 lines · Heiko Stübner
Am Dienstag, 13. Juni 2017, 11:31:53 CEST schrieb Dr. Philipp Tomsich:
Quoted 5 lines
Kever,
thanks a lot! I had just started to work on RK3368 SPL code and the DDR controller would have been next on the list…
You saved me quite a bit of work there.Although the sdram drivers for rk3328 and rk3368 only seem to provide the non-spl portions for now.
Kever, is there a rough time estimate for spl support for these socs?
No, I would like to provide them ASAP, but I don't get enough hands now :( so I decide to make the U-Boot recognize correct DRAM size first which is the most important.
Quoted 2 lines
(Got a rk3328-rock64 sample yesterday, so would be interested on getting a mainline u-boot to run on it)
You can run mainline u-boot now already, just need to using Rockchip loader instead of SPL before U-Boot.
Thanks,
- Kever
cover rockchip: Split sdram common function into sdram_common.c
In reply to Kever YangHi Kever:
Quoted 36 lines · Kever Yang
Some function like the dram capability decode and
dram_init()are the same for all Rockchip SoCs, maybe alaso cap detect function later, addsdram_common.cfor all SoC driver.Kever Yang (7):
rockchip: addsdram_commonfor common functions
rockchip: use common sdram function
rockchip: rk3328: add sdram driver in U-Boot
rockchip: rk3368: add sdram driver for U-Boot
rockchip: dts: rk3328: add dmc node
rockchip: dts: rk3368: add dmc node
rockchip: correct the bank0 ram sizearch/arm/dts/rk3328.dtsi | 7 ++ arch/arm/dts/rk3368.dtsi | 7 ++ arch/arm/include/asm/arch-rockchip/ddr_rk3288.h | 48 ----------- arch/arm/include/asm/arch-rockchip/grf_rk3368.h | 4 +- arch/arm/include/asm/arch-rockchip/sdram_common.h | 58 ++++++++++++++ arch/arm/mach-rockchip/Makefile | 3 + arch/arm/mach-rockchip/rk3188-board.c | 22 ----- arch/arm/mach-rockchip/rk3188/sdram_rk3188.c | 61 +++----------- arch/arm/mach-rockchip/rk3288-board.c | 22 ----- arch/arm/mach-rockchip/rk3288/sdram_rk3288.c | 74 +++++------------ arch/arm/mach-rockchip/rk3328/Makefile | 1 + arch/arm/mach-rockchip/rk3328/sdram_rk3328.c | 66 +++++++++++++++ arch/arm/mach-rockchip/rk3368/Makefile | 1 + arch/arm/mach-rockchip/rk3368/sdram_rk3368.c | 66 +++++++++++++++ arch/arm/mach-rockchip/rk3399/sdram_rk3399.c | 97 ++--------------------- arch/arm/mach-rockchip/sdram_common.c | 71 +++++++++++++++++ board/rockchip/evb_rk3328/evb-rk3328.c | 8 +- board/rockchip/evb_rk3399/evb-rk3399.c | 24 +----- board/rockchip/sheep_rk3368/sheep_rk3368.c | 9 +-- board/theobroma-systems/puma_rk3399/puma-rk3399.c | 24 +----- 20 files changed, 324 insertions(+), 349 deletions(-)
Quoted 4 lines
create mode 100644
arch/arm/include/asm/arch-rockchip/sdram_common.hcreate mode 100644arch/arm/mach-rockchip/rk3328/sdram_rk3328.ccreate mode 100644arch/arm/mach-rockchip/rk3368/sdram_rk3368.ccreate mode 100644arch/arm/mach-rockchip/sdram_common.c
This function tested ok on RK3368 based platform, but it seems that
you have missed the support for PX5 EVB , GeekBox and RV1108.
Another things is that I seen the following warning when compile:
In file included from/home/andy/WorkSpace/U-BOOT/u-boot/arch/arm/mach-rockchip/sdram_common.c:7:0:/home/andy/WorkSpace/U-BOOT/u-boot/arch/arm/mach-rockchip/sdram_common.c:
In function ‘dram_init’:/home/andy/WorkSpace/U-BOOT/u-boot/arch/arm/mach-rockchip/sdram_common.c:67:8:
warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘phys_addr_t {aka long long unsigned int}’ [-Wformat=]
debug("SDRAM base=%lx, size=%x\n", ram.base, ram.size);
^
/home/andy/WorkSpace/U-BOOT/u-boot/include/common.h:59:21: note: in
definition of macro ‘pr_fmt’
#define pr_fmt(fmt) fmt
^/home/andy/WorkSpace/U-BOOT/u-boot/include/common.h:75:2: note: in expansion of macro ‘debug_cond’
debug_cond(_DEBUG, fmt, ##args)
^/home/andy/WorkSpace/U-BOOT/u-boot/arch/arm/mach-rockchip/sdram_common.c:67:2:
note: in expansion of macro ‘debug’
debug("SDRAM base=%lx, size=%x\n", ram.base, ram.size);
^/home/andy/WorkSpace/U-BOOT/u-boot/arch/arm/mach-rockchip/sdram_common.c:67:8:
warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
debug("SDRAM base=%lx, size=%x\n", ram.base, ram.size);
^
/home/andy/WorkSpace/U-BOOT/u-boot/include/common.h:59:21: note: in
definition of macro ‘pr_fmt’
#define pr_fmt(fmt) fmt
^/home/andy/WorkSpace/U-BOOT/u-boot/include/common.h:75:2: note: in expansion of macro ‘debug_cond’
debug_cond(_DEBUG, fmt, ##args)
^/home/andy/WorkSpace/U-BOOT/u-boot/arch/arm/mach-rockchip/sdram_common.c:67:2:
note: in expansion of macro ‘debug’
debug("SDRAM base=%lx, size=%x\n", ram.base, ram.size);
^
LD arch/arm/lib/built-in.o
In file included from /home/andy/WorkSpace/U-BOOT/u-boot/include/linux/delay.h:8:0,
from/home/andy/WorkSpace/U-BOOT/u-boot/include/common.h:26,
from/home/andy/WorkSpace/U-BOOT/u-boot/arch/arm/mach-rockchip/rk3368/sdram_rk3368.c:8:/home/andy/WorkSpace/U-BOOT/u-boot/arch/arm/mach-rockchip/rk3368/sdram_rk3368.c:
In function ‘rk3368_dmc_probe’:/home/andy/WorkSpace/U-BOOT/u-boot/include/linux/kernel.h:155:17:
warning: comparison of distinct pointer types lacks a cast
(void) (&_min1 == &_min2); \
^
/home/andy/WorkSpace/U-BOOT/u-boot/arch/arm/mach-rockchip/rk3368/sdram_rk3368.c:36:20:
note: in expansion of macro ‘min’
priv->info.size = min(priv->info.size, 0xfe000000);
^