6363 MBUS_PORT_CSI = 5 ,
6464 MBUS_PORT_NAND = 6 ,
6565 MBUS_PORT_SS = 7 ,
66+ MBUS_PORT_DE_V3S = 8 ,
67+ MBUS_PORT_DE_CFD_V3S = 9 ,
6668 MBUS_PORT_TS = 8 ,
6769 MBUS_PORT_DI = 9 ,
6870 MBUS_PORT_DE = 10 ,
@@ -134,6 +136,29 @@ static void mctl_set_master_priority_h3(void)
134136 MBUS_CONF (DE_CFD , true, HIGH , 0 , 1024 , 288 , 64 );
135137}
136138
139+ static void mctl_set_master_priority_v3s (void )
140+ {
141+ struct sunxi_mctl_com_reg * const mctl_com =
142+ (struct sunxi_mctl_com_reg * )SUNXI_DRAM_COM_BASE ;
143+
144+ /* enable bandwidth limit windows and set windows size 1us */
145+ writel ((1 << 16 ) | (400 << 0 ), & mctl_com -> bwcr );
146+
147+ /* set cpu high priority */
148+ writel (0x00000001 , & mctl_com -> mapr );
149+
150+ MBUS_CONF ( CPU , true, HIGHEST , 0 , 160 , 100 , 80 );
151+ MBUS_CONF ( GPU , true, HIGH , 0 , 1792 , 1536 , 0 );
152+ MBUS_CONF ( UNUSED , true, HIGHEST , 0 , 256 , 128 , 80 );
153+ MBUS_CONF ( DMA , true, HIGH , 0 , 256 , 100 , 0 );
154+ MBUS_CONF ( VE , true, HIGH , 0 , 2048 , 1600 , 0 );
155+ MBUS_CONF ( CSI , true, HIGHEST , 0 , 384 , 256 , 0 );
156+ MBUS_CONF ( NAND , true, HIGH , 0 , 100 , 50 , 0 );
157+ MBUS_CONF ( SS , true, HIGH , 0 , 384 , 256 , 0 );
158+ MBUS_CONF ( DE_V3S , false, HIGH , 0 , 8192 , 4096 , 0 );
159+ MBUS_CONF (DE_CFD_V3S , true, HIGH , 0 , 640 , 256 , 0 );
160+ }
161+
137162static void mctl_set_master_priority_a64 (void )
138163{
139164 struct sunxi_mctl_com_reg * const mctl_com =
@@ -231,6 +256,9 @@ static void mctl_set_master_priority(uint16_t socid)
231256 case SOCID_H3 :
232257 mctl_set_master_priority_h3 ();
233258 return ;
259+ case SOCID_V3S :
260+ mctl_set_master_priority_v3s ();
261+ return ;
234262 case SOCID_A64 :
235263 mctl_set_master_priority_a64 ();
236264 return ;
@@ -334,6 +362,28 @@ static void mctl_h3_zq_calibration_quirk(struct dram_para *para)
334362 }
335363}
336364
365+ static void mctl_v3s_zq_calibration_quirk (struct dram_para * para )
366+ {
367+ struct sunxi_mctl_ctl_reg * const mctl_ctl =
368+ (struct sunxi_mctl_ctl_reg * )SUNXI_DRAM_CTL0_BASE ;
369+
370+ u32 reg_val ;
371+
372+ clrsetbits_le32 (& mctl_ctl -> zqcr , 0xffffff ,
373+ CONFIG_DRAM_ZQ & 0xffffff );
374+ mctl_phy_init (PIR_ZCAL );
375+
376+ reg_val = readl (& mctl_ctl -> zqdr [0 ]);
377+ reg_val &= (0x1f << 16 ) | (0x1f << 0 );
378+ reg_val |= reg_val << 8 ;
379+ writel (reg_val , & mctl_ctl -> zqdr [0 ]);
380+
381+ reg_val = readl (& mctl_ctl -> zqdr [1 ]);
382+ reg_val &= (0x1f << 16 ) | (0x1f << 0 );
383+ reg_val |= reg_val << 8 ;
384+ writel (reg_val , & mctl_ctl -> zqdr [1 ]);
385+ }
386+
337387static void mctl_set_cr (uint16_t socid , struct dram_para * para )
338388{
339389 struct sunxi_mctl_com_reg * const mctl_com =
@@ -391,7 +441,7 @@ static void mctl_sys_init(uint16_t socid, struct dram_para *para)
391441 CCM_DRAMCLK_CFG_DIV (1 ) |
392442 CCM_DRAMCLK_CFG_SRC_PLL11 |
393443 CCM_DRAMCLK_CFG_UPD );
394- } else if (socid == SOCID_H3 || socid == SOCID_H5 ) {
444+ } else if (socid == SOCID_H3 || socid == SOCID_H5 || socid == SOCID_V3S ) {
395445 clock_set_pll5 (CONFIG_DRAM_CLK * 2 * 1000000 , false);
396446 clrsetbits_le32 (& ccm -> dram_clk_cfg ,
397447 CCM_DRAMCLK_CFG_DIV_MASK |
@@ -474,6 +524,13 @@ static int mctl_channel_init(uint16_t socid, struct dram_para *para)
474524 /* dphy & aphy phase select 270 degree */
475525 clrsetbits_le32 (& mctl_ctl -> pgcr [2 ], (0x3 << 10 ) | (0x3 << 8 ),
476526 (0x1 << 10 ) | (0x2 << 8 ));
527+ } else if (socid == SOCID_V3S ) {
528+ /* dx ddr_clk & hdr_clk dynamic mode */
529+ clrbits_le32 (& mctl_ctl -> pgcr [0 ], (0x3 << 14 ) | (0x3 << 12 ));
530+
531+ /* dphy & aphy phase select 270 degree */
532+ clrsetbits_le32 (& mctl_ctl -> pgcr [2 ], (0x3 << 10 ) | (0x3 << 8 ),
533+ (0x1 << 10 ) | (0x1 << 8 ));
477534 } else if (socid == SOCID_A64 || socid == SOCID_H5 ) {
478535 /* dphy & aphy phase select ? */
479536 clrsetbits_le32 (& mctl_ctl -> pgcr [2 ], (0x3 << 10 ) | (0x3 << 8 ),
@@ -506,7 +563,12 @@ static int mctl_channel_init(uint16_t socid, struct dram_para *para)
506563 mctl_set_bit_delays (para );
507564 udelay (50 );
508565
509- if (socid == SOCID_H3 ) {
566+ if (socid == SOCID_V3S ) {
567+ mctl_v3s_zq_calibration_quirk (para );
568+
569+ mctl_phy_init (PIR_PLLINIT | PIR_DCAL | PIR_PHYRST |
570+ PIR_DRAMRST | PIR_DRAMINIT | PIR_QSGATE );
571+ } else if (socid == SOCID_H3 ) {
510572 mctl_h3_zq_calibration_quirk (para );
511573
512574 mctl_phy_init (PIR_PLLINIT | PIR_DCAL | PIR_PHYRST |
@@ -570,7 +632,7 @@ static int mctl_channel_init(uint16_t socid, struct dram_para *para)
570632 udelay (10 );
571633
572634 /* set PGCR3, CKE polarity */
573- if (socid == SOCID_H3 )
635+ if (socid == SOCID_H3 || socid == SOCID_V3S )
574636 writel (0x00aa0060 , & mctl_ctl -> pgcr [3 ]);
575637 else if (socid == SOCID_A64 || socid == SOCID_H5 || socid == SOCID_R40 )
576638 writel (0xc0aa0060 , & mctl_ctl -> pgcr [3 ]);
@@ -636,6 +698,22 @@ static void mctl_auto_detect_dram_size(uint16_t socid, struct dram_para *para)
636698 0, 0, 0, 0, 0, 0, 0, 0, \
637699 0, 0, 0, 0, 0, 0, 0 }
638700
701+ #define SUN8I_V3S_DX_READ_DELAYS \
702+ {{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0 }, \
703+ { 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0 }, \
704+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, \
705+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}
706+ #define SUN8I_V3S_DX_WRITE_DELAYS \
707+ {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4 }, \
708+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2 }, \
709+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, \
710+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}
711+ #define SUN8I_V3S_AC_DELAYS \
712+ { 0, 0, 0, 0, 0, 0, 0, 0, \
713+ 0, 0, 0, 0, 0, 0, 0, 0, \
714+ 0, 0, 0, 0, 0, 0, 0, 0, \
715+ 0, 0, 0, 0, 0, 0, 0 }
716+
639717#define SUN8I_R40_DX_READ_DELAYS \
640718 {{ 14, 14, 14, 14, 14, 14, 14, 14, 14, 0, 0 }, \
641719 { 14, 14, 14, 14, 14, 14, 14, 14, 14, 0, 0 }, \
@@ -702,6 +780,10 @@ unsigned long sunxi_dram_init(void)
702780 .dx_read_delays = SUN8I_H3_DX_READ_DELAYS ,
703781 .dx_write_delays = SUN8I_H3_DX_WRITE_DELAYS ,
704782 .ac_delays = SUN8I_H3_AC_DELAYS ,
783+ #elif defined(CONFIG_MACH_SUN8I_V3S )
784+ .dx_read_delays = SUN8I_V3S_DX_READ_DELAYS ,
785+ .dx_write_delays = SUN8I_V3S_DX_WRITE_DELAYS ,
786+ .ac_delays = SUN8I_V3S_AC_DELAYS ,
705787#elif defined(CONFIG_MACH_SUN8I_R40 )
706788 .dx_read_delays = SUN8I_R40_DX_READ_DELAYS ,
707789 .dx_write_delays = SUN8I_R40_DX_WRITE_DELAYS ,
@@ -728,8 +810,7 @@ unsigned long sunxi_dram_init(void)
728810 /* Currently we cannot support R40 with dual rank memory */
729811 para .dual_rank = 0 ;
730812#elif defined(CONFIG_MACH_SUN8I_V3S )
731- /* TODO: set delays and mbus priority for V3s */
732- uint16_t socid = SOCID_H3 ;
813+ uint16_t socid = SOCID_V3S ;
733814#elif defined(CONFIG_MACH_SUN50I )
734815 uint16_t socid = SOCID_A64 ;
735816#elif defined(CONFIG_MACH_SUN50I_H5 )
0 commit comments