mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Changhuang Liang <changhuang.liang@starfivetech.com>
To: Vinod Koul <vkoul@kernel.org>,
	Kishon Vijay Abraham I <kishon@kernel.org>
Cc: Keith Zhao <keith.zhao@starfivetech.com>,
	Shengyang Chen <shengyang.chen@starfivetech.com>,
	Changhuang Liang <changhuang.liang@starfivetech.com>,
	linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] phy: starfive: Correct the dphy configure process
Date: Wed, 26 Jun 2024 19:00:59 -0700	[thread overview]
Message-ID: <20240627020059.163535-1-changhuang.liang@starfivetech.com> (raw)

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>
---
 drivers/phy/starfive/phy-jh7110-dphy-tx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/starfive/phy-jh7110-dphy-tx.c b/drivers/phy/starfive/phy-jh7110-dphy-tx.c
index 61b0da6096e5..c64d1c91b130 100644
--- a/drivers/phy/starfive/phy-jh7110-dphy-tx.c
+++ b/drivers/phy/starfive/phy-jh7110-dphy-tx.c
@@ -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);
-- 
2.25.1


             reply	other threads:[~2024-06-27  2:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-27  2:00 Changhuang Liang [this message]
2024-07-02 13:35 ` Vinod Koul

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=20240627020059.163535-1-changhuang.liang@starfivetech.com \
    --to=changhuang.liang@starfivetech.com \
    --cc=keith.zhao@starfivetech.com \
    --cc=kishon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=shengyang.chen@starfivetech.com \
    --cc=vkoul@kernel.org \
    /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

all inboxes | Powered by JetHome®