brcm63xx: enhance dt partitions support to match upstream more closely

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>
This commit is contained in:
Jonas Gorski 2017-06-26 19:01:20 +02:00
parent a41ad1b6f6
commit 85f31afa88

View File

@ -89,7 +89,7 @@
} }
} else { } else {
pr_warn("CFE boot tag CRC invalid (expected %08x, actual %08x)\n", 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; kernellen = 0;
rootfslen = 0; rootfslen = 0;
rootfsaddr = 0; rootfsaddr = 0;
@ -133,14 +133,18 @@
+ struct mtd_partition **pparts, + struct mtd_partition **pparts,
+ struct mtd_part_parser_data *data) + 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; + struct device_node *pp;
+ int i, nr_parts = 0; + int i, nr_parts = 0;
+ const char *partname; + const char *partname;
+ int len; + int len;
+ +
+ dp = of_get_child_by_name(mtd_node, "partitions");
+ if (!dp)
+ dp = mtd_node;
+
+ for_each_child_of_node(dp, pp) { + for_each_child_of_node(dp, pp) {
+ if (node_has_compatible(pp)) + if (node_has_compatible(pp) && dp == mtd_node)
+ continue; + continue;
+ +
+ if (!of_get_property(pp, "reg", &len)) + if (!of_get_property(pp, "reg", &len))
@ -150,7 +154,8 @@
+ if (!partname) + if (!partname)
+ partname = of_get_property(pp, "name", &len); + 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 += 2;
+ +
+ nr_parts++; + nr_parts++;
@ -166,7 +171,7 @@
+ int a_cells, s_cells; + int a_cells, s_cells;
+ size_t size, offset; + size_t size, offset;
+ +
+ if (node_has_compatible(pp)) + if (node_has_compatible(pp) && dp == mtd_node)
+ continue; + continue;
+ +
+ reg = of_get_property(pp, "reg", &len); + reg = of_get_property(pp, "reg", &len);
@ -181,7 +186,8 @@
+ if (!partname) + if (!partname)
+ partname = of_get_property(pp, "name", &len); + 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); + i += parse_bcmtag(master, *pparts, i, offset, size);
+ +
+ if (of_get_property(pp, "read-only", &len)) + if (of_get_property(pp, "read-only", &len))
@ -239,7 +245,7 @@
/* Start building partition list */ /* Start building partition list */
parts[curpart].name = "CFE"; 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; parts[curpart].size = cfelen;
curpart++; curpart++;
@ -270,7 +276,7 @@
parts[curpart].name = "nvram"; parts[curpart].name = "nvram";
parts[curpart].offset = master->size - nvramlen; 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 */ /* Global partition "linux" to make easy firmware upgrade */
parts[curpart].name = "linux"; parts[curpart].name = "linux";
@ -299,7 +305,11 @@
+ struct mtd_partition **pparts, + struct mtd_partition **pparts,
+ struct mtd_part_parser_data *data) + 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); + return bcm63xx_parse_cfe_partitions_of(master, pparts, data);
+ else + else
+ return bcm63xx_parse_cfe_partitions(master, pparts, data); + return bcm63xx_parse_cfe_partitions(master, pparts, data);