diff options
author | Andy Duan <fugang.duan@nxp.com> | 2018-06-05 18:02:46 +0800 |
---|---|---|
committer | Leonard Crestez <leonard.crestez@nxp.com> | 2018-08-24 12:41:33 +0300 |
commit | d5d8b92fcebd64821c3602811be0502997a3dcb7 (patch) | |
tree | 4a9c980892e26d984405570f47228435d48663d3 /drivers | |
parent | f5337a78b120a9122eeb7476e0a9e6d06a2c096e (diff) |
MLK-18483-02 net: fec: add sleep mode support for i.MX8QM/QXP
Add sleep mode support for i.MX8QM/QXP platforms.
Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/freescale/fec.h | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/freescale/fec_fixup.c | 45 | ||||
-rw-r--r-- | drivers/net/ethernet/freescale/fec_main.c | 3 |
3 files changed, 49 insertions, 0 deletions
diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h index 71d6222c5273..0e8c915db794 100644 --- a/drivers/net/ethernet/freescale/fec.h +++ b/drivers/net/ethernet/freescale/fec.h @@ -642,6 +642,7 @@ uint fec_ptp_check_pps_event(struct fec_enet_private *fep); void fec_enet_register_fixup(struct net_device *ndev); int of_fec_enet_parse_fixup(struct device_node *np); void fec_enet_get_mac_from_fuse(struct device_node *np, unsigned char *mac); +void fec_enet_ipg_stop_misc_set(struct device_node *np, bool enabled); /****************************************************************************/ #endif /* FEC_H */ diff --git a/drivers/net/ethernet/freescale/fec_fixup.c b/drivers/net/ethernet/freescale/fec_fixup.c index b78e0912961b..ad47a5759afc 100644 --- a/drivers/net/ethernet/freescale/fec_fixup.c +++ b/drivers/net/ethernet/freescale/fec_fixup.c @@ -197,9 +197,38 @@ static void imx8qm_get_mac_from_fuse(int dev_id, unsigned char *mac, mac[4] = val2; mac[5] = val2 >> 8; } + +static void imx8qm_ipg_stop_enable(int dev_id, bool enabled) +{ + uint32_t mu_id; + sc_ipc_t ipc_handle; + sc_err_t sc_err = SC_ERR_NONE; + uint32_t rsrc_id, val; + + sc_err = sc_ipc_getMuID(&mu_id); + if (sc_err != SC_ERR_NONE) { + pr_err("FEC MAC fuse: Get MU ID failed\n"); + return; + } + + sc_err = sc_ipc_open(&ipc_handle, mu_id); + if (sc_err != SC_ERR_NONE) { + pr_err("FEC MAC fuse: Open MU channel failed\n"); + return; + } + + if (dev_id == 0) + rsrc_id = SC_R_ENET_0; + else + rsrc_id = SC_R_ENET_1; + + val = enabled ? 1 : 0; + sc_misc_set_control(ipc_handle, rsrc_id, SC_C_IPG_STOP, val); +} #else static void imx8qm_get_mac_from_fuse(int dev_id, unsigned char *mac, struct imx_fuse_mac_addr *fuse_mapping) {} +static void imx8qm_ipg_stop_enable(int dev_id, bool enabled) {} #endif void fec_enet_get_mac_from_fuse(struct device_node *np, unsigned char *mac) @@ -222,3 +251,19 @@ void fec_enet_get_mac_from_fuse(struct device_node *np, unsigned char *mac) else if (of_machine_is_compatible("fsl,imx8mq")) imx8mq_get_mac_from_fuse(idx, mac); } + +void fec_enet_ipg_stop_misc_set(struct device_node *np, bool enabled) +{ + int idx; + + if (!np) + return; + + idx = of_alias_get_id(np, "ethernet"); + if (idx < 0) + idx = 0; + + if (of_machine_is_compatible("fsl,imx8qm") || + of_machine_is_compatible("fsl,imx8qxp")) + imx8qm_ipg_stop_enable(idx, enabled); +} diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index b75715f8bf7c..816c872c6c02 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -1128,6 +1128,7 @@ fec_restart(struct net_device *ndev) static int fec_enet_stop_mode(struct fec_enet_private *fep, bool enabled) { struct fec_platform_data *pdata = fep->pdev->dev.platform_data; + struct device_node *np = fep->pdev->dev.of_node; if (fep->gpr.gpr) { if (enabled) @@ -1140,6 +1141,8 @@ static int fec_enet_stop_mode(struct fec_enet_private *fep, bool enabled) 0); } else if (pdata && pdata->sleep_mode_enable) { pdata->sleep_mode_enable(enabled); + } else { + fec_enet_ipg_stop_misc_set(np, enabled); } return 0; |