From patchwork Tue May 31 12:08:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Schocher X-Patchwork-Id: 628219 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3rJskB38Ydz9sDb for ; Tue, 31 May 2016 22:09:54 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 76FFBA7616; Tue, 31 May 2016 14:09:45 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9rF1pP9kFTLN; Tue, 31 May 2016 14:09:45 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DC9A6A7622; Tue, 31 May 2016 14:09:05 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AB834A7516 for ; Tue, 31 May 2016 14:08:22 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OSqyQc4hDuiT for ; Tue, 31 May 2016 14:08:22 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from pollux.denx.de (host-82-135-33-74.customer.m-online.net [82.135.33.74]) by theia.denx.de (Postfix) with ESMTP id A37A5A7528 for ; Tue, 31 May 2016 14:08:20 +0200 (CEST) Received: by pollux.denx.de (Postfix, from userid 515) id 6BE9811E4; Tue, 31 May 2016 14:08:20 +0200 (CEST) From: Heiko Schocher To: u-boot@lists.denx.de Date: Tue, 31 May 2016 14:08:10 +0200 Message-Id: <1464696492-10349-6-git-send-email-hs@denx.de> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1464696492-10349-1-git-send-email-hs@denx.de> References: <1464696492-10349-1-git-send-email-hs@denx.de> Cc: Scott Wood , Tom Rini Subject: [U-Boot] [PATCH v2 5/7] am335x, dxr2: get ECC sType from I2C eeprom X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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" read the ECC Type field from the i2c eeprom, instead configuring it static in the U-Boot binary. see RM: Table 26-17. NAND Geometry Information on I2C EEPROM Signed-off-by: Heiko Schocher --- Changes in v2: - rebase to current mainline commit id: e4a94ce4ac77396b181663c0493c50bc2d5b9143 board/siemens/draco/board.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/board/siemens/draco/board.c b/board/siemens/draco/board.c index 988c12a..41bdef0 100644 --- a/board/siemens/draco/board.c +++ b/board/siemens/draco/board.c @@ -105,6 +105,40 @@ static void print_chip_data(void) } #endif /* CONFIG_SPL_BUILD */ +#define AM335X_NAND_ECC_MASK 0x0f +#define AM335X_NAND_ECC_TYPE_16 0x02 + +static int ecc_type; + +struct am335x_nand_geometry { + u32 magic; + u8 nand_geo_addr; + u8 nand_geo_page; + u8 nand_bus; +}; + +static int draco_read_nand_geometry(void) +{ + struct am335x_nand_geometry geo; + + /* Read NAND geometry */ + if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0x80, 2, + (uchar *)&geo, sizeof(struct am335x_nand_geometry))) { + printf("Could not read the NAND geomtery; something fundamentally wrong on the I2C bus.\n"); + return -EIO; + } + if (geo.magic != 0xa657b310) { + printf("%s: bad magic: %x\n", __func__, geo.magic); + return -EFAULT; + } + if ((geo.nand_bus & AM335X_NAND_ECC_MASK) == AM335X_NAND_ECC_TYPE_16) + ecc_type = 16; + else + ecc_type = 8; + + return 0; +} + /* * Read header information from EEPROM into global structure. */ @@ -147,6 +181,8 @@ static int read_eeprom(void) printf("Warning: No chip data in eeprom\n"); print_ddr3_timings(); + + return draco_read_nand_geometry(); #endif return 0; } @@ -207,7 +243,14 @@ static void spl_siemens_board_init(void) #ifdef CONFIG_BOARD_LATE_INIT int board_late_init(void) { - omap_nand_switch_ecc(1, 8); + int ret; + + ret = draco_read_nand_geometry(); + if (ret != 0) + return ret; + + nand_curr_device = 0; + omap_nand_switch_ecc(1, ecc_type); #ifdef CONFIG_FACTORYSET /* Set ASN in environment*/ if (factory_dat.asn[0] != 0) {