From patchwork Tue Nov 21 15:53:02 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: 13463323 X-Patchwork-Delegate: geert@linux-m68k.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="0lwRPvKH" Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73ABB10C7 for ; Tue, 21 Nov 2023 07:53:43 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-54553e4888bso7983181a12.2 for ; Tue, 21 Nov 2023 07:53:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20230601.gappssmtp.com; s=20230601; t=1700582022; x=1701186822; 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=q1tQAoZQgFgk25StX3LmmkNTA/AsMdJ3cDJnMXgpoTs=; b=0lwRPvKHTRRLEiar3guYeByej6sZJ6/dcHV1KHZCNdmyG03hL6FCBGtPL/rnCugaka bXpw0Kq7kL/DrOOCMFsJcUEfWGXhyOihqgTcDTxSRO7s4GJl/liMsabweYi3jPsgLoQr SR3ZULZWJtklrcEEiBoXgl4TRhMl0tUS3SFWlZeShDokUKV26VUbFCb66hvDVbQk6moC d9zi7YUniuORdqgtZ0Vt7pGYT6x3SJnoG85MYH+kOykL6XrYOsLjZOaxE49jdFKhoGm8 wZrqYOyO5jwwsisCD6uq+BgcJEYZroJBe0kGBwMwUr6uzdEvc0MaYW7mEYZTQcWzi0J1 YOSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700582022; x=1701186822; 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=q1tQAoZQgFgk25StX3LmmkNTA/AsMdJ3cDJnMXgpoTs=; b=QdPQN/Jdn/9oRYceS9yWxaXhwghlmcm/lJt/xenLsJkJZqijda3KStHuCVfQcG+/RI p7HFeE3EA0QOKdJY1LkUXjG6+YgZInMmv5e9J6gWvIvWxmf+7LJCp8cE3GmIwXewW1YW O3ETDWP3pqIsi3tSCIl661lv4iNQD79jbHpjsxhttoOU5v6hkzDMimMxyAyFAVoI2ohd FC3hKkuh+9Ymqbb58n+tlDp/+2GZSvCFFF95cG7uo7vAUzUU5KiVFKVDMDioRPSIp8sf UpIEEI/PseLaW51jlR/j4hirbURdaLo4Oj6rqgkA4CLXVqUt27I6aax3miCXFI1CDi/L nA1w== X-Gm-Message-State: AOJu0Yy9OJXiXkb0eTGIH+04dImm9F79rGPQv1IsRxPa97sqSF9CTQQB UoRPB4xZ8jqWVvPkXSY0eTF+UA== X-Google-Smtp-Source: AGHT+IFumWJ3TPYOouLLfqM3uX8s7lAMI5kBa/WG6pmf3sp5L5nbdO83bWwAKC3hRbCzYR9rGum/Zg== X-Received: by 2002:a17:907:c007:b0:9d3:f436:61e5 with SMTP id ss7-20020a170907c00700b009d3f43661e5mr10541291ejc.29.1700582021271; Tue, 21 Nov 2023 07:53:41 -0800 (PST) Received: from sleipner.berto.se (p4fcc8a96.dip0.t-ipconnect.de. [79.204.138.150]) by smtp.googlemail.com with ESMTPSA id dv8-20020a170906b80800b009fdc15b5304sm2896853ejb.102.2023.11.21.07.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 07:53:40 -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 v3 1/5] net: ethernet: renesas: rcar_gen4_ptp: Remove incorrect comment Date: Tue, 21 Nov 2023 16:53:02 +0100 Message-ID: <20231121155306.515446-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121155306.515446-1-niklas.soderlund+renesas@ragnatech.se> References: <20231121155306.515446-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Reviewed-by: Simon Horman --- * Changes since v2 - No change. * 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 Tue Nov 21 15:53:03 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: 13463324 X-Patchwork-Delegate: geert@linux-m68k.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="aGYjPjNw" Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AACFE1A3 for ; Tue, 21 Nov 2023 07:53:43 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a00f67f120aso180211166b.2 for ; Tue, 21 Nov 2023 07:53:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20230601.gappssmtp.com; s=20230601; t=1700582022; x=1701186822; 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=OsgRT09PxDe983Ru7T/2ehV/VQm25XU9PRCmjt8k4L8=; b=aGYjPjNwEZjPn8kuBshn7NFi2dHasOAha6rlOSaPVBvs13Gdmwr30D8zQOcj8HSyBO t9cP00ZreHTnUnovPbs+2VZbf5ZfS2WVZH4TtACJWcpKU1obMBpOkLnNPyN9tCafg95B tISXzBfQPKcI/HJSI5JEzLJf1MYWjzn0aOBvR6qNNqsLe2AGPDXdaHUlCnpRydcMeWkz qUVckKsnOt87os5K6ry916EF4gDCUZKvcxY9fQUULjOdEt60ofVWkPG8bYmsirGTqn4W aqVjZ/xULE89IWP5f1Erc6ofyHy43CZR9UAV6z3qgoN+CoCwYr/YxJggyKpDn/0y4y7o YTjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700582022; x=1701186822; 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=OsgRT09PxDe983Ru7T/2ehV/VQm25XU9PRCmjt8k4L8=; b=Af6LoB8syDqdy00ifePH7NImz4xDXSkMy+F8yAeLaEQPWgZB/Uo5afpFIuTb2zoiCg +I3lAbNpRT0Z0urk63n3EP7gKEaZT3ksTn3L4GS/OHE+WsKo/J/6QbfWLri1SPZAIJQI cWEq4HF7dcX7ahn1GRHakeFEEA2hxlpCrsfWJgrKdT6Y+W73ouPeqqbrYFzfCNXBRSwf qjryzMrX5cmmiHZdg8yldIyaJOjgxOxx6ckcHM093o86Er3oAzm27RqGP5nS5pFyoWzo hj9wDCBS/TQWkhMzXX8Dp5XhivPOotOC6vgAOnHVVhNn/g7tbsHRRRFX0BGq3rh6f/uL Xu7Q== X-Gm-Message-State: AOJu0YxNCQs6HdTwXCdEQGBSPbLUugPgWbSgzT0d+4fbVSwi+pxIRSbZ T/u5n3q0Hz7l3LwY90wIlUyBQg== X-Google-Smtp-Source: AGHT+IFkaP85F01IPGjJeYVQuKY3ifaMp+75FN1HK2cHpYI9JkXozMDhhs3tuYprFTtd2vpVQciQtg== X-Received: by 2002:a17:906:ae46:b0:9fe:392:c535 with SMTP id lf6-20020a170906ae4600b009fe0392c535mr5313865ejb.69.1700582022034; Tue, 21 Nov 2023 07:53:42 -0800 (PST) Received: from sleipner.berto.se (p4fcc8a96.dip0.t-ipconnect.de. [79.204.138.150]) by smtp.googlemail.com with ESMTPSA id dv8-20020a170906b80800b009fdc15b5304sm2896853ejb.102.2023.11.21.07.53.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 07:53:41 -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 v3 2/5] net: ethernet: renesas: rcar_gen4_ptp: Fail on unknown register layout Date: Tue, 21 Nov 2023 16:53:03 +0100 Message-ID: <20231121155306.515446-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121155306.515446-1-niklas.soderlund+renesas@ragnatech.se> References: <20231121155306.515446-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Reviewed-by: Simon Horman --- * Changes since v2 - No change. * 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 Tue Nov 21 15:53:04 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: 13463325 X-Patchwork-Delegate: geert@linux-m68k.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="1yBNd35c" Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4C5410CF for ; Tue, 21 Nov 2023 07:53:44 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a02c48a0420so81109266b.2 for ; Tue, 21 Nov 2023 07:53:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20230601.gappssmtp.com; s=20230601; t=1700582023; x=1701186823; 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=WnAd+fxIMU0M2YoK/HG0/F62cLWjPueZxjIM5o5heQk=; b=1yBNd35cFskuw3LE/vXn+9efY5IynXYRz724nKrvztXx5VVytLQdSquNY/iKObdNuv auG/RM7qoCdYCePiE10ydIe9+owgMRGWoOjvp5roFwLCwZGfQrdkrRjX+q8B1azyIh2T o9yf6Vi1myH+18o3xaFJwX/NA3tW/8R6I6MK3waAhl5hO0ykCaY1DZfCx58Sabqkk7Rv DtXkJ+arzUwApTbxhoE0UbpCkq1xvRouRRtjzXWPHrQRvFEecZ9CoSXpoZlBgIEzDRro Q8flOyqNAqhzdOXWW2g8AbfKsxIK9MUv2ZNEWAfzVbCA5EvBujE4lZCdFuPpWCKRQHUF AMFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700582023; x=1701186823; 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=WnAd+fxIMU0M2YoK/HG0/F62cLWjPueZxjIM5o5heQk=; b=dpd0M23DJ+5X5c/GZNFkCCuKPDNRtBSLIqeRVVbyDoTv7mGLuhjpcWDLhuQnZ6S+wR H9PxEm1l2wnak2FH4v22FlINZjrcHohByU68oOgoiSQZg1CK+5OJVivy9UwQgFMZdcyJ 0KZ08ceKfhqgb802Q2do12RvuIlc3jbbZj7cEXYu/WsIy0obzmjDJf5WiYuG6LJwoJ9r EW1rXWSDRxXiqwIHcvLNwE8Bf/3vTclu/VLTiQO4kChnVRWSLoImleOaRc/SChqD4H83 s+3z5Rrxl27kuBKpYQNqcWKZyRKPVHcPe2DsR6SewTtJAhLoU0RM1PXv8tajN1m3aS4A qYLA== X-Gm-Message-State: AOJu0YwdvV7AvxEWnoFG7yXNao+GSKoa66r1FCosnrw56A4cUTnIU00A Kajj4RwOwvDIaTwPQ/3iTBd/Sw== X-Google-Smtp-Source: AGHT+IHNgT0RSd5XpQjVPdqZAhwakMa7fQmzFVifYxXJ/RQ6Z6jRRjcHep7Irojk4543l/o35jEYOQ== X-Received: by 2002:a17:906:25a:b0:a02:5bb:5658 with SMTP id 26-20020a170906025a00b00a0205bb5658mr1501587ejl.47.1700582022843; Tue, 21 Nov 2023 07:53:42 -0800 (PST) Received: from sleipner.berto.se (p4fcc8a96.dip0.t-ipconnect.de. [79.204.138.150]) by smtp.googlemail.com with ESMTPSA id dv8-20020a170906b80800b009fdc15b5304sm2896853ejb.102.2023.11.21.07.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 07:53:42 -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 v3 3/5] net: ethernet: renesas: rcar_gen4_ptp: Prepare for shared register layout Date: Tue, 21 Nov 2023 16:53:04 +0100 Message-ID: <20231121155306.515446-4-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121155306.515446-1-niklas.soderlund+renesas@ragnatech.se> References: <20231121155306.515446-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Reviewed-by: Simon Horman --- * Changes since v2 - No change. * 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 Tue Nov 21 15:53:05 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: 13463326 X-Patchwork-Delegate: geert@linux-m68k.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="aQbno+Ou" Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84C0D192 for ; Tue, 21 Nov 2023 07:53:45 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-548ce28fd23so2859722a12.3 for ; Tue, 21 Nov 2023 07:53:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20230601.gappssmtp.com; s=20230601; t=1700582024; x=1701186824; 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=17V51IIEuxQd+MF/T/vSwMOo1lXut//MySN2a8SEJuw=; b=aQbno+Ou3RpQ3/GITQEleP4BsvQ7A4DBxwpoJFndd9Ewt0yFQ4KyI+4lTe1UwD6h5G fgF5/2DiAfYz9F1U/n9BBzL+60CdKuE8t8cb/NQKw0OzeeVKh/eBOVaphQbisCbdCIrE 8rs2F4HpkkS0R8hQUaCEU8Z0GELf4QBYCYC0jLGAXN2HmvSKEKIZOaQ0L4bHA5u9tq4g ZKcNLFWN1kPOjeUGGa+CiySOGq70SxJah6BT8zp5BcBehinbiqqOA0E6lWhkfjj6X6gZ JPzZIpbu98VA0ksBGEKC6+8zApLfatwROjykqTYIHH8fxUo5x0D525xJd9WyhjNIXFHp DdgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700582024; x=1701186824; 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=17V51IIEuxQd+MF/T/vSwMOo1lXut//MySN2a8SEJuw=; b=Eh1L5AVnWouDdRgtbsD0DVYqA7l0rt0oMIhP9PW09TkLhsom31XpObkhCH/sjNuYRm kRXjoNRq6kyVccDl3m5lQHU78Jt3lQ3BBpK6KgDMDGPUDN/GKDiJ+G+3xZXhV812Vav4 Hg1NfhOfEFLwV+qMK/6W49aqfWGSDOyWDJbnSx1OdTpVt+EyZ/hgy6gkCxeAQ0Cz70/n umKFkmGWbSr4FB0X5YFNEphLI9QjEUs1DB5vCBRqkUG7Zxww8pQYf4IAaQy3sUkVe9Zg wAubpevJc4yzJvnGUSoWaa8JKfk7Bq/CKexRAw/wYk624x9PWGV0c73LXQfiD3cQjL+M Ua4w== X-Gm-Message-State: AOJu0Yz1WY8OyowhEG1CcCofgIWmBQS1D8maYfy+o8lol9Q4bpcTyySO 5NH0XO9MjrcXkXsd4uIS1AqemQ== X-Google-Smtp-Source: AGHT+IF4HGIOwlVl6A9RQNOfSZeru7tUlvSwoamjXR53yd5MKn9emQp5rP5UWW0bVKQXLWNIQ4iySg== X-Received: by 2002:a17:906:4ed0:b0:9fe:57b3:bc08 with SMTP id i16-20020a1709064ed000b009fe57b3bc08mr4521811ejv.41.1700582023871; Tue, 21 Nov 2023 07:53:43 -0800 (PST) Received: from sleipner.berto.se (p4fcc8a96.dip0.t-ipconnect.de. [79.204.138.150]) by smtp.googlemail.com with ESMTPSA id dv8-20020a170906b80800b009fdc15b5304sm2896853ejb.102.2023.11.21.07.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 07:53:43 -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 v3 4/5] net: ethernet: renesas: rcar_gen4_ptp: Get clock increment from clock rate Date: Tue, 21 Nov 2023 16:53:05 +0100 Message-ID: <20231121155306.515446-5-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121155306.515446-1-niklas.soderlund+renesas@ragnatech.se> References: <20231121155306.515446-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Reviewed-by: Simon Horman --- * Changes since v2 - No change. * 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 Tue Nov 21 15:53:06 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: 13463327 X-Patchwork-Delegate: geert@linux-m68k.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="C4Q2Qi4V" Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EB941AC for ; Tue, 21 Nov 2023 07:53:46 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5441305cbd1so7930721a12.2 for ; Tue, 21 Nov 2023 07:53:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20230601.gappssmtp.com; s=20230601; t=1700582024; x=1701186824; 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=+7NjNd9CEagYnBdGkDCsdTNCadER1wmGC0fqJQ3aE7s=; b=C4Q2Qi4VCvAaszVloUiwBH0/nK9zWdcHAA/qlTrjrrXeTxampcTN9Oljy6XZ7dDiXY 9QHN4R2LCYAnovYA1xDCwS167UNGVf3D100fXVpJDlMt3+oXiYESd8H0c6ZvAb9oDcNp 0v9SODbrGJcf2a57+xSuhAd6ix9PNYuefoTmNAiqhkOoPzkVhUG44lwvhpIilLqkfr7i fNceqsrZ3sG3ISL5DHfgQc00juDIPqNqi7dXFPwoCqlBWgL0lqY1k9HGbrYgmgQxiM0Q D1nQVFPyQLHBC2eWUoHu/EzZJlH1MbuLSrSSrfv/1xUAsK+GrwmKdGOd/J5OV8j9V+qF t0Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700582024; x=1701186824; 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=+7NjNd9CEagYnBdGkDCsdTNCadER1wmGC0fqJQ3aE7s=; b=pZXLE5dmFablJCYAWChb04QZk1KECo3FnZH1WU4dWdg0k30Iys7pX/nfiZHELQJyEE fymbc21mKDLFuTNhWHk/muhCiufS0FFsiMRCpjPqhM1xUDfeYNfnxdH4xLG01vQ0ogWn qGxK3FyHWtLKWZuYea9a1tihHAz1tHL967XeFW5gfWmmx01y1gK6lSPnHGe39VWjZ2AO 5p+Xm1mMnz9EwybovverkiGBbDY3Va/HRgGV3021+PTGQqV8zc2qwKjzfYufe1cBPdT7 fDVWrtVn459MWdNGIrkc+1mNq/Tfb6cpZYrLcmItBPA1rkMl+jPS3UR6UqEozTAHmO8L CRfQ== X-Gm-Message-State: AOJu0Yw9gyuiQtZJn0IGeMBtcmZfgY3xTXDv+ppJbHzWfwb5dY7c/juT Bn26b6KdJF+oBBSefQypV5fs/w== X-Google-Smtp-Source: AGHT+IGaeCwvreDI3HuvQec1U9qsXvmgbpGRw6bV3x2kFKHLQWUSgeA4BoBICB4OpuMZZDihPh+2DQ== X-Received: by 2002:a17:907:971d:b0:a00:40e7:c311 with SMTP id jg29-20020a170907971d00b00a0040e7c311mr3810382ejc.27.1700582024619; Tue, 21 Nov 2023 07:53:44 -0800 (PST) Received: from sleipner.berto.se (p4fcc8a96.dip0.t-ipconnect.de. [79.204.138.150]) by smtp.googlemail.com with ESMTPSA id dv8-20020a170906b80800b009fdc15b5304sm2896853ejb.102.2023.11.21.07.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 07:53:44 -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 v3 5/5] net: ethernet: renesas: rcar_gen4_ptp: Break out to module Date: Tue, 21 Nov 2023 16:53:06 +0100 Message-ID: <20231121155306.515446-6-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121155306.515446-1-niklas.soderlund+renesas@ragnatech.se> References: <20231121155306.515446-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Reviewed-by: Simon Horman --- * Changes since v2 - Drop the unneeded 'depends on' line from Kconfig symbol RENESAS_GEN4_PTP. * 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 | 9 +++++++++ drivers/net/ethernet/renesas/Makefile | 5 +++-- drivers/net/ethernet/renesas/rcar_gen4_ptp.c | 7 +++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/renesas/Kconfig b/drivers/net/ethernet/renesas/Kconfig index 8ef5b0241e64..733cbb6eb3ed 100644 --- a/drivers/net/ethernet/renesas/Kconfig +++ b/drivers/net/ethernet/renesas/Kconfig @@ -44,7 +44,16 @@ 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 + 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");