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: 13461562 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech-se.20230601.gappssmtp.com header.i=@ragnatech-se.20230601.gappssmtp.com header.b="n9+wGFoa" Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E750A112 for ; Mon, 20 Nov 2023 08:03:28 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-407da05f05aso15360505e9.3 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=gMxVIJgWF56pqybL+gbip6RNFOdeVBDPuhN90n8RB9wI9utTh5hqY9obYjcPyiIZYp /H/ehC3Zo0vj+0GwanWb/yvDbZtHbjiCPPku6I1RbU/Y+HHts/FGarq4AoHRF62VHhIt nv8sXOKOf58h0oLtfNCFUcxbLwWY+ZfnXpqbWTx3VQLTVQwFAPoIxuZq0dqLz0pNUCSZ h/tHmue1WNnnlaxI+oSyF764Fufr/v1TSR48ILayTJ16TR+YxsadwRDIC8GHfV9gqUZM 2jFcGJYOzEgLcDwimkJZG99zP2v8X6n7ldSezckJU+zu29FOBiRlhoGDCcTYEJHS7XkX cE9A== X-Gm-Message-State: AOJu0YyWFu/QwqyDDXKpi1KFCFJPbFT/70m3+YugA45byqc9MuNXbY7T OYhE448zrglis1ZRE1OTf3ZlNw== 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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@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: 13461563 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech-se.20230601.gappssmtp.com header.i=@ragnatech-se.20230601.gappssmtp.com header.b="fl30HzBa" Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F556B4 for ; Mon, 20 Nov 2023 08:03:30 -0800 (PST) Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2c876e44157so24017791fa.2 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=IM/9ekOdBky1+gXEyhFqSXkYHG+6YMFuy0t5jOU24WHHtyyg/vJ04bv9p7e++yLawj K2TncU83+LK2B6l8DbpezndpgIbSfydcHtp4+GJz1Z4gdnvI98qCZpii9dlVs69JYPEJ OD81laZ2eNbQR3LyPsLddGphKZp2kouTsxzX/khjJjYCvikxssggBCejMFKYRvwQEfp+ VYNBNOV39zRBtzBX5w1bhnHdJC+vz8JPvGGfthEVpu4ECyWElxcZj8eJ4o9adqpOEGwJ Yf+pMj5im/Q/eUE826UpTXqYCzHUWw6mNaBzChfC+lBfAbzsjOqtzPETpaBaziEsHqtH o6Ww== X-Gm-Message-State: AOJu0YxcOpLQVzrm+4lH5JP6IQZfVg8zT7sJVP4sYb73e/cBVMBBxJr1 dADNvqjKzYtWdCklihllFWcvgg== 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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@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: 13461564 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech-se.20230601.gappssmtp.com header.i=@ragnatech-se.20230601.gappssmtp.com header.b="MNsrX7oz" 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 95D96100 for ; Mon, 20 Nov 2023 08:03:32 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40b23aeb9d9so7553495e9.3 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=QrIIRbXg9RK7XS0UkplpAvXoJBZFnxNptgobCt6b4R9XC37vOwCoWw+pbWO9qWqvgQ Po7DVfMZo5E8nvA1hepcOcn0A/uOVNPlIKKfI2l40U/RDFnwLKG7DgbdsnGJDHCw1u6u xenqdz8okPi0VKI1imQWE39GXstBgjh/qDtv76BeL1geAd9iP+y19UFm7ICWjmccJNvl Q3yOAt5M/NWkj5ErFAr0sc10ML4LC/r7Cc/FP0J4EVPw6NEASLe9sWSPITwlpH2kqz3U kwz/kDYrt4P4uFN+dl7IAjPTxHZvbKyTIo/hLT0gZvwULxm97KI9Vc/zYlpV8UQ1uEX5 axdA== X-Gm-Message-State: AOJu0YxFzwtaM806CACQVdcFleQz/mos+GmA7MGcsbHJgZPCfrLAxWcq DeqxbWpx69OcSXwGdcmRw7r6hg== 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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@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: 13461565 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech-se.20230601.gappssmtp.com header.i=@ragnatech-se.20230601.gappssmtp.com header.b="syTMbxR/" Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63309114 for ; Mon, 20 Nov 2023 08:03:34 -0800 (PST) Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2c88750e7d1so6720981fa.3 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=YLa4+OAfxTz6jrQmmqhUbJH+CyApBuGO9x1S/ZFIvHypi79Oao1YmTPv3ca3C2ujtS Eo8N4cwBqIpfLgUw14En/yg2wUp0zF8RaK0qStJFXONOI5AIFkv5XFqHZ0gDSCsCppad 1Y/MymJb+xLHSY2SKcWjDzJ84+RfZfQEhPRfQKLvSLEfeD+7V6veJQMmgDanbXrcJqls Cz7c6/QzjVFbCuyg7D6uIPIy+m13+uneT+6Ln+z1QXlwTuSavMzZD0uyEUYakIQzsxnw LgUqWuyOigN2mIQs6oCSpHlZirCBTnu4Ok+Q+9X0LlLwzVx3v2SdP4vgVpbcHEOMnMpP xOtg== X-Gm-Message-State: AOJu0YwUgGS+lf+OXAHjaQq/j50OGHDf4zSf2MamSl1flJHnubi15XWx sgLNzys2tp+roNJkZRt0ET2gBA== 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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@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: 13461566 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech-se.20230601.gappssmtp.com header.i=@ragnatech-se.20230601.gappssmtp.com header.b="vJXcUxqz" Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA764AA for ; Mon, 20 Nov 2023 08:03:35 -0800 (PST) Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-50970c2115eso6535325e87.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=jXg47pmC67dCBOuJFNd3rXMtO8WGkWJo7Uc2frTBkDJi/LDTldf59ANH84SkcX2l6o fr0+0DpLTdgqz8DCIG0xL0YdIsepBpPLbfddDH7Ak9DIEGWpk5MlSO0JRCOCSE17G+Cc QdZqs/aaMoGdadgOJG1Ae7Ed8fibWfymzoCeUd1P4ocF1m39Cwmthg3IZWb7KlAbFoeS 7mpDUAl3sJzg5PpzmL0w+6en1P2z4lxbgOjVOJpqYQiJeFPorCaa182hLPJ+F25SsEPx YoHPRqPaQK2/nHeMaxQqQc0KS0HzO2CWng2LT7YoR0bKeF68Y5PP6OyEnpnIvTsdMn7V eZ1g== X-Gm-Message-State: AOJu0Ywo1ooFzMryPsiVFG6Y5sEnex7698hvEOntI94VD+CzpM7PvrJL A65LL6j85w/iUcFtQkLDsEYDpQ== 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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@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");