Hi everybody,

the attached patch, which is against the kernel 2.6.28.10 and not the whole
OpenWRT tree, adds platform detection for the WRT160NL.

It is a butt ugly hack but it's the only solution I found working since u-boot
does not provide any variables which help in detecting this router. I wanted
to avoid changing the kernel command line since this needs either a serial
port to access u-boot or a specially built kernel.

Throw this away if you find a better way to this.

More patches will come:
- WRT160NL Ethernet
- WRT160NL TRX MTD partition table parser

Best regards,
Christian

---
diff -ur linux-2.6.28.10-orig/arch/mips/ar71xx/prom.c 
linux-2.6.28.10/arch/mips/ar71xx/prom.c
--- linux-2.6.28.10-orig/arch/mips/ar71xx/prom.c        2009-07-16 
21:36:46.000000000 
+0200
+++ linux-2.6.28.10/arch/mips/ar71xx/prom.c     2009-07-21 00:24:13.889986244 
+0200
@@ -215,6 +215,23 @@
                ar71xx_parse_mac_addr(p);
 }
 
+static __init void ar71xx_try_detect_wrt160nl(void)
+{
+       char* ptr = ar71xx_prom_envp;
+       int i;
+
+       for(i = 0; i < 256 * 1024; i++) {
+               if(*ptr == 'W') {
+                       if(memcmp(ptr, "WRT160NL", 8) == 0) {
+                               printk("WRT160NL platform detected\n");
+                               ar71xx_mach = AR71XX_MACH_WRT160NL;
+                               return;
+                       }
+               }
+               ptr++;
+       }
+}
+
 void __init prom_init(void)
 {
        printk(KERN_DEBUG "prom: fw_arg0=%08x, fw_arg1=%08x, "
@@ -228,6 +245,9 @@
                return;
 
        ar71xx_prom_init_generic();
+
+       if(ar71xx_mach == AR71XX_MACH_GENERIC)
+               ar71xx_try_detect_wrt160nl();
 }
 
 void __init prom_free_prom_memory(void)

-- 
---------------------------------------------------
| maintech #      Dipl. Inf (FH) Christian Daniel |
|   GmbH ### Otto-Hahn-Str. 15 · D-97204 Höchberg |
---------------------------------------------------
| AG Würzburg, HRB 8790        Tax-ID DE242279645 |
---------------------------------------------------
| http://www.maintech.de           c...@maintech.de |
---------------------------------------------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to