Index: files/arch/arm/mach-orion5x/dt2-setup.c
===================================================================
--- files/arch/arm/mach-orion5x/dt2-setup.c	(revision 17451)
+++ files/arch/arm/mach-orion5x/dt2-setup.c	(working copy)
@@ -19,6 +19,8 @@
 #include <linux/mv643xx_eth.h>
 #include <linux/ethtool.h>
 #include <linux/if_ether.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
 #include <net/dsa.h>
 #include <linux/ata_platform.h>
 #include <linux/i2c.h>
@@ -76,9 +78,10 @@
 
 static struct mtd_partition dt2_partitions[] = {
 	{
-		.name	= "u-boot",
-		.size	= 0x00080000,
-		.offset	= 0,
+		.name		= "U-Boot Config",
+		.offset		= 0x00000000,
+		/* only the first 4kB is used */
+		.size		= SZ_4K,
 	},
 };
 
@@ -122,12 +125,12 @@
 			set_irq_type(irq, IRQ_TYPE_LEVEL_LOW);
 			printk (KERN_INFO "PCI IntA IRQ: %d\n", irq);
 		} else {
-			printk(KERN_ERR "dt2_pci_preinit failed to "
-					"set_irq_type pin %d\n", pin);
+			printk(KERN_ERR "%s(%d): failed to "
+					"set_irq_type pin %d\n", __FUNCTION__, __LINE__, pin);
 			gpio_free(pin);
 		}
 	} else {
-		printk(KERN_ERR "dt2_pci_preinit failed to request gpio %d\n", pin);
+		printk(KERN_ERR "%s(%d): failed to gpio_request %d\n", __FUNCTION__, __LINE__, pin);
 	}
 
 	pin = DT2_PCI_SLOT0_IRQ_B_PIN;
@@ -137,12 +140,12 @@
 			set_irq_type(irq, IRQ_TYPE_LEVEL_LOW);
 			printk (KERN_INFO "PCI IntB IRQ: %d\n", irq);
 		} else {
-			printk(KERN_ERR "dt2_pci_preinit failed to "
-					"set_irq_type pin %d\n", pin);
+			printk(KERN_ERR "%s(%d): failed to "
+					"set_irq_type pin %d\n", __FUNCTION__, __LINE__, pin);
 			gpio_free(pin);
 		}
 	} else {
-		printk(KERN_ERR "dt2_pci_preinit failed to gpio_request %d\n", pin);
+		printk(KERN_ERR "%s(%d): failed to gpio_request %d\n", __FUNCTION__, __LINE__, pin);
 	}
 }
 
@@ -155,29 +158,21 @@
 	 */
 	irq = orion5x_pci_map_irq(dev, slot, pin);
 	if (irq != -1){
-		printk(KERN_INFO "orion5x_pci_map_irq: %d\n", irq);
+		printk(KERN_INFO "%s: %d\n",__FUNCTION__, irq);
 		return irq;
 	}
 
 	/*
-	 * PCI IRQs are connected via GPIOs
+	 * PCI IRQs are connected via GPIOs.
 	 */
 	switch (slot - DT2_PCI_SLOT0_OFFS) {
 	case 0:
-		if (pin == 1){
-			irq = gpio_to_irq(DT2_PCI_SLOT0_IRQ_A_PIN);
-			printk(KERN_INFO "dt2_pci_map_irq DT2_PCI_SLOT0_IRQ_A_PIN: %d\n", irq);
-		}
-		else {
-			irq = gpio_to_irq(DT2_PCI_SLOT0_IRQ_B_PIN);
-			printk(KERN_INFO "dt2_pci_map_irq DT2_PCI_SLOT0_IRQ_B_PIN: %d\n", irq);
-		}
+		return gpio_to_irq(DT2_PCI_SLOT0_IRQ_A_PIN);
+	case 1:
+		return gpio_to_irq(DT2_PCI_SLOT0_IRQ_B_PIN);
 	default:
-		irq = -1;
-			printk(KERN_INFO "dt2_pci_map_irq IRQ: %d\n", irq);
+		return -1;
 	}
-
-	return irq;
 }
 
 static struct hw_pci dt2_pci __initdata = {
@@ -292,6 +287,40 @@
 	return IRQ_HANDLED;
 }
 
