From b05dcb58fe04c6274fc942fa93efe77072395951 Mon Sep 17 00:00:00 2001
From: wdenk <wdenk>
Date: Fri, 4 Mar 2005 11:27:31 +0000
Subject: [PATCH] * Fix get_partition_info() parameter error in all other calls
   (common/cmd_ide.c, common/cmd_reiser.c, common/cmd_scsi.c).

* Enable USB and IDE support for INKA4x0 board

* Patch by Andrew Dyer, 28 February 2005:
  fix ext2load passing an incorrect pointer to get_partition_info()
  resulting in load failure for devices other than 0
---
 CHANGELOG                 |  9 +++++++++
 board/inka4x0/inka4x0.c   | 29 +++++++++++++++++++++++++++++
 common/cmd_ext2.c         |  5 ++++-
 common/cmd_ide.c          |  2 +-
 common/cmd_reiser.c       |  2 +-
 common/cmd_scsi.c         |  2 +-
 fs/ext2/dev.c             |  5 +----
 include/configs/inka4x0.h | 39 +++++++++++++++++++++++++++++++++++++++
 8 files changed, 85 insertions(+), 8 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 5d6ecf5aa4..38b8d24e8e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,15 @@ Changes for U-Boot 1.1.3:
 * Patch by Stefan Roese, 01 March 2005:
   Update for esd boards dp405 and hub405
 
+* Fix get_partition_info() parameter error in all other calls
+  (common/cmd_ide.c, common/cmd_reiser.c, common/cmd_scsi.c).
+
+* Enable USB and IDE support for INKA4x0 board
+
+* Patch by Andrew Dyer, 28 February 2005:
+  fix ext2load passing an incorrect pointer to get_partition_info()
+  resulting in load failure for devices other than 0
+
 * Add support for SRAM and 2 x Quad UARTs on INKA4x0 board
 
 * Cleanup USB and partition defines
diff --git a/board/inka4x0/inka4x0.c b/board/inka4x0/inka4x0.c
index 08a1b7f00b..4900201dd8 100644
--- a/board/inka4x0/inka4x0.c
+++ b/board/inka4x0/inka4x0.c
@@ -200,3 +200,32 @@ void pci_init_board(void)
         pci_mpc5xxx_init(&hose);
 }
 #endif
