
Add support for fan controller emc2305. Enable support of FAN controller for LX2160A RDB board.
Signed-off-by: Meenakshi Aggarwal meenakshi.aggarwal@nxp.com --- arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 22 +++++++++ board/freescale/common/Makefile | 2 + board/freescale/common/emc2305.c | 75 +++++++++++++++++++++++++++++++ board/freescale/common/emc2305.h | 20 +++++++++ board/freescale/lx2160a/lx2160a.c | 9 ++++ 5 files changed, 128 insertions(+) create mode 100644 board/freescale/common/emc2305.c create mode 100644 board/freescale/common/emc2305.h
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig index 5dba2af..d746e78 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig +++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig @@ -346,6 +346,28 @@ config MAX_CPUS cores, count the reserved ports. This will allocate enough memory in spin table to properly handle all cores.
+config EMC2305 + bool "Fan controller" + help + Enable the EMC2305 fan controller for configuration of fan + speed. + +config I2C_MUX_CH_EMC2305 + hex "I2C channel where EMC2305 is connected" + default 0x9 if ARCH_LX2160A + +config I2C_EMC2305_ADDR + hex "I2C channel where EMC2305 is connected" + default 0x4D if ARCH_LX2160A + +config I2C_EMC2305_CMD + hex "EMC2305 made I2C compliant" + default 0x40 if ARCH_LX2160A + +config I2C_EMC2305_PWM + hex "Speed settings for Fan controller" + default 0x80 if ARCH_LX2160A + config SECURE_BOOT bool "Secure Boot" help diff --git a/board/freescale/common/Makefile b/board/freescale/common/Makefile index e3c5eae..a9d61a8 100644 --- a/board/freescale/common/Makefile +++ b/board/freescale/common/Makefile @@ -64,6 +64,8 @@ obj-$(CONFIG_POWER_MC34VR500) += mc34vr500.o
obj-$(CONFIG_LS102XA_STREAM_ID) += ls102xa_stream_id.o
+obj-$(CONFIG_EMC2305) += emc2305.o + # deal with common files for P-series corenet based devices obj-$(CONFIG_TARGET_P2041RDB) += p_corenet/ obj-$(CONFIG_TARGET_P3041DS) += p_corenet/ diff --git a/board/freescale/common/emc2305.c b/board/freescale/common/emc2305.c new file mode 100644 index 0000000..46f43e0 --- /dev/null +++ b/board/freescale/common/emc2305.c @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2018 NXP. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <command.h> +#include <i2c.h> +#include <asm/io.h> +#ifdef CONFIG_FSL_LSCH2 +#include <asm/arch/immap_lsch2.h> +#elif defined(CONFIG_FSL_LSCH3) +#include <asm/arch/immap_lsch3.h> +#else +#include <asm/immap_85xx.h> +#endif +#include "emc2305.h" + +DECLARE_GLOBAL_DATA_PTR; + +void configure_emc2305(void) +{ + u8 data; + + data = CONFIG_I2C_EMC2305_CMD; + if (i2c_write(CONFIG_I2C_EMC2305_ADDR, + I2C_EMC2305_CONF, 1, &data, 1) != 0){ + printf("Error: failed to configure I2C fan @%x\n", + CONFIG_I2C_EMC2305_ADDR); + } +} + +void set_fan_speed(void) +{ + u8 data; + + data = CONFIG_I2C_EMC2305_PWM; + if (i2c_write(CONFIG_I2C_EMC2305_ADDR, + I2C_EMC2305_FAN1, 1, &data, 1) != 0){ + printf("Error: failed to change fan speed @%x\n", + I2C_EMC2305_FAN1); + } + + if (i2c_write(CONFIG_I2C_EMC2305_ADDR, + I2C_EMC2305_FAN2, 1, &data, 1) != 0){ + printf("Error: failed to change fan speed @%x\n", + I2C_EMC2305_FAN2); + } + + if (i2c_write(CONFIG_I2C_EMC2305_ADDR, + I2C_EMC2305_FAN3, 1, &data, 1) != 0){ + printf("Error: failed to change fan speed @%x\n", + I2C_EMC2305_FAN3); + } + + if (i2c_write(CONFIG_I2C_EMC2305_ADDR, + I2C_EMC2305_FAN4, 1, &data, 1) != 0){ + printf("Error: failed to change fan speed @%x\n", + I2C_EMC2305_FAN4); + } + + if (i2c_write(CONFIG_I2C_EMC2305_ADDR, + I2C_EMC2305_FAN5, 1, &data, 1) != 0){ + printf("Error: failed to change fan speed @%x\n", + I2C_EMC2305_FAN5); + } +} + +void emc2305_init(void) +{ + configure_emc2305(); + set_fan_speed(); +} diff --git a/board/freescale/common/emc2305.h b/board/freescale/common/emc2305.h new file mode 100644 index 0000000..ebbe20f --- /dev/null +++ b/board/freescale/common/emc2305.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2018 NXP + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __EMC2305_H_ +#define __EMC2305_H_ + +#define I2C_EMC2305_CONF 0x20 +#define I2C_EMC2305_FAN1 0x30 +#define I2C_EMC2305_FAN2 0x40 +#define I2C_EMC2305_FAN3 0x50 +#define I2C_EMC2305_FAN4 0x60 +#define I2C_EMC2305_FAN5 0x70 + +void emc2305_init(void); + +#endif /* __EMC2305_H_ */ diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c index 530f658..a4c54a2 100644 --- a/board/freescale/lx2160a/lx2160a.c +++ b/board/freescale/lx2160a/lx2160a.c @@ -26,6 +26,10 @@ #include "../common/vid.h" #include <fsl_immap.h>
+#ifdef CONFIG_EMC2305 +#include "../common/emc2305.h" +#endif + #ifdef CONFIG_TARGET_LX2160AQDS #define CFG_MUX_I2C_SDHC(reg, value) ((reg & 0x3f) | value) #define SET_CFG_MUX1_SDHC1_SDHC(reg) (reg & 0x3f) @@ -93,6 +97,11 @@ int board_early_init_f(void) /* get required clock for UART IP */ uart_get_clock();
+#ifdef CONFIG_EMC2305 + select_i2c_ch_pca9547(CONFIG_I2C_MUX_CH_EMC2305); + emc2305_init(); + select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT); +#endif fsl_lsch3_early_init_f(); return 0; }