U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 5/7] am335x, dxr2: get ECC sType from I2C eeprom
Date: Tue,  7 Jun 2016 08:55:43 +0200	[thread overview]
Message-ID: <1465282545-2810-6-git-send-email-hs@denx.de> (raw)
In-Reply-To: <1465282545-2810-1-git-send-email-hs@denx.de>

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 <hs@denx.de>

---

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) {
-- 
2.5.5

  parent reply	other threads:[~2016-06-07  6:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-07  6:55 [U-Boot] [PATCH v3 0/7] add support for the etamin draco board variant Heiko Schocher
2016-06-07  6:55 ` [U-Boot] [PATCH v3 1/7] siemens,am33x: add ubi fastmap support Heiko Schocher
2016-06-09 18:03   ` [U-Boot] [U-Boot, v3, 1/7] siemens, am33x: " Tom Rini
2016-06-07  6:55 ` [U-Boot] [PATCH v3 2/7] ubi: add new ubi command "ubi detach" Heiko Schocher
2016-06-09 18:03   ` [U-Boot] [U-Boot,v3,2/7] " Tom Rini
2016-06-07  6:55 ` [U-Boot] [PATCH v3 3/7] nand: add nand mtd concat support Heiko Schocher
2016-06-09 18:03   ` [U-Boot] [U-Boot,v3,3/7] " Tom Rini
2016-06-07  6:55 ` [U-Boot] [PATCH v3 4/7] mtd: nand: omap: allow to switch to BCH16 Heiko Schocher
2016-06-09 18:03   ` [U-Boot] [U-Boot, v3, " Tom Rini
2016-06-07  6:55 ` Heiko Schocher [this message]
2016-06-09 18:03   ` [U-Boot] [U-Boot, v3, 5/7] am335x, dxr2: get ECC sType from I2C eeprom Tom Rini
2016-06-07  6:55 ` [U-Boot] [PATCH v3 6/7] dfu, nand, ubi: fix erasing after write finish Heiko Schocher
2016-06-09 18:04   ` [U-Boot] [U-Boot, v3, " Tom Rini
2016-06-23 15:00   ` [U-Boot] [PATCH v3 " Lukasz Majewski
2016-06-07  6:55 ` [U-Boot] [PATCH v3 7/7] siemens,am33x: add draco etamin board Heiko Schocher
2016-06-09 18:04   ` [U-Boot] [U-Boot,v3,7/7] " Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1465282545-2810-6-git-send-email-hs@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox