@@ -62,11 +62,16 @@ static void stmmac_xgmac2_c45_format(struct stmmac_priv *priv, int phyaddr,
6262static void stmmac_xgmac2_c22_format (struct stmmac_priv * priv , int phyaddr ,
6363 int phyreg , u32 * hw_addr )
6464{
65- u32 tmp ;
65+ u32 tmp = 0 ;
6666
67+ if (priv -> synopsys_id < DWXGMAC_CORE_2_20 ) {
68+ /* Until ver 2.20 XGMAC does not support C22 addr >= 4. Those
69+ * bits above bit 3 of XGMAC_MDIO_C22P register are reserved.
70+ */
71+ tmp = readl (priv -> ioaddr + XGMAC_MDIO_C22P );
72+ tmp &= ~MII_XGMAC_C22P_MASK ;
73+ }
6774 /* Set port as Clause 22 */
68- tmp = readl (priv -> ioaddr + XGMAC_MDIO_C22P );
69- tmp &= ~MII_XGMAC_C22P_MASK ;
7075 tmp |= BIT (phyaddr );
7176 writel (tmp , priv -> ioaddr + XGMAC_MDIO_C22P );
7277
@@ -132,8 +137,9 @@ static int stmmac_xgmac2_mdio_read_c22(struct mii_bus *bus, int phyaddr,
132137
133138 priv = netdev_priv (ndev );
134139
135- /* HW does not support C22 addr >= 4 */
136- if (phyaddr > MII_XGMAC_MAX_C22ADDR )
140+ /* Until ver 2.20 XGMAC does not support C22 addr >= 4 */
141+ if (priv -> synopsys_id < DWXGMAC_CORE_2_20 &&
142+ phyaddr > MII_XGMAC_MAX_C22ADDR )
137143 return - ENODEV ;
138144
139145 stmmac_xgmac2_c22_format (priv , phyaddr , phyreg , & addr );
@@ -209,8 +215,9 @@ static int stmmac_xgmac2_mdio_write_c22(struct mii_bus *bus, int phyaddr,
209215
210216 priv = netdev_priv (ndev );
211217
212- /* HW does not support C22 addr >= 4 */
213- if (phyaddr > MII_XGMAC_MAX_C22ADDR )
218+ /* Until ver 2.20 XGMAC does not support C22 addr >= 4 */
219+ if (priv -> synopsys_id < DWXGMAC_CORE_2_20 &&
220+ phyaddr > MII_XGMAC_MAX_C22ADDR )
214221 return - ENODEV ;
215222
216223 stmmac_xgmac2_c22_format (priv , phyaddr , phyreg , & addr );
@@ -551,13 +558,18 @@ int stmmac_mdio_register(struct net_device *ndev)
551558 new_bus -> read_c45 = & stmmac_xgmac2_mdio_read_c45 ;
552559 new_bus -> write_c45 = & stmmac_xgmac2_mdio_write_c45 ;
553560
554- /* Right now only C22 phys are supported */
555- max_addr = MII_XGMAC_MAX_C22ADDR + 1 ;
561+ if (priv -> synopsys_id < DWXGMAC_CORE_2_20 ) {
562+ /* Right now only C22 phys are supported */
563+ max_addr = MII_XGMAC_MAX_C22ADDR + 1 ;
556564
557- /* Check if DT specified an unsupported phy addr */
558- if (priv -> plat -> phy_addr > MII_XGMAC_MAX_C22ADDR )
559- dev_err (dev , "Unsupported phy_addr (max=%d)\n" ,
565+ /* Check if DT specified an unsupported phy addr */
566+ if (priv -> plat -> phy_addr > MII_XGMAC_MAX_C22ADDR )
567+ dev_err (dev , "Unsupported phy_addr (max=%d)\n" ,
560568 MII_XGMAC_MAX_C22ADDR );
569+ } else {
570+ /* XGMAC version 2.20 onwards support 32 phy addr */
571+ max_addr = PHY_MAX_ADDR ;
572+ }
561573 } else {
562574 new_bus -> read = & stmmac_mdio_read_c22 ;
563575 new_bus -> write = & stmmac_mdio_write_c22 ;
0 commit comments