Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2265500rwb; Thu, 27 Jul 2023 04:58:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlGxoXxWUJl0KNDSSB9+cLq1EzEh4RvLyaNZ4sqwfriMYssQtbtCKTXc2ywD/yz/RWPeuEb0 X-Received: by 2002:a05:6a20:4425:b0:131:4a64:9977 with SMTP id ce37-20020a056a20442500b001314a649977mr5701261pzb.50.1690459089047; Thu, 27 Jul 2023 04:58:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690459089; cv=none; d=google.com; s=arc-20160816; b=pzcFZbsDRUqxIuIors+JW4oXad5zgqu6RO0khmsE+ySRf5uaevymbfpyFUf2ozrD69 iRYzFw652HVDCgtWjkuut+fwcwZYSGL2R8PzSWyZylsdmOf6b75QYX2LYVYXCO+xhaSg bPRMLtNqHmuEVAbA3Eyh9n06H44FP/9MLZD8vDmaxMbTz3CdJtGAYEWb+vsazYen4pRa 5tm3FVWS0tREhKfE7Llr1z2AGEtd9NmF2YgrY5Li2V370zrupgzvLDMPqksOavl/VcBN pGjizYuMjGnsaPbCJwQhBN39cK950Aix2qBumxuct3YAUFjXsxTbNVt2sFVCSYyAsiJ9 1Sig== 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=IjBCbSJ221EebTwpD5WfVnJJ00Wo86oSbaahb9kz5ik=; fh=TO4fkcEI9b5r/wMetIII7RIVPqbK0XaoWpj6Tf2aW8M=; b=TLlJ25q8CFDEuCCCDA/iPkyESah3k8O71nsbiwR7IqIYAMgXi3XGHms7Rk9BzoVqaQ XQ6aSZxUiSjL38i4aYLnoVsISwrzl8gkseaT8eE/jCkXbY0fXYcgCC+ttm95HyTUR5sr Yd8YtR3ARE+MTIaYB8KJ3xvNLSmrPNOESyCFm3DsF3GhwnunCA7wNbbypuOAZxMD0nl4 sIOd3wJ7HtdMcmNoe35kG59eiMDTrHphIvYHeel3qJwf1nXQkNiXeqy6geKEGCQp8xkO ox3FPgYiHKUl4Ci9KHfpJn4XZzxvVjBslmsyU6sKiJJ7oER3CUR9mozS9GxoE0hCIxp7 PjrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=MwBXKwDw; 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 k9-20020a637b49000000b005321c340960si1132822pgn.811.2023.07.27.04.57.55; Thu, 27 Jul 2023 04:58:09 -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=MwBXKwDw; 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 S231533AbjG0Lau (ORCPT + 99 others); Thu, 27 Jul 2023 07:30:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231429AbjG0Lam (ORCPT ); Thu, 27 Jul 2023 07:30:42 -0400 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5728C2D4D; Thu, 27 Jul 2023 04:30:12 -0700 (PDT) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 36RBTgnB128131; Thu, 27 Jul 2023 06:29:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1690457382; bh=IjBCbSJ221EebTwpD5WfVnJJ00Wo86oSbaahb9kz5ik=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=MwBXKwDw4hwV3OZJ1gQAv5DoZ5SebGJhDRzQ/SVNFtf0wwhr6JD/Gs+wte8zfjXXX R/mMvWql7oPtYXfJfzPrcYo3K0pQiyOgFr4QriAiiUUiZmfzcQ41Wen+k7vz0GrTIk NtrfjXj7iLRLhfhz2hSoWXNMkH1T0u8gNiqTszAc= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 36RBTf6N039029 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 27 Jul 2023 06:29:42 -0500 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 27 Jul 2023 06:29:41 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE102.ent.ti.com (157.170.170.32) 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; Thu, 27 Jul 2023 06:29:41 -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 36RBTfiN092690; Thu, 27 Jul 2023 06:29:41 -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 36RBTeaX001462; Thu, 27 Jul 2023 06:29:40 -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 v12 10/10] net: ti: icssg-prueth: Add Power management support Date: Thu, 27 Jul 2023 16:58:27 +0530 Message-ID: <20230727112827.3977534-11-danishanwar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230727112827.3977534-1-danishanwar@ti.com> References: <20230727112827.3977534-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, RCVD_IN_MSPIKE_H2,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. Reviewed-by: Andrew Lunn Signed-off-by: MD Danish Anwar --- drivers/net/ethernet/ti/icssg/icssg_prueth.c | 57 ++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c index 01ba397ea2b6..3319373f8457 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c @@ -1817,6 +1817,62 @@ static void prueth_remove(struct platform_device *pdev) prueth_put_cores(prueth, ICSS_SLICE0); } +#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, @@ -1834,6 +1890,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