summaryrefslogtreecommitdiff
path: root/board/freescale/common/emc2305.c
diff options
context:
space:
mode:
authorWasim Khan <wasim.khan@nxp.com>2020-08-27 19:13:34 +0530
committerPriyanka Jain <priyanka.jain@nxp.com>2020-09-24 20:57:32 +0530
commitc63edbc750f9416bb542b24c9b856cce4f2a33e1 (patch)
treeb3242e08c1208345678f118d336f2da0dd10a3c5 /board/freescale/common/emc2305.c
parentada19fd2d2d45bf66f71cb1610a293d30058e7b6 (diff)
board: freescale: emc2305: Pass chip_addr to set_fan_speed
emc2305 is a common driver. It should not use platform specific i2c address for slave device. Pass chip_addr as agrument to emc2305_init() and set_fan_speed() so that emc2305 driver can be used with different platforms. Signed-off-by: Wasim Khan <wasim.khan@nxp.com> Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
Diffstat (limited to 'board/freescale/common/emc2305.c')
-rw-r--r--board/freescale/common/emc2305.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/board/freescale/common/emc2305.c b/board/freescale/common/emc2305.c
index b1ca051db2..050b679f3c 100644
--- a/board/freescale/common/emc2305.c
+++ b/board/freescale/common/emc2305.c
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
- * Copyright 2018 NXP.
+ * Copyright 2018-2020 NXP.
*
- * SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
@@ -14,7 +13,7 @@
DECLARE_GLOBAL_DATA_PTR;
-void set_fan_speed(u8 data)
+void set_fan_speed(u8 data, int chip_addr)
{
u8 index;
u8 Fan[NUM_OF_FANS] = {I2C_EMC2305_FAN1,
@@ -25,14 +24,14 @@ void set_fan_speed(u8 data)
for (index = 0; index < NUM_OF_FANS; index++) {
#ifndef CONFIG_DM_I2C
- if (i2c_write(I2C_EMC2305_ADDR, Fan[index], 1, &data, 1) != 0) {
+ if (i2c_write(chip_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))
+ if (i2c_get_chip_for_busnum(0, chip_addr, 1, &dev))
continue;
if (dm_i2c_write(dev, Fan[index], &data, 1) != 0) {
@@ -43,18 +42,18 @@ void set_fan_speed(u8 data)
}
}
-void emc2305_init(void)
+void emc2305_init(int chip_addr)
{
u8 data;
data = I2C_EMC2305_CMD;
#ifndef CONFIG_DM_I2C
- if (i2c_write(I2C_EMC2305_ADDR, I2C_EMC2305_CONF, 1, &data, 1) != 0)
+ if (i2c_write(chip_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 (!i2c_get_chip_for_busnum(0, chip_addr, 1, &dev))
if (dm_i2c_write(dev, I2C_EMC2305_CONF, &data, 1))
printf("Error: failed to configure EMC2305\n");
#endif