summaryrefslogtreecommitdiff
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
parentcac4ae7a91a4872dd67084cb244f68446a4b39b8 (diff)
colibri_t20: nand: change offset handling
Rather than relying on hard-coded offsets actually make use of partition table parsing implementation.
-rw-r--r--arch/arm/include/asm/global_data.h9
-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
-rw-r--r--common/fdt_decode.c5
-rw-r--r--include/configs/colibri_t20.h3
-rw-r--r--include/fdt_decode.h18
7 files changed, 26 insertions, 84 deletions
diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
index 800f5fe6a58..97cfbf67c63 100644
--- a/arch/arm/include/asm/global_data.h
+++ b/arch/arm/include/asm/global_data.h
@@ -80,12 +80,9 @@ typedef struct global_data {
void **jt; /* jump table */
char env_buf[32]; /* buffer for getenv() before reloc. */
#if defined(CONFIG_COLIBRI_T20) || defined(CONFIG_COLIBRI_T30)
- unsigned env_offset; /* offset to the u-boot environment in mass storage */
- unsigned conf_blk_offset; /* offset to the Toradex config block in mass storage */
- unsigned conf_blk_offset2; /* offset to the Toradex config block (WinCE) in mass storage */
- unsigned kernel_offset; /* offset to the kernel in mass storage */
- unsigned rootfs_size; /* size of the rootfs in mass storage */
- unsigned rootfs_offset; /* offset to the rootfs in mass storage */
+ unsigned env_offset; /* offset to U-Boot environment */
+ unsigned conf_blk_offset; /* offset to Toradex config block */
+ unsigned kernel_offset; /* offset to kernel in mass storage */
#endif
} gd_t;
diff --git a/board/toradex/colibri_t20/colibri_t20.dts b/board/toradex/colibri_t20/colibri_t20.dts
index af332c5dfb7..fb12612060e 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 b4461699b7d..ca817eeeb6c 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 c1eaa8f429d..1c39f655bd2 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;
diff --git a/common/fdt_decode.c b/common/fdt_decode.c
index afa070f2d6b..bf56186af8a 100644
--- a/common/fdt_decode.c
+++ b/common/fdt_decode.c
@@ -718,11 +718,6 @@ int fdt_decode_nand(const void *blob, int node, struct fdt_nand *config)
if (err < 0)
return err;
- err = get_int_array(blob, node, "nv-partitions", config->nv_partitions,
- FDT_NAND_PARTOFFSET_COUNT);
- if (err < 0)
- return err;
-
/* Now look up the controller and decode that */
node = lookup_phandle(blob, node, "controller");
if (node < 0)
diff --git a/include/configs/colibri_t20.h b/include/configs/colibri_t20.h
index 24721ff5734..3888ac79b16 100644
--- a/include/configs/colibri_t20.h
+++ b/include/configs/colibri_t20.h
@@ -59,8 +59,7 @@
#define CONFIG_REVISION_TAG 1
#define CONFIG_SERIAL_TAG 1
-#define CONFIG_TRDX_CFG_BLOCK_OFFSET (gd->conf_blk_offset)
-#define CONFIG_TRDX_CFG_BLOCK_OFFSET2 (gd->conf_blk_offset2)
+#define CONFIG_TRDX_CFG_BLOCK
#define CONFIG_CMD_ASKENV
#define CONFIG_CMD_DIAG
diff --git a/include/fdt_decode.h b/include/fdt_decode.h
index 0969e29dec2..7b9e94919cf 100644
--- a/include/fdt_decode.h
+++ b/include/fdt_decode.h
@@ -244,17 +244,6 @@ enum {
FDT_NAND_TIMING_COUNT
};
-enum {
- FDT_NAND_ENV_OFFSET,
- FDT_NAND_CONFIG_OFFSET,
- FDT_NAND_CONFIG_OFFSET2,
- FDT_NAND_KERNEL_OFFSET,
- FDT_NAND_ROOTFS_LENGTH,
- FDT_NAND_ROOTFS_SIZE,
-
- FDT_NAND_PARTOFFSET_COUNT
-};
-
/* Information about an attached NAND chip */
struct fdt_nand {
struct nand_ctlr *reg;
@@ -273,13 +262,6 @@ struct fdt_nand {
int page_spare_bytes;
int page_data_bytes; /* Bytes in data area */
int timing[FDT_NAND_TIMING_COUNT];
- /*
- * The offset of the start of
- * u-boot-environment config-block 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
- */
- int nv_partitions[FDT_NAND_PARTOFFSET_COUNT];
};
/**