Skip to content

Commit

Permalink
net: fec: add WoL support for i.MX8MQ
Browse files Browse the repository at this point in the history
By default FEC driver treat irq[0] (i.e. int0 described in dt-binding) as
wakeup interrupt, but this situation changed on i.MX8M serials, SoC
integration guys mix wakeup interrupt signal into int2 interrupt line.
This patch introduces FEC_QUIRK_WAKEUP_FROM_INT2 to indicate int2 as wakeup
interrupt for i.MX8MQ.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Link: https://lore.kernel.org/r/20210812070948.25797-1-qiangqing.zhang@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Joakim Zhang authored and Jakub Kicinski committed Aug 13, 2021
1 parent 44e5d08 commit b7cdc96
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
4 changes: 4 additions & 0 deletions drivers/net/ethernet/freescale/fec.h
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,9 @@ struct bufdesc_ex {
*/
#define FEC_QUIRK_DELAYED_CLKS_SUPPORT (1 << 21)

/* i.MX8MQ SoC integration mix wakeup interrupt signal into "int2" interrupt line. */
#define FEC_QUIRK_WAKEUP_FROM_INT2 (1 << 22)

struct bufdesc_prop {
int qid;
/* Address of Rx and Tx buffers */
Expand Down Expand Up @@ -580,6 +583,7 @@ struct fec_enet_private {
bool bufdesc_ex;
int pause_flag;
int wol_flag;
int wake_irq;
u32 quirks;

struct napi_struct napi;
Expand Down
24 changes: 19 additions & 5 deletions drivers/net/ethernet/freescale/fec_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static const struct fec_devinfo fec_imx8mq_info = {
FEC_QUIRK_ERR007885 | FEC_QUIRK_BUG_CAPTURE |
FEC_QUIRK_HAS_RACC | FEC_QUIRK_HAS_COALESCE |
FEC_QUIRK_CLEAR_SETUP_MII | FEC_QUIRK_HAS_MULTI_QUEUES |
FEC_QUIRK_HAS_EEE,
FEC_QUIRK_HAS_EEE | FEC_QUIRK_WAKEUP_FROM_INT2,
};

static const struct fec_devinfo fec_imx8qm_info = {
Expand Down Expand Up @@ -2878,12 +2878,12 @@ fec_enet_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
device_set_wakeup_enable(&ndev->dev, wol->wolopts & WAKE_MAGIC);
if (device_may_wakeup(&ndev->dev)) {
fep->wol_flag |= FEC_WOL_FLAG_ENABLE;
if (fep->irq[0] > 0)
enable_irq_wake(fep->irq[0]);
if (fep->wake_irq > 0)
enable_irq_wake(fep->wake_irq);
} else {
fep->wol_flag &= (~FEC_WOL_FLAG_ENABLE);
if (fep->irq[0] > 0)
disable_irq_wake(fep->irq[0]);
if (fep->wake_irq > 0)
disable_irq_wake(fep->wake_irq);
}

return 0;
Expand Down Expand Up @@ -3696,6 +3696,17 @@ static int fec_enet_get_irq_cnt(struct platform_device *pdev)
return irq_cnt;
}

static void fec_enet_get_wakeup_irq(struct platform_device *pdev)
{
struct net_device *ndev = platform_get_drvdata(pdev);
struct fec_enet_private *fep = netdev_priv(ndev);

if (fep->quirks & FEC_QUIRK_WAKEUP_FROM_INT2)
fep->wake_irq = fep->irq[2];
else
fep->wake_irq = fep->irq[0];
}

static int fec_enet_init_stop_mode(struct fec_enet_private *fep,
struct device_node *np)
{
Expand Down Expand Up @@ -3935,6 +3946,9 @@ fec_probe(struct platform_device *pdev)
fep->irq[i] = irq;
}

/* Decide which interrupt line is wakeup capable */
fec_enet_get_wakeup_irq(pdev);

ret = fec_enet_mii_init(pdev);
if (ret)
goto failed_mii_init;
Expand Down

0 comments on commit b7cdc96

Please sign in to comment.