@@ -125,12 +125,15 @@ struct rockchip_combphy_grfcfg {
125125};
126126
127127struct rockchip_combphy_cfg {
128+ unsigned int num_phys ;
129+ unsigned int phy_ids [3 ];
128130 const struct rockchip_combphy_grfcfg * grfcfg ;
129131 int (* combphy_cfg )(struct rockchip_combphy_priv * priv );
130132};
131133
132134struct rockchip_combphy_priv {
133135 u8 type ;
136+ int id ;
134137 void __iomem * mmio ;
135138 int num_clks ;
136139 struct clk_bulk_data * clks ;
@@ -320,7 +323,7 @@ static int rockchip_combphy_probe(struct platform_device *pdev)
320323 struct rockchip_combphy_priv * priv ;
321324 const struct rockchip_combphy_cfg * phy_cfg ;
322325 struct resource * res ;
323- int ret ;
326+ int ret , id ;
324327
325328 phy_cfg = of_device_get_match_data (dev );
326329 if (!phy_cfg ) {
@@ -338,6 +341,15 @@ static int rockchip_combphy_probe(struct platform_device *pdev)
338341 return ret ;
339342 }
340343
344+ /* find the phy-id from the io address */
345+ priv -> id = - ENODEV ;
346+ for (id = 0 ; id < phy_cfg -> num_phys ; id ++ ) {
347+ if (res -> start == phy_cfg -> phy_ids [id ]) {
348+ priv -> id = id ;
349+ break ;
350+ }
351+ }
352+
341353 priv -> dev = dev ;
342354 priv -> type = PHY_NONE ;
343355 priv -> cfg = phy_cfg ;
@@ -562,6 +574,12 @@ static const struct rockchip_combphy_grfcfg rk3568_combphy_grfcfgs = {
562574};
563575
564576static const struct rockchip_combphy_cfg rk3568_combphy_cfgs = {
577+ .num_phys = 3 ,
578+ .phy_ids = {
579+ 0xfe820000 ,
580+ 0xfe830000 ,
581+ 0xfe840000 ,
582+ },
565583 .grfcfg = & rk3568_combphy_grfcfgs ,
566584 .combphy_cfg = rk3568_combphy_cfg ,
567585};
@@ -578,8 +596,14 @@ static int rk3588_combphy_cfg(struct rockchip_combphy_priv *priv)
578596 rockchip_combphy_param_write (priv -> phy_grf , & cfg -> con1_for_pcie , true);
579597 rockchip_combphy_param_write (priv -> phy_grf , & cfg -> con2_for_pcie , true);
580598 rockchip_combphy_param_write (priv -> phy_grf , & cfg -> con3_for_pcie , true);
581- rockchip_combphy_param_write (priv -> pipe_grf , & cfg -> pipe_pcie1l0_sel , true);
582- rockchip_combphy_param_write (priv -> pipe_grf , & cfg -> pipe_pcie1l1_sel , true);
599+ switch (priv -> id ) {
600+ case 1 :
601+ rockchip_combphy_param_write (priv -> pipe_grf , & cfg -> pipe_pcie1l0_sel , true);
602+ break ;
603+ case 2 :
604+ rockchip_combphy_param_write (priv -> pipe_grf , & cfg -> pipe_pcie1l1_sel , true);
605+ break ;
606+ }
583607 break ;
584608 case PHY_TYPE_USB3 :
585609 /* Set SSC downward spread spectrum */
@@ -736,6 +760,12 @@ static const struct rockchip_combphy_grfcfg rk3588_combphy_grfcfgs = {
736760};
737761
738762static const struct rockchip_combphy_cfg rk3588_combphy_cfgs = {
763+ .num_phys = 3 ,
764+ .phy_ids = {
765+ 0xfee00000 ,
766+ 0xfee10000 ,
767+ 0xfee20000 ,
768+ },
739769 .grfcfg = & rk3588_combphy_grfcfgs ,
740770 .combphy_cfg = rk3588_combphy_cfg ,
741771};
0 commit comments