ar71xx: add RouterBoot related helper routines
authorGabor Juhos <juhosg@openwrt.org>
Sun, 9 Sep 2012 14:05:28 +0000 (14:05 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Sun, 9 Sep 2012 14:05:28 +0000 (14:05 +0000)
SVN-Revision: 33347

target/linux/ar71xx/config-3.3
target/linux/ar71xx/files/arch/mips/ath79/routerboot.c [new file with mode: 0644]
target/linux/ar71xx/files/arch/mips/ath79/routerboot.h [new file with mode: 0644]
target/linux/ar71xx/patches-3.3/602-MIPS-ath79-add-openwrt-stuff.patch
target/linux/ar71xx/patches-3.3/610-MIPS-ath79-openwrt-machines.patch
target/linux/ar71xx/patches-3.3/611-TEW-712BR-support.patch
target/linux/ar71xx/patches-3.3/612-ALL0315N-support.patch
target/linux/ar71xx/patches-3.3/613-RB2011-support.patch

index a13fded6e382914bfa74110f082009f38f2f5306..fd113addd1e7e2e4100e718acadc908dd9010cae 100644 (file)
@@ -83,6 +83,7 @@ CONFIG_ATH79_MACH_WZR_HP_G450H=y
 CONFIG_ATH79_MACH_ZCN_1523H=y
 CONFIG_ATH79_NVRAM=y
 CONFIG_ATH79_PCI_ATH9K_FIXUP=y
 CONFIG_ATH79_MACH_ZCN_1523H=y
 CONFIG_ATH79_NVRAM=y
 CONFIG_ATH79_PCI_ATH9K_FIXUP=y
+# CONFIG_ATH79_ROUTERBOOT is not set
 # CONFIG_ATH79_WDT is not set
 CONFIG_BCMA_POSSIBLE=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 # CONFIG_ATH79_WDT is not set
 CONFIG_BCMA_POSSIBLE=y
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/routerboot.c b/target/linux/ar71xx/files/arch/mips/ath79/routerboot.c
new file mode 100644 (file)
index 0000000..3c6f9aa
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ *  RouterBoot helper routines
+ *
+ *  Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/routerboot.h>
+
+#include "routerboot.h"
+
+static u32 get_u32(void *buf)
+{
+       u8 *p = buf;
+
+       return ((u32) p[3] + ((u32) p[2] << 8) + ((u32) p[1] << 16) +
+              ((u32) p[0] << 24));
+}
+
+static u16 get_u16(void *buf)
+{
+       u8 *p = buf;
+
+       return (u16) p[1] + ((u16) p[0] << 8);
+}
+
+__init int
+routerboot_find_tag(u8 *buf, unsigned int buflen, u16 tag_id,
+                   u8 **tag_data, u16 *tag_len)
+{
+       uint32_t magic;
+       int ret;
+
+       if (buflen < 4)
+               return -EINVAL;
+
+       magic = get_u32(buf);
+       switch (magic) {
+       case RB_MAGIC_HARD:
+               /* skip magic value */
+               buf += 4;
+               buflen -= 4;
+               break;
+
+       case RB_MAGIC_SOFT:
+               if (buflen < 8)
+                       return -EINVAL;
+
+               /* skip magic and CRC value */
+               buf += 8;
+               buflen -= 8;
+
+               break;
+
+       default:
+               return -EINVAL;
+       }
+
+       ret = -ENOENT;
+       while (buflen > 2) {
+               u16 id;
+               u16 len;
+
+               len = get_u16(buf);
+               buf += 2;
+               buflen -= 2;
+
+               if (buflen < 2)
+                       break;
+
+               id = get_u16(buf);
+               buf += 2;
+               buflen -= 2;
+
+               if (id == RB_ID_TERMINATOR)
+                       break;
+
+               if (buflen < len)
+                       break;
+
+               if (id == tag_id) {
+                       if (tag_len)
+                               *tag_len = len;
+                       if (tag_data)
+                               *tag_data = buf;
+                       ret = 0;
+                       break;
+               }
+
+               buf += len;
+               buflen -= len;
+       }
+
+       return ret;
+}
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/routerboot.h b/target/linux/ar71xx/files/arch/mips/ath79/routerboot.h
new file mode 100644 (file)
index 0000000..9a4dde5
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ *  RouterBoot definitions
+ *
+ *  Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#ifndef _ATH79_ROUTERBOOT_H_
+#define _ATH79_ROUTERBOOT_H_
+
+#ifdef CONFIG_ATH79_ROUTERBOOT
+int routerboot_find_tag(u8 *buf, unsigned int buflen, u16 tag_id,
+                       u8 **tag_data, u16 *tag_len);
+#else
+static inline int
+routerboot_find_tag(u8 *buf, unsigned int buflen, u16 tag_id,
+                   u8 **tag_data, u16 *tag_len)
+{
+       return -ENOENT;
+}
+#endif
+
+#endif /* _ATH79_ROUTERBOOT_H_ */
index 85256e77eed8980dc9c532b594c10e3a7deb36cc..3c96819df454ba64629051613c6c73d0eb3f8931 100644 (file)
@@ -21,7 +21,7 @@
  config PCI_AR724X
        def_bool n
  
  config PCI_AR724X
        def_bool n
  
-@@ -125,4 +139,10 @@ config ATH79_DEV_WMAC
+@@ -125,4 +139,13 @@ config ATH79_DEV_WMAC
        depends on (SOC_AR913X || SOC_AR933X || SOC_AR934X || SOC_QCA955X)
        def_bool n
  
        depends on (SOC_AR913X || SOC_AR933X || SOC_AR934X || SOC_QCA955X)
        def_bool n
  
 +
 +config ATH79_PCI_ATH9K_FIXUP
 +      def_bool n
 +
 +config ATH79_PCI_ATH9K_FIXUP
 +      def_bool n
++
++config ATH79_ROUTERBOOT
++      def_bool n
 +
  endif
 --- a/arch/mips/ath79/Makefile
 +++ b/arch/mips/ath79/Makefile
 +
  endif
 --- a/arch/mips/ath79/Makefile
 +++ b/arch/mips/ath79/Makefile
-@@ -17,13 +17,23 @@ obj-$(CONFIG_PCI)                  += pci.o
+@@ -17,13 +17,24 @@ obj-$(CONFIG_PCI)                  += pci.o
  # Devices
  #
  obj-y                                 += dev-common.o
  # Devices
  #
  obj-y                                 += dev-common.o
@@ -53,6 +56,7 @@
 +#
 +obj-$(CONFIG_ATH79_NVRAM)             += nvram.o
 +obj-$(CONFIG_ATH79_PCI_ATH9K_FIXUP)   += pci-ath9k-fixup.o
 +#
 +obj-$(CONFIG_ATH79_NVRAM)             += nvram.o
 +obj-$(CONFIG_ATH79_PCI_ATH9K_FIXUP)   += pci-ath9k-fixup.o
++obj-$(CONFIG_ATH79_ROUTERBOOT)                += routerboot.o
 +
 +#
  # Machines
 +
 +#
  # Machines
index 0efdee15afae0ed0558006441d357647cb85aa17..97e957f2dcaac4d79a7a39444796f7839b98ac4e 100644 (file)
        def_bool n
  
  config ATH79_DEV_GPIO_BUTTONS
        def_bool n
  
  config ATH79_DEV_GPIO_BUTTONS
-@@ -153,4 +667,7 @@ config ATH79_NVRAM
- config ATH79_PCI_ATH9K_FIXUP
+@@ -156,4 +670,7 @@ config ATH79_PCI_ATH9K_FIXUP
+ config ATH79_ROUTERBOOT
        def_bool n
  
 +config PCI_AR724X
        def_bool n
  
 +config PCI_AR724X
  endif
 --- a/arch/mips/ath79/Makefile
 +++ b/arch/mips/ath79/Makefile
  endif
 --- a/arch/mips/ath79/Makefile
 +++ b/arch/mips/ath79/Makefile
-@@ -36,9 +36,62 @@ obj-$(CONFIG_ATH79_PCI_ATH9K_FIXUP) += p
+@@ -37,9 +37,62 @@ obj-$(CONFIG_ATH79_ROUTERBOOT)              += route
  #
  # Machines
  #
  #
  # Machines
  #
index 94a056aa51e6f573363613381aa9c1874968a32c..b8c227e4ca4d4fc192e836419b04e5e52e445da3 100644 (file)
@@ -19,7 +19,7 @@
        select SOC_AR71XX
 --- a/arch/mips/ath79/Makefile
 +++ b/arch/mips/ath79/Makefile
        select SOC_AR71XX
 --- a/arch/mips/ath79/Makefile
 +++ b/arch/mips/ath79/Makefile
-@@ -67,6 +67,7 @@ obj-$(CONFIG_ATH79_MACH_RB750)               += mach-
+@@ -68,6 +68,7 @@ obj-$(CONFIG_ATH79_MACH_RB750)               += mach-
  obj-$(CONFIG_ATH79_MACH_RW2458N)      += mach-rw2458n.o
  obj-$(CONFIG_ATH79_MACH_TEW_632BRP)   += mach-tew-632brp.o
  obj-$(CONFIG_ATH79_MACH_TEW_673GRU)   += mach-tew-673gru.o
  obj-$(CONFIG_ATH79_MACH_RW2458N)      += mach-rw2458n.o
  obj-$(CONFIG_ATH79_MACH_TEW_632BRP)   += mach-tew-632brp.o
  obj-$(CONFIG_ATH79_MACH_TEW_673GRU)   += mach-tew-673gru.o
index bc4e6695e812f0c64a2dc20794bc318ba57767b1..fafb1124001dc66fb0363b655431d91ed789e3b1 100644 (file)
@@ -18,7 +18,7 @@
        select SOC_AR724X
 --- a/arch/mips/ath79/Makefile
 +++ b/arch/mips/ath79/Makefile
        select SOC_AR724X
 --- a/arch/mips/ath79/Makefile
 +++ b/arch/mips/ath79/Makefile
-@@ -39,6 +39,7 @@ obj-$(CONFIG_ATH79_PCI_ATH9K_FIXUP)  += p
+@@ -40,6 +40,7 @@ obj-$(CONFIG_ATH79_ROUTERBOOT)               += route
  obj-$(CONFIG_ATH79_MACH_ALFA_AP96)    += mach-alfa-ap96.o
  obj-$(CONFIG_ATH79_MACH_ALFA_NX)      += mach-alfa-nx.o
  obj-$(CONFIG_ATH79_MACH_ALL0258N)     += mach-all0258n.o
  obj-$(CONFIG_ATH79_MACH_ALFA_AP96)    += mach-alfa-ap96.o
  obj-$(CONFIG_ATH79_MACH_ALFA_NX)      += mach-alfa-nx.o
  obj-$(CONFIG_ATH79_MACH_ALL0258N)     += mach-all0258n.o
index ee16710306f1cf2cf52ab1241936a91ff78fb670..6622b4d96e285f91e906c1075e34a1b9483d1475 100644 (file)
@@ -1,8 +1,8 @@
 --- a/arch/mips/ath79/Kconfig
 +++ b/arch/mips/ath79/Kconfig
 --- a/arch/mips/ath79/Kconfig
 +++ b/arch/mips/ath79/Kconfig
-@@ -333,6 +333,11 @@ config ATH79_MACH_RB750
-       select ATH79_DEV_AP9X_PCI if PCI
+@@ -334,6 +334,11 @@ config ATH79_MACH_RB750
        select ATH79_DEV_USB
        select ATH79_DEV_USB
+       select RLE_DECOMPRESS
  
 +config ATH79_MACH_RB2011
 +      bool "MikroTik RouterBOARD 2011 support"
  
 +config ATH79_MACH_RB2011
 +      bool "MikroTik RouterBOARD 2011 support"
        ATH79_MACH_RW2458N,             /* Redwave RW2458N */
        ATH79_MACH_TEW_632BRP,          /* TRENDnet TEW-632BRP */
        ATH79_MACH_TEW_673GRU,          /* TRENDnet TEW-673GRU */
        ATH79_MACH_RW2458N,             /* Redwave RW2458N */
        ATH79_MACH_TEW_632BRP,          /* TRENDnet TEW-632BRP */
        ATH79_MACH_TEW_673GRU,          /* TRENDnet TEW-673GRU */
-Index: linux-3.3.8/arch/mips/ath79/Makefile
-===================================================================
---- linux-3.3.8.orig/arch/mips/ath79/Makefile
-+++ linux-3.3.8/arch/mips/ath79/Makefile
-@@ -65,6 +65,7 @@ obj-$(CONFIG_ATH79_MACH_PB44)                += mach-p
+--- a/arch/mips/ath79/Makefile
++++ b/arch/mips/ath79/Makefile
+@@ -66,6 +66,7 @@ obj-$(CONFIG_ATH79_MACH_PB44)                += mach-p
  obj-$(CONFIG_ATH79_MACH_PB92)         += mach-pb92.o
  obj-$(CONFIG_ATH79_MACH_RB4XX)                += mach-rb4xx.o
  obj-$(CONFIG_ATH79_MACH_RB750)                += mach-rb750.o
  obj-$(CONFIG_ATH79_MACH_PB92)         += mach-pb92.o
  obj-$(CONFIG_ATH79_MACH_RB4XX)                += mach-rb4xx.o
  obj-$(CONFIG_ATH79_MACH_RB750)                += mach-rb750.o
@@ -34,10 +32,8 @@ Index: linux-3.3.8/arch/mips/ath79/Makefile
  obj-$(CONFIG_ATH79_MACH_RW2458N)      += mach-rw2458n.o
  obj-$(CONFIG_ATH79_MACH_TEW_632BRP)   += mach-tew-632brp.o
  obj-$(CONFIG_ATH79_MACH_TEW_673GRU)   += mach-tew-673gru.o
  obj-$(CONFIG_ATH79_MACH_RW2458N)      += mach-rw2458n.o
  obj-$(CONFIG_ATH79_MACH_TEW_632BRP)   += mach-tew-632brp.o
  obj-$(CONFIG_ATH79_MACH_TEW_673GRU)   += mach-tew-673gru.o
-Index: linux-3.3.8/arch/mips/ath79/prom.c
-===================================================================
---- linux-3.3.8.orig/arch/mips/ath79/prom.c
-+++ linux-3.3.8/arch/mips/ath79/prom.c
+--- a/arch/mips/ath79/prom.c
++++ b/arch/mips/ath79/prom.c
 @@ -181,7 +181,8 @@ void __init prom_init(void)
                }
        }
 @@ -181,7 +181,8 @@ void __init prom_init(void)
                }
        }