hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
u-boot/drivers/ram/rockchip/sdram_rv1126.c
....@@ -374,6 +374,8 @@
374374 break;
375375 delay--;
376376 }
377
+ if (delay <= 0)
378
+ printascii("ERROR: DPLL lock timeout!\n");
377379
378380 writel(DPLL_MODE(CLOCK_FROM_PLL), &dram->cru->mode);
379381 }
....@@ -557,11 +559,18 @@
557559 {
558560 void __iomem *phy_base = dram->phy;
559561 u32 fbdiv, prediv, postdiv, postdiv_en;
562
+ int delay = 1000;
560563
561564 if (wait) {
562565 clrbits_le32(PHY_REG(phy_base, 0x53), PHY_PD_DISB);
563
- while (!(readl(PHY_REG(phy_base, 0x90)) & PHY_PLL_LOCK))
564
- continue;
566
+ while (!(readl(PHY_REG(phy_base, 0x90)) & PHY_PLL_LOCK)) {
567
+ udelay(1);
568
+ if (delay-- <= 0) {
569
+ printascii("ERROR: phy pll lock timeout!\n");
570
+ while (1)
571
+ ;
572
+ }
573
+ }
565574 } else {
566575 freq /= MHz;
567576 prediv = 1;
....@@ -2484,13 +2493,13 @@
24842493 return 0;
24852494 }
24862495
2487
-static int sdram_init_(struct dram_info *dram,
2488
- struct rv1126_sdram_params *sdram_params, u32 post_init)
2496
+int sdram_init_(struct dram_info *dram, struct rv1126_sdram_params *sdram_params, u32 post_init)
24892497 {
24902498 void __iomem *pctl_base = dram->pctl;
24912499 void __iomem *phy_base = dram->phy;
24922500 u32 ddr4_vref;
24932501 u32 mr_tmp, tmp;
2502
+ int delay = 1000;
24942503
24952504 rkclk_configure_ddr(dram, sdram_params);
24962505
....@@ -2538,8 +2547,14 @@
25382547
25392548 rkclk_ddr_reset(dram, 0, 0, 0, 0);
25402549
2541
- while ((readl(pctl_base + DDR_PCTL2_STAT) & 0x7) == 0)
2542
- continue;
2550
+ while ((readl(pctl_base + DDR_PCTL2_STAT) & 0x7) == 0) {
2551
+ udelay(1);
2552
+ if (delay-- <= 0) {
2553
+ printascii("ERROR: Cannot wait dfi_init_done!\n");
2554
+ while (1)
2555
+ ;
2556
+ }
2557
+ }
25432558
25442559 if (sdram_params->base.dramtype == LPDDR3) {
25452560 pctl_write_mr(dram->pctl, 3, 11, lp3_odt_value, LPDDR3);
....@@ -3300,6 +3315,7 @@
33003315 struct rv1126_sdram_params *sdram_params_new;
33013316 void __iomem *pctl_base = dram->pctl;
33023317 void __iomem *phy_base = dram->phy;
3318
+ int delay = 1000;
33033319
33043320 lp_stat = low_power_update(dram, 0);
33053321 sdram_params_new = get_default_sdram_config(freq);
....@@ -3388,8 +3404,14 @@
33883404 (0x0 << ACLK_DDR_UPCTL_EN_SHIFT),
33893405 BUS_SGRF_BASE_ADDR + SGRF_SOC_CON12);
33903406 while ((readl(pctl_base + DDR_PCTL2_DFISTAT) &
3391
- PCTL2_DFI_INIT_COMPLETE) != PCTL2_DFI_INIT_COMPLETE)
3392
- continue;
3407
+ PCTL2_DFI_INIT_COMPLETE) != PCTL2_DFI_INIT_COMPLETE) {
3408
+ udelay(1);
3409
+ if (delay-- <= 0) {
3410
+ printascii("ERROR: Cannot wait DFI_INIT_COMPLETE\n");
3411
+ while (1)
3412
+ ;
3413
+ }
3414
+ }
33933415
33943416 sw_set_req(dram);
33953417 setbits_le32(pctl_base + DDR_PCTL2_MSTR, 0x1 << 29);