rockchip: rk3328: add CONFIG_RAM_ROCKCHIP_DEBUG support
Subsystems (2)
cover rockchip: rk3328: add CONFIG_RAM_ROCKCHIP_DEBUG support
It would be great to allow user to get extra information for debugging issues with TPL. We can reuse the existing code for rk3399 which print out results of memory configuration at TPL.
Matwey V. Kornilov (3):
rockchip: rk3328: use common struct sdram_base_params for struct
rk3328_sdram_params
rockchip: rk3328: use common struct sdram_cap_info for struct
rk3328_sdram_channel rockchip: rk3328: call sdram_print_ddr_info() at init
arch/arm/dts/rk3328-sdram-ddr3-666.dtsi | 2 + arch/arm/dts/rk3328-sdram-lpddr3-1600.dtsi | 2 + arch/arm/dts/rk3328-sdram-lpddr3-666.dtsi | 2 + arch/arm/include/asm/arch-rockchip/sdram_rk3328.h | 17 +--- drivers/ram/rockchip/Makefile | 2 +- drivers/ram/rockchip/sdram_rk3328.c | 116 +++++++++++----------- 6 files changed, 68 insertions(+), 73 deletions(-)
Signature · 1 line
2.16.4
PATCH 1/3 rockchip: rk3328: use common struct sdram_base_params for struct rk3328_sdram_params
Currently, struct sdram_base_params and struct rk3328_sdram_params have similar layouts.
--- arch/arm/dts/rk3328-sdram-ddr3-666.dtsi | 2 ++ arch/arm/dts/rk3328-sdram-lpddr3-1600.dtsi | 2 ++ arch/arm/dts/rk3328-sdram-lpddr3-666.dtsi | 2 ++ arch/arm/include/asm/arch-rockchip/sdram_rk3328.h | 4 +--- drivers/ram/rockchip/sdram_rk3328.c | 28 +++++++++++------------ 5 files changed, 21 insertions(+), 17 deletions(-)
arch/arm/dts/rk3328-sdram-ddr3-666.dtsi +2 -0
@@ -26,6 +26,8 @@ 333 3 + 1 + 0 0 0x00000000
arch/arm/dts/rk3328-sdram-lpddr3-1600.dtsi +2 -0
@@ -27,6 +27,8 @@ 800 6 1 + 0 + 1 0x00000000 0x43041008
arch/arm/dts/rk3328-sdram-lpddr3-666.dtsi +2 -0
@@ -26,6 +26,8 @@ 333 6 + 1 + 0 0 0x00000000
arch/arm/include/asm/arch-rockchip/sdram_rk3328.h +1 -3
@@ -428,9 +428,7 @@ struct rk3328_sdram_channel {struct rk3328_sdram_params {struct rk3328_sdram_channel ch; -unsigned int ddr_freq; -unsigned int dramtype; -unsigned int odt; +struct sdram_base_params base;struct rk3328_ddr_pctl_regs pctl_regs;struct rk3328_ddr_phy_regs phy_regs;struct rk3328_ddr_skew skew;
drivers/ram/rockchip/sdram_rk3328.c +14 -14
@@ -122,7 +122,7 @@ static void rkclk_configure_ddr(struct dram_info *dram,clrbits_le32 (PHY_REG (phy_base,0xef ),1 <<7 );/* for inno ddr phy need 2*freq */ -rkclk_set_dpll (dram, sdram_params->ddr_freq *2 ); +rkclk_set_dpll (dram, sdram_params->base.ddr_freq *2 ); }static void phy_soft_reset (struct dram_info *dram)
@@ -154,7 +154,7 @@ static int pctl_cfg(struct dram_info *dram,* dfi_lp_en_pd=1,dfi_lp_wakeup_pd=2 * hw_lp_idle_x32=1 */ -if (sdram_params->dramtype ==LPDDR3 ) { +if (sdram_params->base.dramtype ==LPDDR3 ) {setbits_le32 (pctl_base +DDR_PCTL2_DFILPCFG0 ,1 ); clrsetbits_le32(pctl_base + DDR_PCTL2_DFILPCFG0, 0xf << 4,
@@ -230,7 +230,7 @@ static unsigned int calculate_ddrconfig(struct rk3328_sdram_params *sdram_params row = sdram_ch.cs0_row; bank = sdram_ch.bk; -if (sdram_params->dramtype ==DDR4 ) { +if (sdram_params->base.dramtype ==DDR4 ) { tmp = ((cs -1 ) <<6 ) | ((row -13 ) <<3 ) | (bw &0x2 ) | die_bw;for (i =10 ; i <17 ; i++) { if (((tmp & 0x7) == (ddr4_cfg_2_rbc[i - 10] & 0x7)) &&
@@ -286,9 +286,9 @@ static void set_ctl_address_map(struct dram_info *dram,copy_to_reg ((u32 *)(pctl_base +DDR_PCTL2_ADDRMAP0 ), &addrmap[sdram_ch.ddrconfig][0 ],9 *4 ); -if (sdram_params->dramtype ==LPDDR3 && sdram_ch.row_3_4) +if (sdram_params->base.dramtype ==LPDDR3 && sdram_ch.row_3_4)setbits_le32 (pctl_base +DDR_PCTL2_ADDRMAP6 ,1 <<31 ); -if (sdram_params->dramtype ==DDR4 && sdram_ch.bw ==0x1 ) +if (sdram_params->base.dramtype ==DDR4 && sdram_ch.bw ==0x1 )setbits_le32 (pctl_base +DDR_PCTL2_PCCFG ,1 <<8 );if (sdram_ch.rank ==1 )
@@ -332,7 +332,7 @@ static void set_ds_odt(struct dram_info *dram,u32 cmd_drv, clk_drv, dqs_drv, dqs_odt;void __iomem *phy_base = dram->phy; -if (sdram_params->dramtype ==DDR3 ) { +if (sdram_params->base.dramtype ==DDR3 ) { cmd_drv = PHY_DDR3_RON_RTT_34ohm; clk_drv = PHY_DDR3_RON_RTT_45ohm; dqs_drv = PHY_DDR3_RON_RTT_34ohm;
@@ -373,7 +373,7 @@ static void phy_cfg(struct dram_info *dram,u32 i;void __iomem *phy_base = dram->phy; -phy_dll_bypass_set (dram, sdram_params->ddr_freq); +phy_dll_bypass_set (dram, sdram_params->base.ddr_freq);for (i =0 ; sdram_params->phy_regs.phy[i][0 ] !=0xFFFFFFFF ; i++) {writel (sdram_params->phy_regs.phy[i][1 ], phy_base + sdram_params->phy_regs.phy[i][0 ]);
@@ -587,7 +587,7 @@ static void dram_all_config(struct dram_info *dram,set_ddrconfig (dram, sdram_ch.ddrconfig); - sys_reg |=SYS_REG_ENC_DDRTYPE (sdram_params->dramtype); + sys_reg |=SYS_REG_ENC_DDRTYPE (sdram_params->base.dramtype); sys_reg |=SYS_REG_ENC_ROW_3_4 (sdram_ch.row_3_4,0 ); sys_reg |=SYS_REG_ENC_RANK (sdram_ch.rank,0 ); sys_reg |=SYS_REG_ENC_COL (sdram_ch.col,0 );
@@ -653,7 +653,7 @@ static int sdram_init(struct dram_info *dram,rkclk_ddr_reset (dram,1 ,1 ,1 ,0 );rkclk_configure_ddr (dram, sdram_params);if (pre_init ==0 ) { -switch (sdram_params->dramtype) { +switch (sdram_params->base.dramtype) {case DDR3 :printf ("DDR3\n" );break ;
@@ -685,13 +685,13 @@ static int sdram_init(struct dram_info *dram,continue ;/* do ddr gate training */ -if (data_training (dram,0 , sdram_params->dramtype) !=0 ) { +if (data_training (dram,0 , sdram_params->base.dramtype) !=0 ) {printf ("data training error\n" );return -1 ; } -if (sdram_params->dramtype ==DDR4 ) -write_vrefdq (dram,0x3 ,5670 , sdram_params->dramtype); +if (sdram_params->base.dramtype ==DDR4 ) +write_vrefdq (dram,0x3 ,5670 , sdram_params->base.dramtype);if (pre_init ==0 ) {rx_deskew_switch_adjust (dram);
@@ -724,7 +724,7 @@ static u64 dram_detect_cap(struct dram_info *dram,u32 cs;u32 bw =1 ;u64 cap =0 ; -u32 dram_type = sdram_params->dramtype; +u32 dram_type = sdram_params->base.dramtype;u32 pwrctl;if (dram_type !=DDR4 ) {
@@ -907,7 +907,7 @@ static int dram_detect_cs1_row(struct rk3328_sdram_params *sdram_params,else cs1_bit =0 ; -if (sdram_params->dramtype ==DDR4 ) { +if (sdram_params->base.dramtype ==DDR4 ) {if (sdram_ch.dbw ==0 ) bktmp = sdram_ch.bk +2 ;else
Signature · 1 line
2.16.4
PATCH 2/3 rockchip: rk3328: use common struct sdram_cap_info for struct rk3328_sdram_channel
In reply to Matwey V. KornilovCurrently, struct sdram_cap_info and struct rk3328_sdram_channel have similar layouts.
--- arch/arm/include/asm/arch-rockchip/sdram_rk3328.h | 13 +--- drivers/ram/rockchip/sdram_rk3328.c | 90 +++++++++++------------ 2 files changed, 46 insertions(+), 57 deletions(-)
arch/arm/include/asm/arch-rockchip/sdram_rk3328.h +1 -12
@@ -411,18 +411,7 @@ struct rk3328_ddr_skew { };struct rk3328_sdram_channel { -unsigned int rank; -unsigned int col; -/* 3:8bank, 2:4bank */ -unsigned int bk; -/* channel buswidth, 2:32bit, 1:16bit, 0:8bit */ -unsigned int bw; -/* die buswidth, 2:32bit, 1:16bit, 0:8bit */ -unsigned int dbw; -unsigned int row_3_4; -unsigned int cs0_row; -unsigned int cs1_row; -unsigned int ddrconfig; +struct sdram_cap_info cap_info;struct rk3328_msch_timings noc_timings; };
drivers/ram/rockchip/sdram_rk3328.c +45 -45
176 lines not on this page · raw message
Signature · 1 line
2.16.4
PATCH 3/3 rockchip: rk3328: call sdram_print_ddr_info() at init
In reply to Matwey V. KornilovMake it possible to use CONFIG_RAM_ROCKCHIP_DEBUG when debuging TPL issues.
--- drivers/ram/rockchip/Makefile | 2 +- drivers/ram/rockchip/sdram_rk3328.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/ram/rockchip/Makefile +1 -1
@@ -3,7 +3,6 @@ # Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH # -obj-$(CONFIG_RAM_ROCKCHIP_DEBUG) += sdram_debug.o obj-$(CONFIG_ROCKCHIP_RK3368) = dmc-rk3368.o obj-$(CONFIG_ROCKCHIP_RK3128) = sdram_rk3128.o obj-$(CONFIG_ROCKCHIP_RK3188) = sdram_rk3188.o
@@ -11,3 +10,4 @@ obj-$(CONFIG_ROCKCHIP_RK322X) = sdram_rk322x.o obj-$(CONFIG_ROCKCHIP_RK3288) = sdram_rk3288.o obj-$(CONFIG_ROCKCHIP_RK3328) = sdram_rk3328.o obj-$(CONFIG_RAM_RK3399) += sdram_rk3399.o +obj-$(CONFIG_RAM_ROCKCHIP_DEBUG) += sdram_debug.o
drivers/ram/rockchip/sdram_rk3328.c +2 -0
@@ -684,6 +684,8 @@ static int sdram_init(struct dram_info *dram,while ((readl (pctl_base +DDR_PCTL2_STAT ) &0x7 ) ==0 )continue ; +sdram_print_ddr_info (&sdram_ch.cap_info, &sdram_params->base); +/* do ddr gate training */ if (data_training (dram,0 , sdram_params->base.dramtype) !=0 ) {printf ("data training error\n" );
Signature · 1 line
2.16.4