From patchwork Thu Nov 29 12:07:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meenakshi Aggarwal X-Patchwork-Id: 1005596 X-Patchwork-Delegate: prabhakar@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 435RXX0NSdz9s55 for ; Fri, 30 Nov 2018 05:54:51 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id BA42FC22484; Thu, 29 Nov 2018 18:53:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: ** X-Spam-Status: No, score=2.4 required=5.0 tests=DATE_IN_FUTURE_03_06 autolearn=no autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 48B40C2247C; Thu, 29 Nov 2018 18:52:01 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 63DD9C2237C; Thu, 29 Nov 2018 06:21:19 +0000 (UTC) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by lists.denx.de (Postfix) with ESMTPS id EC391C222BE for ; Thu, 29 Nov 2018 06:21:18 +0000 (UTC) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 481E41A03BF; Thu, 29 Nov 2018 07:21:18 +0100 (CET) Received: from inv0113.in-blr01.nxp.com (inv0113.in-blr01.nxp.com [165.114.116.118]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id E47C61A0036; Thu, 29 Nov 2018 07:21:17 +0100 (CET) Received: from uefi-OptiPlex-790.ap.freescale.net (uefi-OptiPlex-790.ap.freescale.net [10.232.132.78]) by inv0113.in-blr01.nxp.com (Postfix) with ESMTP id 1E139348; Thu, 29 Nov 2018 11:51:17 +0530 (IST) From: Meenakshi Aggarwal To: u-boot@lists.denx.de, york.sun@nxp.com Date: Thu, 29 Nov 2018 17:37:23 +0530 Message-Id: <1543493243-16780-1-git-send-email-meenakshi.aggarwal@nxp.com> X-Mailer: git-send-email 1.9.1 X-Virus-Scanned: ClamAV using ClamSMTP X-Mailman-Approved-At: Thu, 29 Nov 2018 18:51:56 +0000 Subject: [U-Boot] [PATCH] armv8: emc2305: add support for fan controller X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add support for fan controller emc2305. Enable support of FAN controller for LX2160A RDB board. Signed-off-by: Meenakshi Aggarwal --- 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 +#include +#include +#include +#ifdef CONFIG_FSL_LSCH2 +#include +#elif defined(CONFIG_FSL_LSCH3) +#include +#else +#include +#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 +#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; }