Skip to content

Commit f87f8be

Browse files
Roger QuadrosNipaLocal
authored andcommitted
net: ti: prueth: Adds power management support for PRU-ICSS
Changes for supporting the sleep/resume feature for PRU-ICSS. PRU-ICSS will be kept in IDLE mode for optimal power consumption by Linux power management subsystem and will be resumed when it is required. Signed-off-by: Roger Quadros <[email protected]> Signed-off-by: Andrew F. Davis <[email protected]> Signed-off-by: Basharath Hussain Khaja <[email protected]> Signed-off-by: Parvathi Pudi <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 1b02a2b commit f87f8be

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

drivers/net/ethernet/ti/icssm/icssm_prueth.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,6 +2324,63 @@ static void icssm_prueth_remove(struct platform_device *pdev)
23242324
pru_rproc_put(prueth->pru1);
23252325
}
23262326

2327+
#ifdef CONFIG_PM_SLEEP
2328+
static int icssm_prueth_suspend(struct device *dev)
2329+
{
2330+
struct prueth *prueth = dev_get_drvdata(dev);
2331+
struct net_device *ndev;
2332+
int i, ret;
2333+
2334+
for (i = 0; i < PRUETH_NUM_MACS; i++) {
2335+
ndev = prueth->registered_netdevs[i];
2336+
2337+
if (!ndev)
2338+
continue;
2339+
2340+
if (netif_running(ndev)) {
2341+
netif_device_detach(ndev);
2342+
ret = icssm_emac_ndo_stop(ndev);
2343+
if (ret < 0) {
2344+
netdev_err(ndev, "failed to stop: %d", ret);
2345+
return ret;
2346+
}
2347+
}
2348+
}
2349+
2350+
return 0;
2351+
}
2352+
2353+
static int icssm_prueth_resume(struct device *dev)
2354+
{
2355+
struct prueth *prueth = dev_get_drvdata(dev);
2356+
struct net_device *ndev;
2357+
int i, ret;
2358+
2359+
for (i = 0; i < PRUETH_NUM_MACS; i++) {
2360+
ndev = prueth->registered_netdevs[i];
2361+
2362+
if (!ndev)
2363+
continue;
2364+
2365+
if (netif_running(ndev)) {
2366+
ret = icssm_emac_ndo_open(ndev);
2367+
if (ret < 0) {
2368+
netdev_err(ndev, "failed to start: %d", ret);
2369+
return ret;
2370+
}
2371+
netif_device_attach(ndev);
2372+
}
2373+
}
2374+
2375+
return 0;
2376+
}
2377+
2378+
#endif /* CONFIG_PM_SLEEP */
2379+
2380+
static const struct dev_pm_ops prueth_dev_pm_ops = {
2381+
SET_SYSTEM_SLEEP_PM_OPS(icssm_prueth_suspend, icssm_prueth_resume)
2382+
};
2383+
23272384
/* AM57xx SoC-specific firmware data */
23282385
static struct prueth_private_data am57xx_prueth_pdata = {
23292386
.driver_data = PRUSS_AM57XX,
@@ -2349,6 +2406,7 @@ static struct platform_driver prueth_driver = {
23492406
.driver = {
23502407
.name = "prueth",
23512408
.of_match_table = prueth_dt_match,
2409+
.pm = &prueth_dev_pm_ops,
23522410
},
23532411
};
23542412
module_platform_driver(prueth_driver);

0 commit comments

Comments
 (0)