Index: target/linux/rdc/r8610/config-2.6.30
===================================================================
--- target/linux/rdc/r8610/config-2.6.30	(revision 19979)
+++ target/linux/rdc/r8610/config-2.6.30	(working copy)
@@ -1,3 +0,0 @@
-CONFIG_MTD_PHYSMAP=y
-# CONFIG_MTD_R8610 is not set
-# CONFIG_MTD_RDC3210 is not set
Index: target/linux/rdc/image/mkimg_sitecom.pl
===================================================================
--- target/linux/rdc/image/mkimg_sitecom.pl	(revision 19979)
+++ target/linux/rdc/image/mkimg_sitecom.pl	(working copy)
@@ -1,17 +1,11 @@
 #!/usr/bin/perl
 
-$bzimgsize = -s @ARGV[0];
-$padding = 4 - ($bzimgsize + 2) % 4;
-if ($padding == 4) {
-	$padding = 0; }
 open (bzimg, @ARGV[0]);
 while (<bzimg>) { $i .= $_; }
-$i .= "\0"x$padding;
 $i .= pack "v", -(unpack "%v*", $i); 
 print "CSYS";
 print pack("V", length($i));
 print pack("V", 0);
-#-s @ARGV[1]
 print "WRRM";
 print pack("V", length($i));
 print $i;
Index: target/linux/rdc/image/Makefile
===================================================================
--- target/linux/rdc/image/Makefile	(revision 19979)
+++ target/linux/rdc/image/Makefile	(working copy)
@@ -26,64 +26,26 @@
 endef
 
 define Image/Build/ar525w
-	touch $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).img
-	touch $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2)-web.img
-	dd if=$(KDIR)/root.$(1) of=$(KDIR)/root.tmp $(call trxalign/$(1)) conv=sync
-	mv $(KDIR)/root.tmp $(KDIR)/root.$(1)
-	$(STAGING_DIR_HOST)/bin/airlink -b 1 -j $(shell bash -c 'echo $$[$(3)]') $(KDIR)/bzImage $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).img
-	$(STAGING_DIR_HOST)/bin/airlink -e -b 1 -j $(shell bash -c 'echo $$[$(3)]') $(KDIR)/bzImage $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2)-web.img
+	cp $(KDIR)/bzImage $(KDIR)/bzImage.tmp
+	$(SCRIPT_DIR)/pad_image $(1) $(KDIR)/bzImage.tmp $(KDIR)/root.$(1) 32
+	$(STAGING_DIR_HOST)/bin/airlink -b 1 $(KDIR)/bzImage $(KDIR)/image.tmp
+	cat $(KDIR)/root.$(1) >> image.tmp
+	mv image.tmp $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).img
+	$(STAGING_DIR_HOST)/bin/airlink -e -b 1 $(KDIR)/bzImage $(KDIR)/image.tmp
+	cat $(KDIR)/root.$(1) >> image.tmp
+	mv image.tmp $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2)-web.img
 endef
 
-define Image/Postprocess/sitecom/squashfs
-	dd if=/dev/zero of=$(KDIR)/tmp2.img count=1 bs=32k #32k config data a start of flash
-	cat $(KDIR)/tmp.img >> $(KDIR)/tmp2.img
-	$(call prepare_generic_squashfs,$(KDIR)/tmp2.img)
-	dd if=$(KDIR)/tmp2.img of=$(KDIR)/tmp.img bs=32k skip=1
-endef
-
 define Image/Build/sitecom
-	$(TOPDIR)/target/linux/rdc/image/mkimg_sitecom.pl $(KDIR)/bzImage > $(KDIR)/tmp.img
+	cp $(KDIR)/bzImage $(KDIR)/bzImage.tmp
+	#32k config data + 20 bytes header + 2 bytes checksum after kernel image
+	$(SCRIPT_DIR)/pad_image $(1) $(KDIR)/bzImage.tmp $(KDIR)/root.$(1) 32790
+	$(TOPDIR)/target/linux/rdc/image/mkimg_sitecom.pl $(KDIR)/bzImage.tmp > $(KDIR)/tmp.img
 	cat $(KDIR)/root.$(1) >> $(KDIR)/tmp.img
-	$(call Image/Postprocess/sitecom/$(1))
 	cp $(KDIR)/tmp.img $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).img
+	rm $(KDIR)/tmp.img $(KDIR)/bzImage.tmp
 endef
 
-define Image/Build/dir450
-	touch $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).img
-	dd if=$(KDIR)/root.$(1) of=$(KDIR)/root.tmp $(call trxalign/$(1)) conv=sync
-	mv $(KDIR)/root.tmp $(KDIR)/root.$(1)
-	$(CP) $(KDIR)/root.$(1) $(BIN_DIR)/onlyrootfs-$(BOARD)-$(1)-$(2).img
-endef
-
-define Image/Build/g570s
-	$(call Image/Prepare/$(1))
-	mv $(KDIR)/root.$(1) $(KDIR)/root.tmp
-	dd of=$(KDIR)/root.$(1) if=$(KDIR)/root.tmp $(call trxalign/$(1)) conv=sync
-	$(CP) $(KDIR)/bzImage $(BIN_DIR)/openwrt-tftp-$(BOARD)-$(1)-$(2).img
-	dd of=$(BIN_DIR)/openwrt-tftp-$(BOARD)-$(1)-$(2).img if=/dev/null bs=1024 seek=1024
-	cat $(KDIR)/root.$(1) >> $(BIN_DIR)/openwrt-tftp-$(BOARD)-$(1)-$(2).img
-	if [ ! -x $(STAGING_DIR_HOST)/bin/zyxel_combine ]; then echo "#ERR Please copy the ZyXEL \"combine\" tool as $(STAGING_DIR_HOST)/bin/zyxel_combine to build."; fi
-	sh -c "mkdir $(KDIR)/zyxel.tmp && cd $(KDIR)/zyxel.tmp && mv ../root.tmp initrd.bin && cp ../bzImage kernel.bin && $(STAGING_DIR_HOST)/bin/zyxel_combine -mcf kernel.bin initrd.bin && mv image $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).rmt" || :
-	$(RM) -r $(KDIR)/zyxel.tmp
-endef
-
-define Image/Prepare/amit/squashfs
-	echo -n "0123456789abcdef" > $(KDIR)/root.tmp
-	cat $(KDIR)/root.squashfs >> $(KDIR)/root.tmp
-	dd if=$(KDIR)/root.tmp of=$(KDIR)/root2.tmp bs=64k conv=sync
-	dd if=$(KDIR)/root2.tmp of=$(KDIR)/root.squashfs bs=1 skip=16
-	$(RM) $(KDIR)/root.tmp $(KDIR)/root2.tmp
-	$(call add_jffs2_mark,$(KDIR)/root.squashfs)
-endef
-
-define Image/Build/amit
-	$(call Image/Prepare/amit/$(1))
-	if [ ! -x $(STAGING_DIR_HOST)/bin/amit_makebin ]; then echo "#ERR Please copy the AMIT \"makebin\" tool from http://mgb111.pradnik.net/ as $(STAGING_DIR_HOST)/bin/amit_makebin to build."; fi
-	sh -c "mkdir -p $(KDIR)/amit.tmp/linux_src/arch/i386/boot $(KDIR)/amit.tmp/rom_disk && cd $(KDIR)/amit.tmp && ln -s ../../root.$(1) rom_disk/fs.img && ln -s ../../../../../bzImage linux_src/arch/i386/boot && $(STAGING_DIR_HOST)/bin/amit_makebin && mv upgrade.img $(BIN_DIR)/openwrt-$(BOARD)-$(1)-anas350.bin" || :
-	$(RM) -r $(KDIR)/amit.tmp
-	$(STAGING_DIR_HOST)/bin/makeamitbin -o $(BIN_DIR)/openwrt-$(BOARD)-$(1)-ar360w3g.bin -1 ALK_ATG001 -2 Atropos linux3g $(KDIR)/bzImage ramdisk3g $(KDIR)/root.$(1)
-endef
-
 define Image/Build/bifferboard
 	$(TOPDIR)/target/linux/rdc/image/mkimg_bifferboard.py $(KDIR)/bzImage $(KDIR)/root.$(1) $(KDIR)/tmp.img
 	$(CP) $(KDIR)/tmp.img $(BIN_DIR)/openwrt-$(BOARD)-$(1)-$(2).img
Index: target/linux/rdc/ar525w/config-2.6.30
===================================================================
--- target/linux/rdc/ar525w/config-2.6.30	(revision 19979)
+++ target/linux/rdc/ar525w/config-2.6.30	(working copy)
@@ -1,8 +0,0 @@
-# CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_R8610 is not set
-CONFIG_MTD_RDC3210_ALLOW_JFFS2=y
-CONFIG_MTD_RDC3210_BUSWIDTH=2
-# CONFIG_MTD_RDC3210_FACTORY_PRESENT is not set
-CONFIG_MTD_RDC3210_SIZE=0x400000
-# CONFIG_MTD_RDC3210_STATIC_MAP is not set
-CONFIG_MTD_RDC3210=y
Index: target/linux/rdc/files-2.6.30/arch/x86/include/asm/rdc_boards.h
===================================================================
--- target/linux/rdc/files-2.6.30/arch/x86/include/asm/rdc_boards.h	(revision 0)
+++ target/linux/rdc/files-2.6.30/arch/x86/include/asm/rdc_boards.h	(revision 0)
@@ -0,0 +1,36 @@
+/*
+ *  RDC321x boards
+ *
+ *  Copyright (C) 2007-2009 OpenWrt.org
+ *  Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
+ *  Copyright (C) 2008-2009 Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; either version 2
+ *  of the License, or (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the
+ *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA  02110-1301, USA.
+ *
+ */
+
+#ifndef _RDC_BOARDS_H__
+#define _RDC_BOARDS_H__
+
+#include <linux/leds.h>
+#include <linux/gpio_buttons.h>
+
+struct rdc_platform_data {
+	struct gpio_led_platform_data led_data;
+	struct gpio_buttons_platform_data button_data;
+};
+
+#endif
Index: target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/platform.c
===================================================================
--- target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/platform.c	(revision 19979)
+++ target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/platform.c	(working copy)
@@ -23,267 +23,98 @@
  */
 
 #include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/list.h>
-#include <linux/device.h>
+//#include <linux/kernel.h>
+//#include <linux/list.h>
+//#include <linux/device.h>
 #include <linux/platform_device.h>
-#include <linux/version.h>
-#include <linux/leds.h>
-#include <linux/gpio_buttons.h>
-#include <linux/input.h>
+//#include <linux/version.h>
+//#include <linux/input.h>
 #include <linux/mtd/map.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/physmap.h>
 #include <linux/root_dev.h>
 
