Add WL-700gE support (based on work by jr)
Add WL-700gE support (based on work by jr)
Includes kernel/diag patch and a new target profile


git-svn-id: svn://svn.openwrt.org/openwrt/trunk@6142 3c298f89-4303-0410-b956-a3cf2f4a3e73

--- a/include/kernel-build.mk
+++ b/include/kernel-build.mk
@@ -26,7 +26,7 @@
 FEATURES:=$(sort $(FEATURES))
 
 # For target profile selection - the default set
-DEFAULT_PACKAGES:=base-files libgcc uclibc bridge busybox dnsmasq dropbear iptables mtd ppp ppp-mod-pppoe mtd
+DEFAULT_PACKAGES:=base-files libgcc uclibc bridge busybox dnsmasq dropbear iptables mtd ppp ppp-mod-pppoe mtd kmod-ipt-nathelper
 
 ifeq ($(DUMP),1)
   all: dumpinfo

--- a/package/broadcom-diag/src/diag.c
+++ b/package/broadcom-diag/src/diag.c
@@ -63,6 +63,7 @@
 	WL500GD,
 	WL500GP,
 	ASUS_4702,
+	WL700GE,
 	
 	/* Buffalo */
 	WBR2_G54,
@@ -101,6 +102,20 @@
 	TEW411BRPP,
 };
 
+static void __init wl700ge_init(void) {
+		int pin = 1 << 3;
+
+		/* Enables GPIO 3 that controls HDD and led power on ASUS WL-700gE */
+		printk(MODULE_NAME ": Spinning up HDD and enabling leds\n");
+		gpio_outen(pin, pin);
+		gpio_control(pin, 0);
+		gpio_out(pin, pin);
+
+		/* Wait 5s, so the HDD can spin up */
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(HZ * 5);
+}
+
 static struct platform_t __initdata platforms[] = {
 	/* Linksys */
 	[WAP54GV1] = {
@@ -244,6 +259,25 @@
 			{ .name = "power",	.gpio = 1 << 0, .polarity = REVERSE },
 		},
 	},
