From patchwork Thu Mar 2 19:04:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Franklin S Cooper Jr X-Patchwork-Id: 94800 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp304741qgd; Thu, 2 Mar 2017 11:04:54 -0800 (PST) X-Received: by 10.223.164.83 with SMTP id e19mr13588948wra.201.1488481494289; Thu, 02 Mar 2017 11:04:54 -0800 (PST) Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id 74si27130700wmq.55.2017.03.02.11.04.53; Thu, 02 Mar 2017 11:04:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ti.com Received: by lists.denx.de (Postfix, from userid 105) id 5BCCEC21C92; Thu, 2 Mar 2017 19:04:52 +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=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5E0DEC21C35; Thu, 2 Mar 2017 19:04:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BFBF2C21C35; Thu, 2 Mar 2017 19:04:48 +0000 (UTC) Received: from fllnx210.ext.ti.com (fllnx210.ext.ti.com [198.47.19.17]) by lists.denx.de (Postfix) with ESMTPS id 14943C21C33 for ; Thu, 2 Mar 2017 19:04:47 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v22J4kmG032615 for ; Thu, 2 Mar 2017 13:04:46 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1488481486; bh=SVcyMHGi8kWugMIMCn0nBaezXP4pXQD12Js3GRWiemI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Crh+SddFR4Fz9RbmlBw6UvPNhEITyU+ao0fTA60+1MhygUDIijDg6WoR1HHHAnP1W RmHElg/MuBAyDqr9MiirJ8xKeXlVCQ4pexvegR6ew5bOEWW7c/UYm4y5SU5/bFbuWf lO5QiQVz0q4EENwuxMbOf3HufhBDYiHt4SXEqXHI= Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v22J4kXE013631 for ; Thu, 2 Mar 2017 13:04:46 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.294.0; Thu, 2 Mar 2017 13:04:45 -0600 Received: from dbdmail01.india.ti.com (dbdmail01.india.ti.com [172.24.162.206]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v22J4iQk006759; Thu, 2 Mar 2017 13:04:45 -0600 Received: from udb0273011.am.dhcp.ti.com (udb0273011.am.dhcp.ti.com [128.247.83.33]) by dbdmail01.india.ti.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP id v22J4d25015682; Fri, 3 Mar 2017 00:34:42 +0530 From: Franklin S Cooper Jr To: , , , Date: Thu, 2 Mar 2017 13:04:05 -0600 Message-ID: <20170302190435.23212-2-fcooper@ti.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20170302190435.23212-1-fcooper@ti.com> References: <20170302190435.23212-1-fcooper@ti.com> MIME-Version: 1.0 Cc: Tero Kristo , "Franklin S Cooper Jr ." Subject: [U-Boot] [PATCH 01/31] ti: common: board_detect: Allow settings board detection variables manually 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Nishanth Menon In some situations the EEPROM used for board detection may not be programmed or simply programmed incorrectly. Therefore, it may be necessary to "simulate" reading the contents of the EEPROM to set appropriate variables used in the board detection code. This may also be helpful in certain boot modes where doing i2c reads may be costly and the config supports running only a specific board. Signed-off-by: Nishanth Menon Signed-off-by: Tero Kristo Signed-off-by: Keerthy Signed-off-by: Franklin S Cooper Jr. --- board/ti/common/board_detect.c | 24 ++++++++++++++++++++++++ board/ti/common/board_detect.h | 17 +++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c index a5dba94..5aaf884 100644 --- a/board/ti/common/board_detect.c +++ b/board/ti/common/board_detect.c @@ -116,6 +116,30 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr, return 0; } +int __maybe_unused ti_i2c_eeprom_am_set(const char *name, const char *rev) +{ + struct ti_common_eeprom *ep; + + if (!name || !rev) + return -1; + + ep = TI_EEPROM_DATA; + if (ep->header == TI_EEPROM_HEADER_MAGIC) + goto already_set; + + /* Set to 0 all fields */ + memset(ep, 0, sizeof(*ep)); + strncpy(ep->name, name, TI_EEPROM_HDR_NAME_LEN); + strncpy(ep->version, rev, TI_EEPROM_HDR_REV_LEN); + /* Some dummy serial number to identify the platform */ + strncpy(ep->serial, "0000", TI_EEPROM_HDR_SERIAL_LEN); + /* Mark it with a valid header */ + ep->header = TI_EEPROM_HEADER_MAGIC; + +already_set: + return 0; +} + int __maybe_unused ti_i2c_eeprom_am_get(int bus_addr, int dev_addr) { int rc; diff --git a/board/ti/common/board_detect.h b/board/ti/common/board_detect.h index 343fcb4..eeeacd3 100644 --- a/board/ti/common/board_detect.h +++ b/board/ti/common/board_detect.h @@ -193,4 +193,21 @@ u64 board_ti_get_emif2_size(void); */ void set_board_info_env(char *name); +/** + * ti_i2c_eeprom_am_set() - Setup the eeprom data with predefined values + * @name: Name of the board + * @rev: Revision of the board + * + * In some cases such as in RTC-only mode, we are able to skip reading eeprom + * and wasting i2c based initialization time by using predefined flags for + * detecting what platform we are booting on. For those platforms, provide + * a handy function to pre-program information. + * + * NOTE: many eeprom information such as serial number, mac address etc is not + * available. + * + * Return: 0 if all went fine, else return error. + */ +int ti_i2c_eeprom_am_set(const char *name, const char *rev); + #endif /* __BOARD_DETECT_H */