public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Marcus Folkesson <marcus.folkesson@gmail.com>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Peter Rosin <peda@axentia.se>,
	Michael Hennerich <michael.hennerich@analog.com>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	Andi Shyti <andi.shyti@kernel.org>,
	Bartosz Golaszewski <brgl@kernel.org>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v7 2/5] i2c: mux: add support for per channel bus frequency
Date: Mon, 23 Feb 2026 16:57:47 +0200	[thread overview]
Message-ID: <aZxq6wXsS7DDEfIV@smile.fi.intel.com> (raw)
In-Reply-To: <20260223-i2c-mux-v7-2-ec75b214718a@gmail.com>

On Mon, Feb 23, 2026 at 03:33:51PM +0100, Marcus Folkesson wrote:
> There may be several reasons why you may need to use a certain speed
> on an I2C bus. E.g.
> 
> - When several devices are attached to the bus, the speed must be
>   selected according to the slowest device.
> 
> - Electrical conditions may limit the usuable speed on the bus for
>   different reasons.
> 
> With an I2C multiplexer, it is possible to group the attached devices
> after their preferred speed by e.g. put all "slow" devices on a separate
> channel on the multiplexer.
> 
> Consider the following topology:
> 
>                       .----------. 100kHz .--------.
>     .--------. 400kHz |          |--------| dev D1 |
>     |  root  |--+-----| I2C MUX  |        '--------'
>     '--------'  |     |          |--. 400kHz .--------.
>                 |     '----------'  '-------| dev D2 |
>                 |  .--------.               '--------'
>                 '--| dev D3 |
>                    '--------'
> 
> One requirement with this design is that a multiplexer may only use the
> same or lower bus speed as its parent.
> Otherwise, if the multiplexer would have to increase the bus frequency,
> then all siblings (D3 in this case) would run into a clock speed it may
> not support.
> 
> The bus frequency for each channel is set in the devicetree. As the
> i2c-mux bindings import the i2c-controller schema, the clock-frequency
> property is already allowed.
> If no clock-frequency property is set, the channel inherit their parent
> bus speed.
> 
> The following example uses dt bindings to illustrate the topology above:
> 
>     i2c {
> 	clock-frequency = <400000>;
> 
>         i2c-mux {
>             i2c@0 {
>                 clock-frequency = <100000>;
> 
>                 D1 {
>                     ...
>                 };
>             };
> 
>             i2c@1 {
>                 D2 {
>                   ...
>                 };
>             };
>         };
> 
>         D3 {
>             ...
>         }
>     };

...

> +static int i2c_mux_select_chan(struct i2c_adapter *adap, u32 chan_id, u32 *oldclock)
> +{
> +	struct i2c_mux_priv *priv = adap->algo_data;
> +	struct i2c_mux_core *muxc = priv->muxc;
> +	struct i2c_adapter *parent = muxc->parent;
> +	int ret;
> +
> +	if (priv->adap.clock_hz && priv->adap.clock_hz < parent->clock_hz) {
> +		*oldclock = parent->clock_hz;
> +
> +		if (muxc->mux_locked)
> +			ret = i2c_adapter_set_clk_freq(parent, priv->adap.clock_hz);
> +		else
> +			ret = __i2c_adapter_set_clk_freq(parent, priv->adap.clock_hz);
> +
> +		dev_dbg(&adap->dev, "Set clock frequency %dHz on %s\n",
> +			priv->adap.clock_hz, parent->name);

%u

> +		if (ret)
> +			dev_err(&adap->dev,
> +				"Failed to set clock frequency %dHz on adapter %s: %d\n",
> +				*oldclock, parent->name, ret);

%u

Oh, and so on...

Please, carefully inspect all printf() specifiers in the patches.

> +	}
> +
> +	return muxc->select(muxc, priv->chan_id);
> +}

-- 
With Best Regards,
Andy Shevchenko




  reply	other threads:[~2026-02-23 14:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-23 14:33 [PATCH v7 0/5] I2C Mux per channel bus speed Marcus Folkesson
2026-02-23 14:33 ` [PATCH v7 1/5] i2c: core: add callback to change bus frequency Marcus Folkesson
2026-02-23 14:53   ` Andy Shevchenko
2026-02-23 14:55     ` Andy Shevchenko
2026-02-23 14:33 ` [PATCH v7 2/5] i2c: mux: add support for per channel " Marcus Folkesson
2026-02-23 14:57   ` Andy Shevchenko [this message]
2026-02-23 14:33 ` [PATCH v7 3/5] i2c: davinci: calculate bus freq from Hz instead of kHz Marcus Folkesson
2026-02-23 14:59   ` Andy Shevchenko
2026-03-09 11:14     ` Marcus Folkesson
2026-03-09 11:33       ` Andy Shevchenko
2026-02-23 14:33 ` [PATCH v7 4/5] i2c: davinci: add support for setting bus frequency Marcus Folkesson
2026-02-23 15:01   ` Andy Shevchenko
2026-02-23 14:33 ` [PATCH v7 5/5] docs: i2c: i2c-topology: add section about bus speed Marcus Folkesson

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=aZxq6wXsS7DDEfIV@smile.fi.intel.com \
    --to=andriy.shevchenko@intel.com \
    --cc=andi.shyti@kernel.org \
    --cc=brgl@bgdev.pl \
    --cc=brgl@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcus.folkesson@gmail.com \
    --cc=michael.hennerich@analog.com \
    --cc=peda@axentia.se \
    --cc=wsa+renesas@sang-engineering.com \
    /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