+	[WL700GE] = {
+		.name		= "ASUS WL-700gE",
+		.buttons	= {
+			{ .name = "reset",	.gpio = 1 << 7 }, // on back, hardwired, always resets device regardless OS state
+			{ .name = "ses",	.gpio = 1 << 4 }, // on back, actual name ezsetup
+			{ .name = "power",	.gpio = 1 << 0 }, // on front
+			{ .name = "copy",	.gpio = 1 << 6 }, // on front
+		},
+		.leds		= {
+#if 0
+			// GPIO that controls power led also enables/disables some essential functions
+			// - power to HDD
+			// - switch leds
+			{ .name = "power",	.gpio = 1 << 3, .polarity = NORMAL },  // actual name power
+#endif
+			{ .name = "diag",	.gpio = 1 << 1, .polarity = REVERSE }, // actual name ready
+		},
+		.platform_init = wl700ge_init,
+	},
 	/* Buffalo */
 	[WHR_G54S] = {
 		.name		= "Buffalo WHR-G54S",
@@ -478,10 +512,14 @@
 
 	boardnum = getvar("boardnum");
 	boardtype = getvar("boardtype");
+
+	if (strncmp(getvar("model_no"), "WL700",5) == 0) {
+		return &platforms[WL700GE]; }
+
 	if (strncmp(getvar("pmon_ver"), "CFE", 3) == 0) {
 		/* CFE based - newer hardware */
 		if (!strcmp(boardnum, "42")) { /* Linksys */
-			if (!strcmp(boardtype, "0x478") && !strcmp(getvar("cardbus"), 1))
+			if (!strcmp(boardtype, "0x478") && !strcmp(getvar("cardbus"), "1"))
 				return &platforms[WRT350N];
 
 			if (!strcmp(boardtype, "0x0101") && !strcmp(getvar("boot_ver"), "v3.6"))
@@ -873,6 +911,9 @@
 	memcpy(&platform, detected, sizeof(struct platform_t));
 
 	printk(MODULE_NAME ": Detected '%s'\n", platform.name);
+	if (platform.platform_init != NULL) {
+		platform.platform_init();
+	}
 
 	if (!(diag = proc_mkdir("diag", NULL))) {
 		printk(MODULE_NAME ": proc_mkdir on /proc/diag failed\n");

--- a/package/broadcom-diag/src/diag.h
+++ b/package/broadcom-diag/src/diag.h
@@ -66,6 +66,7 @@
 	struct button_t buttons[MAX_GPIO];
 	u32 button_mask;
 	u32 button_polarity;
+	void (*platform_init)(void);
 
 	struct led_t leds[MAX_GPIO];
 };

--- a/package/kernel/modules/netfilter.mk
+++ b/package/kernel/modules/netfilter.mk
@@ -87,7 +87,6 @@
 
 define KernelPackage/ipt-nathelper
   TITLE:=Default Conntrack and NAT helpers
-  DEFAULT:=y
   DESCRIPTION:=\
 	Default Netfilter (IPv4) Conntrack and NAT helpers \\\
 	\\\

--- a/package/kernel/modules/other.mk
+++ b/package/kernel/modules/other.mk
@@ -64,6 +64,14 @@
 endef
 $(eval $(call KernelPackage,ide-pdc202xx))
 
+define KernelPackage/ide-aec62xx
+  TITLE:=AEC62xx IDE driver
+  SUBMENU:=$(EMENU)
+  KCONFIG:=$(CONFIG_BLK_DEV_AEC62XX)
+  FILES:=$(MODULES_DIR)/kernel/drivers/ide/pci/aec62xx.$(LINUX_KMOD_SUFFIX)
+  AUTOLOAD:=$(call AutoLoad,30,aec62xx)
+endef
+$(eval $(call KernelPackage,ide-aec62xx))
 
 define KernelPackage/lp
   TITLE:=Parallel port and line printer support

--- a/scripts/metadata.pl
+++ b/scripts/metadata.pl
@@ -297,8 +297,12 @@
 	bool "$profile->{name}"
 	depends LINUX_$target->{conf}
 EOF
+			my %pkgs;
 			foreach my $pkg (@{$target->{packages}}, @{$profile->{packages}}) {
-				print "\tselect DEFAULT_$pkg\n";
+				$pkgs{$pkg} = 1;
+			}
+			foreach my $pkg (keys %pkgs) {
+				print "\tselect DEFAULT_$pkg\n" unless ($pkg =~ /^-/ or $pkgs{"-$pkg"});
 			}
 			print "\n";
 		}

--- a/target/imagebuilder/files/Makefile
+++ b/target/imagebuilder/files/Makefile
@@ -87,6 +87,8 @@
 
 BUILD_PACKAGES:=$(sort $(DEFAULT_PACKAGES) $(PACKAGES) $($(PROFILE)_PACKAGES) kernel)
 BUILD_PACKAGES:=$(patsubst base-files,base-files-$(BOARD)-$(KERNEL),$(BUILD_PACKAGES))
+# "-pkgname" in the package list means remove "pkgname" from the package list
+BUILD_PACKAGES:=$(filter-out $(filter -%,$(BUILD_PACKAGES)) $(patsubst -%,%,$(filter -%,$(BUILD_PACKAGES))),$(BUILD_PACKAGES)
 
 image:
 	if [ -z "$($(PROFILE)_NAME)" ]; then \

--- a/target/linux/brcm-2.4/Makefile
+++ b/target/linux/brcm-2.4/Makefile
@@ -112,5 +112,16 @@
 endef
 $(eval $(call Profile,WLHDD))
 
+define Profile/WL700GE
+  NAME:=WL-700gE
+  PACKAGES:=-ppp -ppp-mod-pppoe -kmod-ipt-nathelper -iptables -dnsmasq -bridge kmod-ide-core kmod-ide-aec62xx kmod-fs-ext3 fdisk e2fsprogs
+endef
+
+define Profile/WL700GE/Description
+	Minimal package set optimized for booting the WL-700gE from flash with a writable filesystem
+	and the utilities to create a new filesystem on the HDD
+endef
+$(eval $(call Profile,WL700GE))
+
 $(eval $(call BuildKernel))
 

--- a/target/linux/brcm-2.4/base-files/etc/init.d/netconfig
+++ b/target/linux/brcm-2.4/base-files/etc/init.d/netconfig
@@ -101,6 +101,17 @@
 			c["wan_ifname"]=""
 		}
 	
+		# ASUS WL-700gE
+		# These are actually same as defaults above. For some reason this script applies
+		# Generic BCM94704 settings instead so we revert to proper settings here.	
+		# Hopefully someone will fix this properly soon.
+		if (model == "ASUS WL-700gE") {
+			c["lan_ifname"]="eth0.0"
+			c["wan_ifname"]="eth0.1"
+			c["vlan0ports"]="1 2 3 4 5*"
+			c["vlan1ports"]="0 5"
+		}
+		
 		print "#### VLAN configuration "
 		print "config switch eth0"
 		p("vlan0", "vlan0ports")

--- a/target/linux/brcm-2.4/config
+++ b/target/linux/brcm-2.4/config
@@ -598,7 +598,7 @@
 CONFIG_BLK_DEV_IDEDMA=y
 # CONFIG_IDEDMA_PCI_WIP is not set
 # CONFIG_BLK_DEV_ADMA100 is not set
-# CONFIG_BLK_DEV_AEC62XX is not set
+CONFIG_BLK_DEV_AEC62XX=m
 # CONFIG_BLK_DEV_ALI15X3 is not set
 # CONFIG_WDC_ALI15X3 is not set
 # CONFIG_BLK_DEV_AMD74XX is not set

--- /dev/null
+++ b/target/linux/brcm-2.4/patches/012-aec62xx.patch
@@ -1,1 +1,102 @@
+--- linux-2.4.34/drivers/ide/pci/aec62xx.c.old  2006-12-23 22:34:20.000000000 +0200
++++ linux-2.4.34/drivers/ide/pci/aec62xx.c      2007-01-14 12:06:05.000000000 +0200
+@@ -3,6 +3,8 @@
+  *
+  * Copyright (C) 1999-2002	Andre Hedrick <andre@linux-ide.org>
+  *
++ * With Broadcom 4780 patches
++ *
+  */
+ 
+ #include <linux/module.h>
+@@ -329,7 +331,11 @@
+ 	ide_hwif_t *hwif	= HWIF(drive);
+ 	struct hd_driveid *id	= drive->id;
+ 
+-	if ((id->capability & 1) && drive->autodma) {
++#ifndef CONFIG_BCM947XX
++	if ((id->capability & 1) && drive->autodma) {
++#else
++	if (1) {
++#endif
+ 		/* Consult the list of known "bad" drives */
+ 		if (hwif->ide_dma_bad_drive(drive))
+ 			goto fast_ata_pio;
+@@ -414,10 +416,60 @@
+ {
+ 	int bus_speed = system_bus_clock();
+ 
++#ifndef CONFIG_BCM947XX
+ 	if (dev->resource[PCI_ROM_RESOURCE].start) {
+ 		pci_write_config_dword(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
+ 		printk(KERN_INFO "%s: ROM enabled at 0x%08lx\n", name, dev->resource[PCI_ROM_RESOURCE].start);
+ 	}
++#else
++	if (dev->resource[PCI_ROM_RESOURCE].start) {
++		pci_write_config_dword(dev, PCI_ROM_ADDRESS,
++					dev->resource[PCI_ROM_RESOURCE].
++					start | PCI_ROM_ADDRESS_ENABLE);
++	} else {
++		pci_write_config_dword(dev, PCI_ROM_ADDRESS,
++					dev->resource[PCI_ROM_RESOURCE].
++					start);
++	}
++
++	/* Set IDE controller parameters manually - FIXME: replace magic values */
++	{
++		byte setting;
++
++		pci_write_config_word(dev, PCI_COMMAND, 0x0007);
++		//pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x5A);
++		pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x13);
++
++		pci_write_config_byte(dev, 0x40, 0x31);
++		pci_write_config_byte(dev, 0x41, 0x31);
++		pci_write_config_byte(dev, 0x42, 0x31);
++		pci_write_config_byte(dev, 0x43, 0x31);
++		// Set IDE Command Speed
++		pci_write_config_byte(dev, 0x48, 0x31);
++
++		// Disable WriteSubSysID & PIOROM
++		pci_read_config_byte(dev, 0x49, &setting);
++		setting &= 0x07;
++		pci_write_config_byte(dev, 0x49, setting);
++
++		// Enable PCI burst & INTA & PCI memory read multiple, FIFO threshold=80
++		pci_read_config_byte(dev, 0x4A, &setting);
++		//setting = (setting & 0xFE) | 0xA8;
++		setting = (setting & 0xFE) | 0xD8;
++		setting = (setting & 0xF7);
++		pci_write_config_byte(dev, 0x4A, setting);
++
++		//pci_write_config_byte(dev, 0x4B, 0x20);
++		pci_write_config_byte(dev, 0x4B, 0x2C);
++		//pci_write_config_byte(dev, 0x4B, 0x0C);
++
++		// Set PreRead count: 512 byte
++		pci_write_config_byte(dev, 0x4C, 0);
++		pci_write_config_word(dev, 0x4D, 0x0002);
++		pci_write_config_byte(dev, 0x54, 0);
++		pci_write_config_word(dev, 0x55, 0x0002);
++	}
++#endif
+ 
+ #if defined(DISPLAY_AEC62XX_TIMINGS) && defined(CONFIG_PROC_FS)
+ 	aec_devs[n_aec_devs++] = dev;
+@@ -500,6 +552,7 @@
+ 
+ static void __init init_setup_aec6x80 (struct pci_dev *dev, ide_pci_device_t *d)
+ {
++#ifndef CONFIG_BCM947XX /* Causes OOPS on BCM4780 */
+ 	unsigned long bar4reg = pci_resource_start(dev, 4);
+ 
+ 	if (inb(bar4reg+2) & 0x10) {
+@@ -512,6 +565,7 @@
+ 			strcpy(d->name, "AEC6280R");
+ 	}
+ 
++#endif
+ 	ide_setup_pci_device(dev, d);
+ }
+ 
 

comments