diff options
author | 2023-10-10 14:33:42 +0000 | |
---|---|---|
committer | 2023-10-10 14:33:42 +0000 | |
commit | af1a266670d040d2f4083ff309d732d648afba2a (patch) | |
tree | 2fc46203448ddcc6f81546d379abfaeb323575e9 /roms/u-boot/board/freescale/common/emc2305.c | |
parent | e02cda008591317b1625707ff8e115a4841aa889 (diff) |
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'roms/u-boot/board/freescale/common/emc2305.c')
-rw-r--r-- | roms/u-boot/board/freescale/common/emc2305.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/roms/u-boot/board/freescale/common/emc2305.c b/roms/u-boot/board/freescale/common/emc2305.c new file mode 100644 index 000000000..9a75c5a09 --- /dev/null +++ b/roms/u-boot/board/freescale/common/emc2305.c @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2018-2020 NXP. + * + */ + +#include <common.h> +#include <command.h> +#include <i2c.h> +#include <asm/global_data.h> +#include <asm/io.h> + +#include "emc2305.h" + +DECLARE_GLOBAL_DATA_PTR; + +void set_fan_speed(u8 data, int chip_addr) +{ + u8 index; + u8 Fan[NUM_OF_FANS] = {I2C_EMC2305_FAN1, + I2C_EMC2305_FAN2, + I2C_EMC2305_FAN3, + I2C_EMC2305_FAN4, + I2C_EMC2305_FAN5}; + + for (index = 0; index < NUM_OF_FANS; index++) { +#if !CONFIG_IS_ENABLED(DM_I2C) + 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, chip_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 + } +} + +void emc2305_init(int chip_addr) +{ + u8 data; + + data = I2C_EMC2305_CMD; +#if !CONFIG_IS_ENABLED(DM_I2C) + 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, chip_addr, 1, &dev)) + if (dm_i2c_write(dev, I2C_EMC2305_CONF, &data, 1)) + printf("Error: failed to configure EMC2305\n"); +#endif + +} |