Added support for TQM834x boards.
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index ab6ccbb..6a5576c 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -84,7 +84,7 @@
 
 #if (CONFIG_COMMANDS & CFG_CMD_IMLS)
 #include <flash.h>
-extern flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
+extern flash_info_t flash_info[]; /* info for FLASH chips */
 static int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 #endif
 
@@ -1082,7 +1082,7 @@
 	for (i=0, info=&flash_info[0]; i<CFG_MAX_FLASH_BANKS; ++i, ++info) {
 		if (info->flash_id == FLASH_UNKNOWN)
 			goto next_bank;
-		for (j=0; j<CFG_MAX_FLASH_SECT; ++j) {
+		for (j=0; j<info->sector_count; ++j) {
 
 			if (!(hdr=(image_header_t *)info->start[j]) ||
 			    (ntohl(hdr->ih_magic) != IH_MAGIC))
diff --git a/common/cmd_flash.c b/common/cmd_flash.c
index d5be30c..0aa4783 100644
--- a/common/cmd_flash.c
+++ b/common/cmd_flash.c
@@ -404,7 +404,11 @@
 {
 	flash_info_t *info;
 	ulong bank;
+#ifdef CFG_MAX_FLASH_BANKS_DETECT
+	int s_first[CFG_MAX_FLASH_BANKS_DETECT], s_last[CFG_MAX_FLASH_BANKS_DETECT];
+#else
 	int s_first[CFG_MAX_FLASH_BANKS], s_last[CFG_MAX_FLASH_BANKS];
+#endif
 	int erased = 0;
 	int planned;
 	int rcode = 0;
@@ -617,7 +621,11 @@
 {
 	flash_info_t *info;
 	ulong bank;
+#ifdef CFG_MAX_FLASH_BANKS_DETECT
+	int s_first[CFG_MAX_FLASH_BANKS_DETECT], s_last[CFG_MAX_FLASH_BANKS_DETECT];
+#else
 	int s_first[CFG_MAX_FLASH_BANKS], s_last[CFG_MAX_FLASH_BANKS];
+#endif
 	int protected, i;
 	int planned;
 	int rcode;
diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c
index fda0c95..34920b1 100644
--- a/common/cmd_jffs2.c
+++ b/common/cmd_jffs2.c
@@ -316,7 +316,7 @@
 {
 #if (CONFIG_COMMANDS & CFG_CMD_FLASH)
 	/* info for FLASH chips */
-	extern flash_info_t flash_info[CFG_MAX_FLASH_BANKS];
+	extern flash_info_t flash_info[];
 	flash_info_t *flash;
 	int offset_aligned;
 	u32 end_offset;
@@ -711,7 +711,7 @@
 	if (type == MTD_DEV_TYPE_NOR) {
 #if (CONFIG_COMMANDS & CFG_CMD_FLASH)
 		if (num < CFG_MAX_FLASH_BANKS) {
-			extern flash_info_t flash_info[CFG_MAX_FLASH_BANKS];
+			extern flash_info_t flash_info[];
 			*size = flash_info[num].size;
 			return 0;
 		}
diff --git a/common/cmd_mii.c b/common/cmd_mii.c
index 722b9f0..f93232c 100644
--- a/common/cmd_mii.c
+++ b/common/cmd_mii.c
@@ -91,7 +91,7 @@
 		 * Look for any and all PHYs.  Valid addresses are 0..31.
 		 */
 		if (argc >= 3) {
-			start = addr; end = addr + 1;
+			start = addrlo; end = addrhi + 1;
 		} else {
 			start = 0; end = 32;
 		}
diff --git a/common/flash.c b/common/flash.c
index b308413..2fb3319 100644
--- a/common/flash.c
+++ b/common/flash.c
@@ -28,7 +28,7 @@
 
 #if !defined(CFG_NO_FLASH)
 
-extern flash_info_t  flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
+extern flash_info_t  flash_info[]; /* info for FLASH chips */
 
 /*-----------------------------------------------------------------------
  * Functions