brcm63xx: enhance dt partitions support to match upstream more closely
authorJonas Gorski <jonas.gorski@gmail.com>
Mon, 26 Jun 2017 17:01:20 +0000 (19:01 +0200)
committerJonas Gorski <jonas.gorski@gmail.com>
Sun, 11 Feb 2018 22:15:05 +0000 (23:15 +0100)
Partitions are supposed to be enclosed in an extra partitions node. Allow
the bcm63xxpart parser to cope with that.

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
target/linux/brcm63xx/patches-4.4/425-bcm63xxpart_parse_paritions_from_dt.patch

index d64d42c9dc01c5a8316bdec8c9564d34806e863a..ea73690d80c851e54d3a5e236403daacbf29e175 100644 (file)
@@ -89,7 +89,7 @@
                }
        } else {
                pr_warn("CFE boot tag CRC invalid (expected %08x, actual %08x)\n",
-@@ -119,23 +108,139 @@ static int bcm63xx_parse_cfe_partitions(
+@@ -119,23 +108,145 @@ static int bcm63xx_parse_cfe_partitions(
                kernellen = 0;
                rootfslen = 0;
                rootfsaddr = 0;
 +                                         struct mtd_partition **pparts,
 +                                         struct mtd_part_parser_data *data)
 +{
-+      struct device_node *dp = mtd_get_of_node(master);
++      struct device_node *dp, *mtd_node = mtd_get_of_node(master);
 +      struct device_node *pp;
 +      int i, nr_parts = 0;
 +      const char *partname;
 +      int len;
 +
++      dp = of_get_child_by_name(mtd_node, "partitions");
++      if (!dp)
++              dp = mtd_node;
++
 +      for_each_child_of_node(dp, pp) {
-+              if (node_has_compatible(pp))
++              if (node_has_compatible(pp) && dp == mtd_node)
 +                      continue;
 +
 +              if (!of_get_property(pp, "reg", &len))
 +              if (!partname)
 +                      partname = of_get_property(pp, "name", &len);
 +
-+              if (!strcmp(partname, "linux"))
++              if (!strcmp(partname, "linux") ||
++                  of_device_is_compatible(pp, "brcm,bcm963xx-imagetag"))
 +                      nr_parts += 2;
 +
 +              nr_parts++;
 +              int a_cells, s_cells;
 +              size_t size, offset;
 +
-+              if (node_has_compatible(pp))
++              if (node_has_compatible(pp) && dp == mtd_node)
 +                      continue;
 +
 +              reg = of_get_property(pp, "reg", &len);
 +              if (!partname)
 +                      partname = of_get_property(pp, "name", &len);
 +
-+              if (!strcmp(partname, "linux"))
++              if (!strcmp(partname, "linux") ||
++                  of_device_is_compatible(pp, "brcm,bcm963xx-imagetag"))
 +                      i += parse_bcmtag(master, *pparts, i, offset, size);
 +
 +              if (of_get_property(pp, "read-only", &len))
  
        /* Start building partition list */
        parts[curpart].name = "CFE";
-@@ -143,29 +248,7 @@ static int bcm63xx_parse_cfe_partitions(
+@@ -143,29 +254,7 @@ static int bcm63xx_parse_cfe_partitions(
        parts[curpart].size = cfelen;
        curpart++;
  
  
        parts[curpart].name = "nvram";
        parts[curpart].offset = master->size - nvramlen;
-@@ -174,25 +257,33 @@ static int bcm63xx_parse_cfe_partitions(
+@@ -174,25 +263,37 @@ static int bcm63xx_parse_cfe_partitions(
  
        /* Global partition "linux" to make easy firmware upgrade */
        parts[curpart].name = "linux";
 +                                  struct mtd_partition **pparts,
 +                                  struct mtd_part_parser_data *data)
 +{
-+      if (mtd_get_of_node(master) && of_get_child_count(mtd_get_of_node(master)))
++      struct device_node *np, *mtd_node = mtd_get_of_node(master);
++      np = of_get_child_by_name(mtd_node, "partitions");
++
++      if ((np && of_device_is_compatible(np, "fixed-partitions")) ||
++          (!np && of_get_child_count(mtd_node)))
 +              return bcm63xx_parse_cfe_partitions_of(master, pparts, data);
 +      else
 +              return bcm63xx_parse_cfe_partitions(master, pparts, data);