@@ -54,6 +54,8 @@ struct rockchip_lvds_soc_data {
5454 int grf_soc_con6 ;
5555 int grf_soc_con7 ;
5656 int grf_soc_con15 ;
57+
58+ bool has_vop_sel ;
5759};
5860
5961struct rockchip_lvds {
@@ -215,7 +217,7 @@ static int rk3288_lvds_poweron(struct rockchip_lvds *lvds)
215217 return 0 ;
216218}
217219
218- static int rk3368_lvds_poweron (struct rockchip_lvds * lvds )
220+ static int rk336x_lvds_poweron (struct rockchip_lvds * lvds )
219221{
220222 u32 delay_times = 20 ;
221223
@@ -255,7 +257,7 @@ static int rk3368_lvds_poweron(struct rockchip_lvds *lvds)
255257 return 0 ;
256258}
257259
258- static void rk3368_output_ttl (struct rockchip_lvds * lvds )
260+ static void rk336x_output_ttl (struct rockchip_lvds * lvds )
259261{
260262 u32 val = 0 ;
261263
@@ -270,10 +272,10 @@ static void rk3368_output_ttl(struct rockchip_lvds *lvds)
270272 v_MSB_SEL (1 ) | v_DIG_INTER_RST (1 );
271273 lvds_writel (lvds , MIPIPHY_REGE0 , val );
272274
273- rk3368_lvds_poweron (lvds );
275+ rk336x_lvds_poweron (lvds );
274276}
275277
276- static void rk3368_output_lvds (struct rockchip_lvds * lvds )
278+ static void rk336x_output_lvds (struct rockchip_lvds * lvds )
277279{
278280 /* digital internal disable */
279281 lvds_msk_reg (lvds , MIPIPHY_REGE1 , m_DIG_INTER_EN , v_DIG_INTER_EN (0 ));
@@ -289,16 +291,16 @@ static void rk3368_output_lvds(struct rockchip_lvds *lvds)
289291 m_MSB_SEL | m_DIG_INTER_RST ,
290292 v_MSB_SEL (1 ) | v_DIG_INTER_RST (1 ));
291293
292- rk3368_lvds_poweron (lvds );
294+ rk336x_lvds_poweron (lvds );
293295 lvds_msk_reg (lvds , MIPIPHY_REGE1 , m_DIG_INTER_EN , v_DIG_INTER_EN (1 ));
294296}
295297
296- static int rk3368_lvds_output (struct rockchip_lvds * lvds )
298+ static int rk336x_lvds_output (struct rockchip_lvds * lvds )
297299{
298300 if (lvds -> output == DISPLAY_OUTPUT_RGB )
299- rk3368_output_ttl (lvds );
301+ rk336x_output_ttl (lvds );
300302 else
301- rk3368_output_lvds (lvds );
303+ rk336x_output_lvds (lvds );
302304 return 0 ;
303305}
304306
@@ -328,8 +330,8 @@ static int rockchip_lvds_poweron(struct rockchip_lvds *lvds)
328330 }
329331 if (LVDS_CHIP (lvds ) == RK3288_LVDS )
330332 rk3288_lvds_poweron (lvds );
331- else if (LVDS_CHIP (lvds ) == RK3368_LVDS )
332- rk3368_lvds_output (lvds );
333+ else if (LVDS_CHIP (lvds ) == RK336X_LVDS )
334+ rk336x_lvds_output (lvds );
333335
334336 return 0 ;
335337}
@@ -353,8 +355,8 @@ static void rockchip_lvds_poweroff(struct rockchip_lvds *lvds)
353355 pm_runtime_put (lvds -> dev );
354356 if (lvds -> pclk )
355357 clk_disable (lvds -> pclk );
356- } else if (LVDS_CHIP (lvds ) == RK3368_LVDS ) {
357- val = v_RK3368_LVDSMODE_EN (0 ) | v_RK3368_MIPIPHY_TTL_EN (0 );
358+ } else if (LVDS_CHIP (lvds ) == RK336X_LVDS ) {
359+ val = v_RK336X_LVDSMODE_EN (0 ) | v_RK336X_MIPIPHY_TTL_EN (0 );
358360 ret = regmap_write (lvds -> grf , lvds -> soc_data -> grf_soc_con7 , val );
359361 if (ret != 0 ) {
360362 dev_err (lvds -> dev , "Could not write to GRF: %d\n" , ret );
@@ -513,7 +515,7 @@ static void rockchip_lvds_encoder_mode_set(struct drm_encoder *encoder,
513515 dev_err (lvds -> dev , "Could not write to GRF: %d\n" , ret );
514516 return ;
515517 }
516- } else if (LVDS_CHIP (lvds ) == RK3368_LVDS ) {
518+ } else if (LVDS_CHIP (lvds ) == RK336X_LVDS ) {
517519 if (lvds -> output == DISPLAY_OUTPUT_RGB ) {
518520 /* iomux to lcdc */
519521 if (lvds -> pins && !IS_ERR (lvds -> pins -> default_state ))
@@ -522,18 +524,18 @@ static void rockchip_lvds_encoder_mode_set(struct drm_encoder *encoder,
522524
523525 lvds_dsi_writel (lvds , 0x0 , 0x4 );/*set clock lane enable*/
524526 /* enable lvds mode */
525- val = v_RK3368_LVDSMODE_EN (0 ) |
526- v_RK3368_MIPIPHY_TTL_EN (1 ) |
527- v_RK3368_MIPIPHY_LANE0_EN (1 ) |
528- v_RK3368_MIPIDPI_FORCEX_EN (1 );
527+ val = v_RK336X_LVDSMODE_EN (0 ) |
528+ v_RK336X_MIPIPHY_TTL_EN (1 ) |
529+ v_RK336X_MIPIPHY_LANE0_EN (1 ) |
530+ v_RK336X_MIPIDPI_FORCEX_EN (1 );
529531 ret = regmap_write (lvds -> grf ,
530532 lvds -> soc_data -> grf_soc_con7 , val );
531533 if (ret != 0 ) {
532534 dev_err (lvds -> dev ,
533535 "Could not write to GRF: %d\n" , ret );
534536 return ;
535537 }
536- val = v_RK3368_FORCE_JETAG (0 );
538+ val = v_RK336X_FORCE_JETAG (0 );
537539 ret = regmap_write (lvds -> grf ,
538540 lvds -> soc_data -> grf_soc_con15 , val );
539541 if (ret != 0 ) {
@@ -543,13 +545,14 @@ static void rockchip_lvds_encoder_mode_set(struct drm_encoder *encoder,
543545 }
544546 } else if (lvds -> output == DISPLAY_OUTPUT_LVDS ) {
545547 /* enable lvds mode */
546- val = v_RK3368_LVDSMODE_EN (1 ) | v_RK3368_MIPIPHY_TTL_EN (0 );
548+ val = v_RK336X_LVDSMODE_EN (1 ) |
549+ v_RK336X_MIPIPHY_TTL_EN (0 );
547550 /* config lvds_format */
548- val |= v_RK3368_LVDS_OUTPUT_FORMAT (lvds -> format );
551+ val |= v_RK336X_LVDS_OUTPUT_FORMAT (lvds -> format );
549552 /* LSB receive mode */
550- val |= v_RK3368_LVDS_MSBSEL (LVDS_MSB_D7 );
551- val |= v_RK3368_MIPIPHY_LANE0_EN (1 ) |
552- v_RK3368_MIPIDPI_FORCEX_EN (1 );
553+ val |= v_RK336X_LVDS_MSBSEL (LVDS_MSB_D7 );
554+ val |= v_RK336X_MIPIPHY_LANE0_EN (1 ) |
555+ v_RK336X_MIPIDPI_FORCEX_EN (1 );
553556 ret = regmap_write (lvds -> grf ,
554557 lvds -> soc_data -> grf_soc_con7 , val );
555558 if (ret != 0 ) {
@@ -567,6 +570,9 @@ static int rockchip_lvds_set_vop_source(struct rockchip_lvds *lvds,
567570 u32 val ;
568571 int ret ;
569572
573+ if (!lvds -> soc_data -> has_vop_sel )
574+ return 0 ;
575+
570576 ret = drm_of_encoder_active_endpoint_id (lvds -> dev -> of_node , encoder );
571577 if (ret < 0 )
572578 return ret ;
@@ -581,7 +587,14 @@ static int rockchip_lvds_set_vop_source(struct rockchip_lvds *lvds,
581587 ret = regmap_write (lvds -> grf , lvds -> soc_data -> grf_soc_con6 , val );
582588 if (ret < 0 )
583589 return ret ;
590+ } else {
591+ if (ret )
592+ val = RK3366_LVDS_VOP_SEL_LIT ;
593+ else
594+ val = RK3366_LVDS_VOP_SEL_BIG ;
595+ regmap_write (lvds -> grf , RK3366_GRF_SOC_CON0 , val );
584596 }
597+
585598 return 0 ;
586599}
587600
@@ -637,14 +650,21 @@ static struct rockchip_lvds_soc_data rk3288_lvds_data = {
637650 .chip_type = RK3288_LVDS ,
638651 .grf_soc_con6 = 0x025c ,
639652 .grf_soc_con7 = 0x0260 ,
653+ .has_vop_sel = true,
654+ };
655+
656+ static struct rockchip_lvds_soc_data rk3366_lvds_data = {
657+ .chip_type = RK336X_LVDS ,
658+ .grf_soc_con7 = RK3366_GRF_SOC_CON5 ,
659+ .grf_soc_con15 = RK3366_GRF_SOC_CON6 ,
660+ .has_vop_sel = true,
640661};
641662
642- static struct rockchip_lvds_soc_data rk33xx_lvds_data = {
643- .chip_type = RK3368_LVDS ,
644- .grf_soc_con5 = 0x0414 ,
645- .grf_soc_con6 = 0x0418 ,
646- .grf_soc_con7 = 0x041c ,
647- .grf_soc_con15 = 0x043c ,
663+ static struct rockchip_lvds_soc_data rk3368_lvds_data = {
664+ .chip_type = RK336X_LVDS ,
665+ .grf_soc_con7 = RK3368_GRF_SOC_CON7 ,
666+ .grf_soc_con15 = RK3368_GRF_SOC_CON15 ,
667+ .has_vop_sel = false,
648668};
649669
650670static const struct of_device_id rockchip_lvds_dt_ids [] = {
@@ -653,8 +673,12 @@ static const struct of_device_id rockchip_lvds_dt_ids[] = {
653673 .data = & rk3288_lvds_data
654674 },
655675 {
656- .compatible = "rockchip,rk33xx-lvds" ,
657- .data = & rk33xx_lvds_data
676+ .compatible = "rockchip,rk3366-lvds" ,
677+ .data = & rk3366_lvds_data
678+ },
679+ {
680+ .compatible = "rockchip,rk3368-lvds" ,
681+ .data = & rk3368_lvds_data
658682 },
659683 {}
660684};
@@ -830,7 +854,7 @@ static int rockchip_lvds_probe(struct platform_device *pdev)
830854 lvds -> regs = devm_ioremap_resource (& pdev -> dev , res );
831855 if (IS_ERR (lvds -> regs ))
832856 return PTR_ERR (lvds -> regs );
833- } else if (LVDS_CHIP (lvds ) == RK3368_LVDS ) {
857+ } else if (LVDS_CHIP (lvds ) == RK336X_LVDS ) {
834858 /* lvds regs on MIPIPHY_REG */
835859 res = platform_get_resource_byname (pdev , IORESOURCE_MEM ,
836860 "mipi_lvds_phy" );
0 commit comments