Commit 326dde3e authored by Iyappan Subramanian's avatar Iyappan Subramanian Committed by David S. Miller

xgene: Check all RGMII phy mode variants

This patch addresses the review comment from the previous patch set,
by using phy_interface_mode_is_rgmii() helper function to address
all RGMII phy mode variants.
Signed-off-by: default avatarIyappan Subramanian <isubramanian@apm.com>
Signed-off-by: default avatarQuan Nguyen <qnguyen@apm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 32d0f783
...@@ -127,7 +127,7 @@ static int xgene_get_link_ksettings(struct net_device *ndev, ...@@ -127,7 +127,7 @@ static int xgene_get_link_ksettings(struct net_device *ndev,
struct phy_device *phydev = ndev->phydev; struct phy_device *phydev = ndev->phydev;
u32 supported; u32 supported;
if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) { if (phy_interface_mode_is_rgmii(pdata->phy_mode)) {
if (phydev == NULL) if (phydev == NULL)
return -ENODEV; return -ENODEV;
...@@ -177,7 +177,7 @@ static int xgene_set_link_ksettings(struct net_device *ndev, ...@@ -177,7 +177,7 @@ static int xgene_set_link_ksettings(struct net_device *ndev,
struct xgene_enet_pdata *pdata = netdev_priv(ndev); struct xgene_enet_pdata *pdata = netdev_priv(ndev);
struct phy_device *phydev = ndev->phydev; struct phy_device *phydev = ndev->phydev;
if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) { if (phy_interface_mode_is_rgmii(pdata->phy_mode)) {
if (!phydev) if (!phydev)
return -ENODEV; return -ENODEV;
...@@ -304,7 +304,7 @@ static int xgene_set_pauseparam(struct net_device *ndev, ...@@ -304,7 +304,7 @@ static int xgene_set_pauseparam(struct net_device *ndev,
struct phy_device *phydev = ndev->phydev; struct phy_device *phydev = ndev->phydev;
u32 oldadv, newadv; u32 oldadv, newadv;
if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII || if (phy_interface_mode_is_rgmii(pdata->phy_mode) ||
pdata->phy_mode == PHY_INTERFACE_MODE_SGMII) { pdata->phy_mode == PHY_INTERFACE_MODE_SGMII) {
if (!phydev) if (!phydev)
return -EINVAL; return -EINVAL;
......
...@@ -272,7 +272,7 @@ void xgene_enet_wr_mac(struct xgene_enet_pdata *pdata, u32 wr_addr, u32 wr_data) ...@@ -272,7 +272,7 @@ void xgene_enet_wr_mac(struct xgene_enet_pdata *pdata, u32 wr_addr, u32 wr_data)
u32 done; u32 done;
if (pdata->mdio_driver && ndev->phydev && if (pdata->mdio_driver && ndev->phydev &&
pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) { phy_interface_mode_is_rgmii(pdata->phy_mode)) {
struct mii_bus *bus = ndev->phydev->mdio.bus; struct mii_bus *bus = ndev->phydev->mdio.bus;
return xgene_mdio_wr_mac(bus->priv, wr_addr, wr_data); return xgene_mdio_wr_mac(bus->priv, wr_addr, wr_data);
...@@ -326,12 +326,13 @@ static void xgene_enet_rd_mcx_csr(struct xgene_enet_pdata *pdata, ...@@ -326,12 +326,13 @@ static void xgene_enet_rd_mcx_csr(struct xgene_enet_pdata *pdata,
u32 xgene_enet_rd_mac(struct xgene_enet_pdata *pdata, u32 rd_addr) u32 xgene_enet_rd_mac(struct xgene_enet_pdata *pdata, u32 rd_addr)
{ {
void __iomem *addr, *rd, *cmd, *cmd_done; void __iomem *addr, *rd, *cmd, *cmd_done;
struct net_device *ndev = pdata->ndev;
u32 done, rd_data; u32 done, rd_data;
u8 wait = 10; u8 wait = 10;
if (pdata->mdio_driver && pdata->ndev->phydev && if (pdata->mdio_driver && ndev->phydev &&
pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) { phy_interface_mode_is_rgmii(pdata->phy_mode)) {
struct mii_bus *bus = pdata->ndev->phydev->mdio.bus; struct mii_bus *bus = ndev->phydev->mdio.bus;
return xgene_mdio_rd_mac(bus->priv, rd_addr); return xgene_mdio_rd_mac(bus->priv, rd_addr);
} }
...@@ -349,8 +350,7 @@ u32 xgene_enet_rd_mac(struct xgene_enet_pdata *pdata, u32 rd_addr) ...@@ -349,8 +350,7 @@ u32 xgene_enet_rd_mac(struct xgene_enet_pdata *pdata, u32 rd_addr)
udelay(1); udelay(1);
if (!done) if (!done)
netdev_err(pdata->ndev, "mac read failed, addr: %04x\n", netdev_err(ndev, "mac read failed, addr: %04x\n", rd_addr);
rd_addr);
rd_data = ioread32(rd); rd_data = ioread32(rd);
iowrite32(0, cmd); iowrite32(0, cmd);
......
...@@ -1634,7 +1634,7 @@ static int xgene_enet_get_irqs(struct xgene_enet_pdata *pdata) ...@@ -1634,7 +1634,7 @@ static int xgene_enet_get_irqs(struct xgene_enet_pdata *pdata)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int i, ret, max_irqs; int i, ret, max_irqs;
if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) if (phy_interface_mode_is_rgmii(pdata->phy_mode))
max_irqs = 1; max_irqs = 1;
else if (pdata->phy_mode == PHY_INTERFACE_MODE_SGMII) else if (pdata->phy_mode == PHY_INTERFACE_MODE_SGMII)
max_irqs = 2; max_irqs = 2;
...@@ -1760,7 +1760,7 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata) ...@@ -1760,7 +1760,7 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
dev_err(dev, "Unable to get phy-connection-type\n"); dev_err(dev, "Unable to get phy-connection-type\n");
return pdata->phy_mode; return pdata->phy_mode;
} }
if (pdata->phy_mode != PHY_INTERFACE_MODE_RGMII && if (!phy_interface_mode_is_rgmii(pdata->phy_mode) &&
pdata->phy_mode != PHY_INTERFACE_MODE_SGMII && pdata->phy_mode != PHY_INTERFACE_MODE_SGMII &&
pdata->phy_mode != PHY_INTERFACE_MODE_XGMII) { pdata->phy_mode != PHY_INTERFACE_MODE_XGMII) {
dev_err(dev, "Incorrect phy-connection-type specified\n"); dev_err(dev, "Incorrect phy-connection-type specified\n");
...@@ -1805,7 +1805,7 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata) ...@@ -1805,7 +1805,7 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
pdata->cle.base = base_addr + BLOCK_ETH_CLE_CSR_OFFSET; pdata->cle.base = base_addr + BLOCK_ETH_CLE_CSR_OFFSET;
pdata->eth_ring_if_addr = base_addr + BLOCK_ETH_RING_IF_OFFSET; pdata->eth_ring_if_addr = base_addr + BLOCK_ETH_RING_IF_OFFSET;
pdata->eth_diag_csr_addr = base_addr + BLOCK_ETH_DIAG_CSR_OFFSET; pdata->eth_diag_csr_addr = base_addr + BLOCK_ETH_DIAG_CSR_OFFSET;
if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII || if (phy_interface_mode_is_rgmii(pdata->phy_mode) ||
pdata->phy_mode == PHY_INTERFACE_MODE_SGMII) { pdata->phy_mode == PHY_INTERFACE_MODE_SGMII) {
pdata->mcx_mac_addr = pdata->base_addr + BLOCK_ETH_MAC_OFFSET; pdata->mcx_mac_addr = pdata->base_addr + BLOCK_ETH_MAC_OFFSET;
pdata->mcx_stats_addr = pdata->mcx_stats_addr =
...@@ -1904,6 +1904,9 @@ static void xgene_enet_setup_ops(struct xgene_enet_pdata *pdata) ...@@ -1904,6 +1904,9 @@ static void xgene_enet_setup_ops(struct xgene_enet_pdata *pdata)
{ {
switch (pdata->phy_mode) { switch (pdata->phy_mode) {
case PHY_INTERFACE_MODE_RGMII: case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII_RXID:
case PHY_INTERFACE_MODE_RGMII_TXID:
pdata->mac_ops = &xgene_gmac_ops; pdata->mac_ops = &xgene_gmac_ops;
pdata->port_ops = &xgene_gport_ops; pdata->port_ops = &xgene_gport_ops;
pdata->rm = RM3; pdata->rm = RM3;
...@@ -2100,7 +2103,7 @@ static int xgene_enet_probe(struct platform_device *pdev) ...@@ -2100,7 +2103,7 @@ static int xgene_enet_probe(struct platform_device *pdev)
if (pdata->phy_mode == PHY_INTERFACE_MODE_XGMII) { if (pdata->phy_mode == PHY_INTERFACE_MODE_XGMII) {
INIT_DELAYED_WORK(&pdata->link_work, link_state); INIT_DELAYED_WORK(&pdata->link_work, link_state);
} else if (!pdata->mdio_driver) { } else if (!pdata->mdio_driver) {
if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) if (phy_interface_mode_is_rgmii(pdata->phy_mode))
ret = xgene_enet_mdio_config(pdata); ret = xgene_enet_mdio_config(pdata);
else else
INIT_DELAYED_WORK(&pdata->link_work, link_state); INIT_DELAYED_WORK(&pdata->link_work, link_state);
...@@ -2131,7 +2134,7 @@ static int xgene_enet_probe(struct platform_device *pdev) ...@@ -2131,7 +2134,7 @@ static int xgene_enet_probe(struct platform_device *pdev)
if (pdata->mdio_driver) if (pdata->mdio_driver)
xgene_enet_phy_disconnect(pdata); xgene_enet_phy_disconnect(pdata);
else if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) else if (phy_interface_mode_is_rgmii(pdata->phy_mode))
xgene_enet_mdio_remove(pdata); xgene_enet_mdio_remove(pdata);
err1: err1:
xgene_enet_delete_desc_rings(pdata); xgene_enet_delete_desc_rings(pdata);
...@@ -2155,7 +2158,7 @@ static int xgene_enet_remove(struct platform_device *pdev) ...@@ -2155,7 +2158,7 @@ static int xgene_enet_remove(struct platform_device *pdev)
if (pdata->mdio_driver) if (pdata->mdio_driver)
xgene_enet_phy_disconnect(pdata); xgene_enet_phy_disconnect(pdata);
else if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) else if (phy_interface_mode_is_rgmii(pdata->phy_mode))
xgene_enet_mdio_remove(pdata); xgene_enet_mdio_remove(pdata);
unregister_netdev(ndev); unregister_netdev(ndev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment