Skip to content

Commit 10857e6

Browse files
rohangt07davem330
authored andcommitted
net: stmmac: XGMAC support for mdio C22 addr > 3
For XGMAC versions < 2.2 number of supported mdio C22 addresses is restricted to 3. From XGMAC version 2.2 there are no restrictions on the C22 addresses, it supports all valid mdio addresses(0 to 31). Signed-off-by: Rohan G Thomas <rohan.g.thomas@intel.com> Acked-by: Jose Abreu <Jose.Abreu@synopsys.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 653a18c commit 10857e6

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

drivers/net/ethernet/stmicro/stmmac/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#define DWMAC_CORE_5_10 0x51
3636
#define DWMAC_CORE_5_20 0x52
3737
#define DWXGMAC_CORE_2_10 0x21
38+
#define DWXGMAC_CORE_2_20 0x22
3839
#define DWXLGMAC_CORE_2_00 0x20
3940

4041
/* Device ID */

drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,16 @@ static void stmmac_xgmac2_c45_format(struct stmmac_priv *priv, int phyaddr,
6262
static 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

Comments
 (0)