mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marcus Folkesson <marcus.folkesson@gmail.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>,
	 Michael Hennerich <michael.hennerich@analog.com>,
	 Bartosz Golaszewski <brgl@bgdev.pl>,
	Andi Shyti <andi.shyti@kernel.org>,
	 Andy Shevchenko <andriy.shevchenko@intel.com>,
	 Bartosz Golaszewski <brgl@kernel.org>,
	Peter Rosin <peda@lysator.liu.se>,
	 Peter Rosin <peda@lysator.liu.se>
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org,
	 Marcus Folkesson <marcus.folkesson@gmail.com>
Subject: [PATCH v13 1/8] i2c: core: add callback to change bus frequency
Date: Thu, 15 Oct 2026 13:01:48 +0200	[thread overview]
Message-ID: <20261015-i2c-mux-v13-1-778a12cfe93b@gmail.com> (raw)
In-Reply-To: <20261015-i2c-mux-v13-0-778a12cfe93b@gmail.com>

All devices on the same I2C bus share the same clock line and the bus
frequency must therefore be chosen so that all attached devices are able
to tolerate that clock rate. IOW, the bus speed must be set for the
slowest attached device.

With I2C multiplexers/switches on the other hand, it would be possible
to have different "domains" that run with different speeds.

Prepare for such a feature by providing an optional callback function to
change bus frequency.

As a side effect, several bus drivers keep the bus speed in a
private structure and can now have this value stored in a uniform way
instead.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
 include/linux/i2c.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 6a847fc88d25..d2d60e937244 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -635,6 +635,15 @@ struct i2c_timings {
 	u32 analog_filter_cutoff_freq_hz;
 };
 
+/**
+ * struct i2c_bus_ops - I2C bus control operations
+ * @set_clk_freq: Set clock frequency for the adapter.
+ *	Returns negative errno, or 0 on success.
+ */
+struct i2c_bus_ops {
+	int (*set_clk_freq)(struct i2c_adapter *adap, u32 clock_Hz);
+};
+
 /**
  * struct i2c_bus_recovery_info - I2C bus recovery information
  * @recover_bus: Recover routine. Either pass driver's recover_bus() routine, or
@@ -744,6 +753,7 @@ struct i2c_adapter_quirks {
 /*
  * i2c_adapter is the structure used to identify a physical i2c bus along
  * with the access algorithms necessary to access it.
+ *
  */
 struct i2c_adapter {
 	struct module *owner;
@@ -760,6 +770,7 @@ struct i2c_adapter {
 #ifdef CONFIG_I2C_DYNAMIC_TIMEOUT
 	int user_timeout;		/* I2C_TIMEOUT ioctl value in jiffies */
 #endif
+	u32 clock_Hz;			/* bus clock speed */
 	int retries;
 	struct device dev;		/* the adapter device */
 	unsigned long locked_flags;	/* owned by the I2C core */
@@ -774,6 +785,7 @@ struct i2c_adapter {
 	struct list_head userspace_clients;
 
 	struct i2c_bus_recovery_info *bus_recovery_info;
+	const struct i2c_bus_ops *bus_ops;
 	const struct i2c_adapter_quirks *quirks;
 
 	struct irq_domain *host_notify_domain;

-- 
2.55.0


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

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 11:01 [PATCH v13 0/8] I2C Mux per channel bus speed Marcus Folkesson
2026-10-15 11:01 ` Marcus Folkesson [this message]
2026-10-15 11:01 ` [PATCH v13 2/8] i2c: mux: add idle_state property to i2c_mux_core Marcus Folkesson
2026-10-15 11:01 ` [PATCH v13 3/8] i2c: mux: add support for per channel bus frequency Marcus Folkesson
2026-10-15 11:01 ` [PATCH v13 4/8] i2c: davinci: calculate bus freq from Hz instead of kHz Marcus Folkesson
2026-10-15 11:01 ` [PATCH v13 5/8] i2c: davinci: add support for setting bus frequency Marcus Folkesson
2026-10-15 11:01 ` [PATCH v13 6/8] i2c: mux: ltc4306: set correct idle_state in i2c_mux_core Marcus Folkesson
2026-10-15 11:01 ` [PATCH v13 7/8] docs: i2c: i2c-topology: add section about bus speed Marcus Folkesson
2026-10-15 11:01 ` [PATCH v13 8/8] i2c: mux: pca954x: use idle state from i2c_mux_core 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=20261015-i2c-mux-v13-1-778a12cfe93b@gmail.com \
    --to=marcus.folkesson@gmail.com \
    --cc=andi.shyti@kernel.org \
    --cc=andriy.shevchenko@intel.com \
    --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=michael.hennerich@analog.com \
    --cc=peda@lysator.liu.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

all inboxes | Powered by JetHome®