From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Magnus Damm <magnus.damm@gmail.com>,
Richard Cochran <richardcochran@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"DavidS. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Vadim Fedorenko <vadim.fedorenko@linux.dev>,
Sergey Shtylyov <sergei.shtylyov@gmail.com>,
linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Cc: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Subject: [PATCH net-next v2 08/10] net: ethernet: ravb: Add callback for gPTP clock index
Date: Tue, 11 Aug 2026 18:01:58 +0200 [thread overview]
Message-ID: <20260811160200.2049987-9-niklas.soderlund+renesas@ragnatech.se> (raw)
In-Reply-To: <20260811160200.2049987-1-niklas.soderlund+renesas@ragnatech.se>
Prepare for adding Gen4 support which have an optional external gPTP
clock. Add a callback to get the clock index and use it to determine if
the device shall report gPTP support.
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Sergey Shtylyov <sergei.shtylyov@gmail.com>
---
drivers/net/ethernet/renesas/ravb.h | 2 ++
drivers/net/ethernet/renesas/ravb_main.c | 19 +++++++++++++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 60f32bfa48c6..b4df5cab0e5c 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1042,6 +1042,7 @@ struct ravb_ptp {
* critical points in the RAVB driver.
*
* @probe: Probe the gPTP clock
+ * @clock_index: Get the PTP clock index, if any
* @set_config_mode: Enter config mode
* @dmac_start: Called when the DMAC starts
* @dmac_stop: Called when the DMAC stops
@@ -1050,6 +1051,7 @@ struct ravb_ptp {
*/
struct ravb_gptp_info {
int (*probe)(struct net_device *ndev);
+ int (*clock_index)(struct net_device *ndev);
int (*set_config_mode)(struct net_device *ndev);
int (*dmac_start)(struct net_device *ndev);
void (*dmac_stop)(struct net_device *ndev);
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 743f53f61bb8..12877a8488ed 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1773,8 +1773,13 @@ static int ravb_get_ts_info(struct net_device *ndev,
{
struct ravb_private *priv = netdev_priv(ndev);
const struct ravb_hw_info *hw_info = priv->info;
+ int index = -1;
- if (hw_info->ptp) {
+ if (hw_info->ptp && hw_info->ptp->clock_index)
+ index = hw_info->ptp->clock_index(ndev);
+
+ /* Only advertise ptp clock if present. */
+ if (index >= 0) {
info->so_timestamping =
SOF_TIMESTAMPING_TX_SOFTWARE |
SOF_TIMESTAMPING_TX_HARDWARE |
@@ -1785,7 +1790,7 @@ static int ravb_get_ts_info(struct net_device *ndev,
(1 << HWTSTAMP_FILTER_NONE) |
(1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
(1 << HWTSTAMP_FILTER_ALL);
- info->phc_index = ptp_clock_index(priv->ptp.clock);
+ info->phc_index = index;
}
return 0;
@@ -2653,6 +2658,13 @@ static int ravb_gen2_ptp_probe(struct net_device *ndev)
return ravb_compute_gti(ndev, priv->clk);
}
+static int ravb_gen2_ptp_clock_index(struct net_device *ndev)
+{
+ struct ravb_private *priv = netdev_priv(ndev);
+
+ return ptp_clock_index(priv->ptp.clock);
+}
+
static int ravb_gen2_ptp_set_config_mode(struct net_device *ndev)
{
int ret;
@@ -2669,6 +2681,7 @@ static int ravb_gen2_ptp_set_config_mode(struct net_device *ndev)
static const struct ravb_gptp_info ravb_gen2_ptp_info = {
.probe = ravb_gen2_ptp_probe,
+ .clock_index = ravb_gen2_ptp_clock_index,
.set_config_mode = ravb_gen2_ptp_set_config_mode,
.dmac_start = ravb_ptp_init,
.dmac_stop = ravb_ptp_stop,
@@ -2706,6 +2719,7 @@ static int ravb_gen3_ptp_set_config_mode(struct net_device *ndev)
static const struct ravb_gptp_info ravb_gen3_ptp_info = {
.probe = ravb_gen2_ptp_probe,
+ .clock_index = ravb_gen2_ptp_clock_index,
.set_config_mode = ravb_gen3_ptp_set_config_mode,
.ndev_open = ravb_ptp_init,
.ndev_close = ravb_ptp_stop,
@@ -2778,6 +2792,7 @@ static int ravb_rzv2m_ptp_probe(struct net_device *ndev)
static const struct ravb_gptp_info ravb_rzv2m_ptp_info = {
.probe = ravb_rzv2m_ptp_probe,
+ .clock_index = ravb_gen2_ptp_clock_index,
.set_config_mode = ravb_gen2_ptp_set_config_mode,
.dmac_start = ravb_ptp_init,
.dmac_stop = ravb_ptp_stop,
--
2.55.0
next prev parent reply other threads:[~2026-08-11 16:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 16:01 [PATCH net-next v2 00/10] ravb: Add gPTP support for Gen4 Niklas Söderlund
2026-08-11 16:01 ` [PATCH net-next v2 01/10] net: ethernet: ravb: Remove gPTP control from WoL setup and restore Niklas Söderlund
2026-08-11 16:01 ` [PATCH net-next v2 02/10] net: ethernet: ravb: Move programming of gPTP timer interval Niklas Söderlund
2026-08-11 16:01 ` [PATCH net-next v2 03/10] net: ethernet: ravb: Simplify gPTP start and stop Niklas Söderlund
2026-08-11 16:01 ` [PATCH net-next v2 04/10] net: ethernet: ravb: Remove redundant argument to ravb_ptp_init() Niklas Söderlund
2026-08-11 16:01 ` [PATCH net-next v2 05/10] net: ethernet: ravb: Propagate error from ptp_clock_register() Niklas Söderlund
2026-08-11 16:01 ` [PATCH net-next v2 06/10] net: ethernet: ravb: Replace gPTP flags with callbacks Niklas Söderlund
2026-08-11 16:01 ` [PATCH net-next v2 07/10] net: ethernet: ravb: Add callback for gPTP probe Niklas Söderlund
2026-08-11 16:01 ` Niklas Söderlund [this message]
2026-08-11 16:01 ` [PATCH net-next v2 09/10] dt-bindings: net: renesas,etheravb: Add optional gPTP phandle for Gen4 Niklas Söderlund
2026-08-13 8:48 ` Krzysztof Kozlowski
2026-08-11 16:02 ` [PATCH net-next v2 10/10] net: ethernet: ravb: Add gPTP support " Niklas Söderlund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260811160200.2049987-9-niklas.soderlund+renesas@ragnatech.se \
--to=niklas.soderlund+renesas@ragnatech.se \
--cc=andrew+netdev@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=geert+renesas@glider.be \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=sergei.shtylyov@gmail.com \
--cc=vadim.fedorenko@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox