From c59593a2df5786603bb1b5dad300a6f473196507 Mon Sep 17 00:00:00 2001
From: Florian Fainelli <florian@openwrt.org>
Date: Fri, 5 Oct 2007 10:37:35 +0000
Subject: [PATCH] Finally fix the rb500 boot (#2436)

SVN-Revision: 9133
---
 .../rb532/files/arch/mips/rb500/devices.c     | 24 +++++++++----------
 .../linux/rb532/files/arch/mips/rb500/prom.c  |  4 ++--
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/target/linux/rb532/files/arch/mips/rb500/devices.c b/target/linux/rb532/files/arch/mips/rb500/devices.c
index d8342feb19..1ca808beaf 100644
--- a/target/linux/rb532/files/arch/mips/rb500/devices.c
+++ b/target/linux/rb532/files/arch/mips/rb500/devices.c
@@ -151,7 +151,7 @@ void rb500_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 }
 
 static struct resource nand_slot0_res[] = {
-	{
+	[0] = {
 		.name = "nand_membase",
 		.flags = IORESOURCE_MEM
 	}
@@ -163,8 +163,8 @@ struct platform_nand_data rb500_nand_data = {
 };
 
 static struct platform_device nand_slot0 = {
-	.id = 0,
 	.name = "gen_nand",
+	.id = -1,
 	.resource = nand_slot0_res,
 	.num_resources = ARRAY_SIZE(nand_slot0_res),
 	.dev.platform_data = &rb500_nand_data,
@@ -234,6 +234,13 @@ static void __init rb500_nand_setup(void)
 		changeLatchU5(LO_FOFF | LO_CEX, LO_ULED | LO_ALE | LO_CLE | LO_WPX);
         else
 		changeLatchU5(LO_WPX | LO_FOFF | LO_CEX, LO_ULED | LO_ALE | LO_CLE);
+
+	/* Setup NAND specific settings */
+	rb500_nand_data.chip.nr_chips = 1;
+	rb500_nand_data.chip.nr_partitions = ARRAY_SIZE(rb500_partition_info);
+	rb500_nand_data.chip.partitions = rb500_partition_info;
+	rb500_nand_data.chip.chip_delay = NAND_CHIP_DELAY;
+	rb500_nand_data.chip.options = NAND_NO_AUTOINCR;
 }
 
 
@@ -248,19 +255,12 @@ static int __init plat_setup_devices(void)
 		cf_slot0_res[0].end = cf_slot0_res[0].start + 0x1000;
 	}
 
-	/* Initialise the NAND device */
-	rb500_nand_setup();
-
 	/* Read the NAND resources from the device controller */
 	nand_slot0_res[0].start = readl(CFG_DC_DEV2 + CFG_DC_DEVBASE);
 	nand_slot0_res[0].end = nand_slot0_res[0].start + 0x1000;
-
-	/* Setup NAND specific settings */
-	rb500_nand_data.chip.nr_chips = 1;
-	rb500_nand_data.chip.nr_partitions = ARRAY_SIZE(rb500_partition_info);
-	rb500_nand_data.chip.partitions = rb500_partition_info;
-	rb500_nand_data.chip.chip_delay = NAND_CHIP_DELAY;
-	rb500_nand_data.chip.options = NAND_NO_AUTOINCR;
+	
+	/* Initialise the NAND device */
+	rb500_nand_setup();
 
 	return platform_add_devices(rb500_devs, ARRAY_SIZE(rb500_devs));
 }
diff --git a/target/linux/rb532/files/arch/mips/rb500/prom.c b/target/linux/rb532/files/arch/mips/rb500/prom.c
index 2a33c0a052..222bfe2d23 100644
--- a/target/linux/rb532/files/arch/mips/rb500/prom.c
+++ b/target/linux/rb532/files/arch/mips/rb500/prom.c
@@ -42,7 +42,7 @@ extern void __init setup_serial_port(void);
 
 unsigned int idt_cpu_freq = 132000000;
 EXPORT_SYMBOL(idt_cpu_freq);
-char *board_type;
+char board_type[11];
 EXPORT_SYMBOL(board_type);
 unsigned int gpio_bootup_state = 0;
 EXPORT_SYMBOL(gpio_bootup_state);
@@ -135,8 +135,8 @@ void __init prom_setup_cmdline(void){
 		}
 #endif
 		if (i>0) *(cp++) = ' ';
+
 		if (strncmp(prom_argv[i], BOARD_TAG, sizeof(BOARD_TAG) - 1) == 0) {
-			board_type = (char *)kzalloc((sizeof(prom_argv[i]) + sizeof(BOARD_TAG) -1), GFP_KERNEL);
 			strcpy(board_type, prom_argv[i] + sizeof(BOARD_TAG) -1);
 		}
 		if (strncmp(prom_argv[i], GPIO_TAG, sizeof(GPIO_TAG) - 1) == 0) {
-- 
GitLab