-/* Flash */
-#ifdef CONFIG_MTD_R8610
-#define CONFIG_MTD_RDC3210 1
-#elif defined CONFIG_MTD_RDC3210
-static struct resource rdc_flash_resource[] = {
-	[0] = {
-		.start = (u32)-CONFIG_MTD_RDC3210_SIZE,
-		.end = (u32)-1,
-		.flags = IORESOURCE_MEM,
-	},
-};
+#include <asm/rdc_boards.h>
 
-static struct platform_device rdc_flash_device = {
-	.name = "rdc321x-flash",
-	.id = -1,
-	.num_resources = ARRAY_SIZE(rdc_flash_resource),
-	.resource = rdc_flash_resource,
-};
-#else
-static struct mtd_partition rdc_flash_parts[15];
+static struct rdc_platform_data rdcplat_data;
 
-static struct resource rdc_flash_resource = {
-	.end = (u32)-1,
-	.flags = IORESOURCE_MEM,
-};
-
-static struct physmap_flash_data rdc_flash_data = {
-	.parts = rdc_flash_parts,
-};
-
-static struct platform_device rdc_flash_device = {
-	.name = "physmap-flash",
-	.id = -1,
-	.resource = &rdc_flash_resource,
-	.num_resources = 1,
-	.dev.platform_data = &rdc_flash_data,
-};
-#endif
-
 /* LEDS */
-static struct gpio_led default_leds[] = {
-	{ .name = "rdc321x:dmz", .gpio = 1, .active_low = 1},
-};
-
-static struct gpio_led sitecom_leds[] = {
-	{ .name = "rdc321x:power", .gpio = 15, .active_low = 1},
-	{ .name = "rdc321x:usb0", .gpio = 0, .active_low = 1},
-	{ .name = "rdc321x:usb1", .gpio = 1, .active_low = 1},
-};
-
-static struct gpio_led_platform_data rdc321x_led_data = {
-	.num_leds = ARRAY_SIZE(default_leds),
-	.leds = default_leds,
-};
-
 static struct platform_device rdc321x_leds = {
 	.name = "leds-gpio",
 	.id = -1,
 	.dev = {
-		.platform_data = &rdc321x_led_data,
+		.platform_data = &rdcplat_data.led_data,
 	}
 };
 
 /* Button */
