public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy@kernel.org>
To: Binbin Zhou <zhoubinbin@loongson.cn>
Cc: Binbin Zhou <zhoubb.aaron@gmail.com>,
	Huacai Chen <chenhuacai@loongson.cn>,
	Andi Shyti <andi.shyti@kernel.org>, Wolfram Sang <wsa@kernel.org>,
	linux-i2c@vger.kernel.org, Huacai Chen <chenhuacai@kernel.org>,
	Xuerui Wang <kernel@xen0n.name>,
	loongarch@lists.linux.dev, stable@vger.kernel.org,
	Hongliang Wang <wanghongliang@loongson.cn>
Subject: Re: [PATCH] i2c: ls2x: Fix frequency division register access
Date: Tue, 18 Feb 2025 13:33:14 +0200	[thread overview]
Message-ID: <Z7Rv-s4agg0vVO5P@smile.fi.intel.com> (raw)
In-Reply-To: <20250218111133.3058590-1-zhoubinbin@loongson.cn>

On Tue, Feb 18, 2025 at 07:11:33PM +0800, Binbin Zhou wrote:
> According to the chip manual, the I2C register access type of
> Loongson-2K2000/LS7A is "B", so we can only access registers in byte
> form (readb/writeb).
> 
> Although Loongson-2K0500/Loongson-2K1000 do not have similar
> constraints, register accesses in byte form also behave correctly.
> 
> Also, in hardware, the frequency division registers are defined as two
> separate registers (high 8-bit and low 8-bit), so we just access them
> directly as bytes.

...

>  	/* Calculate and set i2c frequency. */
> -	writew(LS2X_I2C_PCLK_FREQ / (5 * t->bus_freq_hz) - 1,
> -	       priv->base + I2C_LS2X_PRER);
> +	val = LS2X_I2C_PCLK_FREQ / (5 * t->bus_freq_hz) - 1;
> +	writeb(FIELD_GET(GENMASK(7, 0), val), priv->base + I2C_LS2X_PRER_LO);
> +	writeb(FIELD_GET(GENMASK(15, 8), val), priv->base + I2C_LS2X_PRER_HI);

Now this needs a comment to prevent from appearing a patch that basically
changes that back to 16-bit write.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-02-18 11:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-18 11:11 [PATCH] i2c: ls2x: Fix frequency division register access Binbin Zhou
2025-02-18 11:33 ` Andy Shevchenko [this message]
2025-02-18 11:52   ` Binbin Zhou

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=Z7Rv-s4agg0vVO5P@smile.fi.intel.com \
    --to=andy@kernel.org \
    --cc=andi.shyti@kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=kernel@xen0n.name \
    --cc=linux-i2c@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=wanghongliang@loongson.cn \
    --cc=wsa@kernel.org \
    --cc=zhoubb.aaron@gmail.com \
    --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