[U-Boot,2/4] i2c: mxc: add fuse check
diff mbox series

Message ID 20190719033721.5730-2-peng.fan@nxp.com
State Superseded
Delegated to: Stefano Babic
Headers show
Series
  • [U-Boot,1/4] imx: add module fuse support
Related show

Commit Message

Peng Fan July 19, 2019, 3:22 a.m. UTC
Add fuse check for I2C. If the fuse indicate the module
not work in the SoC, let's fail the initialization.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/i2c/mxc_i2c.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Patch
diff mbox series

diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
index 2e157bca58..fd2d858854 100644
--- a/drivers/i2c/mxc_i2c.c
+++ b/drivers/i2c/mxc_i2c.c
@@ -18,6 +18,7 @@ 
 #include <asm/arch/imx-regs.h>
 #include <linux/errno.h>
 #include <asm/mach-imx/mxc_i2c.h>
+#include <asm/mach-imx/sys_proto.h>
 #include <asm/io.h>
 #include <i2c.h>
 #include <watchdog.h>
@@ -740,6 +741,14 @@  void bus_i2c_init(int index, int speed, int unused,
 		return;
 	}
 
+	if (IS_ENABLED(CONFIG_IMX_MODULE_FUSE)) {
+		if (i2c_fused((u32)mxc_i2c_buses[index].base)) {
+			printf("I2C@0x%x is fused, disable it\n",
+			       (u32)mxc_i2c_buses[index].base);
+			return;
+		}
+	}
+
 	/*
 	 * Warning: Be careful to allow the assignment to a static
 	 * variable here. This function could be called while U-Boot is
@@ -885,6 +894,13 @@  static int mxc_i2c_probe(struct udevice *bus)
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
+	if (IS_ENABLED(CONFIG_IMX_MODULE_FUSE)) {
+		if (i2c_fused(addr)) {
+			printf("I2C@0x%lx is fused, disable it\n", addr);
+			return -ENODEV;
+		}
+	}
+
 	i2c_bus->base = addr;
 	i2c_bus->index = bus->seq;
 	i2c_bus->bus = bus;