Skip to content

Commit b6ef830

Browse files
jayesh-tiAndi Shyti
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
1 parent 0fc829d commit b6ef830

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

drivers/i2c/busses/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,7 @@ config I2C_OMAP
940940
tristate "OMAP I2C adapter"
941941
depends on ARCH_OMAP || ARCH_K3 || COMPILE_TEST
942942
default MACH_OMAP_OSK
943+
select MULTIPLEXER
943944
help
944945
If you say yes to this option, support will be included for the
945946
I2C interface on the Texas Instruments OMAP1/2 family of processors.

drivers/i2c/busses/i2c-omap.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/platform_device.h>
2525
#include <linux/clk.h>
2626
#include <linux/io.h>
27+
#include <linux/mux/consumer.h>
2728
#include <linux/of.h>
2829
#include <linux/slab.h>
2930
#include <linux/platform_data/i2c-omap.h>
@@ -211,6 +212,7 @@ struct omap_i2c_dev {
211212
u16 syscstate;
212213
u16 westate;
213214
u16 errata;
215+
struct mux_state *mux_state;
214216
};
215217

216218
static const u8 reg_map_ip_v1[] = {
@@ -1452,6 +1454,23 @@ omap_i2c_probe(struct platform_device *pdev)
14521454
(1000 * omap->speed / 8);
14531455
}
14541456

1457+
if (of_property_read_bool(node, "mux-states")) {
1458+
struct mux_state *mux_state;
1459+
1460+
mux_state = devm_mux_state_get(&pdev->dev, NULL);
1461+
if (IS_ERR(mux_state)) {
1462+
r = PTR_ERR(mux_state);
1463+
dev_dbg(&pdev->dev, "failed to get I2C mux: %d\n", r);
1464+
goto err_disable_pm;
1465+
}
1466+
omap->mux_state = mux_state;
1467+
r = mux_state_select(omap->mux_state);
1468+
if (r) {
1469+
dev_err(&pdev->dev, "failed to select I2C mux: %d\n", r);
1470+
goto err_disable_pm;
1471+
}
1472+
}
1473+
14551474
/* reset ASAP, clearing any IRQs */
14561475
omap_i2c_init(omap);
14571476

@@ -1511,6 +1530,9 @@ static void omap_i2c_remove(struct platform_device *pdev)
15111530

15121531
i2c_del_adapter(&omap->adapter);
15131532

1533+
if (omap->mux_state)
1534+
mux_state_deselect(omap->mux_state);
1535+
15141536
ret = pm_runtime_get_sync(&pdev->dev);
15151537
if (ret < 0)
15161538
dev_err(omap->dev, "Failed to resume hardware, skip disable\n");

0 commit comments

Comments
 (0)