]> git.itanic.dy.fi Git - linux-stable/commitdiff
phy: zynqmp: Allow variation in refclk rate
authorSean Anderson <sean.anderson@seco.com>
Tue, 11 Jul 2023 19:45:39 +0000 (15:45 -0400)
committerVinod Koul <vkoul@kernel.org>
Wed, 12 Jul 2023 16:57:44 +0000 (22:27 +0530)
Due to limited available frequency ratios, the reference clock rate may
not be exactly the same as the required rate. Allow a small (100 ppm)
deviation.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Link: https://lore.kernel.org/r/20230711194542.898230-1-sean.anderson@seco.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/phy/xilinx/phy-zynqmp.c

index b0c2045b886ee6b6663062953650147dbde5f5fb..2559c6594cea2bcdde2a06af52bcc40eebf246d0 100644 (file)
@@ -904,7 +904,10 @@ static int xpsgtr_get_ref_clocks(struct xpsgtr_dev *gtr_dev)
                rate = clk_get_rate(clk);
 
                for (i = 0 ; i < ARRAY_SIZE(ssc_lookup); i++) {
-                       if (rate == ssc_lookup[i].refclk_rate) {
+                       /* Allow an error of 100 ppm */
+                       unsigned long error = ssc_lookup[i].refclk_rate / 10000;
+
+                       if (abs(rate - ssc_lookup[i].refclk_rate) < error) {
                                gtr_dev->refclk_sscs[refclk] = &ssc_lookup[i];
                                break;
                        }