summaryrefslogtreecommitdiff
path: root/board/freescale/common/emc2305.c
diff options
context:
space:
mode:
authorChuanhua Han <chuanhua.han@nxp.com>2019-07-10 16:00:20 +0300
committerPrabhakar Kushwaha <prabhakar.kushwaha@nxp.com>2019-08-22 06:37:35 +0300
commit0eba65d2013e5517e70cc9b3d467ba8183b54cd9 (patch)
tree3ef821bfef5ebc08e458eda17b3885e442ea133d /board/freescale/common/emc2305.c
parentbc475d0fde85ed524943d686b326f4dca8c5efcf (diff)
downloadu-boot-0eba65d2013e5517e70cc9b3d467ba8183b54cd9.tar.xz
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/emc2305.c')
-rw-r--r--board/freescale/common/emc2305.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/board/freescale/common/emc2305.c b/board/freescale/common/emc2305.c
index 8523084da9..b1ca051db2 100644
--- a/board/freescale/common/emc2305.c
+++ b/board/freescale/common/emc2305.c
@@ -24,10 +24,22 @@ void set_fan_speed(u8 data)
I2C_EMC2305_FAN5};
for (index = 0; index < NUM_OF_FANS; index++) {
+#ifndef CONFIG_DM_I2C
if (i2c_write(I2C_EMC2305_ADDR, Fan[index], 1, &data, 1) != 0) {
printf("Error: failed to change fan speed @%x\n",
Fan[index]);
}
+#else
+ struct udevice *dev;
+
+ if (i2c_get_chip_for_busnum(0, I2C_EMC2305_ADDR, 1, &dev))
+ continue;
+
+ if (dm_i2c_write(dev, Fan[index], &data, 1) != 0) {
+ printf("Error: failed to change fan speed @%x\n",
+ Fan[index]);
+ }
+#endif
}
}
@@ -36,6 +48,15 @@ void emc2305_init(void)
u8 data;
data = I2C_EMC2305_CMD;
+#ifndef CONFIG_DM_I2C
if (i2c_write(I2C_EMC2305_ADDR, I2C_EMC2305_CONF, 1, &data, 1) != 0)
printf("Error: failed to configure EMC2305\n");
+#else
+ struct udevice *dev;
+
+ if (!i2c_get_chip_for_busnum(0, I2C_EMC2305_ADDR, 1, &dev))
+ if (dm_i2c_write(dev, I2C_EMC2305_CONF, &data, 1))
+ printf("Error: failed to configure EMC2305\n");
+#endif
+
}