diff options
author | Mathias Kresin <dev@kresin.me> | 2020-12-27 10:26:37 +0100 |
---|---|---|
committer | Mathias Kresin <dev@kresin.me> | 2021-04-12 23:23:09 +0200 |
commit | e44e454ee65bb0631fbea64ea1e30b40735ed97b (patch) | |
tree | 6581a14c92f5732db1d42bbe649c65ccdd4a30ee /target/linux/lantiq/patches-5.10/0101-find_active_root.patch | |
parent | 276c85825c859f93d3f7ce501630af631e4d9e32 (diff) | |
download | upstream-e44e454ee65bb0631fbea64ea1e30b40735ed97b.tar.gz upstream-e44e454ee65bb0631fbea64ea1e30b40735ed97b.tar.bz2 upstream-e44e454ee65bb0631fbea64ea1e30b40735ed97b.zip |
lantiq: copy target to kernel 5.10
Duplicate kernel 5.4 config and patches for kernel 5.10.
Duplicate the devicetree source files as well, they need kernel 5.10
specific adjustments.
Signed-off-by: Mathias Kresin <dev@kresin.me>
Diffstat (limited to 'target/linux/lantiq/patches-5.10/0101-find_active_root.patch')
-rw-r--r-- | target/linux/lantiq/patches-5.10/0101-find_active_root.patch | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/target/linux/lantiq/patches-5.10/0101-find_active_root.patch b/target/linux/lantiq/patches-5.10/0101-find_active_root.patch new file mode 100644 index 0000000000..d541cc247c --- /dev/null +++ b/target/linux/lantiq/patches-5.10/0101-find_active_root.patch @@ -0,0 +1,93 @@ +--- a/drivers/mtd/parsers/ofpart_core.c ++++ b/drivers/mtd/parsers/ofpart_core.c +@@ -33,6 +33,38 @@ static bool node_has_compatible(struct d + return of_get_property(pp, "compatible", NULL); + } + ++static uint8_t * brnboot_get_selected_root_part(struct mtd_info *master, ++ loff_t offset) ++{ ++ static uint8_t root_id; ++ int err, len; ++ ++ err = mtd_read(master, offset, 0x01, &len, &root_id); ++ ++ if (mtd_is_bitflip(err) || !err) ++ return &root_id; ++ ++ return NULL; ++} ++ ++static void brnboot_set_active_root_part(struct mtd_partition *pparts, ++ struct device_node **part_nodes, ++ int nr_parts, ++ uint8_t *root_id) ++{ ++ int i; ++ ++ for (i = 0; i < nr_parts; i++) { ++ int part_root_id; ++ ++ if (!of_property_read_u32(part_nodes[i], "brnboot,root-id", &part_root_id) ++ && part_root_id == *root_id) { ++ pparts[i].name = "firmware"; ++ break; ++ } ++ } ++} ++ + static int parse_fixed_partitions(struct mtd_info *master, + const struct mtd_partition **pparts, + struct mtd_part_parser_data *data) +@@ -46,6 +78,8 @@ static int parse_fixed_partitions(struct + struct device_node *pp; + int nr_parts, i, ret = 0; + bool dedicated = true; ++ uint8_t *proot_id = NULL; ++ struct device_node **part_nodes; + + /* Pull of_node from the master device node */ + mtd_node = mtd_get_of_node(master); +@@ -86,7 +120,9 @@ static int parse_fixed_partitions(struct + return 0; + + parts = kcalloc(nr_parts, sizeof(*parts), GFP_KERNEL); +- if (!parts) ++ part_nodes = kcalloc(nr_parts, sizeof(*part_nodes), GFP_KERNEL); ++ ++ if (!parts || !part_nodes) + return -ENOMEM; + + i = 0; +@@ -135,6 +171,11 @@ static int parse_fixed_partitions(struct + if (of_get_property(pp, "lock", &len)) + parts[i].mask_flags |= MTD_POWERUP_LOCK; + ++ if (!proot_id && of_device_is_compatible(pp, "brnboot,root-selector")) ++ proot_id = brnboot_get_selected_root_part(master, parts[i].offset); ++ ++ part_nodes[i] = pp; ++ + i++; + } + +@@ -144,6 +185,11 @@ static int parse_fixed_partitions(struct + if (quirks && quirks->post_parse) + quirks->post_parse(master, parts, nr_parts); + ++ if (proot_id) ++ brnboot_set_active_root_part(parts, part_nodes, nr_parts, proot_id); ++ ++ kfree(part_nodes); ++ + *pparts = parts; + return nr_parts; + +@@ -154,6 +200,7 @@ ofpart_fail: + ofpart_none: + of_node_put(pp); + kfree(parts); ++ kfree(part_nodes); + return ret; + } + |