From patchwork Mon Nov 20 16:01:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13461555 X-Patchwork-Delegate: geert@linux-m68k.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 772B9C197A0 for ; Mon, 20 Nov 2023 16:03:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233500AbjKTQDd (ORCPT ); Mon, 20 Nov 2023 11:03:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231486AbjKTQDc (ORCPT ); Mon, 20 Nov 2023 11:03:32 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9ECF100 for ; Mon, 20 Nov 2023 08:03:28 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-409299277bbso15374405e9.2 for ; Mon, 20 Nov 2023 08:03:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20230601.gappssmtp.com; s=20230601; t=1700496207; x=1701101007; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RCuKJJPaD5V6lLtWPkXeck252UXqGAE7uAoQWOQcy7A=; b=n9+wGFoaq07UZl2jBer0LJnA6GzNJVhYdLs8c/ckH65Fbpu4Q8g9JClHRPv0dlovOu 4RT7vl159hknqDpa+2yiK6a5GY1ijEWkkYXz0wdj/VpwN+IgtxtqpZ8tl9LD8ePuuGAR y6tum0Pq2HgJ2VocCiKuVBW1ZTUA6M2UF7o3BqXNx71O6y+BP5Tqi5QdH7CzWkdjmVHe s9sINtPnjh/SFoQ7Kynni91EFiLP79rOZxS/rUUubsiszcJU/ht1/McpCO8yFPEGHwyN hBNgdJDIYDCSRk8S6ZcPPcQhJMF9f6vkRGCs9RcNtTIQJr6MK1uv7RELMMPPwTv4uqGN nNcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700496207; x=1701101007; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RCuKJJPaD5V6lLtWPkXeck252UXqGAE7uAoQWOQcy7A=; b=IVhPcB/++aOvGnzgfO0i994MEEJ6FW5rmnHO5NNrssJc088WfkpA0K9e5+73VqAKja vOVINaeKD0PDQ8nYUWZHWyLUJ4ZDQccwPsxx1OCnrybSRC75Cj4NPn8yBq3ppBLKLNkZ hafGFLebSkMdwJq+jRm5rTXPKNBn/62H2L0NgeUTz+DW8J0n5Rhq0gvyBCnzwycAr96m 4Xia8CHT1SE4oWRjonw2f1VlJgddb5SBfZj18OTabJPe5r7mYv/yznhuFHs4QvBh+VUY wFoVRCCZJ98s8qZ44Cri0c+0pYCvwngp836GXafO2fpgWLlQB5I+yPHC1ElyXY2yFtoj SZ/w== X-Gm-Message-State: AOJu0Yw8UIPAr8IzCiWNvzeSYRB/2xzZ0wHTkU0Adhw4YMBSmwOQt/HN N+BlIxxnFWwcY2QJbFgOA44MFg== X-Google-Smtp-Source: AGHT+IGrIn6cydY9Wp9P9eVUO8ONV3ded3Cd20aFLroq7J4ObGAvD/0N6ml7GMMx+5YPZ3v/3kn5Dg== X-Received: by 2002:a05:600c:4507:b0:401:daf2:2735 with SMTP id t7-20020a05600c450700b00401daf22735mr5802675wmo.31.1700496207198; Mon, 20 Nov 2023 08:03:27 -0800 (PST) Received: from sleipner.berto.se (p4fcc8a96.dip0.t-ipconnect.de. [79.204.138.150]) by smtp.googlemail.com with ESMTPSA id m21-20020a7bce15000000b004080f0376a0sm13564631wmc.42.2023.11.20.08.03.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 08:03:26 -0800 (PST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , netdev@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Wolfram Sang Subject: [net-next v2 1/5] net: ethernet: renesas: rcar_gen4_ptp: Remove incorrect comment Date: Mon, 20 Nov 2023 17:01:14 +0100 Message-ID: <20231120160118.3524309-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231120160118.3524309-1-niklas.soderlund+renesas@ragnatech.se> References: <20231120160118.3524309-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The comments intent was to indicates which function uses the enum. While upstreaming rcar_gen4_ptp the function was renamed but this comment was left with the old function name. Instead of correcting the comment remove it, it adds little value. Signed-off-by: Niklas Söderlund Reviewed-by: Wolfram Sang --- * Changes since v1 - Added review tag from Wolfram. --- drivers/net/ethernet/renesas/rcar_gen4_ptp.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/rcar_gen4_ptp.h b/drivers/net/ethernet/renesas/rcar_gen4_ptp.h index b1bbea8d3a52..9f148110df66 100644 --- a/drivers/net/ethernet/renesas/rcar_gen4_ptp.h +++ b/drivers/net/ethernet/renesas/rcar_gen4_ptp.h @@ -13,7 +13,6 @@ #define RCAR_GEN4_PTP_CLOCK_S4 PTPTIVC_INIT #define RCAR_GEN4_GPTP_OFFSET_S4 0x00018000 -/* for rcar_gen4_ptp_init */ enum rcar_gen4_ptp_reg_layout { RCAR_GEN4_PTP_REG_LAYOUT_S4 }; From patchwork Mon Nov 20 16:01:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13461556 X-Patchwork-Delegate: geert@linux-m68k.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 631C4C2BB3F for ; Mon, 20 Nov 2023 16:03:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233675AbjKTQDf (ORCPT ); Mon, 20 Nov 2023 11:03:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233671AbjKTQDe (ORCPT ); Mon, 20 Nov 2023 11:03:34 -0500 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACA20E7 for ; Mon, 20 Nov 2023 08:03:30 -0800 (PST) Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2c875207626so26308951fa.1 for ; Mon, 20 Nov 2023 08:03:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20230601.gappssmtp.com; s=20230601; t=1700496209; x=1701101009; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TAl6nd1nCzN04zqiBnYIqrG9SwaJGuvdGPy3QreQOpU=; b=fl30HzBajmU6iBX/sNZgfLeGSGBViaEUu7KUbSEmOLODZoM292E8eatYCZL4Ub09f0 +Rbtw3vzg09boNsmENP2mkMdjli6fBFsbu/z11YFdCmX4IhKH8gQ22RC7bYk4RHDXdil iMWLjKZAkbnkPcB6fkg+VJycPPckYppNLUCegngV/e4oU0BW/xGV2h3HFhsXpsOvb4I1 wJZ1/h90NdpWp0f3jYMJkYOXEfkP53WOd/DWzRNlC/L9naLcz1WB8VeU30TE16XH8mQm grjbM+IQTTI++AB8WvazShgNYHFnF2KXihqA6COnzIF3LWgtUvkFU/R563TyfWMVJS2Z q/1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700496209; x=1701101009; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TAl6nd1nCzN04zqiBnYIqrG9SwaJGuvdGPy3QreQOpU=; b=mn6FnZd54fofeHHYhDQP7UkUAGLnTk9/clLQuHmk4YD3YwXYmKH2/MkkU4V/r4TdpG v3wAl4Hy1yYLz+IZI2SdwkVartKk1+fLGKY478wuomrhEAitRJRYJTmZpspfUgiO8Eqk 6Yi4/5PIzomh7/7tAQtib+vDk3MuThurrgcVwShuGfxJwAXO+i3dRt2jSHWS063xoZAF 80Yvv+s5euP3bqcZoeCl0T+S3Wqd7VIfxuLy40TpXG+2qctfK5UR7jr0aBDsJboenkwJ rr+Zd5MtcdryJlamDZ7GoTDduCih9/LBuXj3rr1snuk59gz0zrCdVNn8TtKYldbfmnja WriQ== X-Gm-Message-State: AOJu0YypbdCEwDxPxUU9DwhfH8yRUc9vqJo/GxH5c6SvWVqsMuwiQYUY nChfsmhAXU1FYNGZW+ByYomIlA== X-Google-Smtp-Source: AGHT+IH9y3TjxSbJc9gvoYuUHR2atdzxyQzCyOsaNpkl35ZWJdmfWceSEAGzPZVSde7QgIkoFiUFzg== X-Received: by 2002:a2e:709:0:b0:2c5:6c7:9e73 with SMTP id 9-20020a2e0709000000b002c506c79e73mr5317559ljh.48.1700496208747; Mon, 20 Nov 2023 08:03:28 -0800 (PST) Received: from sleipner.berto.se (p4fcc8a96.dip0.t-ipconnect.de. [79.204.138.150]) by smtp.googlemail.com with ESMTPSA id m21-20020a7bce15000000b004080f0376a0sm13564631wmc.42.2023.11.20.08.03.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 08:03:27 -0800 (PST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , netdev@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Wolfram Sang Subject: [net-next v2 2/5] net: ethernet: renesas: rcar_gen4_ptp: Fail on unknown register layout Date: Mon, 20 Nov 2023 17:01:15 +0100 Message-ID: <20231120160118.3524309-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231120160118.3524309-1-niklas.soderlund+renesas@ragnatech.se> References: <20231120160118.3524309-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Instead of printing a warning and proceeding with an unknown register layout return an error. The only call site is already prepared to propagate the error. Signed-off-by: Niklas Söderlund Reviewed-by: Wolfram Sang --- * Changes since v1 - Added review tag from Wolfram. --- drivers/net/ethernet/renesas/rcar_gen4_ptp.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/renesas/rcar_gen4_ptp.c b/drivers/net/ethernet/renesas/rcar_gen4_ptp.c index c007e33c47e1..443ca5a18703 100644 --- a/drivers/net/ethernet/renesas/rcar_gen4_ptp.c +++ b/drivers/net/ethernet/renesas/rcar_gen4_ptp.c @@ -130,23 +130,30 @@ static struct ptp_clock_info rcar_gen4_ptp_info = { .enable = rcar_gen4_ptp_enable, }; -static void rcar_gen4_ptp_set_offs(struct rcar_gen4_ptp_private *ptp_priv, - enum rcar_gen4_ptp_reg_layout layout) +static int rcar_gen4_ptp_set_offs(struct rcar_gen4_ptp_private *ptp_priv, + enum rcar_gen4_ptp_reg_layout layout) { - WARN_ON(layout != RCAR_GEN4_PTP_REG_LAYOUT_S4); + if (layout != RCAR_GEN4_PTP_REG_LAYOUT_S4) + return -EINVAL; ptp_priv->offs = &s4_offs; + + return 0; } int rcar_gen4_ptp_register(struct rcar_gen4_ptp_private *ptp_priv, enum rcar_gen4_ptp_reg_layout layout, u32 clock) { + int ret; + if (ptp_priv->initialized) return 0; spin_lock_init(&ptp_priv->lock); - rcar_gen4_ptp_set_offs(ptp_priv, layout); + ret = rcar_gen4_ptp_set_offs(ptp_priv, layout); + if (ret) + return ret; ptp_priv->default_addend = clock; iowrite32(ptp_priv->default_addend, ptp_priv->addr + ptp_priv->offs->increment); From patchwork Mon Nov 20 16:01:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13461557 X-Patchwork-Delegate: geert@linux-m68k.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0875C197A0 for ; Mon, 20 Nov 2023 16:03:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233671AbjKTQDg (ORCPT ); Mon, 20 Nov 2023 11:03:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231486AbjKTQDg (ORCPT ); Mon, 20 Nov 2023 11:03:36 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95556E7 for ; Mon, 20 Nov 2023 08:03:32 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4083f613272so20473685e9.1 for ; Mon, 20 Nov 2023 08:03:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20230601.gappssmtp.com; s=20230601; t=1700496211; x=1701101011; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DBeiRtTR30Aw803NjtzRAQiI+Q09Cy8Ok3O7jfIgDgA=; b=MNsrX7oz/Ad9YS7d1955q6K17E6AxoKo7txpHcWSHap9xCb8pkffN/n0AF4MFzZfPH T2DYclbCd/DSieRuZWUCfI0sWlMhyFy4JQsgwNufOvaUAtGEq4CMs94rzL310sVUrBo1 dp/JnrN5Y0QVk/3DqYnkw36YydiuBwgI1PL6imT4B+OcBST26LXflgBq4kHXnNBsDNB8 tSuaLW/iYRbGJXwofkKyng8b2l1v6c2dKG2oGCy5G8zFrNG20np33ao1oI7hare1PvY3 TsMKZytasIrwJaW2Vn4oFhESQmfmdwTdIuLSrFLsl+7AU4ixEdyywW+ipZ6FksuG05JQ YFbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700496211; x=1701101011; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DBeiRtTR30Aw803NjtzRAQiI+Q09Cy8Ok3O7jfIgDgA=; b=eTJEbXqAquVbNyvrb4KaDaH+iBrjfjBc/SZA3DLihs49j1u4u+ryRvuyNkROX1y64o 5PGRZPMPaQG3PF4ZpGPOXqyQxa4QNvzZ+oYG3BYH+UY7+wsIMzObfTcXW0EjbCT6gXg+ JdIkvuUr/63mPNnHUpS9QHIU67bIDwAOYAMebiIMMgYrwEbieVyXG80fLUeQkg7pIrev +tqRdonSmnwQhhMdgNQYFUU/rihrkyUcHruP54JBPSp2EKXcAYjeUPBbr7QR8z7f9vTL ITHlzLl4Xbt5e3LFoQpLTz6l2DY3TGHz2f5wFqCKKtbyRe2e1+wbK3hQa9Mo+n4zEgdX k14Q== X-Gm-Message-State: AOJu0Yw7hRZYZU0PE+qji48pLCdCgpoNrR8o2jM9VJt6ClN1a50tOeIu BhvTwtenCDOxUGrMUOVh9D6jAQ== X-Google-Smtp-Source: AGHT+IEhdRXHJH9C1lGvVT5c9+d+yG+EGNpVGHT6+dHmHovhw1nYFnMGUmTSojTe4I/1sUNCgjfrTw== X-Received: by 2002:a05:600c:1c83:b0:40a:4a5c:3af0 with SMTP id k3-20020a05600c1c8300b0040a4a5c3af0mr6672691wms.24.1700496211100; Mon, 20 Nov 2023 08:03:31 -0800 (PST) Received: from sleipner.berto.se (p4fcc8a96.dip0.t-ipconnect.de. [79.204.138.150]) by smtp.googlemail.com with ESMTPSA id m21-20020a7bce15000000b004080f0376a0sm13564631wmc.42.2023.11.20.08.03.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 08:03:29 -0800 (PST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , netdev@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Wolfram Sang Subject: [net-next v2 3/5] net: ethernet: renesas: rcar_gen4_ptp: Prepare for shared register layout Date: Mon, 20 Nov 2023 17:01:16 +0100 Message-ID: <20231120160118.3524309-4-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231120160118.3524309-1-niklas.soderlund+renesas@ragnatech.se> References: <20231120160118.3524309-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org All known R-Car Gen4 SoC share the same register layout, rename the R-Car S4 specific identifiers so they can be shared with the upcoming R-Car V4H support. Signed-off-by: Niklas Söderlund Reviewed-by: Wolfram Sang --- * Changes since v1 - Fix spelling in commit message. - Added review tag from Wolfram. --- drivers/net/ethernet/renesas/rcar_gen4_ptp.c | 6 +++--- drivers/net/ethernet/renesas/rcar_gen4_ptp.h | 4 ++-- drivers/net/ethernet/renesas/rswitch.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/renesas/rcar_gen4_ptp.c b/drivers/net/ethernet/renesas/rcar_gen4_ptp.c index 443ca5a18703..59f6351e9ae9 100644 --- a/drivers/net/ethernet/renesas/rcar_gen4_ptp.c +++ b/drivers/net/ethernet/renesas/rcar_gen4_ptp.c @@ -14,7 +14,7 @@ #include "rcar_gen4_ptp.h" #define ptp_to_priv(ptp) container_of(ptp, struct rcar_gen4_ptp_private, info) -static const struct rcar_gen4_ptp_reg_offset s4_offs = { +static const struct rcar_gen4_ptp_reg_offset gen4_offs = { .enable = PTPTMEC, .disable = PTPTMDC, .increment = PTPTIVC0, @@ -133,10 +133,10 @@ static struct ptp_clock_info rcar_gen4_ptp_info = { static int rcar_gen4_ptp_set_offs(struct rcar_gen4_ptp_private *ptp_priv, enum rcar_gen4_ptp_reg_layout layout) { - if (layout != RCAR_GEN4_PTP_REG_LAYOUT_S4) + if (layout != RCAR_GEN4_PTP_REG_LAYOUT) return -EINVAL; - ptp_priv->offs = &s4_offs; + ptp_priv->offs = &gen4_offs; return 0; } diff --git a/drivers/net/ethernet/renesas/rcar_gen4_ptp.h b/drivers/net/ethernet/renesas/rcar_gen4_ptp.h index 9f148110df66..35664d1dc472 100644 --- a/drivers/net/ethernet/renesas/rcar_gen4_ptp.h +++ b/drivers/net/ethernet/renesas/rcar_gen4_ptp.h @@ -14,7 +14,7 @@ #define RCAR_GEN4_GPTP_OFFSET_S4 0x00018000 enum rcar_gen4_ptp_reg_layout { - RCAR_GEN4_PTP_REG_LAYOUT_S4 + RCAR_GEN4_PTP_REG_LAYOUT }; /* driver's definitions */ @@ -27,7 +27,7 @@ enum rcar_gen4_ptp_reg_layout { #define PTPRO 0 -enum rcar_gen4_ptp_reg_s4 { +enum rcar_gen4_ptp_reg { PTPTMEC = PTPRO + 0x0010, PTPTMDC = PTPRO + 0x0014, PTPTIVC0 = PTPRO + 0x0020, diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index 43a7795d6591..e1e29a2caf22 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1828,7 +1828,7 @@ static int rswitch_init(struct rswitch_private *priv) rswitch_fwd_init(priv); - err = rcar_gen4_ptp_register(priv->ptp_priv, RCAR_GEN4_PTP_REG_LAYOUT_S4, + err = rcar_gen4_ptp_register(priv->ptp_priv, RCAR_GEN4_PTP_REG_LAYOUT, RCAR_GEN4_PTP_CLOCK_S4); if (err < 0) goto err_ptp_register; From patchwork Mon Nov 20 16:01:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13461558 X-Patchwork-Delegate: geert@linux-m68k.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D0AEC197A0 for ; Mon, 20 Nov 2023 16:03:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233751AbjKTQDj (ORCPT ); Mon, 20 Nov 2023 11:03:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233746AbjKTQDi (ORCPT ); Mon, 20 Nov 2023 11:03:38 -0500 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 656EA116 for ; Mon, 20 Nov 2023 08:03:34 -0800 (PST) Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2c6b30acacdso57627761fa.2 for ; Mon, 20 Nov 2023 08:03:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20230601.gappssmtp.com; s=20230601; t=1700496212; x=1701101012; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WWR8mH0snzJeJ0OqKxEnUfckbbEo5Y+jU7UsXhSvYEg=; b=syTMbxR/1W+Ye7l3Fhe/hdFfCcGkNhzawL+Y92c5BM7k9fIjox0pxbrOSbhqB1T5pf w7Igyp0DbCnmjAF2UVDYrVeDqpZ0gxZnYavNHZLpbejQcZxp0+3RruD4SQxuI7uqRq/Q IRqVLefLrw763tc5yt0f0zgvkuYfuBnQzTatbxuqxZPnuZoMn5Sqmg6GYOitDBui9TTb gtOuKKAndK+W0v2JO1aphzqQuquu92JC44ZnyGTwTp6BVv/p3siAZpXbEdK0muFqx0UH fqNQSBDal8tIa618rmnRDwS/+JGFhgZ57tqfQthBdfAX03SNQwgS6rbCiJdwlXYU6LJU vXfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700496212; x=1701101012; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WWR8mH0snzJeJ0OqKxEnUfckbbEo5Y+jU7UsXhSvYEg=; b=mGJz9Zp9gvzZcXNA5xt1mgg1FV0Sc0vXtQ2TgwsVQtkajFuHVTOWh97DoBdMlGSYTg h3eGWnPl18IWv9coyT0xAiLMQe4LQgYm1pn12m8BcvdDBcaweiPgbJJyPc2FP5LgmKkW cL1/2BNIWDkDnbTahhQiQxTUiBId49vIU15+HodMpmyLiaMy289n5xPRqeZFsOlW/opL iwLARvTWN231KEODnqBrrA4n9l/giiSoOuT71Ki3i/7huJu51MGhXjJyhU5JL+jAREU2 qz1F/YZuee4B1fhoVc8XKijV03INHuUijMAKmfkXwV1kAyeryNS3s2Ackz4+oduh9Pix kcIA== X-Gm-Message-State: AOJu0Yzp4am/gOeMXQ7neXHoEMcRiLZz2xdWljea30xlQtKl8oeNCD4U MRm2mYOYD+rBryHutdwIpxe9zg== X-Google-Smtp-Source: AGHT+IFWxADQkF/OwNhFoaa3Lm6bCrCfgTEaR5/3SxqpH39mcIVeYXeRfrfdcrPUNFNYoyVJlqfDrQ== X-Received: by 2002:a05:651c:382:b0:2c8:87d6:1fbb with SMTP id e2-20020a05651c038200b002c887d61fbbmr756247ljp.31.1700496212571; Mon, 20 Nov 2023 08:03:32 -0800 (PST) Received: from sleipner.berto.se (p4fcc8a96.dip0.t-ipconnect.de. [79.204.138.150]) by smtp.googlemail.com with ESMTPSA id m21-20020a7bce15000000b004080f0376a0sm13564631wmc.42.2023.11.20.08.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 08:03:31 -0800 (PST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , netdev@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Geert Uytterhoeven Subject: [net-next v2 4/5] net: ethernet: renesas: rcar_gen4_ptp: Get clock increment from clock rate Date: Mon, 20 Nov 2023 17:01:17 +0100 Message-ID: <20231120160118.3524309-5-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231120160118.3524309-1-niklas.soderlund+renesas@ragnatech.se> References: <20231120160118.3524309-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Instead of using hard coded clock increment values for each SoC derive the clock increment from the module clock. This is done in preparation to support a second platform, R-Car V4H that uses a 200Mhz clock compared with the 320Mhz clock used on R-Car S4. Tested on both SoCs, S4 reports a clock of 320000000Hz which gives a value of 0x19000000. Documentation says a 320Mhz clock is used and the correct increment for that clock is 0x19000000. V4H reports a clock of 199999992Hz which gives a value of 0x2800001a. Documentation says a 200Mhz clock is used and the correct increment for that clock is 0x28000000. Suggested-by: Geert Uytterhoeven Signed-off-by: Niklas Söderlund --- * Changes since v1 - New in v2. In v1 a patch adding a new hard coded value for V4H was present, that patch have been dropped in favor of this approach. --- drivers/net/ethernet/renesas/rcar_gen4_ptp.c | 14 ++++++++++++-- drivers/net/ethernet/renesas/rcar_gen4_ptp.h | 4 +--- drivers/net/ethernet/renesas/rswitch.c | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/renesas/rcar_gen4_ptp.c b/drivers/net/ethernet/renesas/rcar_gen4_ptp.c index 59f6351e9ae9..9583894634ae 100644 --- a/drivers/net/ethernet/renesas/rcar_gen4_ptp.c +++ b/drivers/net/ethernet/renesas/rcar_gen4_ptp.c @@ -141,8 +141,18 @@ static int rcar_gen4_ptp_set_offs(struct rcar_gen4_ptp_private *ptp_priv, return 0; } +static s64 rcar_gen4_ptp_rate_to_increment(u32 rate) +{ + /* Timer increment in ns. + * bit[31:27] - integer + * bit[26:0] - decimal + * increment[ns] = perid[ns] * 2^27 => (1ns * 2^27) / rate[hz] + */ + return div_s64(1000000000LL << 27, rate); +} + int rcar_gen4_ptp_register(struct rcar_gen4_ptp_private *ptp_priv, - enum rcar_gen4_ptp_reg_layout layout, u32 clock) + enum rcar_gen4_ptp_reg_layout layout, u32 rate) { int ret; @@ -155,7 +165,7 @@ int rcar_gen4_ptp_register(struct rcar_gen4_ptp_private *ptp_priv, if (ret) return ret; - ptp_priv->default_addend = clock; + ptp_priv->default_addend = rcar_gen4_ptp_rate_to_increment(rate); iowrite32(ptp_priv->default_addend, ptp_priv->addr + ptp_priv->offs->increment); ptp_priv->clock = ptp_clock_register(&ptp_priv->info, NULL); if (IS_ERR(ptp_priv->clock)) diff --git a/drivers/net/ethernet/renesas/rcar_gen4_ptp.h b/drivers/net/ethernet/renesas/rcar_gen4_ptp.h index 35664d1dc472..e22da5acd53d 100644 --- a/drivers/net/ethernet/renesas/rcar_gen4_ptp.h +++ b/drivers/net/ethernet/renesas/rcar_gen4_ptp.h @@ -9,8 +9,6 @@ #include -#define PTPTIVC_INIT 0x19000000 /* 320MHz */ -#define RCAR_GEN4_PTP_CLOCK_S4 PTPTIVC_INIT #define RCAR_GEN4_GPTP_OFFSET_S4 0x00018000 enum rcar_gen4_ptp_reg_layout { @@ -64,7 +62,7 @@ struct rcar_gen4_ptp_private { }; int rcar_gen4_ptp_register(struct rcar_gen4_ptp_private *ptp_priv, - enum rcar_gen4_ptp_reg_layout layout, u32 clock); + enum rcar_gen4_ptp_reg_layout layout, u32 rate); int rcar_gen4_ptp_unregister(struct rcar_gen4_ptp_private *ptp_priv); struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev); diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index e1e29a2caf22..d6089429f654 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1829,7 +1829,7 @@ static int rswitch_init(struct rswitch_private *priv) rswitch_fwd_init(priv); err = rcar_gen4_ptp_register(priv->ptp_priv, RCAR_GEN4_PTP_REG_LAYOUT, - RCAR_GEN4_PTP_CLOCK_S4); + clk_get_rate(priv->clk)); if (err < 0) goto err_ptp_register; From patchwork Mon Nov 20 16:01:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13461559 X-Patchwork-Delegate: geert@linux-m68k.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF3C7C5AD4C for ; Mon, 20 Nov 2023 16:03:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233746AbjKTQDk (ORCPT ); Mon, 20 Nov 2023 11:03:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233740AbjKTQDj (ORCPT ); Mon, 20 Nov 2023 11:03:39 -0500 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA6B4A7 for ; Mon, 20 Nov 2023 08:03:35 -0800 (PST) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-50970c2115eso6535324e87.1 for ; Mon, 20 Nov 2023 08:03:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20230601.gappssmtp.com; s=20230601; t=1700496214; x=1701101014; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Qer5SIgtLUsRnvdV4wIK4MVmII4A/reZeCq78BgyVHs=; b=vJXcUxqzL69qzWIxz964/H4wl6qOFllrt407lDIkJPzcIC4M+xELDMYj1WHO1HWBiV 7DeEyPqFMGJOtPoYdmZq6vIkQJGltTWM6tB32PEWSbd59z2DR4ZIQGcrYqcp5LJVDoY1 7xuLkR7SUaKhCEhVNM29q85P6HXrzI/1FGwa/zWXdViKfIWc9rASAtg/ZBpaeQ4xp599 uIgLZa9u2FYxCnrp65ZvmlQekknofj1urtiy7tVUMFk6ZwGCUVT0MqIPmFQ7o4KFXgel uSDmjElUWBLQCWbo8T0kD1sdGqM+wzGGkJUILDKF7N07wAQ2hN+cIPB0vSFhan20LDOa pLTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700496214; x=1701101014; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qer5SIgtLUsRnvdV4wIK4MVmII4A/reZeCq78BgyVHs=; b=KLMIDW3GSd5/kBn4XKhuLY8mMKrFoChU2mrHTKMDIRYR7bzoRHQ6CtG8fGWRIvmWRt TFrc/iWLyLKbZkSwaVWNghS/AHLfWSpd36sjJOaRF2PiE94VU12UcA0MzfF9r9vf2Q8o OJ201ER89EQYMTi9vDt1sgCJKfy0/M8NDPJ09HRnJfnodxGkYhCURvJxDyKWmUTTBwuF YOcxcQtsupFp6T2Kekc8mSNAWiR5DkRfQVtO7Y7PKenjlG5U2vW3+cbAXYgeozkPgwNX jCidUtq6yjCHdjcsQrgdq7iQ6ADSW49mlogPAnT+8OEddrBg9MHUjWMHyfEv6fns7exe s2SA== X-Gm-Message-State: AOJu0YzFTnmjh80ReQYPfyqTe8nbzO4PBHfoWLwd0/x//CD8ot1sdkp1 7qNCjKm+csW/Wb3WCUXOGSgCzQ== X-Google-Smtp-Source: AGHT+IE/JH4O1AgW0MQmqNiPFcTJsQoZ04eHzRRpqqhKljW8mWvlGUoQAFLMlaGmIk9pUbyHaE5lpg== X-Received: by 2002:ac2:44a9:0:b0:507:a9b7:f071 with SMTP id c9-20020ac244a9000000b00507a9b7f071mr5100756lfm.1.1700496213929; Mon, 20 Nov 2023 08:03:33 -0800 (PST) Received: from sleipner.berto.se (p4fcc8a96.dip0.t-ipconnect.de. [79.204.138.150]) by smtp.googlemail.com with ESMTPSA id m21-20020a7bce15000000b004080f0376a0sm13564631wmc.42.2023.11.20.08.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 08:03:33 -0800 (PST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , netdev@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [net-next v2 5/5] net: ethernet: renesas: rcar_gen4_ptp: Break out to module Date: Mon, 20 Nov 2023 17:01:18 +0100 Message-ID: <20231120160118.3524309-6-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231120160118.3524309-1-niklas.soderlund+renesas@ragnatech.se> References: <20231120160118.3524309-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The Gen4 gPTP support will be shared between the existing Renesas Ethernet Switch driver and the upcoming Renesas Ethernet-TSN driver. In preparation for this break out the gPTP support to its own module. Signed-off-by: Niklas Söderlund --- * Changes since v1 - s/Gen3/Gen4/ in commit message. - Add missing MODULE_AUTHOR() and MODULE_DESCRIPTION() definitions. - Make Kconfig tristate depend on COMPILE_TEST. All drivers that make use of the shared code auto selects this anyhow. --- drivers/net/ethernet/renesas/Kconfig | 10 ++++++++++ drivers/net/ethernet/renesas/Makefile | 5 +++-- drivers/net/ethernet/renesas/rcar_gen4_ptp.c | 7 +++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/renesas/Kconfig b/drivers/net/ethernet/renesas/Kconfig index 8ef5b0241e64..5a2e7da90e69 100644 --- a/drivers/net/ethernet/renesas/Kconfig +++ b/drivers/net/ethernet/renesas/Kconfig @@ -44,7 +44,17 @@ config RENESAS_ETHER_SWITCH select CRC32 select MII select PHYLINK + select RENESAS_GEN4_PTP help Renesas Ethernet Switch device driver. +config RENESAS_GEN4_PTP + tristate "Renesas R-Car Gen4 gPTP support" if COMPILE_TEST + depends on ARCH_RENESAS || COMPILE_TEST + select CRC32 + select MII + select PHYLIB + help + Renesas R-Car Gen4 gPTP device driver. + endif # NET_VENDOR_RENESAS diff --git a/drivers/net/ethernet/renesas/Makefile b/drivers/net/ethernet/renesas/Makefile index e8fd85b5fe8f..9070acfd6aaf 100644 --- a/drivers/net/ethernet/renesas/Makefile +++ b/drivers/net/ethernet/renesas/Makefile @@ -8,5 +8,6 @@ obj-$(CONFIG_SH_ETH) += sh_eth.o ravb-objs := ravb_main.o ravb_ptp.o obj-$(CONFIG_RAVB) += ravb.o -rswitch_drv-objs := rswitch.o rcar_gen4_ptp.o -obj-$(CONFIG_RENESAS_ETHER_SWITCH) += rswitch_drv.o +obj-$(CONFIG_RENESAS_ETHER_SWITCH) += rswitch.o + +obj-$(CONFIG_RENESAS_GEN4_PTP) += rcar_gen4_ptp.o diff --git a/drivers/net/ethernet/renesas/rcar_gen4_ptp.c b/drivers/net/ethernet/renesas/rcar_gen4_ptp.c index 9583894634ae..72e7fcc56693 100644 --- a/drivers/net/ethernet/renesas/rcar_gen4_ptp.c +++ b/drivers/net/ethernet/renesas/rcar_gen4_ptp.c @@ -176,6 +176,7 @@ int rcar_gen4_ptp_register(struct rcar_gen4_ptp_private *ptp_priv, return 0; } +EXPORT_SYMBOL_GPL(rcar_gen4_ptp_register); int rcar_gen4_ptp_unregister(struct rcar_gen4_ptp_private *ptp_priv) { @@ -183,6 +184,7 @@ int rcar_gen4_ptp_unregister(struct rcar_gen4_ptp_private *ptp_priv) return ptp_clock_unregister(ptp_priv->clock); } +EXPORT_SYMBOL_GPL(rcar_gen4_ptp_unregister); struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev) { @@ -196,3 +198,8 @@ struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev) return ptp; } +EXPORT_SYMBOL_GPL(rcar_gen4_ptp_alloc); + +MODULE_AUTHOR("Yoshihiro Shimoda"); +MODULE_DESCRIPTION("Renesas R-Car Gen4 gPTP driver"); +MODULE_LICENSE("GPL");