From patchwork Fri Jan 10 07:13:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basharath Hussain Khaja X-Patchwork-Id: 13933873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 59AEEE7719C for ; Fri, 10 Jan 2025 07:18:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OJK9edcXiUw0RWX6sjEYfyqim2K+D1H/MN+6E+o7jTk=; b=TzDvwiQ1LTqowfbvOfflwjKFaC xb/WUx9WF9WxW83Xm1gVm1Fob1cVP5i1XmxgWtQbl4YDdBNe4zoAzTQwxFbe+Tg/NANyOi/DfTV4Q aza3xd/D3v4sVR9InQT8p+6i/K9fnAYlQFwknsZ5dGc9eY+tQ7jSuJmIdKwtO3Ae+M30evkxl+eNI oQPWEWVGZJTv7LgNfdx/5XrhZ0MpnXc+EmGscSs05a3V/NpezlDEmvbko6r/k5+bzt6MjwCv6LTt2 sWuguIwNxiA/HjYvdK2gWSGnC4Fdc9ihofHpZ1rb8TTizScYup7/MpTUQJXRLR7guLSRifjMszq23 9m2VLpTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tW9Hs-0000000EMDm-30Y2; Fri, 10 Jan 2025 07:18:32 +0000 Received: from server.wki.vra.mybluehostin.me ([162.240.238.73]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tW9Ea-0000000ELml-1SnI for linux-arm-kernel@lists.infradead.org; Fri, 10 Jan 2025 07:15:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=couthit.com ; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=OJK9edcXiUw0RWX6sjEYfyqim2K+D1H/MN+6E+o7jTk=; b=ojvBWUYbLxsx2D5ovmnSfS7cf2 NOfAyK4zywukHHDet93UXwA6PATdU78WX68mT0CAYRWs/htvvGnJLGHDwAfYuduH+6pR0azuwfCqx gR875OvR0j1T8dWtROQgxT/AjJaE6U8ZEoM8fbegaq6JSO/rF7kiybFO3qdXjDXVEHZhPWiIn/14i 5DXcfCLq8rLqGeJPsVYnHiuE0ANX0aX7Z0a3/00znnMr4ryyNMr46w/hVwj83mIZ9ntcFQGtqf9hf fvoQx1bvvYTftV8EUx61s2T/eZ0+3KdHcdjMz/qksCk1WkOSqlFyJUVrZLqgdE1AgwgGFucntgXYc HLfQpuBg==; Received: from [122.175.9.182] (port=50142 helo=cypher.couthit.local) by server.wki.vra.mybluehostin.me with esmtpa (Exim 4.96.2) (envelope-from ) id 1tW9ET-0002S5-39; Fri, 10 Jan 2025 12:45:02 +0530 From: Basharath Hussain Khaja To: danishanwar@ti.com, rogerq@kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, nm@ti.com, ssantosh@kernel.org, tony@atomide.com, richardcochran@gmail.com, parvathi@couthit.com, basharath@couthit.com, schnelle@linux.ibm.com, rdunlap@infradead.org, diogo.ivo@siemens.com, m-karicheri2@ti.com, horms@kernel.org, jacob.e.keller@intel.com, m-malladi@ti.com, javier.carrasco.cruz@gmail.com, afd@ti.com, s-anna@ti.com Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, pratheesh@ti.com, prajith@ti.com, vigneshr@ti.com, praneeth@ti.com, srk@ti.com, rogerq@ti.com, krishna@couthit.com, pmohan@couthit.com, mohan@couthit.com Subject: [RFC PATCH 09/10] net: ti: prueth: Adds power management support for PRU-ICSS Date: Fri, 10 Jan 2025 12:43:50 +0530 Message-Id: <20250110071351.66888-10-basharath@couthit.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250109105600.41297-1-basharath@couthit.com> References: <20250109105600.41297-1-basharath@couthit.com> MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.wki.vra.mybluehostin.me X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - couthit.com X-Get-Message-Sender-Via: server.wki.vra.mybluehostin.me: authenticated_id: basharath@couthit.com X-Authenticated-Sender: server.wki.vra.mybluehostin.me: basharath@couthit.com X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250109_231508_411865_5B404F78 X-CRM114-Status: GOOD ( 12.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Roger Quadros 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 Signed-off-by: Andrew F. Davis Signed-off-by: Parvathi Pudi Signed-off-by: Basharath Hussain Khaja --- drivers/net/ethernet/ti/icssm/icssm_prueth.c | 62 ++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/drivers/net/ethernet/ti/icssm/icssm_prueth.c b/drivers/net/ethernet/ti/icssm/icssm_prueth.c index 97de6b7ebd29..7727975dab88 100644 --- a/drivers/net/ethernet/ti/icssm/icssm_prueth.c +++ b/drivers/net/ethernet/ti/icssm/icssm_prueth.c @@ -2325,6 +2325,67 @@ static void icssm_prueth_remove(struct platform_device *pdev) pru_rproc_put(prueth->pru0); } +#ifdef CONFIG_PM_SLEEP +static int icssm_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 = icssm_emac_ndo_stop(ndev); + if (ret < 0) { + netdev_err(ndev, "failed to stop: %d", ret); + return ret; + } + } + } + + pruss_cfg_ocp_master_ports(prueth->pruss, 0); + + return 0; +} + +static int icssm_prueth_resume(struct device *dev) +{ + struct prueth *prueth = dev_get_drvdata(dev); + struct net_device *ndev; + int i, ret; + + pruss_cfg_ocp_master_ports(prueth->pruss, 1); + + for (i = 0; i < PRUETH_NUM_MACS; i++) { + ndev = prueth->registered_netdevs[i]; + + if (!ndev) + continue; + + if (netif_running(ndev)) { + ret = icssm_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(icssm_prueth_suspend, icssm_prueth_resume) +}; + /* AM57xx SoC-specific firmware data */ static struct prueth_private_data am57xx_prueth_pdata = { .fw_pru[PRUSS_PRU0] = { @@ -2349,6 +2410,7 @@ static struct platform_driver prueth_driver = { .driver = { .name = "prueth", .of_match_table = prueth_dt_match, + .pm = &prueth_dev_pm_ops, }, }; module_platform_driver(prueth_driver);