summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorMarcel Ziswiler <marcel.ziswiler@toradex.com>2012-10-18 12:53:36 +0200
committerMax Krummenacher <max.krummenacher@toradex.com>2012-10-18 19:18:14 +0200
commit822ebe51342db269164a7dd7a5394e2e5892422d (patch)
tree0bd774f3a73b7baddd272d57296454644413e552 /board
parentcac4ae7a91a4872dd67084cb244f68446a4b39b8 (diff)
colibri_t20: nand: change offset handling
Rather than relying on hard-coded offsets actually make use of partition table parsing implementation.
Diffstat (limited to 'board')
-rw-r--r--board/toradex/colibri_t20/colibri_t20.dts13
-rw-r--r--board/toradex/common/board.c53
-rw-r--r--board/toradex/common/tegra2_nand.c9
3 files changed, 22 insertions, 53 deletions
diff --git a/board/toradex/colibri_t20/colibri_t20.dts b/board/toradex/colibri_t20/colibri_t20.dts
index af332c5dfb..fb12612060 100644
--- a/board/toradex/colibri_t20/colibri_t20.dts
+++ b/board/toradex/colibri_t20/colibri_t20.dts
@@ -159,14 +159,6 @@
* TWHR, Max(tCS, tCH, tALS, tALH), TWH, TWP, TRH, TADL
*/
timing = <12 100 20 80 20 10 12 10 70>;
-
- /*
- * The offset of the start of
- * u-boot-environment config-block config-block (WinCE) kernel rootfs-size rootfs-start
- * rootfs: the numbers are concatenated to mtdparts=tegra_nand:<rootfs-size>K@<rootfs-start>K(userspace)
- * take them from a download with NVFLASH
- */
- /* unknown nv-partitions = <0xE00000 0x1000000 0x1000000 0x1200000 1018368 28160>; */
};
/* Colibri T20 256MB V1.2a new */
@@ -180,7 +172,6 @@
skipped-spare-bytes = <4>;
page-spare-bytes = <128>;
timing = <15 100 25 80 25 10 15 10 100>;
- nv-partitions = <0x980000 0x11c0000 0x7380000 0xc80000 503552 19712>;
};
/* Colibri T20 before V1.1x aka old */
@@ -194,7 +185,6 @@
skipped-spare-bytes = <4>;
page-spare-bytes = <128>;
timing = <12 100 20 60 15 10 12 10 70>;
- nv-partitions = <0xE00000 0x1880000 0x7900000 0x1200000 1018368 28160>;
};
/* Colibri T20 512MB V1.2a intermediate */
@@ -208,7 +198,6 @@
skipped-spare-bytes = <4>;
page-spare-bytes = <64>;
timing = <12 100 20 80 20 10 12 10 70>;
- /* unknown nv-partitions = <0xE00000 0x1880000 0x1880000 0x1200000 1018368 28160>; */
};
/* Colibri T20 512MB V1.2a new */
@@ -222,7 +211,6 @@
skipped-spare-bytes = <4>;
page-spare-bytes = <128>;
timing = <15 100 25 80 25 10 15 10 100>;
- nv-partitions = <0x980000 0x11c0000 0x7380000 0xc80000 1027840 19712>;
};
/* Colibri T20 512MB 3.3V TSOP test */
@@ -236,7 +224,6 @@
skipped-spare-bytes = <4>;
page-spare-bytes = <64>;
timing = <20 100 20 60 20 10 12 10 70>;
- nv-partitions = <0x740000 0xE60000 0x1880000 0x9C0000 1032576 15488>;
};
nand-controller@0x70008000 {
diff --git a/board/toradex/common/board.c b/board/toradex/common/board.c
index b4461699b7..ca817eeeb6 100644
--- a/board/toradex/common/board.c
+++ b/board/toradex/common/board.c
@@ -65,6 +65,8 @@
#include <fdt_decode.h>
#include <libfdt.h>
+#include "tegra2_partitions.h"
+
DECLARE_GLOBAL_DATA_PTR;
@@ -270,7 +272,7 @@ enum {
UART_ALL = 0xf
};
-#if defined(BOARD_LATE_INIT) && (defined(CONFIG_TRDX_CFG_BLOCK_OFFSET) || \
+#if defined(BOARD_LATE_INIT) && (defined(CONFIG_TRDX_CFG_BLOCK) || \
defined(CONFIG_REVISION_TAG) || defined(CONFIG_SERIAL_TAG))
static unsigned char *config_block = NULL;
#endif
@@ -549,7 +551,7 @@ int board_late_init(void)
{
char env_str[256 ];
-#ifdef CONFIG_TRDX_CFG_BLOCK_OFFSET
+#ifdef CONFIG_TRDX_CFG_BLOCK
char *addr_str, *end;
unsigned char bi_enetaddr[6] = {0, 0, 0, 0, 0, 0}; /* Ethernet address */
int i;
@@ -560,16 +562,15 @@ int board_late_init(void)
unsigned char toradex_oui[3] = { 0x00, 0x14, 0x2d };
int valid = 0;
- unsigned int offset;
int ret;
-#endif /* CONFIG_TRDX_CFG_BLOCK_OFFSET */
+#endif /* CONFIG_TRDX_CFG_BLOCK */
#ifdef CONFIG_VIDEO_TEGRA
/* Make sure we finish initing the LCD */
tegra_lcd_check_next_stage(gd->blob, 1);
#endif
-#ifdef CONFIG_TRDX_CFG_BLOCK_OFFSET
+#ifdef CONFIG_TRDX_CFG_BLOCK
/* Allocate RAM area for config block */
config_block = malloc(size);
if (!config_block) {
@@ -577,31 +578,19 @@ int board_late_init(void)
return -1;
}
- for (i = 0; i < 2; i++) {
- if (i == 0)
- offset = CONFIG_TRDX_CFG_BLOCK_OFFSET;
- else
- offset = CONFIG_TRDX_CFG_BLOCK_OFFSET2;
-
- /* Clear it */
- memset((void *)config_block, 0, size);
+ /* Clear it */
+ memset((void *)config_block, 0, size);
- /* Read production parameter config block */
+ /* Read production parameter config block */
#ifdef CONFIG_CMD_NAND
- ret = nand_read_skip_bad(&nand_info[0], offset, &size, (unsigned char *) config_block);
-#endif
- /* Check validity */
- if ( (ret==0) && (size>0) ) {
- mac_addr = config_block + 8;
- if (!(memcmp(mac_addr, toradex_oui, 3))) {
- valid = 1;
- break;
- }
- }
- else {
- /* probably there is no flash,
- * give up reading the config block, the nand flash layer crashes on the second attempt */
- break;
+ ret = nand_read_skip_bad(&nand_info[0], gd->conf_blk_offset, &size,
+ (unsigned char *) config_block);
+#endif
+ /* Check validity */
+ if ((ret == 0) && (size > 0)) {
+ mac_addr = config_block + 8;
+ if (!(memcmp(mac_addr, toradex_oui, 3))) {
+ valid = 1;
}
}
@@ -643,7 +632,7 @@ int board_late_init(void)
}
}
-#endif /* CONFIG_TRDX_CFG_BLOCK_OFFSET */
+#endif /* CONFIG_TRDX_CFG_BLOCK */
/* set the nand kernel offset */
if (!getenv("lnxoffset")) {
@@ -653,8 +642,10 @@ int board_late_init(void)
/* set the mtdparts string */
if (!getenv("mtdparts")) {
- sprintf(env_str, "mtdparts=tegra_nand:%uK@%uK(userspace)",
- (unsigned)(gd->rootfs_size), (unsigned)(gd->rootfs_offset) );
+ sprintf(env_str, "mtdparts=tegra_nand:");
+ i = strlen(env_str);
+ nvtegra_mtdparts_string(env_str + i, sizeof(env_str) - i);
+
setenv("mtdparts", env_str);
}
diff --git a/board/toradex/common/tegra2_nand.c b/board/toradex/common/tegra2_nand.c
index c1eaa8f429..1c39f655bd 100644
--- a/board/toradex/common/tegra2_nand.c
+++ b/board/toradex/common/tegra2_nand.c
@@ -1048,15 +1048,6 @@ int board_nand_init(struct nand_chip *nand)
printf("Could not decode NAND flash device node\n");
return -1;
}
-
- //copy partition information to global data
- gd->env_offset = (unsigned)(config->nv_partitions[FDT_NAND_ENV_OFFSET]);
- gd->conf_blk_offset = (unsigned)(config->nv_partitions[FDT_NAND_CONFIG_OFFSET]);
- gd->conf_blk_offset2 = (unsigned)(config->nv_partitions[FDT_NAND_CONFIG_OFFSET2]);
- gd->kernel_offset = (unsigned)(config->nv_partitions[FDT_NAND_KERNEL_OFFSET]);
- gd->rootfs_size = (unsigned)(config->nv_partitions[FDT_NAND_ROOTFS_LENGTH]);
- gd->rootfs_offset = (unsigned)(config->nv_partitions[FDT_NAND_ROOTFS_SIZE]);
-
if (!config->enabled)
return -1;
info->reg = config->reg;