diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index b788e8f5260d..27e2b31955ba 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 77e66a9870ab..2dff47c2a125 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 (priv->ptp.clock && 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; @@ -2656,6 +2661,16 @@ 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); + + if (!priv->ptp.clock) + return -ENODEV; + + return ptp_clock_index(priv->ptp.clock); +} + static int ravb_gen2_ptp_set_config_mode(struct net_device *ndev) { int ret; @@ -2672,6 +2687,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, @@ -2709,6 +2725,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, @@ -2781,6 +2798,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,