]> www.infradead.org Git - users/willy/linux.git/commitdiff
phy: starfive: Correct the dphy configure process
authorChanghuang Liang <changhuang.liang@starfivetech.com>
Thu, 27 Jun 2024 02:00:59 +0000 (19:00 -0700)
committerVinod Koul <vkoul@kernel.org>
Tue, 2 Jul 2024 13:19:14 +0000 (18:49 +0530)
We actually want to calculate the alignment values first, then
use the alignment value to look up the data from reg_configs[].

Fixes: d3ab79553308 ("phy: starfive: Add mipi dphy tx support")
Reviewed-by: Shengyang Chen <shengyang.chen@starfivetech.com>
Signed-off-by: Changhuang Liang <changhuang.liang@starfivetech.com>
Link: https://lore.kernel.org/r/20240627020059.163535-1-changhuang.liang@starfivetech.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/phy/starfive/phy-jh7110-dphy-tx.c

index 61b0da6096e5590adcdf1664564b61e7f81f4887..c64d1c91b1307eec7708c76c9f10bf2afb98de08 100644 (file)
@@ -235,12 +235,14 @@ static int stf_dphy_configure(struct phy *phy, union phy_configure_opts *opts)
        const struct stf_dphy_config *p = reg_configs;
        unsigned long alignment  = STF_DPHY_BITRATE_ALIGN;
        u32 bitrate = opts->mipi_dphy.hs_clk_rate;
-       u32 i = stf_dphy_get_config_index(bitrate);
        u32 tmp;
+       u32 i;
 
        if (bitrate % alignment)
                bitrate += alignment - (bitrate % alignment);
 
+       i = stf_dphy_get_config_index(bitrate);
+
        tmp = readl(dphy->topsys + STF_DPHY_APBIFSAIF_SYSCFG(100));
        tmp &= ~STF_DPHY_REFCLK_IN_SEL;
        tmp |= FIELD_PREP(STF_DPHY_REFCLK_IN_SEL, STF_DPHY_REFCLK_12M);