From patchwork Mon Sep 13 17:38:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 12490347 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 527D5C433EF for ; Mon, 13 Sep 2021 17:50:27 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2A1A3610CF for ; Mon, 13 Sep 2021 17:50:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2A1A3610CF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Cjo3eM0tDnJR/90y0+vk7CngwGf2UIA+qWjtIBg3P58=; b=T9w/TFiQsf++CB ux9UMU8WtmJ9lIrIS4ABdT3d9toBT7RuC2JjASO95QMyj+ciHV/RZDSLrI4AZKcWbynkSQcyxPtSK ZAChjeroaiyZ91/WCzoWObQmTORRFHZFk9XooGEfmxapwx8RZxoHY2RGrx+MZaL0x8k0zAcv4JT81 N0RfCygyZvLKGL1KStFJ+qu/xnmK5q1lh76vSky04y3rQBJtMVOsF2zGXuaXnaiCuNTogjst5qqbq 3Iiy7VX/6kEs3ffbkFT4pl2r+K+dJF3wXKuKfBy7VznqcydG21hGSWvxVKOpl25XBIYK74vRvvtAT TxexaUSk3zzOB4rjSW+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mPq3t-002oLX-Cv; Mon, 13 Sep 2021 17:48:09 +0000 Received: from inva021.nxp.com ([92.121.34.21]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mPpug-002jqf-Kv for linux-arm-kernel@lists.infradead.org; Mon, 13 Sep 2021 17:38:40 +0000 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 674092005AC; Mon, 13 Sep 2021 19:38:37 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 4F5EE2005E6; Mon, 13 Sep 2021 19:38:37 +0200 (CEST) Received: from fsr-ub1664-175.ea.freescale.net (fsr-ub1664-175.ea.freescale.net [10.171.82.40]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 80C6820363; Mon, 13 Sep 2021 19:38:36 +0200 (CEST) From: Abel Vesa To: Rob Herring , Dong Aisheng , Shawn Guo , Sascha Hauer , Fabio Estevam , "catalin.marinas@arm.com" , Will Deacon , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Georgi Djakov , Adrian Hunter , Ulf Hansson , Ahmad Fatoum Cc: Pengutronix Kernel Team , linux-serial@vger.kernel.org, NXP Linux Team , Linux Kernel Mailing List , devicetree@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Abel Vesa Subject: [RFC 17/19] net: ethernet: fec_main: Add interconnect support Date: Mon, 13 Sep 2021 20:38:12 +0300 Message-Id: <1631554694-9599-18-git-send-email-abel.vesa@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1631554694-9599-1-git-send-email-abel.vesa@nxp.com> References: <1631554694-9599-1-git-send-email-abel.vesa@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210913_103839_010131_1F2E8932 X-CRM114-Status: GOOD ( 18.58 ) 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On probe, if the dts node contains a valid icc path, then look for the fsl,icc-rate property and get the rate. Also set the icc bandwidth for that path to the nominal rate needed for fec to function right. Then enable and disable the path every time the fec is used or not. This will result in reducing the clock speeds along the icc path for each pl301 and NoC, but still meet the requirements for all the other icc consumers. Signed-off-by: Abel Vesa --- drivers/net/ethernet/freescale/fec.h | 3 +++ drivers/net/ethernet/freescale/fec_main.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h index 7b4961daa254..2c5784febbeb 100644 --- a/drivers/net/ethernet/freescale/fec.h +++ b/drivers/net/ethernet/freescale/fec.h @@ -558,6 +558,9 @@ struct fec_enet_private { unsigned int num_tx_queues; unsigned int num_rx_queues; + struct icc_path *bus_path; + unsigned int bus_rate; + /* The saved address of a sent-in-place packet/buffer, for skfree(). */ struct fec_enet_priv_tx_q *tx_queue[FEC_ENET_MAX_TX_QS]; struct fec_enet_priv_rx_q *rx_queue[FEC_ENET_MAX_RX_QS]; diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 80bd5c629fa0..67374d436e73 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -3805,6 +3806,18 @@ fec_probe(struct platform_device *pdev) fep->pdev = pdev; fep->dev_id = dev_id++; + fep->bus_path = devm_of_icc_get(&pdev->dev, "path"); + if (IS_ERR(fep->bus_path)) { + return PTR_ERR(fep->bus_path); + } else if (fep->bus_path) { + if (of_property_read_u32(np, "fsl,icc-rate", &fep->bus_rate)) { + dev_err(&pdev->dev, "icc-rate missing\n"); + return -EINVAL; + } + + icc_set_bw(fep->bus_path, 0, fep->bus_rate); + } + platform_set_drvdata(pdev, ndev); if ((of_machine_is_compatible("fsl,imx6q") || @@ -4075,6 +4088,8 @@ static int __maybe_unused fec_suspend(struct device *dev) if (fep->clk_enet_out || fep->reg_phy) fep->link = 0; + icc_disable(fep->bus_path); + return 0; } @@ -4085,6 +4100,8 @@ static int __maybe_unused fec_resume(struct device *dev) int ret; int val; + icc_enable(fep->bus_path); + if (fep->reg_phy && !(fep->wol_flag & FEC_WOL_FLAG_ENABLE)) { ret = regulator_enable(fep->reg_phy); if (ret) @@ -4134,6 +4151,7 @@ static int __maybe_unused fec_runtime_suspend(struct device *dev) clk_disable_unprepare(fep->clk_ahb); clk_disable_unprepare(fep->clk_ipg); + icc_disable(fep->bus_path); return 0; } @@ -4143,6 +4161,7 @@ static int __maybe_unused fec_runtime_resume(struct device *dev) struct fec_enet_private *fep = netdev_priv(ndev); int ret; + icc_enable(fep->bus_path); ret = clk_prepare_enable(fep->clk_ahb); if (ret) return ret;