Skip to content

Commit db845b9

Browse files
ahalaneykuba-moo
authored andcommitted
net: stmmac: dwmac-qcom-ethqos: Use max frequency for clk_ptp_ref
Qualcomm clocks can set their frequency to a variety of levels generally. Let's use the max for clk_ptp_ref to ensure the best timestamping resolution possible. Without this, the default value of the clock is used. For sa8775p-ride this is 19.2 MHz, far less than the 230.4 MHz possible. Reviewed-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: Andrew Halaney <ahalaney@redhat.com> Link: https://lore.kernel.org/r/20230725211853.895832-4-ahalaney@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent d928d14 commit db845b9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,23 @@ static void ethqos_clks_disable(void *data)
694694
ethqos_clks_config(data, false);
695695
}
696696

697+
static void ethqos_ptp_clk_freq_config(struct stmmac_priv *priv)
698+
{
699+
struct plat_stmmacenet_data *plat_dat = priv->plat;
700+
int err;
701+
702+
if (!plat_dat->clk_ptp_ref)
703+
return;
704+
705+
/* Max the PTP ref clock out to get the best resolution possible */
706+
err = clk_set_rate(plat_dat->clk_ptp_ref, ULONG_MAX);
707+
if (err)
708+
netdev_err(priv->dev, "Failed to max out clk_ptp_ref: %d\n", err);
709+
plat_dat->clk_ptp_rate = clk_get_rate(plat_dat->clk_ptp_ref);
710+
711+
netdev_dbg(priv->dev, "PTP rate %d\n", plat_dat->clk_ptp_rate);
712+
}
713+
697714
static int qcom_ethqos_probe(struct platform_device *pdev)
698715
{
699716
struct device_node *np = pdev->dev.of_node;
@@ -779,6 +796,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
779796
plat_dat->bsp_priv = ethqos;
780797
plat_dat->fix_mac_speed = ethqos_fix_mac_speed;
781798
plat_dat->dump_debug_regs = rgmii_dump;
799+
plat_dat->ptp_clk_freq_config = ethqos_ptp_clk_freq_config;
782800
plat_dat->has_gmac4 = 1;
783801
if (ethqos->has_emac_ge_3)
784802
plat_dat->dwmac4_addrs = &data->dwmac4_addrs;

0 commit comments

Comments
 (0)