-static struct gpio_button rdc321x_gpio_btn[] = {
-	{
-		.gpio = 6,
-		.code = BTN_0,
-		.desc = "Reset",
-		.active_low = 1,
-	}
-};
-
-static struct gpio_buttons_platform_data rdc321x_gpio_btn_data = {
-	.buttons = rdc321x_gpio_btn,
-	.nbuttons = ARRAY_SIZE(rdc321x_gpio_btn),
-};
-
-static struct platform_device rdc321x_button = {
+static struct platform_device rdc321x_buttons = {
 	.name = "gpio-buttons",
 	.id = -1,
 	.dev = {
-		.platform_data = &rdc321x_gpio_btn_data,
+		.platform_data = &rdcplat_data.button_data,
 	}
 };
-
-static struct platform_device *rdc321x_devs[] = {
-	&rdc_flash_device,
+	
+static __initdata struct platform_device *rdc321x_devs[] = {
 	&rdc321x_leds,
-	&rdc321x_button,
+	&rdc321x_buttons,
 };
 
-static int probe_flash_start(struct map_info *the_map)
-{
-	struct mtd_info *res;
+const char *__initdata boards[] = {
+	"Sitecom",
+	"AR525W",
+	"Bifferboard",
+	"R8610",
+	0
+};
 
-	the_map->virt = ioremap(the_map->phys, the_map->size);
-	if (the_map->virt == NULL)
-		return 1;
-	for (the_map->bankwidth = 32; the_map->bankwidth; the_map->bankwidth
-			>>= 1) {
-		res = do_map_probe("cfi_probe", the_map);
-		if (res == NULL)
-			res = do_map_probe("jedec_probe", the_map);
-		if (res != NULL)
-			break;
-	}
-	iounmap(the_map->virt);
-	if (res != NULL)
-		the_map->phys = (u32)-(s32)(the_map->size = res->size);
-	return res == NULL;
-}
+static struct map_info rdc_map_info = {
+	.name = "rdc_flash",
+	.size = 0x800000,	//8MB
+	.phys = 0xFF800000,	//(u32) -rdc_map_info.size;
+	.bankwidth = 2
+};
 
 static int __init rdc_board_setup(void)
 {
-#ifndef CONFIG_MTD_RDC3210
-	struct map_info rdc_map_info;
-	u32 the_header[8];
-
-	ROOT_DEV = 0;
-	rdc_map_info.name = rdc_flash_device.name;
-	rdc_map_info.size = 0x800000;	//8MB
-	rdc_map_info.phys = (u32) -rdc_map_info.size;
-	rdc_map_info.bankwidth = 2;
-	rdc_map_info.set_vpp = NULL;
+	struct mtd_partition *partitions;
+	int count, res;
+	struct mtd_info *mtdinfo;
+	
 	simple_map_init(&rdc_map_info);
-	while (probe_flash_start(&rdc_map_info)) {
-		if (rdc_map_info.size /= 2 < 0x100000)	//1MB
-			panic("Could not find start of flash!");
+	
+	while (true) {
+		rdc_map_info.virt = ioremap(rdc_map_info.phys, rdc_map_info.size);
+		if (rdc_map_info.virt == NULL)
+			continue;
+		
+		mtdinfo = do_map_probe("cfi_probe", &rdc_map_info);
+		if (mtdinfo == NULL)
+			mtdinfo = do_map_probe("jedec_probe", &rdc_map_info);
+		if (mtdinfo != NULL)
+			break;
+
+		iounmap(rdc_map_info.virt);
+		if ((rdc_map_info.size >>= 1) < 0x100000)	//1MB
+			panic("RDC321x: Could not find start of flash!");
 		rdc_map_info.phys = (u32) -rdc_map_info.size;
 	}
-	rdc_flash_resource.start = rdc_map_info.phys;
-	rdc_flash_data.width = rdc_map_info.bankwidth;
-	rdc_map_info.virt = ioremap_nocache(rdc_map_info.phys, 0x10);
-	if (rdc_map_info.virt == NULL)
-		panic("Could not ioremap to read device magic!");
-	the_header[0] = ((u32 *)rdc_map_info.virt)[0];
-	the_header[1] = ((u32 *)rdc_map_info.virt)[1];
-	the_header[2] = ((u32 *)rdc_map_info.virt)[2];
-	the_header[3] = ((u32 *)rdc_map_info.virt)[3];
-	iounmap(rdc_map_info.virt);
-	rdc_map_info.virt = ioremap_nocache(rdc_map_info.phys + 0x8000, 0x10);
-	if (rdc_map_info.virt == NULL)
-		panic("Could not ioremap to read device magic!");
-	the_header[4] = ((u32 *)rdc_map_info.virt)[0];
-	the_header[5] = ((u32 *)rdc_map_info.virt)[1];
-	the_header[6] = ((u32 *)rdc_map_info.virt)[2];
-	the_header[7] = ((u32 *)rdc_map_info.virt)[3];
-	iounmap(rdc_map_info.virt);
-	if (!memcmp(the_header, "GMTK", 4)) {	/* Gemtek */
-		/* TODO */
-	} else if (!memcmp(the_header + 4, "CSYS", 4)) {	/* Sitecom */
-		rdc_flash_parts[0].name = "system";
-		rdc_flash_parts[0].offset = 0;
-		rdc_flash_parts[0].size = rdc_map_info.size - 0x10000;
-		rdc_flash_parts[1].name = "config";
-		rdc_flash_parts[1].offset = 0;
-		rdc_flash_parts[1].size = 0x8000;
-		rdc_flash_parts[2].name = "magic";
-		rdc_flash_parts[2].offset = 0x8000;
-		rdc_flash_parts[2].size = 0x14;
-		rdc_flash_parts[3].name = "kernel";
-		rdc_flash_parts[3].offset = 0x8014;
-		rdc_flash_parts[3].size = the_header[5];
-		rdc_flash_parts[4].name = "rootfs";
-		rdc_flash_parts[4].offset = 0x8014 + the_header[5];
-		rdc_flash_parts[4].size = rdc_flash_parts[0].size - rdc_flash_parts[4].offset;
-		rdc_flash_parts[5].name = "bootloader";
-		rdc_flash_parts[5].offset = rdc_flash_parts[0].size;
-		rdc_flash_parts[5].size = 0x10000;
-		rdc_flash_data.nr_parts = 6;
-
-		rdc321x_led_data.num_leds = ARRAY_SIZE(sitecom_leds);
-		rdc321x_led_data.leds = sitecom_leds;
-	} else if (!memcmp(((u8 *)the_header) + 14, "Li", 2)) {	/* AMIT */
-		rdc_flash_parts[0].name = "kernel_parthdr";
-		rdc_flash_parts[0].offset = 0;
-		rdc_flash_parts[0].size = 0x10;
-		rdc_flash_parts[1].name = "kernel";
-		rdc_flash_parts[1].offset = 0x10;
-		rdc_flash_parts[1].size = 0xffff0;
-		rdc_flash_parts[2].name = "rootfs_parthdr";
-		rdc_flash_parts[2].offset = 0x100000;
-		rdc_flash_parts[2].size = 0x10;
-		rdc_flash_parts[3].name = "rootfs";
-		rdc_flash_parts[3].offset = 0x100010;
-		rdc_flash_parts[3].size = rdc_map_info.size - 0x160010;
-		rdc_flash_parts[4].name = "config_parthdr";
-		rdc_flash_parts[4].offset = rdc_map_info.size - 0x60000;
-		rdc_flash_parts[4].size = 0x10;
-		rdc_flash_parts[5].name = "config";
-		rdc_flash_parts[5].offset = rdc_map_info.size - 0x5fff0;
-		rdc_flash_parts[5].size = 0xfff0;
-		rdc_flash_parts[6].name = "recoveryfs_parthdr";
-		rdc_flash_parts[6].offset = rdc_map_info.size - 0x50000;
-		rdc_flash_parts[6].size = 0x10;
-		rdc_flash_parts[7].name = "recoveryfs";
-		rdc_flash_parts[7].offset = rdc_map_info.size - 0x4fff0;
-		rdc_flash_parts[7].size = 0x3fff0;
-		rdc_flash_parts[8].name = "recovery_parthdr";
-		rdc_flash_parts[8].offset = rdc_map_info.size - 0x10000;
-		rdc_flash_parts[8].size = 0x10;
-		rdc_flash_parts[9].name = "recovery";
-		rdc_flash_parts[9].offset = rdc_map_info.size - 0xfff0;
-		rdc_flash_parts[9].size = 0x7ff0;
-		rdc_flash_parts[10].name = "productinfo_parthdr";
-		rdc_flash_parts[10].offset = rdc_map_info.size - 0x8000;
-		rdc_flash_parts[10].size = 0x10;
-		rdc_flash_parts[11].name = "productinfo";
-		rdc_flash_parts[11].offset = rdc_map_info.size - 0x7ff0;
-		rdc_flash_parts[11].size = 0x1ff0;
-		rdc_flash_parts[12].name = "bootloader_parthdr";
-		rdc_flash_parts[12].offset = rdc_map_info.size - 0x6000;
-		rdc_flash_parts[12].size = 0x10;
-		rdc_flash_parts[13].name = "bootloader";
-		rdc_flash_parts[13].offset = rdc_map_info.size - 0x5ff0;
-		rdc_flash_parts[13].size = 0x5ff0;
-		rdc_flash_parts[14].name = "everything";
-		rdc_flash_parts[14].offset = 0;
-		rdc_flash_parts[14].size = rdc_map_info.size;
-		rdc_flash_data.nr_parts = 15;
-	} else {	/* ZyXEL */
-		rdc_flash_parts[0].name = "kernel";
-		rdc_flash_parts[0].offset = 0;
-		rdc_flash_parts[0].size = 0x100000;
-		rdc_flash_parts[1].name = "rootfs";
-		rdc_flash_parts[1].offset = 0x100000;
-		rdc_flash_parts[1].size = rdc_map_info.size - 0x140000;
-		rdc_flash_parts[2].name = "linux";
-		rdc_flash_parts[2].offset = 0;
-		rdc_flash_parts[2].size = rdc_map_info.size - 0x40000;
-		rdc_flash_parts[3].name = "config";
-		rdc_flash_parts[3].offset = rdc_map_info.size - 0x40000;
-		rdc_flash_parts[3].size = 0x10000;
-		rdc_flash_parts[4].name = "productinfo";
-		rdc_flash_parts[4].offset = rdc_map_info.size - 0x30000;
-		rdc_flash_parts[4].size = 0x10000;
-		rdc_flash_parts[5].name = "bootloader";
-		rdc_flash_parts[5].offset = rdc_map_info.size - 0x20000;
-		rdc_flash_parts[5].size = 0x20000;
-		rdc_flash_data.nr_parts = 6;
+	
+	count = parse_mtd_partitions(mtdinfo, boards, &partitions, (unsigned long) &rdcplat_data);
+	
+	if (count <= 0) {
+		panic("RDC321x: can't identify board type");
+		return -ENOSYS;
 	}
-#endif
+	
+	ROOT_DEV = 0;
+	res = add_mtd_partitions(mtdinfo, partitions, count);
+	if (res)
+		return res;
+	
 	return platform_add_devices(rdc321x_devs, ARRAY_SIZE(rdc321x_devs));
+
 }
 
-#ifdef CONFIG_MTD_RDC3210
-arch_initcall(rdc_board_setup);
-#else
 late_initcall(rdc_board_setup);
-#endif
Index: target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/boards/r8610.c
===================================================================
--- target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/boards/r8610.c	(revision 0)
+++ target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/boards/r8610.c	(revision 0)
@@ -0,0 +1,65 @@
+/*
+ *  R8610 RDC321x platform devices
+ *
+ *  Copyright (C) 2009, Florian Fainelli 
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; either version 2
+ *  of the License, or (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the
+ *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA  02110-1301, USA.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/mtd/physmap.h>
+#include <linux/input.h>
+
+#include <asm/rdc_boards.h>
+
+static int __init parse_r8610_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long plat_data)
+{
+	struct mtd_partition *rdc_flash_parts;
+	
+	rdc_flash_parts = kzalloc(sizeof(struct mtd_partition) * 4, GFP_KERNEL);
+	
+	*pparts = rdc_flash_parts;
+	
+	rdc_flash_parts[0].name = "kernel";
+	rdc_flash_parts[0].size = 0x001f0000;
+	rdc_flash_parts[0].offset = 0;
+	rdc_flash_parts[1].name = "config";
+	rdc_flash_parts[1].size = 0x10000;
+	rdc_flash_parts[1].offset = MTDPART_OFS_APPEND;
+	rdc_flash_parts[2].name = "rootfs";
+	rdc_flash_parts[2].size = 0x1E0000; 
+	rdc_flash_parts[2].offset = MTDPART_OFS_APPEND;
+	rdc_flash_parts[3].name = "redboot";
+	rdc_flash_parts[3].size = 0x20000;
+	rdc_flash_parts[3].offset = MTDPART_OFS_APPEND;
+	rdc_flash_parts[3].mask_flags = MTD_WRITEABLE;
+
+	return 4;
+}
+
+struct mtd_part_parser __initdata r8610_parser = {
+	.owner = THIS_MODULE,
+	.parse_fn = parse_r8610_partitions,
+	.name = "R8610",
+};
+
+static int __init r8610_setup(void)
+{
+	return register_mtd_parser(&r8610_parser);
+}
+
+arch_initcall(r8610_setup);
Index: target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/boards/sitecom.c
===================================================================
--- target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/boards/sitecom.c	(revision 0)
+++ target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/boards/sitecom.c	(revision 0)
@@ -0,0 +1,111 @@
+/*
+ *  Sitecom RDC321x platform devices
+ *
+ *  Copyright (C) 2007-2009 OpenWrt.org
+ *  Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
+ *  Copyright (C) 2008-2009 Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; either version 2
+ *  of the License, or (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the
+ *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA  02110-1301, USA.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/mtd/physmap.h>
+#include <linux/input.h>
+
+#include <asm/rdc_boards.h>
+
+struct image_header {
+	char	magic[4];
+	u32	kernel_length;
+	u32	ramdisk_length;
+	char	magic2[4];
+	u32	kernel_length2;
+};
+
+static struct gpio_led sitecom_leds[] = {
+	{ .name = "rdc321x:power", .gpio = 15, .active_low = 1},
+	{ .name = "rdc321x:usb0", .gpio = 0, .active_low = 1},
+	{ .name = "rdc321x:usb1", .gpio = 1, .active_low = 1},
+};
+
+static struct gpio_button sitecom_btns[] = {
+	{
+		.gpio = 6,
+		.code = BTN_0,
+		.desc = "Reset",
+		.active_low = 1,
+	}
+};
+
+static int __init parse_sitecom_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long plat_data)
+{
+	struct image_header header;
+	int res;
+	size_t len;
+	struct mtd_partition *rdc_flash_parts;
+	struct rdc_platform_data *pdata = (struct rdc_platform_data *) plat_data;
+	
+	if (master->size != 0x400000) //4MB
+		return -ENOSYS;
+
+	res =  master->read(master, 0x8000, sizeof(header), &len, (char *)&header);
+	if (res)
+		return res;
+
+	if (strncmp(header.magic, "CSYS", 4) || strncmp(header.magic2, "WRRM", 4))
+		return -ENOSYS;
+	
+	rdc_flash_parts = kzalloc(sizeof(struct mtd_partition) * 5, GFP_KERNEL);
+	
+	rdc_flash_parts[0].name = "firmware";
+	rdc_flash_parts[0].offset = 0x8000;
+	rdc_flash_parts[0].size = 0x3F0000;
+	rdc_flash_parts[1].name = "config";
+	rdc_flash_parts[1].offset = 0;
+	rdc_flash_parts[1].size = 0x8000;
+	rdc_flash_parts[2].name = "kernel";
+	rdc_flash_parts[2].offset = 0x8014;
+	rdc_flash_parts[2].size = header.kernel_length;
+	rdc_flash_parts[3].name = "rootfs";
+	rdc_flash_parts[3].offset = 0x8014 + header.kernel_length;
+	rdc_flash_parts[3].size = 0x3F0000 - rdc_flash_parts[3].offset;
+	rdc_flash_parts[4].name = "bootloader";
+	rdc_flash_parts[4].offset = 0x3F0000;
+	rdc_flash_parts[4].size = 0x10000;
+
+	*pparts = rdc_flash_parts;
+	
+	pdata->led_data.num_leds = ARRAY_SIZE(sitecom_leds);
+	pdata->led_data.leds = sitecom_leds;
+	pdata->button_data.nbuttons = ARRAY_SIZE(sitecom_btns);
+	pdata->button_data.buttons = sitecom_btns;
+	
+	return 5;
+}
+
+struct mtd_part_parser __initdata sitecom_parser = {
+	.owner = THIS_MODULE,
+	.parse_fn = parse_sitecom_partitions,
+	.name = "Sitecom",
+};
+
+static int __init sitecom_setup(void)
+{
+	return register_mtd_parser(&sitecom_parser);
+}
+
+arch_initcall(sitecom_setup);
Index: target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/boards/ar525w.c
===================================================================
--- target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/boards/ar525w.c	(revision 0)
+++ target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/boards/ar525w.c	(revision 0)
@@ -0,0 +1,108 @@
+/*
+ * ar525w RDC321x platform devices
+ *
+ *  Copyright (C) 2007-2009 OpenWrt.org
+ *  Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
+ *  Copyright (C) 2008-2009 Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; either version 2
+ *  of the License, or (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the
+ *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA  02110-1301, USA.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/mtd/physmap.h>
+#include <linux/input.h>
+
+#include <asm/rdc_boards.h>
+
+struct image_header {
+	char magic[4];              /* ASICII: GMTK */
+	u32 checksum;               /* CRC32 */
+	u32 version;                /* x.x.x.x */
+	u32 kernelsz;               /* The size of the kernel image */
+	u32 imagesz;                /* The length of this image file ( kernel + romfs + this header) */
+	u32 pid;                    /* Product ID */
+	u32 fastcksum;              /* Partial CRC32 on (First(256), medium(256), last(512)) */
+	u32 reserved;
+};
+
+static struct gpio_led ar525w_leds[] = {
+	{ .name = "rdc321x:dmz", .gpio = 1, .active_low = 1},
+};
+static struct gpio_button ar525w_btns[] = {
+	{
+		.gpio = 6,
+		.code = BTN_0,
+		.desc = "Reset",
+		.active_low = 1,
+	}
+};
+
+static int __init parse_ar525w_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long plat_data)
+{
+	struct image_header header;
+	int res;
+	size_t len;
+	struct mtd_partition *rdc_flash_parts;
+	struct rdc_platform_data *pdata = (struct rdc_platform_data *) plat_data;
+	
+	if (master->size != 0x400000) //4MB
+		return -ENOSYS;
+
+	res =  master->read(master, 0x0, sizeof(header), &len, (char *)&header);
+	if (res)
+		return res;
+
+	if (strncmp(header.magic, "GMTK", 4))
+		return -ENOSYS;
+	
+	rdc_flash_parts = kzalloc(sizeof(struct mtd_partition) * 4, GFP_KERNEL);
+	
+	rdc_flash_parts[0].name = "firmware";
+	rdc_flash_parts[0].offset = 0x0;
+	rdc_flash_parts[0].size = 0x3E0000;
+	rdc_flash_parts[1].name = "kernel";
+	rdc_flash_parts[1].offset = sizeof(struct image_header);
+	rdc_flash_parts[1].size = header.kernelsz;
+	rdc_flash_parts[2].name = "rootfs";
+	rdc_flash_parts[2].offset = rdc_flash_parts[1].offset + rdc_flash_parts[1].size;
+	rdc_flash_parts[2].size = rdc_flash_parts[0].size - rdc_flash_parts[2].offset;
+	rdc_flash_parts[3].name = "bootloader";
+	rdc_flash_parts[3].offset = 0x3E0000;
+	rdc_flash_parts[3].size = 0x20000;
+
+	*pparts = rdc_flash_parts;
+	
+	pdata->led_data.num_leds = ARRAY_SIZE(ar525w_leds);
+	pdata->led_data.leds = ar525w_leds;
+	pdata->button_data.nbuttons = ARRAY_SIZE(ar525w_btns);
+	pdata->button_data.buttons = ar525w_btns;
+	
+	return 4;
+}
+
+static struct mtd_part_parser __initdata ar525w_parser = {
+	.owner = THIS_MODULE,
+	.parse_fn = parse_ar525w_partitions,
+	.name = "AR525W",
+};
+
+static int __init ar525w_setup(void)
+{
+	return register_mtd_parser(&ar525w_parser);
+}
+
+arch_initcall(ar525w_setup);
Index: target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/boards/bifferboard.c
===================================================================
--- target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/boards/bifferboard.c	(revision 0)
+++ target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/boards/bifferboard.c	(revision 0)
@@ -0,0 +1,82 @@
+/*
+ *  Bifferboard RDC321x platform devices
+ *
+ *  Copyright (C) 2010 bifferos@yahoo.co.uk 
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; either version 2
+ *  of the License, or (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the
+ *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA  02110-1301, USA.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/mtd/physmap.h>
+#include <linux/input.h>
+
+#include <asm/rdc_boards.h>
+
+static int __init parse_bifferboard_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long plat_data)
+{
+	int res;
+	size_t len;
+	struct mtd_partition *rdc_flash_parts;
+	u32 kernel_len;
+	u16 tmp;
+
+	if (master->size == 0x100000)
+		kernel_len = master->size - 0x10000;
+	else {
+		res =  master->read(master, 0x4000 + 1036, 2, &len, (char *) &tmp);
+		if (res)
+			return res;
+		kernel_len = tmp * master->erasesize;
+	}
+	
+	rdc_flash_parts = kzalloc(sizeof(struct mtd_partition) * 4, GFP_KERNEL);
+	
+	*pparts = rdc_flash_parts;
+
+	rdc_flash_parts[0].name = "biffboot";
+	rdc_flash_parts[0].offset = master->size - 0x10000;
+	rdc_flash_parts[0].size = 0x10000;
+	rdc_flash_parts[0].mask_flags = MTD_WRITEABLE;
+	rdc_flash_parts[1].name = "firmware";
+	rdc_flash_parts[1].offset = 0;
+	rdc_flash_parts[1].size = rdc_flash_parts[0].offset;
+	rdc_flash_parts[2].name = "kernel";
+	rdc_flash_parts[2].offset = 0x00000000;
+	rdc_flash_parts[2].size = kernel_len;
+	
+	if (master->size == 0x100000)
+		return 2;
+
+	rdc_flash_parts[3].name = "rootfs";
+	rdc_flash_parts[3].offset = MTDPART_OFS_APPEND;
+	rdc_flash_parts[3].size = rdc_flash_parts[1].size - rdc_flash_parts[2].size;
+
+	return 4;
+}
+
+struct mtd_part_parser __initdata bifferboard_parser = {
+	.owner = THIS_MODULE,
+	.parse_fn = parse_bifferboard_partitions,
+	.name = "Bifferboard",
+};
+
+static int __init bifferboard_setup(void)
+{
+	return register_mtd_parser(&bifferboard_parser);
+}
+
+arch_initcall(bifferboard_setup);
Index: target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/pci.c
===================================================================
--- target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/pci.c	(revision 19979)
+++ target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/pci.c	(working copy)
@@ -80,6 +80,8 @@
 		dev_err(&pdev->dev, "failed to register watchdog\n");
 		return err;
 	}
+	
+	panic_on_unrecovered_nmi = 1;
 
 	err = platform_device_register(&rdc321x_gpio_device);
 	if (err) {
Index: target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/Makefile
===================================================================
--- target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/Makefile	(revision 19979)
+++ target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/Makefile	(working copy)
@@ -1,5 +1,5 @@
 #
 # Makefile for the RDC321x specific parts of the kernel
 #
-obj-$(CONFIG_X86_RDC321X)        := gpio.o platform.o pci.o reboot.o
+obj-$(CONFIG_X86_RDC321X)        := gpio.o platform.o pci.o reboot.o boards/sitecom.o boards/ar525w.o boards/bifferboard.o boards/r8610.o
 
Index: target/linux/rdc/files-2.6.30/drivers/watchdog/rdc321x_wdt.c
===================================================================
--- target/linux/rdc/files-2.6.30/drivers/watchdog/rdc321x_wdt.c	(revision 19979)
+++ target/linux/rdc/files-2.6.30/drivers/watchdog/rdc321x_wdt.c	(working copy)
@@ -243,8 +243,7 @@
 		return err;
 	}
 
-	panic_on_unrecovered_nmi = 1;
-	dev_info(&pdev->dev, "watchdog inig success\n");
+	dev_info(&pdev->dev, "watchdog init success\n");
 
 	return 0;
 }
@@ -275,6 +274,9 @@
 
 static void __exit rdc321x_wdt_exit(void)
 {
+	while (timer_pending(&rdc321x_wdt_dev.timer))
+		msleep(100);
+	
 	platform_driver_unregister(&rdc321x_wdt_driver);
 }
 
Index: target/linux/rdc/bifferboard/config-2.6.30
===================================================================
--- target/linux/rdc/bifferboard/config-2.6.30	(revision 19979)
+++ target/linux/rdc/bifferboard/config-2.6.30	(working copy)
@@ -1,8 +0,0 @@
-CONFIG_CMDLINE="console=ttyS0,115200 rootfstype=squashfs,jffs2"
-# CONFIG_MTD_PHYSMAP is not set
-CONFIG_MTD_RDC3210_ALLOW_JFFS2=y
-CONFIG_MTD_RDC3210_BUSWIDTH=2
-# CONFIG_MTD_RDC3210_FACTORY_PRESENT is not set
-CONFIG_MTD_RDC3210_SIZE=0x800000
-# CONFIG_MTD_RDC3210_STATIC_MAP is not set
-CONFIG_MTD_RDC3210=y
Index: target/linux/rdc/Makefile
===================================================================
--- target/linux/rdc/Makefile	(revision 19979)
+++ target/linux/rdc/Makefile	(working copy)
@@ -11,7 +11,7 @@
 BOARDNAME:=RDC 321x
 FEATURES:=squashfs jffs2 pci usb pcmcia
 CFLAGS:=-Os -pipe -march=i486 -funit-at-a-time
-SUBTARGETS:=amit ar525w r8610 dir-450 sitecom bifferboard
+SUBTARGETS:=ar525w r8610 sitecom bifferboard
 
 LINUX_VERSION:=2.6.30.10
 
Index: scripts/pad_image
===================================================================
--- scripts/pad_image	(revision 0)
+++ scripts/pad_image	(revision 0)
@@ -0,0 +1,95 @@
+#!/bin/bash
+
+function usage {
+  echo "Usage: prepare_image image_type kernel_image rootfs_image header_size"
+  echo "Padd root and kernel image to the correct size and append the jffs2 start marker as needed"
+  exit 1
+}
+
+function pad_file {
+	echo "Padding $1 to size $2"
+	dd if=$1 of=$1.paddingtempfile bs=$2 count=1 conv=sync &> /dev/null
+	mv $1.paddingtempfile $1
+}
+
+#filesize filestart padding
+function calc_pad {
+	[  $((($1 + $2) & ($3 - 1))) == 0 ] && echo $1
+	echo $(((($1 + $2) | ($3 - 1)) + 1 - $2))
+}
+
+function prep_squash {
+	kernel_pad_size=$(calc_pad $kernel_size $header_size 32)
+	kernel_end=$(($header_size + $kernel_pad_size))
+	pad_file $kernel_image $kernel_pad_size
+
+	#4k
+	rootfs_pad_size=$(calc_pad $rootfs_size $kernel_end 4096)
+	pad_file $rootfs_image $rootfs_pad_size
+	echo -ne '\xde\xad\xc0\xde' >> $rootfs_image
+	
+	#8k
+	rootfs_pad_size=$(calc_pad $rootfs_size $kernel_end 8192)
+	[ $rootfs_pad_size == rootfs_old_padsize ] || {
+		pad_file $rootfs_image $rootfs_pad_size
+		rootfs_old_padsize=$rootfs_pad_size
+		echo -ne '\xde\xad\xc0\xde' >> $rootfs_image
+	}
+
+	#64k
+	rootfs_pad_size=$(calc_pad $rootfs_size $kernel_end 65536)
+	[ $rootfs_pad_size == rootfs_old_padsize ] || {
+		pad_file $rootfs_image $rootfs_pad_size
+		rootfs_old_padsize=$rootfs_pad_size
+		echo -ne '\xde\xad\xc0\xde' >> $rootfs_image
+	}
+
+	#128k
+	rootfs_pad_size=$(calc_pad $rootfs_size $kernel_end 131072)
+	[ $rootfs_pad_size == rootfs_old_padsize ] || {
+		pad_file $rootfs_image $rootfs_pad_size
+		rootfs_old_padsize=$rootfs_pad_size
+		echo -ne '\xde\xad\xc0\xde' >> $rootfs_image
+	}
+	
+}
+
+function prep_jffs2 {
+	kernel_pad_size=$(calc_pad $kernel_size $header_size $1)
+	pad_file $kernel_image $kernel_pad_size
+}
+
+image_type=$1
+kernel_image=$2
+rootfs_image=$3
+header_size=$4
+
+if [ -z "$image_type" ] || [ -z "$rootfs_image" ] || [ -z "$kernel_image" ] || [ -z "$header_size" ]; then
+	usage
+fi
+
+if [ ! -e "$rootfs_image" ] || [ -z "$kernel_image" ]; then
+	echo "input file not found"
+	exit 1
+fi
+
+kernel_size=$(stat -c "%s" "$kernel_image")
+rootfs_size=$(stat -c "%s" "$rootfs_image")
+
+if [ $kernel_size == 0 ] || [ $rootfs_size == 0 ]; then
+	echo "kernel or rootfs empty"
+	exit 1
+fi
+
+case $image_type in
+	squashfs )
+		prep_squash ;;
+	jffs2-64k )
+		prep_jffs2 65536 ;;
+	jffs2-128k )
+		prep_jffs2 131072 ;;
+	* )
+		echo "Unknown image type"
+		exit 1 ;;
+esac
+

Property changes on: scripts/pad_image
___________________________________________________________________
Added: svn:executable
   + *