+static int dt2_netdev_event(struct notifier_block *this,
+				unsigned long event, void *ptr)
+{
+	struct net_device *dev = ptr;
+	struct sockaddr mac;
+
+	if (event == NETDEV_REGISTER && strcmp(dev->name, dt2_switch_chip_data.port_names[0]) == 0) {
+		memcpy(mac.sa_data, dt2_eeprom.gw.mac_addr[1], 6);
+		if (is_valid_ether_addr(mac.sa_data)) {
+			mac.sa_family = dev->type;
+			/*
+			 * Setting individual MAC address for WAN port makes switch WAN port to
+			 * not function properly. (It is pingable from lan side, but not outside.) 
+			 * This not only in this code but also from  Opewrt /etc/config/network
+			 * Therefore until it is resolved, setting WAN MAC address is disabled.
+			 */
+			dev_set_mac_address(dev, &mac);
+			printk(KERN_INFO
+				"dt2: MAC address now set to %.2x:%.2x:%.2x:%.2x:%.2x:%.2x for port 1\n",
+				mac.sa_data[0], mac.sa_data[1], mac.sa_data[2],
+				mac.sa_data[3], mac.sa_data[4], mac.sa_data[5]);
+		}
+		else {
+			printk(KERN_ERR "dt2: No valid MAC address for port 1\n");
+		}
+	}
+
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block dt2_netdev_notifier = {
+	.notifier_call = dt2_netdev_event,
+};
+
 static void __init dt2_init(void)
 {
 	DECLARE_MAC_BUF(mac_buf);
@@ -305,7 +334,6 @@
 	/*
 	 * Configure peripherals.
 	 */
-
 	orion5x_uart0_init();
 	orion5x_ehci0_init();
 	orion5x_ehci1_init();
@@ -313,18 +341,16 @@
 	orion5x_sata_init(&dt2_sata_data);
 	orion5x_xor_init();
 
-	printk(KERN_INFO "U-Boot parameters:\n");
-	printk(KERN_INFO "Sys Clk = %d, Tclk = %d, BoardID = 0x%02x\n", mvSysclk, mvTclk, gBoardId);
+	printk(KERN_INFO "dt2: Serial: %s\n", dt2_eeprom.fc.dt2_serial_number);
+	printk(KERN_INFO "dt2: Revision: %016x\n", dt2_eeprom.fc.dt2_revision);
 
-	printk(KERN_INFO "Serial: %s\n", dt2_eeprom.fc.dt2_serial_number);
-	printk(KERN_INFO "Revision: %016x\n", dt2_eeprom.fc.dt2_revision);
-	printk(KERN_INFO "DT2: Using MAC address %s for port 0\n",
-	       print_mac(mac_buf, dt2_eeprom.gw.mac_addr[0]));
-	printk(KERN_INFO "DT2: Using MAC address %s for port 1\n",
-	       print_mac(mac_buf, dt2_eeprom.gw.mac_addr[1]));
+	register_netdevice_notifier(&dt2_netdev_notifier);
 
 	orion5x_eth_init(&dt2_eth_data);
 	memcpy(dt2_eth_data.mac_addr, dt2_eeprom.gw.mac_addr[0], 6);
+	printk(KERN_INFO "dt2: MAC address now set to %s for port 0\n",
+	       print_mac(mac_buf, dt2_eeprom.gw.mac_addr[0]));
+
 	orion5x_eth_switch_init(&dt2_switch_plat_data, NO_IRQ);
 
 	i2c_register_board_info(0, &dt2_i2c_rtc, 1);
@@ -337,18 +363,18 @@
 
 	if (request_irq(gpio_to_irq(DT2_PIN_GPIO_RESET), &dt2_reset_handler,
 			IRQF_DISABLED | IRQF_TRIGGER_LOW,
-			"DT2: Reset button", NULL) < 0) {
+			"Reset button", NULL) < 0) {
 
-		printk("DT2: Reset Button IRQ %d not available\n",
-			gpio_to_irq(DT2_PIN_GPIO_RESET));
+		printk(KERN_ERR "%s(%d): Reset Button IRQ %d not available\n",
+			__FUNCTION__, __LINE__, gpio_to_irq(DT2_PIN_GPIO_RESET));
 	}
 
 	if (request_irq(gpio_to_irq(DT2_PIN_GPIO_POWER), &dt2_power_handler,
 			IRQF_DISABLED | IRQF_TRIGGER_LOW,
-			"DT2: Power button", NULL) < 0) {
+			"Power button", NULL) < 0) {
 
-		printk(KERN_DEBUG "DT2: Power Button IRQ %d not available\n",
-			gpio_to_irq(DT2_PIN_GPIO_POWER));
+		printk(KERN_ERR "%s(%d): Power Button IRQ %d not available\n",
+			__FUNCTION__, __LINE__, gpio_to_irq(DT2_PIN_GPIO_POWER));
 	}
 }
 
