Skip to content

Commit

Permalink
Merge branch 'xgene-gpio'
Browse files Browse the repository at this point in the history
Iyappan Subramanian says:

====================
drivers: net: xgene: fix: Use GPIO to get link status

Since the link value reported by the link status register is not
reliable if no SPF module inserted, this patchset fixes the issue by
using GPIO to determine the link status when no module inserted.
====================

Signed-off-by: Iyappan Subramanian <isubramanian@apm.com>
Signed-off-by: Quan Nguyen <qnguyen@apm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Oct 12, 2016
2 parents c66549f + d2561ed commit b07bf5f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions arch/arm64/configs/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ CONFIG_GPIO_DWAPB=y
CONFIG_GPIO_PL061=y
CONFIG_GPIO_RCAR=y
CONFIG_GPIO_XGENE=y
CONFIG_GPIO_XGENE_SB=y
CONFIG_GPIO_PCA953X=y
CONFIG_GPIO_PCA953X_IRQ=y
CONFIG_GPIO_MAX77620=y
Expand Down
6 changes: 5 additions & 1 deletion drivers/net/ethernet/apm/xgene/xgene_enet_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1381,9 +1381,13 @@ static void xgene_enet_gpiod_get(struct xgene_enet_pdata *pdata)
{
struct device *dev = &pdata->pdev->dev;

if (pdata->phy_mode != PHY_INTERFACE_MODE_XGMII)
pdata->sfp_gpio_en = false;
if (pdata->phy_mode != PHY_INTERFACE_MODE_XGMII ||
(!device_property_present(dev, "sfp-gpios") &&
!device_property_present(dev, "rxlos-gpios")))
return;

pdata->sfp_gpio_en = true;
pdata->sfp_rdy = gpiod_get(dev, "rxlos", GPIOD_IN);
if (IS_ERR(pdata->sfp_rdy))
pdata->sfp_rdy = gpiod_get(dev, "sfp", GPIOD_IN);
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/apm/xgene/xgene_enet_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ struct xgene_enet_pdata {
u8 rx_delay;
bool mdio_driver;
struct gpio_desc *sfp_rdy;
bool sfp_gpio_en;
};

struct xgene_indirect_ctl {
Expand Down
19 changes: 17 additions & 2 deletions drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,16 +415,31 @@ static void xgene_enet_clear(struct xgene_enet_pdata *pdata,
xgene_enet_wr_ring_if(pdata, addr, data);
}

static int xgene_enet_gpio_lookup(struct xgene_enet_pdata *pdata)
{
struct device *dev = &pdata->pdev->dev;

pdata->sfp_rdy = gpiod_get(dev, "rxlos", GPIOD_IN);
if (IS_ERR(pdata->sfp_rdy))
pdata->sfp_rdy = gpiod_get(dev, "sfp", GPIOD_IN);

if (IS_ERR(pdata->sfp_rdy))
return -ENODEV;

return 0;
}

static void xgene_enet_link_state(struct work_struct *work)
{
struct xgene_enet_pdata *pdata = container_of(to_delayed_work(work),
struct xgene_enet_pdata, link_work);
struct gpio_desc *sfp_rdy = pdata->sfp_rdy;
struct net_device *ndev = pdata->ndev;
u32 link_status, poll_interval;

link_status = xgene_enet_link_status(pdata);
if (link_status && !IS_ERR(sfp_rdy) && !gpiod_get_value(sfp_rdy))
if (pdata->sfp_gpio_en && link_status &&
(!IS_ERR(pdata->sfp_rdy) || !xgene_enet_gpio_lookup(pdata)) &&
!gpiod_get_value(pdata->sfp_rdy))
link_status = 0;

if (link_status) {
Expand Down

0 comments on commit b07bf5f

Please sign in to comment.