aboutsummaryrefslogtreecommitdiff
path: root/board/freescale/common/qixis.c
diff options
context:
space:
mode:
authorChuanhua Han <chuanhua.han@nxp.com>2019-07-10 21:00:20 +0800
committerPrabhakar Kushwaha <prabhakar.kushwaha@nxp.com>2019-08-22 09:07:35 +0530
commit0eba65d2013e5517e70cc9b3d467ba8183b54cd9 (patch)
tree3ef821bfef5ebc08e458eda17b3885e442ea133d /board/freescale/common/qixis.c
parentbc475d0fde85ed524943d686b326f4dca8c5efcf (diff)
downloadu-boot-0eba65d2013e5517e70cc9b3d467ba8183b54cd9.zip
u-boot-0eba65d2013e5517e70cc9b3d467ba8183b54cd9.tar.gz
u-boot-0eba65d2013e5517e70cc9b3d467ba8183b54cd9.tar.bz2
boards: lx2160a: Add support of I2C driver model
DM_I2C_COMPAT is a compatibility layer that allows using the non-DM I2C API when DM_I2C is used. When DM_I2C_COMPAT is not enabled for compilation, a compilation error will be generated. This patch solves the problem that the i2c-related api of the lx2160a platform does not support dm. Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com> Reviewed-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
Diffstat (limited to 'board/freescale/common/qixis.c')
-rw-r--r--board/freescale/common/qixis.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/board/freescale/common/qixis.c b/board/freescale/common/qixis.c
index 1f20223..716c93b 100644
--- a/board/freescale/common/qixis.c
+++ b/board/freescale/common/qixis.c
@@ -31,13 +31,30 @@
#ifdef CONFIG_SYS_I2C_FPGA_ADDR
u8 qixis_read_i2c(unsigned int reg)
{
+#ifndef CONFIG_DM_I2C
return i2c_reg_read(CONFIG_SYS_I2C_FPGA_ADDR, reg);
+#else
+ struct udevice *dev;
+
+ if (i2c_get_chip_for_busnum(0, CONFIG_SYS_I2C_FPGA_ADDR, 1, &dev))
+ return 0xff;
+
+ return dm_i2c_reg_read(dev, reg);
+#endif
}
void qixis_write_i2c(unsigned int reg, u8 value)
{
u8 val = value;
+#ifndef CONFIG_DM_I2C
i2c_reg_write(CONFIG_SYS_I2C_FPGA_ADDR, reg, val);
+#else
+ struct udevice *dev;
+
+ if (!i2c_get_chip_for_busnum(0, CONFIG_SYS_I2C_FPGA_ADDR, 1, &dev))
+ dm_i2c_reg_write(dev, reg, val);
+#endif
+
}
#endif