From patchwork Fri Jun 7 13:02:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diogo Ivo X-Patchwork-Id: 13689886 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 6C2B5C27C53 for ; Fri, 7 Jun 2024 13:14:43 +0000 (UTC) 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=l00zcDDgtwf5znwm20JMLq38hbmmK04P/iHW6lS1STQ=; b=NBtxAv5iO6CPto dGf8EMjz9Zru2wC0jgLHHxxF2jIMoIOVTbdR5ITnZwVkniPv3oaDDRy+srFxsXXSPWrfbCidweF7z +g5Q+AZv6JrxtI6eUaY+B0gywpEJHeJ/c5pCUMOieQNq0fc8Vw4obRBIosk9Va6/tm9E8rFbai8fr XH9eMQVVG4RY7S2DXigK0dK/8pZFQhhygKFliLP8E+FZkK1/si8FCpwKBLIA5GHJPKwGk2ETHH1I2 NkJ1B/Zhrr9EGWKYVd+MQ/TsD7ZyhDpuWYs1YNTXLgdD/1zThLkRkmyHwLi6IPbyinFmak4HEQD/M Q0nF5KdIDP8gV7Um77Jw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFZQL-0000000E4UL-1Kno; Fri, 07 Jun 2024 13:14:29 +0000 Received: from mta-65-226.siemens.flowmailer.net ([185.136.65.226]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFZQE-0000000E4Q9-068I for linux-arm-kernel@lists.infradead.org; Fri, 07 Jun 2024 13:14:23 +0000 Received: by mta-65-226.siemens.flowmailer.net with ESMTPSA id 20240607131411c609fa9967e825e823 for ; Fri, 07 Jun 2024 15:14:11 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm2; d=siemens.com; i=diogo.ivo@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=x4YRkE+XFm1D29pl4Ld17TEKG1sVow5yeZQG9PSUP5I=; b=nYmeSFk74uBHWoVjis9ZQ9m+FJ9ij+amjNoT5PiUDD19q+62u5h477q3LMBZEY35Y4szWD ZZ1ceJVATUF1+IlD/agl8j+BVQT71CKyZFsU5ts4olczCHLXSh4BhjzWp6BBIv+e7K0YLEyp 3FZ5vgtAqCBDgIU33fY3yPszvUC2I=; From: Diogo Ivo Date: Fri, 07 Jun 2024 14:02:42 +0100 Subject: [PATCH net-next v3 1/4] net: ti: icssg-prueth: Enable PTP timestamping support for SR1.0 devices MIME-Version: 1.0 Message-Id: <20240607-iep-v3-1-4824224105bc@siemens.com> References: <20240607-iep-v3-0-4824224105bc@siemens.com> In-Reply-To: <20240607-iep-v3-0-4824224105bc@siemens.com> To: MD Danish Anwar , Roger Quadros , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jan Kiszka , Jacob Keller , Simon Horman Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Diogo Ivo , Wojciech Drewek X-Developer-Signature: v=1; a=ed25519-sha256; t=1717766048; l=3143; i=diogo.ivo@siemens.com; s=20240529; h=from:subject:message-id; bh=gVkjhihYssjxx3HmUUIcdEn5ObHN127myBwzSS6vJW0=; b=/6z6UNJ8Q+JAQ6UI+lCH/iEhQ/GrLgj+QGFY9A2csJuBtmOkHvOKse56pxv2KMMjJJjIJUK9J MF01S7dd/yjDI6b2d/bGrge50GTXcT0N6AK54YGXc68BgCqoa4utP88 X-Developer-Key: i=diogo.ivo@siemens.com; a=ed25519; pk=BRGXhMh1q5KDlZ9y2B8SodFFY8FGupal+NMtJPwRpUQ= X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1320519:519-21489:flowmailer X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240607_061422_265524_1754A730 X-CRM114-Status: GOOD ( 11.60 ) 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 Enable PTP support for AM65x SR1.0 devices by registering with the IEP infrastructure in order to expose a PTP clock to userspace. Reviewed-by: Jacob Keller Reviewed-by: Wojciech Drewek Signed-off-by: Diogo Ivo --- drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c | 51 +++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c index 7b3304bbd7fc..fa98bdb11ece 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c @@ -1011,16 +1011,44 @@ static int prueth_probe(struct platform_device *pdev) dev_dbg(dev, "sram: pa %llx va %p size %zx\n", prueth->msmcram.pa, prueth->msmcram.va, prueth->msmcram.size); + prueth->iep0 = icss_iep_get_idx(np, 0); + if (IS_ERR(prueth->iep0)) { + ret = dev_err_probe(dev, PTR_ERR(prueth->iep0), + "iep0 get failed\n"); + goto free_pool; + } + + prueth->iep1 = icss_iep_get_idx(np, 1); + if (IS_ERR(prueth->iep1)) { + ret = dev_err_probe(dev, PTR_ERR(prueth->iep1), + "iep1 get failed\n"); + goto put_iep0; + } + + ret = icss_iep_init(prueth->iep0, NULL, NULL, 0); + if (ret) { + dev_err_probe(dev, ret, "failed to init iep0\n"); + goto put_iep; + } + + ret = icss_iep_init(prueth->iep1, NULL, NULL, 0); + if (ret) { + dev_err_probe(dev, ret, "failed to init iep1\n"); + goto exit_iep0; + } + if (eth0_node) { ret = prueth_netdev_init(prueth, eth0_node); if (ret) { dev_err_probe(dev, ret, "netdev init %s failed\n", eth0_node->name); - goto free_pool; + goto exit_iep; } if (of_find_property(eth0_node, "ti,half-duplex-capable", NULL)) prueth->emac[PRUETH_MAC0]->half_duplex = 1; + + prueth->emac[PRUETH_MAC0]->iep = prueth->iep0; } if (eth1_node) { @@ -1033,6 +1061,8 @@ static int prueth_probe(struct platform_device *pdev) if (of_find_property(eth1_node, "ti,half-duplex-capable", NULL)) prueth->emac[PRUETH_MAC1]->half_duplex = 1; + + prueth->emac[PRUETH_MAC1]->iep = prueth->iep1; } /* register the network devices */ @@ -1091,6 +1121,19 @@ static int prueth_probe(struct platform_device *pdev) prueth_netdev_exit(prueth, eth_node); } +exit_iep: + icss_iep_exit(prueth->iep1); +exit_iep0: + icss_iep_exit(prueth->iep0); + +put_iep: + icss_iep_put(prueth->iep1); + +put_iep0: + icss_iep_put(prueth->iep0); + prueth->iep0 = NULL; + prueth->iep1 = NULL; + free_pool: gen_pool_free(prueth->sram_pool, (unsigned long)prueth->msmcram.va, msmc_ram_size); @@ -1138,6 +1181,12 @@ static void prueth_remove(struct platform_device *pdev) prueth_netdev_exit(prueth, eth_node); } + icss_iep_exit(prueth->iep1); + icss_iep_exit(prueth->iep0); + + icss_iep_put(prueth->iep1); + icss_iep_put(prueth->iep0); + gen_pool_free(prueth->sram_pool, (unsigned long)prueth->msmcram.va, MSMC_RAM_SIZE_SR1);