Linux I2C development
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: Hongliang Wang <wanghongliang@loongson.cn>
Cc: Binbin Zhou <zhoubinbin@loongson.cn>,
	Andi Shyti <andi.shyti@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Huacai Chen <chenhuacai@kernel.org>,
	linux-i2c@vger.kernel.org, devicetree@vger.kernel.org,
	loongarch@lists.linux.dev, Xi Ruoyao <xry111@xry111.site>,
	Huacai Chen <chenhuacai@loongson.cn>,
	stable@vger.kernel.org
Subject: Re: [PATCH v11 2/2] i2c: ls2x: Add clocks property parsing and adjust bus speed
Date: Tue, 10 Nov 2026 12:27:36 +0100	[thread overview]
Message-ID: <avL_qCs9EFquoZ7_@shikoro> (raw)
In-Reply-To: <20261106030203.15709-3-wanghongliang@loongson.cn>

On Fri, Nov 06, 2026 at 11:02:03AM +0800, Hongliang Wang wrote:
> The original driver uses a fixed PCLK frequency(LS2X_I2C_PCLK_FREQ) and
> fixed div(5) for I2C bus speed calculation. As PCLK frequency and div
> vary on different SoCs and ACPI platforms, this leads to inaccurate I2C
> bus speed calculation and poor adaptability across platforms.
> 
> Improve the accuracy of I2C bus speed calculation across different
> platforms by parsing the real I2C bus reference clock (PCLK) and div.
> Support both DTS and ACPI.
> 
> For DTS:
> - Retrieve I2C bus reference clock via the common clock framework
> - Fetch div from match data for LS2K/LS7A series
> - Fallback to default values if clock lookup fails or the obtained
>   pclk or div is zero
> 
> For ACPI:
> - Parse "clocks" property to get I2C bus reference clock
> - Parse "clock-div" property to get div
> - Fallback to the default values if property parsing fails or the
>   obtained pclk or div is zero
> 
> Calculate the I2C clock prescaler based on reference clock, div and
> target bus frequency with the formula:
> 
> prescale = (pclk * 10) / (div * bus_freq_hz) - 1
> 
> Dynamically acquiring PCLK and div per platform ensures accurate I2C bus
> speed calculation and reliable operation across different platforms.
> 
> Reviewed-by: Binbin Zhou <zhoubinbin@loongson.cn>
> Tested-by: Xi Ruoyao <xry111@xry111.site>
> Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
> Cc: stable@vger.kernel.org
> Signed-off-by: Hongliang Wang <wanghongliang@loongson.cn>

Applied to my for-andi branch, thanks!


      reply	other threads:[~2026-11-10 11:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06  3:02 [PATCH v11 0/2] i2c: ls2x: Add clock- related properties and parsing Hongliang Wang
2026-11-06  3:02 ` [PATCH v11 1/2] dt-bindings: i2c: ls2x-i2c: Add clocks and clock-frequency properties Hongliang Wang
2026-11-10 11:25   ` Wolfram Sang
2026-11-06  3:02 ` [PATCH v11 2/2] i2c: ls2x: Add clocks property parsing and adjust bus speed Hongliang Wang
2026-11-10 11:27   ` Wolfram Sang [this message]

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=avL_qCs9EFquoZ7_@shikoro \
    --to=wsa+renesas@sang-engineering.com \
    --cc=andi.shyti@kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=wanghongliang@loongson.cn \
    --cc=xry111@xry111.site \
    --cc=zhoubinbin@loongson.cn \
    /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