|
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>
|
@@ -211,6 +212,7 @@ struct omap_i2c_dev {
|
211 | 212 | u16 syscstate;
|
212 | 213 | u16 westate;
|
213 | 214 | u16 errata;
|
| 215 | + struct mux_state *mux_state; |
214 | 216 | };
|
215 | 217 |
|
216 | 218 | static const u8 reg_map_ip_v1[] = {
|
@@ -1452,6 +1454,23 @@ omap_i2c_probe(struct platform_device *pdev)
|
1452 | 1454 | (1000 * omap->speed / 8);
|
1453 | 1455 | }
|
1454 | 1456 |
|
| 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 | + |
1455 | 1474 | /* reset ASAP, clearing any IRQs */
|
1456 | 1475 | omap_i2c_init(omap);
|
1457 | 1476 |
|
@@ -1511,6 +1530,9 @@ static void omap_i2c_remove(struct platform_device *pdev)
|
1511 | 1530 |
|
1512 | 1531 | i2c_del_adapter(&omap->adapter);
|
1513 | 1532 |
|
| 1533 | + if (omap->mux_state) |
| 1534 | + mux_state_deselect(omap->mux_state); |
| 1535 | + |
1514 | 1536 | ret = pm_runtime_get_sync(&pdev->dev);
|
1515 | 1537 | if (ret < 0)
|
1516 | 1538 | dev_err(omap->dev, "Failed to resume hardware, skip disable\n");
|
|
0 commit comments