From a6616eea406d8654f5a0198a26c5748a86c75272 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 18 Apr 2021 21:51:00 +0200 Subject: [PATCH] mediatek: update mtd parser patches This updates the patches to match the versions included in the mtd subsystem for the next Linux kernel version. Signed-off-by: Hauke Mehrtens --- .../dts/mt7622-buffalo-wsr-2533dhp2.dts | 2 +- ...ings-mtd-brcm-trx-Add-brcm-trx-magic.patch | 32 ++++++++ ...trx-Allow-to-specify-trx-magic-in-DT.patch | 75 ------------------- ...Allow-to-specify-brcm-trx-magic-in-D.patch | 50 +++++++++++++ ...llow-to-use-TRX-parser-on-Mediatek-.patch} | 12 +-- ...trx-Allow-to-specify-trx-magic-in-DT.patch | 8 +- 6 files changed, 94 insertions(+), 85 deletions(-) create mode 100644 target/linux/mediatek/patches-5.10/350-dt-bindings-mtd-brcm-trx-Add-brcm-trx-magic.patch delete mode 100644 target/linux/mediatek/patches-5.10/350-mtd-parsers-trx-Allow-to-specify-trx-magic-in-DT.patch create mode 100644 target/linux/mediatek/patches-5.10/351-mtd-parsers-trx-Allow-to-specify-brcm-trx-magic-in-D.patch rename target/linux/mediatek/patches-5.10/{351-mtd-parsers-Remove-dependency-to-BRCM-architectures.patch => 352-mtd-parsers-trx-Allow-to-use-TRX-parser-on-Mediatek-.patch} (55%) diff --git a/target/linux/mediatek/dts/mt7622-buffalo-wsr-2533dhp2.dts b/target/linux/mediatek/dts/mt7622-buffalo-wsr-2533dhp2.dts index ce5cd1c9be00..62e2e7f4cb21 100644 --- a/target/linux/mediatek/dts/mt7622-buffalo-wsr-2533dhp2.dts +++ b/target/linux/mediatek/dts/mt7622-buffalo-wsr-2533dhp2.dts @@ -279,7 +279,7 @@ partition@200000 { compatible = "brcm,trx"; - trx-magic = <0x32504844>; + brcm,trx-magic = <0x32504844>; label = "firmware"; reg = <0x200000 0x3a00000>; }; 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 new file mode 100644 index 000000000000..1f34652141d5 --- /dev/null +++ b/target/linux/mediatek/patches-5.10/350-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/mediatek/patches-5.10/350-mtd-parsers-trx-Allow-to-specify-trx-magic-in-DT.patch b/target/linux/mediatek/patches-5.10/350-mtd-parsers-trx-Allow-to-specify-trx-magic-in-DT.patch deleted file mode 100644 index 4db51a88ad19..000000000000 --- a/target/linux/mediatek/patches-5.10/350-mtd-parsers-trx-Allow-to-specify-trx-magic-in-DT.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 0600e3d81628002a5cd80cf83ee454851b0063c0 Mon Sep 17 00:00:00 2001 -From: Hauke Mehrtens -Date: Sun, 7 Mar 2021 18:19:26 +0100 -Subject: mtd: parsers: trx: Allow to specify 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 ---- - .../bindings/mtd/partitions/brcm,trx.txt | 5 +++++ - drivers/mtd/parsers/parser_trx.c | 21 ++++++++++++++++++- - 2 files changed, 25 insertions(+), 1 deletion(-) - ---- 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: -+ -+- trx-magic: TRX magic, if it is different from the default magic -+ 0x30524448 as a u32. -+ - Example: - - flash@0 { ---- a/drivers/mtd/parsers/parser_trx.c -+++ b/drivers/mtd/parsers/parser_trx.c -@@ -74,6 +74,24 @@ out_default: - return "rootfs"; - } - -+static uint32_t parser_trx_get_magic(struct mtd_info *mtd) -+{ -+ uint32_t trx_magic = TRX_MAGIC; -+ struct device_node *np; -+ int err; -+ -+ np = mtd_get_of_node(mtd); -+ if (!np) -+ return trx_magic; -+ -+ /* Get different magic from device tree if specified */ -+ err = of_property_read_u32(np, "trx-magic", &trx_magic); -+ if (err != 0 && err != -EINVAL) -+ pr_err("failed to parse \"trx-magic\" DT attribute, use default: %d\n", err); -+ -+ return trx_magic; -+} -+ - static int parser_trx_parse(struct mtd_info *mtd, - const struct mtd_partition **pparts, - struct mtd_part_parser_data *data) -@@ -83,6 +101,7 @@ static int parser_trx_parse(struct mtd_i - struct trx_header trx; - size_t bytes_read; - uint8_t curr_part = 0, i = 0; -+ uint32_t trx_magic = parser_trx_get_magic(mtd); - int err; - - parts = kcalloc(TRX_PARSER_MAX_PARTS, sizeof(struct mtd_partition), -@@ -97,7 +116,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/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 new file mode 100644 index 000000000000..ac98556101c5 --- /dev/null +++ b/target/linux/mediatek/patches-5.10/351-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 +@@ -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/351-mtd-parsers-Remove-dependency-to-BRCM-architectures.patch b/target/linux/mediatek/patches-5.10/352-mtd-parsers-trx-Allow-to-use-TRX-parser-on-Mediatek-.patch similarity index 55% rename from target/linux/mediatek/patches-5.10/351-mtd-parsers-Remove-dependency-to-BRCM-architectures.patch rename to target/linux/mediatek/patches-5.10/352-mtd-parsers-trx-Allow-to-use-TRX-parser-on-Mediatek-.patch index fa94c2230455..b37f4611015f 100644 --- a/target/linux/mediatek/patches-5.10/351-mtd-parsers-Remove-dependency-to-BRCM-architectures.patch +++ b/target/linux/mediatek/patches-5.10/352-mtd-parsers-trx-Allow-to-use-TRX-parser-on-Mediatek-.patch @@ -1,11 +1,13 @@ -From 63f0cf88ab5461acb0911252f12bb94ee3bf05a2 Mon Sep 17 00:00:00 2001 +From 81bb218c829246962a6327c64eec18ddcc049936 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens -Date: Sun, 7 Mar 2021 18:23:29 +0100 -Subject: mtd: parsers: Remove dependency to BRCM architectures +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 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(-) @@ -17,7 +19,7 @@ Signed-off-by: Hauke Mehrtens config MTD_PARSER_TRX tristate "Parser for TRX format partitions" - depends on MTD && (BCM47XX || ARCH_BCM_5301X || COMPILE_TEST) -+ depends on MTD ++ 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/mediatek/patches-5.4/0350-mtd-parsers-trx-Allow-to-specify-trx-magic-in-DT.patch b/target/linux/mediatek/patches-5.4/0350-mtd-parsers-trx-Allow-to-specify-trx-magic-in-DT.patch index 4db51a88ad19..0446ce9386fd 100644 --- a/target/linux/mediatek/patches-5.4/0350-mtd-parsers-trx-Allow-to-specify-trx-magic-in-DT.patch +++ b/target/linux/mediatek/patches-5.4/0350-mtd-parsers-trx-Allow-to-specify-trx-magic-in-DT.patch @@ -1,7 +1,7 @@ From 0600e3d81628002a5cd80cf83ee454851b0063c0 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 7 Mar 2021 18:19:26 +0100 -Subject: mtd: parsers: trx: Allow to specify trx-magic in DT +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 @@ -23,7 +23,7 @@ Signed-off-by: Hauke Mehrtens +Optional properties: + -+- trx-magic: TRX magic, if it is different from the default magic ++- brcm,trx-magic: TRX magic, if it is different from the default magic + 0x30524448 as a u32. + Example: @@ -46,9 +46,9 @@ Signed-off-by: Hauke Mehrtens + return trx_magic; + + /* Get different magic from device tree if specified */ -+ err = of_property_read_u32(np, "trx-magic", &trx_magic); ++ err = of_property_read_u32(np, "brcm,trx-magic", &trx_magic); + if (err != 0 && err != -EINVAL) -+ pr_err("failed to parse \"trx-magic\" DT attribute, use default: %d\n", err); ++ pr_err("failed to parse \"brcm,trx-magic\" DT attribute, use default: %d\n", err); + + return trx_magic; +} -- 2.30.2