* [PATCH] i2c: tegra: Use non-HS timings for clock divisor
@ 2026-11-10 16:23 Akhil R
2026-11-10 17:06 ` Jon Hunter
0 siblings, 1 reply; 2+ messages in thread
From: Akhil R @ 2026-11-10 16:23 UTC (permalink / raw)
To: Laxman Dewangan, Dmitry Osipenko, Andi Shyti, Thierry Reding,
Jonathan Hunter, Wolfram Sang, Kartik Rajput, Akhil R, linux-i2c,
linux-tegra, linux-kernel
Programming the HS timing registers overwrites the local tlow and thigh
values before they are used to calculate the controller clock rate. On
controllers with HS support, this mixes HS timings with the clock divisor
calculation and sets an incorrect clock rate.
Calculate the clock multiplier before the HS register setup overwrites
the selected non-HS timings.
Fixes: 978b3ccbbac3 ("i2c: tegra: Add HS mode support")
Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
---
drivers/i2c/busses/i2c-tegra.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 76d21bc51c618..6a98432734d37 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -976,6 +976,8 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
if (i2c_dev->hw->has_interface_timing_reg && tsu_thd)
i2c_writel(i2c_dev, tsu_thd, i2c_dev->hw->regs->interface_timing_1);
+ clk_multiplier = (tlow + thigh + 2) * (non_hs_mode + 1);
+
/* Write HS mode registers. These will get used only for HS mode*/
if (i2c_dev->hw->enable_hs_mode_support) {
tlow = i2c_dev->hw->tlow_hs_mode;
@@ -988,8 +990,6 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
i2c_writel(i2c_dev, tsu_thd, i2c_dev->hw->regs->hs_interface_timing_1);
}
- clk_multiplier = (tlow + thigh + 2) * (non_hs_mode + 1);
-
err = clk_set_rate(i2c_dev->div_clk,
t->bus_freq_hz * clk_multiplier);
if (err) {
base-commit: 7649ba73f9e7e1e04d0b46213e39c79ae09dd55c
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] i2c: tegra: Use non-HS timings for clock divisor
2026-11-10 16:23 [PATCH] i2c: tegra: Use non-HS timings for clock divisor Akhil R
@ 2026-11-10 17:06 ` Jon Hunter
0 siblings, 0 replies; 2+ messages in thread
From: Jon Hunter @ 2026-11-10 17:06 UTC (permalink / raw)
To: Akhil R, Laxman Dewangan, Dmitry Osipenko, Andi Shyti,
Thierry Reding, Wolfram Sang, Kartik Rajput, linux-i2c,
linux-tegra, linux-kernel
On 10/11/2026 16:23, Akhil R wrote:
> Programming the HS timing registers overwrites the local tlow and thigh
> values before they are used to calculate the controller clock rate. On
> controllers with HS support, this mixes HS timings with the clock divisor
> calculation and sets an incorrect clock rate.
>
> Calculate the clock multiplier before the HS register setup overwrites
> the selected non-HS timings.
>
> Fixes: 978b3ccbbac3 ("i2c: tegra: Add HS mode support")
> Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
> ---
> drivers/i2c/busses/i2c-tegra.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
> index 76d21bc51c618..6a98432734d37 100644
> --- a/drivers/i2c/busses/i2c-tegra.c
> +++ b/drivers/i2c/busses/i2c-tegra.c
> @@ -976,6 +976,8 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
> if (i2c_dev->hw->has_interface_timing_reg && tsu_thd)
> i2c_writel(i2c_dev, tsu_thd, i2c_dev->hw->regs->interface_timing_1);
>
> + clk_multiplier = (tlow + thigh + 2) * (non_hs_mode + 1);
> +
> /* Write HS mode registers. These will get used only for HS mode*/
> if (i2c_dev->hw->enable_hs_mode_support) {
> tlow = i2c_dev->hw->tlow_hs_mode;
> @@ -988,8 +990,6 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
> i2c_writel(i2c_dev, tsu_thd, i2c_dev->hw->regs->hs_interface_timing_1);
> }
>
> - clk_multiplier = (tlow + thigh + 2) * (non_hs_mode + 1);
> -
> err = clk_set_rate(i2c_dev->div_clk,
> t->bus_freq_hz * clk_multiplier);
> if (err) {
>
> base-commit: 7649ba73f9e7e1e04d0b46213e39c79ae09dd55c
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Thanks!
Jon
--
nvpublic
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-10 17:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10 16:23 [PATCH] i2c: tegra: Use non-HS timings for clock divisor Akhil R
2026-11-10 17:06 ` Jon Hunter
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®