@@ -394,8 +420,8 @@
 		/* Locate the Freecom cmdline */
 		if (t->hdr.tag == ATAG_CMDLINE) {
 			p = t->u.cmdline.cmdline;
-			printk("%s(%d): Found cmdline '%s' at 0x%0lx\n",
-			       __FUNCTION__, __LINE__, p, (unsigned long)p);
+			printk(KERN_INFO "Found Freecom cmdline '%s' at 0x%0lx\n",
+			       p, (unsigned long)p);
 		}
 		/*
 		 * Many orion-based systems have buggy bootloader implementations.
@@ -411,7 +437,7 @@
 		}
 	}
 
-	printk("%s(%d): End of table at 0x%0lx\n", __FUNCTION__, __LINE__, (unsigned long)t);
+	printk(KERN_INFO "End of table at 0x%0lx\n", (unsigned long)t);
 
 	/* Overwrite the end of the table with a new cmdline tag. */ 
 	t->hdr.tag = ATAG_CMDLINE;
@@ -423,13 +449,12 @@
 	strlcpy(t->u.cmdline.cmdline + strlen(p), openwrt_init_tag,
 		COMMAND_LINE_SIZE - strlen(p));
 
-	printk("%s(%d): New cmdline '%s' at 0x%0lx\n",
-	       __FUNCTION__, __LINE__,
+	printk(KERN_INFO "Set new OpenWrt cmdline '%s' at 0x%0lx\n",	       
 	       t->u.cmdline.cmdline, (unsigned long)t->u.cmdline.cmdline);
 
 	t = tag_next(t);
 
-	printk("%s(%d): New end of table at 0x%0lx\n", __FUNCTION__, __LINE__, (unsigned long)t);
+	printk(KERN_INFO "New end of table at 0x%0lx\n", (unsigned long)t);
 
 	t->hdr.tag = ATAG_NONE;
 	t->hdr.size = 0;
Index: harddisk/profiles/100-DT2.mk
===================================================================
--- harddisk/profiles/100-DT2.mk	(revision 0)
+++ harddisk/profiles/100-DT2.mk	(revision 0)
@@ -0,0 +1,20 @@
+#
+# Copyright (C) 2009 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Profile/DT2
+  NAME:=Freecom DT2
+  PACKAGES:= \
+	kmod-madwifi wireless-tools \
+	kmod-usb-core kmod-usb-uhci kmod-usb2 kmod-usb-storage \
+	kmod-fs-ext2 kmod-fs-ext3
+endef
+
+define Profile/DT2/Description
+	Package set optimized for the Freecom DT2
+endef
+$(eval $(call Profile,DT2))
+
Index: harddisk/config-default
===================================================================
--- harddisk/config-default	(revision 17451)
+++ harddisk/config-default	(working copy)
@@ -33,3 +33,6 @@
 CONFIG_EXT2_FS=y
 CONFIG_EXT3_FS=y
 CONFIG_JBD=y
+CONFIG_MTD_JEDECPROBE=y
+# CONFIG_MTD_IMPA7 is not set
+
Index: harddisk/base-files/lib/upgrade/platform.sh
===================================================================
--- harddisk/base-files/lib/upgrade/platform.sh	(revision 0)
+++ harddisk/base-files/lib/upgrade/platform.sh	(revision 0)
@@ -0,0 +1,58 @@
+RAMFS_COPY_BIN="/bin/gzip /bin/tar /bin/rm /usr/bin/bzip2 /usr/bin/cut /usr/bin/expr /usr/bin/uboot-dt2 /usr/bin/decodefw-dt2"
+platform_check_image() {
+	[ "$ARGC" -gt 1 ] && return 1
+
+	case "$(get_magic_word "$1")" in
+		4454) return 0;;
+		*)
+			echo "Invalid image type"
+			return 1
+		;;
+	esac
+}
+
+platform_do_upgrade() {
+	MTD_BIN=/tmp/mtd0.bin
+	UBOOT_CONFIG=/dev/mtd0
+
+	#mount new root partition
+	NEWROOTDEV=$(cat /proc/cmdline | cut -d" " -f2 | cut -d= -f2)
+	NEWROOTDEV=${NEWROOTDEV:7:1}
+	if  [ $NEWROOTDEV == 1 ]; then
+		NEWROOTDEV=0
+	else
+		NEWROOTDEV=1
+	fi
+	mount /dev/md$NEWROOTDEV /mnt
+
+	#extract firmware
+	rm -R /mnt/*		
+	decodefw-dt2 -s "$1"  -d /tmp/.update	
+	cd /mnt
+	tar -xj -f /tmp/.update
+	rm -f /tmp/.update
+	
+	dd if=$UBOOT_CONFIG of=$MTD_BIN
+	uboot-dt2 -s -w -d $MTD_BIN -n bootargs_root -x "root=/dev/md$NEWROOTDEV rw"
+	NEWROOTDEV=`expr $NEWROOTDEV + 1`
+	uboot-dt2 -s -w -d $MTD_BIN -n bootpartition -x $NEWROOTDEV
+	mtd -e $UBOOT_CONFIG write $MTD_BIN $UBOOT_CONFIG
+
+	#restore conffiles 
+	[ "$SAVE_CONFIG" -eq 1 ] && {
+		cd /mnt
+		v "Restoring config files..."
+		[ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
+		tar x${TAR_V}z -f "$CONF_TAR"
+	}
+	
+	return 0
+}
+
+platform_refresh_partitions() {
+	return 0
+}
+
+platform_copy_config() {
+	return 0
+}
Index: harddisk/base-files/etc/config/fstab
===================================================================
--- harddisk/base-files/etc/config/fstab	(revision 0)
+++ harddisk/base-files/etc/config/fstab	(revision 0)
@@ -0,0 +1,10 @@
+config mount
+	option target	/home
+	option device	/dev/md3
+	option fstype	ext3
+	option options	rw,sync
+	option enabled	1
+
+config swap
+	option device	/dev/md2
+	option enabled	1

Property changes on: harddisk/base-files/etc/config/fstab
___________________________________________________________________
Added: svn:executable
   + *

Index: harddisk/base-files/etc/diag.sh
===================================================================
--- harddisk/base-files/etc/diag.sh	(revision 0)
+++ harddisk/base-files/etc/diag.sh	(revision 0)
@@ -0,0 +1,15 @@
+#!/bin/sh
+# Copyright (C) 2009 OpenWrt.org
+
+set_state() {
+        case "$1" in
+                preinit)
+                ;;
+                done)
+                        [ -d /sys/class/leds/dt2:blue:satahw ] && {
+                                echo 1 > /sys/class/leds/dt2:blue:satahw/brightness
+                                echo 1 > /sys/class/leds/dt2:blue:power/brightness
+                        }
+                ;;
+        esac
+}
Index: harddisk/base-files/sbin/mount_root
===================================================================
--- harddisk/base-files/sbin/mount_root	(revision 0)
+++ harddisk/base-files/sbin/mount_root	(revision 0)
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Copyright (C) 2009 OpenWrt.org
+. /etc/functions.sh
+
+ROOTDEV=$(cat /proc/cmdline | cut -d" " -f2 | cut -d= -f2)
+
+mount -o remount,rw,noatime,nodiratime $ROOTDEV /

Property changes on: harddisk/base-files/sbin/mount_root
___________________________________________________________________
Added: svn:executable
   + *

Index: Makefile
===================================================================
--- Makefile	(revision 17451)
+++ Makefile	(working copy)
@@ -20,4 +20,15 @@
 
 DEFAULT_PACKAGES += kmod-ath9k hostapd-mini
 
+ifeq ($(CONFIG_TARGET_orion_harddisk_DT2),y)
+PATCH_DIR:=./patches-dt2
+define Kernel/Patch
+	#enable some busybox utilities disabled by default but needed for sysupdate
+	$(SED) 's,.*CONFIG_BUSYBOX_CONFIG_BZIP2.*,CONFIG_BUSYBOX_CONFIG_BZIP2=y,' \
+		-e 's,.*CONFIG_BUSYBOX_CONFIG_FEATURE_SEAMLESS_BZ2.*,CONFIG_BUSYBOX_CONFIG_FEATURE_SEAMLESS_BZ2=y,' \
+		$(TOPDIR)/.config
+	$(call Kernel/Patch/Default)
+endef
+endif
+
 $(eval $(call BuildTarget))
Index: patches-dt2/200-dt2_board_support.patch
===================================================================
--- patches-dt2/200-dt2_board_support.patch	(revision 0)
+++ patches-dt2/200-dt2_board_support.patch	(revision 0)
@@ -0,0 +1,23 @@
+--- a/arch/arm/mach-orion5x/Kconfig
++++ b/arch/arm/mach-orion5x/Kconfig
+@@ -16,6 +16,13 @@ config MACH_RD88F5182
+ 	  Say 'Y' here if you want your kernel to support the
+ 	  Marvell Orion-NAS (88F5182) RD2
+ 
++config MACH_DT2
++	bool "Freecom DataTank Gateway"
++	select I2C_BOARDINFO
++	help
++	  Say 'Y' here if you want your kernel to support the
++	  Freecom DataTank Gateway
++
+ config MACH_KUROBOX_PRO
+ 	bool "KuroBox Pro"
+ 	select I2C_BOARDINFO
+--- a/arch/arm/mach-orion5x/Makefile
++++ b/arch/arm/mach-orion5x/Makefile
+@@ -17,3 +17,4 @@ obj-$(CONFIG_MACH_WNR854T)	+= wnr854t-se
+ obj-$(CONFIG_MACH_RD88F5181L_GE)	+= rd88f5181l-ge-setup.o
+ obj-$(CONFIG_MACH_RD88F5181L_FXO)	+= rd88f5181l-fxo-setup.o
+ obj-$(CONFIG_MACH_RD88F6183AP_GE)	+= rd88f6183ap-ge-setup.o
++obj-$(CONFIG_MACH_DT2)		+= dt2-setup.o
