Changing I2C frequency on iMX8X


I was wondering if there are ways to programmatically, during runtime, change the frequency of enabled i2c buses on iMX8X SOMs? So far, we’ve been setting the i2c bus frequency in the device tree with no issues, but would like to understand if there are some device driver which allows us to control the bus speed directly. I found somewhat of an example here, though I haven’t been able to verify if it works with the i2c-imx-lpi2c drivers used for the i2c buses on the iMX8X modules.

sudo modprobe -r i2c_bcm2708
sudo modprobe i2c_bcm2708 baudrate=32000

For most part of my search, it appears that the device tree is the only way to set the i2c bus frequency, and that it is impossible to alter it during runtime, or at least, without a reboot. Just wanted a confirmation if this is truly the case.

Since one I2C bus may have many devices connected changing an I2C frequency on the fly is not recommended and not implemented. The mentioned i2c_bcm2708 driver uses an old driver model when Device Tree was not introduced yet. And even there bus frequency can only be set once during driver modprobe. You can adjust I2C bus speed more flexible ways by using Device Tree overlays.

If I2C bus speed change on run time is mandatory for your application you can modify the bus driver.