kernel: add GS110TPPV1 support to mtdsplit_uimage
[openwrt/staging/hauke.git] / target / linux / generic / files / drivers / mtd / mtdsplit / mtdsplit_uimage.c
index 525ad8218bd272930fc9015c6ba958ffc50670e0..57d8b9f420d769712493cd6579875cc7d8f52ec3 100644 (file)
@@ -258,6 +258,7 @@ static struct mtd_part_parser uimage_generic_parser = {
        .type = MTD_PARSER_TYPE_FIRMWARE,
 };
 
+#define FW_MAGIC_GS110TPPV1    0x4e474520
 #define FW_MAGIC_WNR2000V1     0x32303031
 #define FW_MAGIC_WNR2000V3     0x32303033
 #define FW_MAGIC_WNR2000V4     0x32303034
@@ -275,6 +276,10 @@ static ssize_t uimage_verify_wndr3700(u_char *buf, size_t len, int *extralen)
        uint8_t expected_type = IH_TYPE_FILESYSTEM;
 
        switch (be32_to_cpu(header->ih_magic)) {
+       case FW_MAGIC_GS110TPPV1:
+       case FW_MAGIC_WNR2000V4:
+               expected_type = IH_TYPE_KERNEL;
+               break;
        case FW_MAGIC_WNR612V2:
        case FW_MAGIC_WNR1000V2:
        case FW_MAGIC_WNR1000V2_VC:
@@ -285,9 +290,6 @@ static ssize_t uimage_verify_wndr3700(u_char *buf, size_t len, int *extralen)
        case FW_MAGIC_WNDR3700V2:
        case FW_MAGIC_WPN824N:
                break;
-       case FW_MAGIC_WNR2000V4:
-               expected_type = IH_TYPE_KERNEL;
-               break;
        default:
                return -EINVAL;
        }
@@ -319,8 +321,57 @@ static struct mtd_part_parser uimage_netgear_parser = {
        .of_match_table = mtdsplit_uimage_netgear_of_match_table,
        .parse_fn = mtdsplit_uimage_parse_netgear,
        .type = MTD_PARSER_TYPE_FIRMWARE,
+
 };
 
+
+/**************************************************
+ * ALLNET
+ **************************************************/
+
+#define FW_MAGIC_SG8208M       0x00000006
+#define FW_MAGIC_SG8310PM      0x83000006
+
+static ssize_t uimage_verify_allnet(u_char *buf, size_t len, int *extralen)
+{
+       struct uimage_header *header = (struct uimage_header *)buf;
+
+       switch (be32_to_cpu(header->ih_magic)) {
+       case FW_MAGIC_SG8208M:
+       case FW_MAGIC_SG8310PM:
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       if (header->ih_os != IH_OS_LINUX)
+               return -EINVAL;
+
+       return 0;
+}
+
+static int
+mtdsplit_uimage_parse_allnet(struct mtd_info *master,
+                             const struct mtd_partition **pparts,
+                             struct mtd_part_parser_data *data)
+{
+       return __mtdsplit_parse_uimage(master, pparts, data,
+                                     uimage_verify_allnet);
+}
+
+static const struct of_device_id mtdsplit_uimage_allnet_of_match_table[] = {
+       { .compatible = "allnet,uimage" },
+       {},
+};
+
+static struct mtd_part_parser uimage_allnet_parser = {
+       .owner = THIS_MODULE,
+       .name = "allnet-fw",
+       .of_match_table = mtdsplit_uimage_allnet_of_match_table,
+       .parse_fn = mtdsplit_uimage_parse_allnet,
+};
+
+
 /**************************************************
  * Edimax
  **************************************************/
@@ -407,6 +458,43 @@ static struct mtd_part_parser uimage_fonfxc_parser = {
        .parse_fn = mtdsplit_uimage_parse_fonfxc,
 };
 
+/**************************************************
+ * SGE (T&W) Shenzhen Gongjin Electronics
+ **************************************************/
+
+#define SGE_PAD_LEN            96
+
+static ssize_t uimage_find_sge(u_char *buf, size_t len, int *extralen)
+{
+       if (uimage_verify_default(buf, len, extralen) < 0)
+               return -EINVAL;
+
+       *extralen = SGE_PAD_LEN;
+
+       return 0;
+}
+
+static int
+mtdsplit_uimage_parse_sge(struct mtd_info *master,
+                             const struct mtd_partition **pparts,
+                             struct mtd_part_parser_data *data)
+{
+       return __mtdsplit_parse_uimage(master, pparts, data,
+                                      uimage_find_sge);
+}
+
+static const struct of_device_id mtdsplit_uimage_sge_of_match_table[] = {
+       { .compatible = "sge,uimage" },
+       {},
+};
+
+static struct mtd_part_parser uimage_sge_parser = {
+       .owner = THIS_MODULE,
+       .name = "sge-fw",
+       .of_match_table = mtdsplit_uimage_sge_of_match_table,
+       .parse_fn = mtdsplit_uimage_parse_sge,
+};
+
 /**************************************************
  * OKLI (OpenWrt Kernel Loader Image)
  **************************************************/
@@ -468,8 +556,10 @@ static int __init mtdsplit_uimage_init(void)
 {
        register_mtd_parser(&uimage_generic_parser);
        register_mtd_parser(&uimage_netgear_parser);
+       register_mtd_parser(&uimage_allnet_parser);
        register_mtd_parser(&uimage_edimax_parser);
        register_mtd_parser(&uimage_fonfxc_parser);
+       register_mtd_parser(&uimage_sge_parser);
        register_mtd_parser(&uimage_okli_parser);
 
        return 0;