From: INAGAKI Hiroshi Date: Sat, 12 Feb 2022 04:09:23 +0000 (+0900) Subject: kernel: move parser_trx patches of custom magic to generic X-Git-Tag: v22.03.0-rc1~246 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=cc49abc06bca59911caf5b904c3181814636e4da;p=openwrt%2Fstaging%2Fhauke.git kernel: move parser_trx patches of custom magic to generic This patch moves the patches of parser_trx in mediatek target to generic/backport-5.10 to use the changes from ramips target and backport the additional patch of the parser. Signed-off-by: INAGAKI Hiroshi --- diff --git a/target/linux/generic/backport-5.10/409-v5.14-0001-dt-bindings-mtd-brcm-trx-Add-brcm-trx-magic.patch b/target/linux/generic/backport-5.10/409-v5.14-0001-dt-bindings-mtd-brcm-trx-Add-brcm-trx-magic.patch new file mode 100644 index 0000000000..1f34652141 --- /dev/null +++ b/target/linux/generic/backport-5.10/409-v5.14-0001-dt-bindings-mtd-brcm-trx-Add-brcm-trx-magic.patch @@ -0,0 +1,32 @@ +From a4d82940ff85a7e307953dfa715f65d5ab487e10 Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Sun, 18 Apr 2021 23:46:14 +0200 +Subject: dt-bindings: mtd: brcm,trx: Add brcm,trx-magic + +This adds the description of an additional property which allows to +specify a custom partition parser magic to detect a trx partition. +Buffalo has multiple device which are using the trx format, but with +different magic values. + +Signed-off-by: Hauke Mehrtens +Acked-by: Rob Herring +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20210418214616.239574-2-hauke@hauke-m.de +--- + .../devicetree/bindings/mtd/partitions/brcm,trx.txt | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt ++++ b/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt +@@ -28,6 +28,11 @@ detected by a software parsing TRX heade + Required properties: + - compatible : (required) must be "brcm,trx" + ++Optional properties: ++ ++- brcm,trx-magic: TRX magic, if it is different from the default magic ++ 0x30524448 as a u32. ++ + Example: + + flash@0 { diff --git a/target/linux/generic/backport-5.10/409-v5.14-0002-mtd-parsers-trx-Allow-to-specify-brcm-trx-magic-in-D.patch b/target/linux/generic/backport-5.10/409-v5.14-0002-mtd-parsers-trx-Allow-to-specify-brcm-trx-magic-in-D.patch new file mode 100644 index 0000000000..de2d914852 --- /dev/null +++ b/target/linux/generic/backport-5.10/409-v5.14-0002-mtd-parsers-trx-Allow-to-specify-brcm-trx-magic-in-D.patch @@ -0,0 +1,50 @@ +From d7f7e04f8b67571a4bf5a0dcd4f9da4214f5262c Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Sun, 18 Apr 2021 23:46:15 +0200 +Subject: mtd: parsers: trx: Allow to specify brcm, trx-magic in DT + +Buffalo uses a different TRX magic for every device, to be able to use +this trx parser, make it possible to specify the TRX magic in device +tree. If no TRX magic is specified in device tree, the standard value +will be used. This value should only be specified if a vendor chooses to +use a non standard TRX magic. + +Signed-off-by: Hauke Mehrtens +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20210418214616.239574-3-hauke@hauke-m.de +--- + drivers/mtd/parsers/parser_trx.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +--- a/drivers/mtd/parsers/parser_trx.c ++++ b/drivers/mtd/parsers/parser_trx.c +@@ -51,13 +51,20 @@ static int parser_trx_parse(struct mtd_i + const struct mtd_partition **pparts, + struct mtd_part_parser_data *data) + { ++ struct device_node *np = mtd_get_of_node(mtd); + struct mtd_partition *parts; + struct mtd_partition *part; + struct trx_header trx; + size_t bytes_read; + uint8_t curr_part = 0, i = 0; ++ uint32_t trx_magic = TRX_MAGIC; + int err; + ++ /* Get different magic from device tree if specified */ ++ err = of_property_read_u32(np, "brcm,trx-magic", &trx_magic); ++ if (err != 0 && err != -EINVAL) ++ pr_err("failed to parse \"brcm,trx-magic\" DT attribute, using default: %d\n", err); ++ + parts = kcalloc(TRX_PARSER_MAX_PARTS, sizeof(struct mtd_partition), + GFP_KERNEL); + if (!parts) +@@ -70,7 +77,7 @@ static int parser_trx_parse(struct mtd_i + return err; + } + +- if (trx.magic != TRX_MAGIC) { ++ if (trx.magic != trx_magic) { + kfree(parts); + return -ENOENT; + } diff --git a/target/linux/generic/backport-5.10/409-v5.14-0003-mtd-parsers-trx-Allow-to-use-TRX-parser-on-Mediatek-.patch b/target/linux/generic/backport-5.10/409-v5.14-0003-mtd-parsers-trx-Allow-to-use-TRX-parser-on-Mediatek-.patch new file mode 100644 index 0000000000..faac535270 --- /dev/null +++ b/target/linux/generic/backport-5.10/409-v5.14-0003-mtd-parsers-trx-Allow-to-use-TRX-parser-on-Mediatek-.patch @@ -0,0 +1,25 @@ +From 81bb218c829246962a6327c64eec18ddcc049936 Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Sun, 18 Apr 2021 23:46:16 +0200 +Subject: mtd: parsers: trx: Allow to use TRX parser on Mediatek SoCs + +Buffalo uses the TRX partition format also on Mediatek MT7622 SoCs. + +Signed-off-by: Hauke Mehrtens +Signed-off-by: Miquel Raynal +Link: https://lore.kernel.org/linux-mtd/20210418214616.239574-4-hauke@hauke-m.de +--- + drivers/mtd/parsers/Kconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/mtd/parsers/Kconfig ++++ b/drivers/mtd/parsers/Kconfig +@@ -115,7 +115,7 @@ config MTD_AFS_PARTS + + config MTD_PARSER_TRX + tristate "Parser for TRX format partitions" +- depends on MTD && (BCM47XX || ARCH_BCM_5301X || COMPILE_TEST) ++ depends on MTD && (BCM47XX || ARCH_BCM_5301X || ARCH_MEDIATEK || COMPILE_TEST) + help + TRX is a firmware format used by Broadcom on their devices. It + may contain up to 3/4 partitions (depending on the version). diff --git a/target/linux/generic/config-5.10 b/target/linux/generic/config-5.10 index bf96908178..ca93b5f269 100644 --- a/target/linux/generic/config-5.10 +++ b/target/linux/generic/config-5.10 @@ -3624,6 +3624,7 @@ CONFIG_MTD_OF_PARTS=y # CONFIG_MTD_ONENAND is not set # CONFIG_MTD_OOPS is not set # CONFIG_MTD_OTP is not set +# CONFIG_MTD_PARSER_TRX is not set # CONFIG_MTD_PARTITIONED_MASTER is not set # CONFIG_MTD_PCI is not set # CONFIG_MTD_PCMCIA is not set diff --git a/target/linux/generic/pending-5.10/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch b/target/linux/generic/pending-5.10/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch index 2ea59cd872..bcea45d009 100644 --- a/target/linux/generic/pending-5.10/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch +++ b/target/linux/generic/pending-5.10/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch @@ -40,7 +40,7 @@ Signed-off-by: Rafał Miłecki static const char *parser_trx_data_part_name(struct mtd_info *master, size_t offset) { -@@ -79,21 +106,21 @@ static int parser_trx_parse(struct mtd_i +@@ -86,21 +113,21 @@ static int parser_trx_parse(struct mtd_i if (trx.offset[2]) { part = &parts[curr_part++]; part->name = "loader"; diff --git a/target/linux/mediatek/patches-5.10/350-dt-bindings-mtd-brcm-trx-Add-brcm-trx-magic.patch b/target/linux/mediatek/patches-5.10/350-dt-bindings-mtd-brcm-trx-Add-brcm-trx-magic.patch deleted file mode 100644 index 1f34652141..0000000000 --- a/target/linux/mediatek/patches-5.10/350-dt-bindings-mtd-brcm-trx-Add-brcm-trx-magic.patch +++ /dev/null @@ -1,32 +0,0 @@ -From a4d82940ff85a7e307953dfa715f65d5ab487e10 Mon Sep 17 00:00:00 2001 -From: Hauke Mehrtens -Date: Sun, 18 Apr 2021 23:46:14 +0200 -Subject: dt-bindings: mtd: brcm,trx: Add brcm,trx-magic - -This adds the description of an additional property which allows to -specify a custom partition parser magic to detect a trx partition. -Buffalo has multiple device which are using the trx format, but with -different magic values. - -Signed-off-by: Hauke Mehrtens -Acked-by: Rob Herring -Signed-off-by: Miquel Raynal -Link: https://lore.kernel.org/linux-mtd/20210418214616.239574-2-hauke@hauke-m.de ---- - .../devicetree/bindings/mtd/partitions/brcm,trx.txt | 5 +++++ - 1 file changed, 5 insertions(+) - ---- a/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt -+++ b/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt -@@ -28,6 +28,11 @@ detected by a software parsing TRX heade - Required properties: - - compatible : (required) must be "brcm,trx" - -+Optional properties: -+ -+- brcm,trx-magic: TRX magic, if it is different from the default magic -+ 0x30524448 as a u32. -+ - Example: - - flash@0 { diff --git a/target/linux/mediatek/patches-5.10/351-mtd-parsers-trx-Allow-to-specify-brcm-trx-magic-in-D.patch b/target/linux/mediatek/patches-5.10/351-mtd-parsers-trx-Allow-to-specify-brcm-trx-magic-in-D.patch deleted file mode 100644 index ac98556101..0000000000 --- a/target/linux/mediatek/patches-5.10/351-mtd-parsers-trx-Allow-to-specify-brcm-trx-magic-in-D.patch +++ /dev/null @@ -1,50 +0,0 @@ -From d7f7e04f8b67571a4bf5a0dcd4f9da4214f5262c Mon Sep 17 00:00:00 2001 -From: Hauke Mehrtens -Date: Sun, 18 Apr 2021 23:46:15 +0200 -Subject: mtd: parsers: trx: Allow to specify brcm, trx-magic in DT - -Buffalo uses a different TRX magic for every device, to be able to use -this trx parser, make it possible to specify the TRX magic in device -tree. If no TRX magic is specified in device tree, the standard value -will be used. This value should only be specified if a vendor chooses to -use a non standard TRX magic. - -Signed-off-by: Hauke Mehrtens -Signed-off-by: Miquel Raynal -Link: https://lore.kernel.org/linux-mtd/20210418214616.239574-3-hauke@hauke-m.de ---- - drivers/mtd/parsers/parser_trx.c | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - ---- a/drivers/mtd/parsers/parser_trx.c -+++ b/drivers/mtd/parsers/parser_trx.c -@@ -78,13 +78,20 @@ static int parser_trx_parse(struct mtd_i - const struct mtd_partition **pparts, - struct mtd_part_parser_data *data) - { -+ struct device_node *np = mtd_get_of_node(mtd); - struct mtd_partition *parts; - struct mtd_partition *part; - struct trx_header trx; - size_t bytes_read; - uint8_t curr_part = 0, i = 0; -+ uint32_t trx_magic = TRX_MAGIC; - int err; - -+ /* Get different magic from device tree if specified */ -+ err = of_property_read_u32(np, "brcm,trx-magic", &trx_magic); -+ if (err != 0 && err != -EINVAL) -+ pr_err("failed to parse \"brcm,trx-magic\" DT attribute, using default: %d\n", err); -+ - parts = kcalloc(TRX_PARSER_MAX_PARTS, sizeof(struct mtd_partition), - GFP_KERNEL); - if (!parts) -@@ -97,7 +104,7 @@ static int parser_trx_parse(struct mtd_i - return err; - } - -- if (trx.magic != TRX_MAGIC) { -+ if (trx.magic != trx_magic) { - kfree(parts); - return -ENOENT; - } diff --git a/target/linux/mediatek/patches-5.10/352-mtd-parsers-trx-Allow-to-use-TRX-parser-on-Mediatek-.patch b/target/linux/mediatek/patches-5.10/352-mtd-parsers-trx-Allow-to-use-TRX-parser-on-Mediatek-.patch deleted file mode 100644 index b37f461101..0000000000 --- a/target/linux/mediatek/patches-5.10/352-mtd-parsers-trx-Allow-to-use-TRX-parser-on-Mediatek-.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 81bb218c829246962a6327c64eec18ddcc049936 Mon Sep 17 00:00:00 2001 -From: Hauke Mehrtens -Date: Sun, 18 Apr 2021 23:46:16 +0200 -Subject: mtd: parsers: trx: Allow to use TRX parser on Mediatek SoCs - -Buffalo uses the TRX partition format also on Mediatek MT7622 SoCs. - -Signed-off-by: Hauke Mehrtens -Signed-off-by: Miquel Raynal -Link: https://lore.kernel.org/linux-mtd/20210418214616.239574-4-hauke@hauke-m.de ---- - drivers/mtd/parsers/Kconfig | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/drivers/mtd/parsers/Kconfig -+++ b/drivers/mtd/parsers/Kconfig -@@ -131,7 +131,7 @@ config MTD_AFS_PARTS - - config MTD_PARSER_TRX - tristate "Parser for TRX format partitions" -- depends on MTD && (BCM47XX || ARCH_BCM_5301X || COMPILE_TEST) -+ depends on MTD && (BCM47XX || ARCH_BCM_5301X || ARCH_MEDIATEK || COMPILE_TEST) - help - TRX is a firmware format used by Broadcom on their devices. It - may contain up to 3/4 partitions (depending on the version).