+
+#if defined (CFG_CMD_IDE) && defined (CONFIG_IDE_RESET)
+
+#define GPIO_PSC1_4	0x01000000UL
+
+void init_ide_reset (void)
+{
+	debug ("init_ide_reset\n");
+
+    	/* Configure PSC1_4 as GPIO output for ATA reset */
+	*(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4;
+	*(vu_long *) MPC5XXX_WU_GPIO_DIR    |= GPIO_PSC1_4;
+	/* Deassert reset */
+	*(vu_long *) MPC5XXX_WU_GPIO_DATA   |= GPIO_PSC1_4;
+}
+
+void ide_set_reset (int idereset)
+{
+	debug ("ide_reset(%d)\n", idereset);
+
+	if (idereset) {
+		*(vu_long *) MPC5XXX_WU_GPIO_DATA &= ~GPIO_PSC1_4;
+		/* Make a delay. MPC5200 spec says 25 usec min */
+		udelay(500000);
+	} else {
+		*(vu_long *) MPC5XXX_WU_GPIO_DATA |=  GPIO_PSC1_4;
+	}
+}
+#endif /* defined (CFG_CMD_IDE) && defined (CONFIG_IDE_RESET) */
diff --git a/common/cmd_ext2.c b/common/cmd_ext2.c
index 75afb320ec..af836cd614 100644
--- a/common/cmd_ext2.c
+++ b/common/cmd_ext2.c
@@ -41,6 +41,9 @@
 #include <linux/ctype.h>
 #include <asm/byteorder.h>
 #include <ext2fs.h>
+#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE))
+#include <usb.h>
+#endif
 
 #ifndef CONFIG_DOS_PARTITION
 #error DOS partition support must be selected
@@ -223,7 +226,7 @@ int do_ext2load (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	PRINTF("Using device %s%d, partition %d\n", argv[1], dev, part);
 
 	if (part != 0) {
-		if (get_partition_info (&dev_desc[dev], part, &info)) {
+		if (get_partition_info (dev_desc, part, &info)) {
 			printf ("** Bad partition %d **\n", part);
 			return(1);
 		}
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index 1cc88e3e50..e185c95b26 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -413,7 +413,7 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		}
 		part = simple_strtoul(++ep, NULL, 16);
 	}
-	if (get_partition_info (&ide_dev_desc[dev], part, &info)) {
+	if (get_partition_info (ide_dev_desc, part, &info)) {
 		SHOW_BOOT_PROGRESS (-1);
 		return 1;
 	}
diff --git a/common/cmd_reiser.c b/common/cmd_reiser.c
index cb316e5969..508ffcbdac 100644
--- a/common/cmd_reiser.c
+++ b/common/cmd_reiser.c
@@ -212,7 +212,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	PRINTF("Using device %s%d, partition %d\n", argv[1], dev, part);
 
 	if (part != 0) {
-		if (get_partition_info (&dev_desc[dev], part, &info)) {
+		if (get_partition_info (dev_desc, part, &info)) {
 			printf ("** Bad partition %d **\n", part);
 			return 1;
 		}
diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c
index 68e46b6389..7ee9d8efb1 100644
--- a/common/cmd_scsi.c
+++ b/common/cmd_scsi.c
@@ -243,7 +243,7 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		}
 		part = simple_strtoul(++ep, NULL, 16);
 	}
-	if (get_partition_info (&scsi_dev_desc[dev], part, &info)) {
+	if (get_partition_info (scsi_dev_desc, part, &info)) {
 		printf("error reading partinfo\n");
 		return 1;
 	}
diff --git a/fs/ext2/dev.c b/fs/ext2/dev.c
index 35a576daa8..1469e982b7 100644
--- a/fs/ext2/dev.c
+++ b/fs/ext2/dev.c
@@ -33,7 +33,6 @@
 static block_dev_desc_t *ext2fs_block_dev_desc;
 static disk_partition_t part_info;
 
-#undef DEBUG
 int ext2fs_set_blk_dev (block_dev_desc_t * rbdd, int part)
 {
 	ext2fs_block_dev_desc = rbdd;
@@ -74,9 +73,7 @@ int ext2fs_devread (int sector, int byte_offset, int byte_len, char *buf) {
 	sector += byte_offset >> SECTOR_BITS;
 	byte_offset &= SECTOR_SIZE - 1;
 
-#if defined(DEBUG)
-	printf (" <%d, %d, %d>\n", sector, byte_offset, byte_len);
-#endif
+	debug (" <%d, %d, %d>\n", sector, byte_offset, byte_len);
 
 	if (ext2fs_block_dev_desc == NULL) {
 		printf ("** Invalid Block Device Descriptor (NULL)\n");
diff --git a/include/configs/inka4x0.h b/include/configs/inka4x0.h
index 15b124a2ab..038ab75e7c 100644
--- a/include/configs/inka4x0.h
+++ b/include/configs/inka4x0.h
@@ -80,12 +80,17 @@
  * Supported commands
  */
 #define CONFIG_COMMANDS	       (CONFIG_CMD_DFL	| \
+				CFG_CMD_EXT2	| \
+				CFG_CMD_FAT	| \
+				CFG_CMD_IDE	| \
 				CFG_CMD_PCI	| \
 				CFG_CMD_USB	)
 
 /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
 #include <cmd_confdefs.h>
 
+#define	CONFIG_TIMESTAMP	1	/* Print image info with timestamp */
+
 #if (TEXT_BASE == 0xFFE00000)		/* Boot low */
 #   define CFG_LOWBOOT		1
 #endif
@@ -281,4 +286,38 @@
 #define CONFIG_USB_CONFIG	0x00001000
 #define CONFIG_USB_STORAGE
 
+/*-----------------------------------------------------------------------
+ * IDE/ATA stuff Supports IDE harddisk
+ *-----------------------------------------------------------------------
+ */
+
+#undef  CONFIG_IDE_8xx_PCCARD		/* Use IDE with PC Card	Adapter	*/
+
+#undef	CONFIG_IDE_8xx_DIRECT		/* Direct IDE    not supported	*/
+#undef	CONFIG_IDE_LED			/* LED   for ide not supported	*/
+
+#define	CONFIG_IDE_RESET		/* reset for ide supported	*/
+#define CONFIG_IDE_PREINIT
+
+#define CFG_IDE_MAXBUS		1	/* max. 1 IDE bus		*/
+#define CFG_IDE_MAXDEVICE	2	/* max. 1 drive per IDE bus	*/
+
+#define CFG_ATA_IDE0_OFFSET	0x0000
+
+#define CFG_ATA_BASE_ADDR	MPC5XXX_ATA
+
+/* Offset for data I/O			*/
+#define CFG_ATA_DATA_OFFSET	(0x0060)
+
+/* Offset for normal register accesses	*/
+#define CFG_ATA_REG_OFFSET	(CFG_ATA_DATA_OFFSET)
+
+/* Offset for alternate registers	*/
+#define CFG_ATA_ALT_OFFSET	(0x005C)
+
+/* Interval between registers                                                */
+#define CFG_ATA_STRIDE          4
+
+#define CONFIG_ATAPI            1
+
 #endif /* __CONFIG_H */