Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2996661rwo; Mon, 24 Jul 2023 04:55:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlHNzfrS7QV6NyyDOhT1b2JsyFzPe8cC+e1elKsOTf7gsEBa81rssob8kpaJlqDUOwKdTG1H X-Received: by 2002:a17:906:9bf6:b0:993:ec93:a5ef with SMTP id de54-20020a1709069bf600b00993ec93a5efmr9153891ejc.47.1690199711734; Mon, 24 Jul 2023 04:55:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690199711; cv=none; d=google.com; s=arc-20160816; b=BZYUofJ4AIzPg/UWiofsZQX1fXe2tD0rmERyj8RPgO0JLKqmN5QfTGRw9SI1ZDeFrx Bzkvg2SrJ9liuIP44ix2GUALhCee3B2TJj90w0mnAu4HxdCvRSwq+U/csKE5rt72v3JX npZ8giMka3S1mVrVow09k0kn36qU30M7Nl1Tg+LMIygll8dExB/02j4Sn0R/gA033tSJ zKI1cnE14a2seqLLRivQt8ZQOIQPl9Uz5av9W7A6tT9sG3JmbQJhNHF2thivFeJtpaqN P/ljcmlM67nTAw4Lo5ghf6Dex8rCqt/40957zik/Uqh1SOO+HAUCV67ZbMYGiZMw+eOr sC8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TUFI28QkqhwCli+ZAIc0ejOORJ5GwGvqBlmS1gbjbB4=; fh=TO4fkcEI9b5r/wMetIII7RIVPqbK0XaoWpj6Tf2aW8M=; b=e07U56g6CN11Xr1jAXV6pWOrvFHjxKsnhai/IU6hl3jUzg2Sz9uc5kUpVjYNLvCTlq 7ywNWPC+ztIxmHp3hgImI9uh8RqvQ98MPuV+buz6jvv83lRO1Vf14A5cqlLhF44l60hp HdTRys/DG6C6GtwxSVRzp9wMXU5yhRTMzAs1rKWNN/NlbiDiseHrTlObcoVr0FO/khY8 jxDTUTDWZA0YSZGamgyDqLZp7aRj4xYtEVM2x0dFPMzYgEJkw+gHHSP7SVKrQATlS+gX l63l7fQ8Cd7iGT65JqVfszs2CUK2vs+geOAOiI/UVHcLQy/2RsuYlVTRqPQA27TBxuRH OjZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=WUhsKRtA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h18-20020a1709063c1200b0098e48ad11e8si5837791ejg.902.2023.07.24.04.54.45; Mon, 24 Jul 2023 04:55:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=WUhsKRtA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229608AbjGXLcO (ORCPT + 99 others); Mon, 24 Jul 2023 07:32:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230110AbjGXLbv (ORCPT ); Mon, 24 Jul 2023 07:31:51 -0400 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43DA9E7B; Mon, 24 Jul 2023 04:31:24 -0700 (PDT) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 36OBUpbg049976; Mon, 24 Jul 2023 06:30:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1690198251; bh=TUFI28QkqhwCli+ZAIc0ejOORJ5GwGvqBlmS1gbjbB4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=WUhsKRtAL6vOdDTZPlr1I3GUkQrWsRkgkJZ617ydXQPD1ZtN+KfFjp3qvnecVOhyz /cHLQNI5Ug5tCq+NnBOOtKcmvLXReyUtZiLfJ/PuHpDFoRcJrUi5W1m6IhwGZlpPgU FIFvYw3RFErvLk5x87l/pyl7bCFjn5W70lEtnSO0= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 36OBUp9c065145 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 24 Jul 2023 06:30:51 -0500 Received: from DFLE109.ent.ti.com (10.64.6.30) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 24 Jul 2023 06:30:50 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 24 Jul 2023 06:30:50 -0500 Received: from lelv0854.itg.ti.com (lelv0854.itg.ti.com [10.181.64.140]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 36OBUot7076926; Mon, 24 Jul 2023 06:30:50 -0500 Received: from localhost (uda0501179.dhcp.ti.com [172.24.227.217]) by lelv0854.itg.ti.com (8.14.7/8.14.7) with ESMTP id 36OBUn38010863; Mon, 24 Jul 2023 06:30:50 -0500 From: MD Danish Anwar To: Randy Dunlap , Roger Quadros , Simon Horman , Vignesh Raghavendra , Andrew Lunn , Richard Cochran , Conor Dooley , Krzysztof Kozlowski , Rob Herring , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , MD Danish Anwar CC: , , , , , , Subject: [PATCH v11 10/10] net: ti: icssg-prueth: Add Power management support Date: Mon, 24 Jul 2023 16:59:34 +0530 Message-ID: <20230724112934.2637802-11-danishanwar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724112934.2637802-1-danishanwar@ti.com> References: <20230724112934.2637802-1-danishanwar@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add suspend / resume APIs to support power management in ICSSG ethernet driver. Signed-off-by: MD Danish Anwar Reviewed-by: Andrew Lunn --- drivers/net/ethernet/ti/icssg_prueth.c | 57 ++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/drivers/net/ethernet/ti/icssg_prueth.c b/drivers/net/ethernet/ti/icssg_prueth.c index a34e29ed3351..53d93a33c64d 100644 --- a/drivers/net/ethernet/ti/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg_prueth.c @@ -1835,6 +1835,62 @@ static int prueth_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int prueth_suspend(struct device *dev) +{ + struct prueth *prueth = dev_get_drvdata(dev); + struct net_device *ndev; + int i, ret; + + for (i = 0; i < PRUETH_NUM_MACS; i++) { + ndev = prueth->registered_netdevs[i]; + + if (!ndev) + continue; + + if (netif_running(ndev)) { + netif_device_detach(ndev); + ret = emac_ndo_stop(ndev); + if (ret < 0) { + netdev_err(ndev, "failed to stop: %d", ret); + return ret; + } + } + } + + return 0; +} + +static int prueth_resume(struct device *dev) +{ + struct prueth *prueth = dev_get_drvdata(dev); + struct net_device *ndev; + int i, ret; + + for (i = 0; i < PRUETH_NUM_MACS; i++) { + ndev = prueth->registered_netdevs[i]; + + if (!ndev) + continue; + + if (netif_running(ndev)) { + ret = emac_ndo_open(ndev); + if (ret < 0) { + netdev_err(ndev, "failed to start: %d", ret); + return ret; + } + netif_device_attach(ndev); + } + } + + return 0; +} +#endif /* CONFIG_PM_SLEEP */ + +static const struct dev_pm_ops prueth_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(prueth_suspend, prueth_resume) +}; + static const struct prueth_pdata am654_icssg_pdata = { .fdqring_mode = K3_RINGACC_RING_MODE_MESSAGE, .quirk_10m_link_issue = 1, @@ -1852,6 +1908,7 @@ static struct platform_driver prueth_driver = { .driver = { .name = "icssg-prueth", .of_match_table = prueth_dt_match, + .pm = &prueth_dev_pm_ops, }, }; module_platform_driver(prueth_driver); -- 2.34.1