Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: omap: Add support for setting mux

Some SoCs require muxes in the routing for SDA and SCL lines.
Therefore, add support for setting the mux by reading the mux-states
property from the dt-node.

Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com>
Link: https://lore.kernel.org/r/20250318103622.29979-3-j-choudhary@ti.com
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>

authored by

Jayesh Choudhary and committed by
Andi Shyti
b6ef830c 0fc829db

+23
+1
drivers/i2c/busses/Kconfig
··· 940 940 tristate "OMAP I2C adapter" 941 941 depends on ARCH_OMAP || ARCH_K3 || COMPILE_TEST 942 942 default MACH_OMAP_OSK 943 + select MULTIPLEXER 943 944 help 944 945 If you say yes to this option, support will be included for the 945 946 I2C interface on the Texas Instruments OMAP1/2 family of processors.
+22
drivers/i2c/busses/i2c-omap.c
··· 24 24 #include <linux/platform_device.h> 25 25 #include <linux/clk.h> 26 26 #include <linux/io.h> 27 + #include <linux/mux/consumer.h> 27 28 #include <linux/of.h> 28 29 #include <linux/slab.h> 29 30 #include <linux/platform_data/i2c-omap.h> ··· 212 211 u16 syscstate; 213 212 u16 westate; 214 213 u16 errata; 214 + struct mux_state *mux_state; 215 215 }; 216 216 217 217 static const u8 reg_map_ip_v1[] = { ··· 1454 1452 (1000 * omap->speed / 8); 1455 1453 } 1456 1454 1455 + if (of_property_read_bool(node, "mux-states")) { 1456 + struct mux_state *mux_state; 1457 + 1458 + mux_state = devm_mux_state_get(&pdev->dev, NULL); 1459 + if (IS_ERR(mux_state)) { 1460 + r = PTR_ERR(mux_state); 1461 + dev_dbg(&pdev->dev, "failed to get I2C mux: %d\n", r); 1462 + goto err_disable_pm; 1463 + } 1464 + omap->mux_state = mux_state; 1465 + r = mux_state_select(omap->mux_state); 1466 + if (r) { 1467 + dev_err(&pdev->dev, "failed to select I2C mux: %d\n", r); 1468 + goto err_disable_pm; 1469 + } 1470 + } 1471 + 1457 1472 /* reset ASAP, clearing any IRQs */ 1458 1473 omap_i2c_init(omap); 1459 1474 ··· 1529 1510 int ret; 1530 1511 1531 1512 i2c_del_adapter(&omap->adapter); 1513 + 1514 + if (omap->mux_state) 1515 + mux_state_deselect(omap->mux_state); 1532 1516 1533 1517 ret = pm_runtime_get_sync(&pdev->dev); 1534 1518 if (ret < 0)