* [PATCH 0/2] mtd: parsers: trx: Add support for Buffalo WSR-2533DHP2 @ 2021-03-15 17:07 Hauke Mehrtens 2021-03-15 17:07 ` [PATCH 1/2] mtd: parsers: trx: Allow to specify trx-magic in DT Hauke Mehrtens 2021-03-15 17:07 ` [PATCH 2/2] mtd: parsers: trx: Remove dependency to BRCM architectures Hauke Mehrtens 0 siblings, 2 replies; 9+ messages in thread From: Hauke Mehrtens @ 2021-03-15 17:07 UTC (permalink / raw) To: miquel.raynal, richard, vigneshr, robh+dt Cc: linux-mtd, devicetree, rafal, musashino.open, Hauke Mehrtens The Buffalo WSR-2533DHP2 uses a Mediatek MT7622 SoC, with the TRX partition format with a special magic. Buffalo probably ported the code from their older Broadcom based devices. Hauke Mehrtens (2): mtd: parsers: trx: Allow to specify trx-magic in DT mtd: parsers: trx: Remove dependency to BRCM architectures .../bindings/mtd/partitions/brcm,trx.txt | 5 +++++ drivers/mtd/parsers/Kconfig | 2 +- drivers/mtd/parsers/parser_trx.c | 21 ++++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) -- 2.30.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] mtd: parsers: trx: Allow to specify trx-magic in DT 2021-03-15 17:07 [PATCH 0/2] mtd: parsers: trx: Add support for Buffalo WSR-2533DHP2 Hauke Mehrtens @ 2021-03-15 17:07 ` Hauke Mehrtens 2021-03-17 9:25 ` Miquel Raynal 2021-03-18 6:43 ` Rafał Miłecki 2021-03-15 17:07 ` [PATCH 2/2] mtd: parsers: trx: Remove dependency to BRCM architectures Hauke Mehrtens 1 sibling, 2 replies; 9+ messages in thread From: Hauke Mehrtens @ 2021-03-15 17:07 UTC (permalink / raw) To: miquel.raynal, richard, vigneshr, robh+dt Cc: linux-mtd, devicetree, rafal, musashino.open, Hauke Mehrtens 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 <hauke@hauke-m.de> --- .../bindings/mtd/partitions/brcm,trx.txt | 5 +++++ drivers/mtd/parsers/parser_trx.c | 21 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt b/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt index b677147ca4e1..715a18ca36bd 100644 --- 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 header. 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 { diff --git a/drivers/mtd/parsers/parser_trx.c b/drivers/mtd/parsers/parser_trx.c index 8541182134d4..fd424587caa4 100644 --- a/drivers/mtd/parsers/parser_trx.c +++ b/drivers/mtd/parsers/parser_trx.c @@ -47,6 +47,24 @@ static const char *parser_trx_data_part_name(struct mtd_info *master, 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) @@ -56,6 +74,7 @@ static int parser_trx_parse(struct mtd_info *mtd, 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), @@ -70,7 +89,7 @@ static int parser_trx_parse(struct mtd_info *mtd, return err; } - if (trx.magic != TRX_MAGIC) { + if (trx.magic != trx_magic) { kfree(parts); return -ENOENT; } -- 2.30.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] mtd: parsers: trx: Allow to specify trx-magic in DT 2021-03-15 17:07 ` [PATCH 1/2] mtd: parsers: trx: Allow to specify trx-magic in DT Hauke Mehrtens @ 2021-03-17 9:25 ` Miquel Raynal 2021-04-18 16:53 ` Hauke Mehrtens 2021-03-18 6:43 ` Rafał Miłecki 1 sibling, 1 reply; 9+ messages in thread From: Miquel Raynal @ 2021-03-17 9:25 UTC (permalink / raw) To: Hauke Mehrtens Cc: richard, vigneshr, robh+dt, linux-mtd, devicetree, rafal, musashino.open Hi Hauke, Hauke Mehrtens <hauke@hauke-m.de> wrote on Mon, 15 Mar 2021 18:07:10 +0100: > 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 <hauke@hauke-m.de> > --- > .../bindings/mtd/partitions/brcm,trx.txt | 5 +++++ > drivers/mtd/parsers/parser_trx.c | 21 ++++++++++++++++++- Can you please split this patch: 1- dt-binding update 2- driver update This way we can collect Rob's ack for the binding patch. Thanks, Miquèl ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] mtd: parsers: trx: Allow to specify trx-magic in DT 2021-03-17 9:25 ` Miquel Raynal @ 2021-04-18 16:53 ` Hauke Mehrtens 0 siblings, 0 replies; 9+ messages in thread From: Hauke Mehrtens @ 2021-04-18 16:53 UTC (permalink / raw) To: Miquel Raynal Cc: richard, vigneshr, robh+dt, linux-mtd, devicetree, rafal, musashino.open On 3/17/21 10:25 AM, Miquel Raynal wrote: > Hi Hauke, > > Hauke Mehrtens <hauke@hauke-m.de> wrote on Mon, 15 Mar 2021 18:07:10 > +0100: > >> 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 <hauke@hauke-m.de> >> --- >> .../bindings/mtd/partitions/brcm,trx.txt | 5 +++++ >> drivers/mtd/parsers/parser_trx.c | 21 ++++++++++++++++++- > > Can you please split this patch: > 1- dt-binding update > 2- driver update > > This way we can collect Rob's ack for the binding patch. > Hi, Sorry for answering so late. I will split this into two patches. Hauke ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] mtd: parsers: trx: Allow to specify trx-magic in DT 2021-03-15 17:07 ` [PATCH 1/2] mtd: parsers: trx: Allow to specify trx-magic in DT Hauke Mehrtens 2021-03-17 9:25 ` Miquel Raynal @ 2021-03-18 6:43 ` Rafał Miłecki 2021-04-18 16:59 ` Hauke Mehrtens 1 sibling, 1 reply; 9+ messages in thread From: Rafał Miłecki @ 2021-03-18 6:43 UTC (permalink / raw) To: Hauke Mehrtens, miquel.raynal, richard, vigneshr, robh+dt Cc: linux-mtd, devicetree, rafal, musashino.open On 15.03.2021 18:07, Hauke Mehrtens wrote: > 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 <hauke@hauke-m.de> > --- > .../bindings/mtd/partitions/brcm,trx.txt | 5 +++++ > drivers/mtd/parsers/parser_trx.c | 21 ++++++++++++++++++- > 2 files changed, 25 insertions(+), 1 deletion(-) > > diff --git a/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt b/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt > index b677147ca4e1..715a18ca36bd 100644 > --- 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 header. > 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. It may need to be brcm,trx-magic and ack for sending a separated bt-bindings patch. > diff --git a/drivers/mtd/parsers/parser_trx.c b/drivers/mtd/parsers/parser_trx.c > index 8541182134d4..fd424587caa4 100644 > --- a/drivers/mtd/parsers/parser_trx.c > +++ b/drivers/mtd/parsers/parser_trx.c > @@ -47,6 +47,24 @@ static const char *parser_trx_data_part_name(struct mtd_info *master, > 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; This check seems redundant, of_ returns -EINVAL also for NULL node. > + /* 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); I'm not native, but shouldn't that be s/use/using/ ? > + > + return trx_magic; > +} ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] mtd: parsers: trx: Allow to specify trx-magic in DT 2021-03-18 6:43 ` Rafał Miłecki @ 2021-04-18 16:59 ` Hauke Mehrtens 0 siblings, 0 replies; 9+ messages in thread From: Hauke Mehrtens @ 2021-04-18 16:59 UTC (permalink / raw) To: Rafał Miłecki, miquel.raynal, richard, vigneshr, robh+dt Cc: linux-mtd, devicetree, rafal, musashino.open On 3/18/21 7:43 AM, Rafał Miłecki wrote: > On 15.03.2021 18:07, Hauke Mehrtens wrote: >> 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 <hauke@hauke-m.de> >> --- >> .../bindings/mtd/partitions/brcm,trx.txt | 5 +++++ >> drivers/mtd/parsers/parser_trx.c | 21 ++++++++++++++++++- >> 2 files changed, 25 insertions(+), 1 deletion(-) >> >> diff --git >> a/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt >> b/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt >> index b677147ca4e1..715a18ca36bd 100644 >> --- 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 header. >> 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. > > It may need to be brcm,trx-magic and ack for sending a separated > bt-bindings patch. Ok, I will rename it to brcm,trx-magic. >> diff --git a/drivers/mtd/parsers/parser_trx.c >> b/drivers/mtd/parsers/parser_trx.c >> index 8541182134d4..fd424587caa4 100644 >> --- a/drivers/mtd/parsers/parser_trx.c >> +++ b/drivers/mtd/parsers/parser_trx.c >> @@ -47,6 +47,24 @@ static const char *parser_trx_data_part_name(struct >> mtd_info *master, >> 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; > > This check seems redundant, of_ returns -EINVAL also for NULL node. Thanks for the information, I will remove this check. Then it could also be easier to just inline this code. > > >> + /* 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); > > I'm not native, but shouldn't that be s/use/using/ ? I am also not a native speaker, but I agree with you and will change this. Hauke ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] mtd: parsers: trx: Remove dependency to BRCM architectures 2021-03-15 17:07 [PATCH 0/2] mtd: parsers: trx: Add support for Buffalo WSR-2533DHP2 Hauke Mehrtens 2021-03-15 17:07 ` [PATCH 1/2] mtd: parsers: trx: Allow to specify trx-magic in DT Hauke Mehrtens @ 2021-03-15 17:07 ` Hauke Mehrtens 2021-03-18 6:45 ` Rafał Miłecki 1 sibling, 1 reply; 9+ messages in thread From: Hauke Mehrtens @ 2021-03-15 17:07 UTC (permalink / raw) To: miquel.raynal, richard, vigneshr, robh+dt Cc: linux-mtd, devicetree, rafal, musashino.open, Hauke Mehrtens Buffalo uses the TRX partition format also on Mediatek SoCs. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> --- drivers/mtd/parsers/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/parsers/Kconfig b/drivers/mtd/parsers/Kconfig index d90c30229052..6242903d8844 100644 --- a/drivers/mtd/parsers/Kconfig +++ b/drivers/mtd/parsers/Kconfig @@ -96,7 +96,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 help TRX is a firmware format used by Broadcom on their devices. It may contain up to 3/4 partitions (depending on the version). -- 2.30.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] mtd: parsers: trx: Remove dependency to BRCM architectures 2021-03-15 17:07 ` [PATCH 2/2] mtd: parsers: trx: Remove dependency to BRCM architectures Hauke Mehrtens @ 2021-03-18 6:45 ` Rafał Miłecki 2021-04-18 17:03 ` Hauke Mehrtens 0 siblings, 1 reply; 9+ messages in thread From: Rafał Miłecki @ 2021-03-18 6:45 UTC (permalink / raw) To: Hauke Mehrtens, miquel.raynal, richard, vigneshr, robh+dt Cc: linux-mtd, devicetree, rafal, musashino.open On 15.03.2021 18:07, Hauke Mehrtens wrote: > Buffalo uses the TRX partition format also on Mediatek SoCs. > > Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> > --- > drivers/mtd/parsers/Kconfig | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mtd/parsers/Kconfig b/drivers/mtd/parsers/Kconfig > index d90c30229052..6242903d8844 100644 > --- a/drivers/mtd/parsers/Kconfig > +++ b/drivers/mtd/parsers/Kconfig > @@ -96,7 +96,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 > help > TRX is a firmware format used by Broadcom on their devices. It > may contain up to 3/4 partitions (depending on the version). > Please check Documentation/kbuild/kconfig-language.rst and commit 18084e435ff6 ("Documentation/kbuild: Document platform dependency practises") I think you should rather add platform to DEPENDS. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] mtd: parsers: trx: Remove dependency to BRCM architectures 2021-03-18 6:45 ` Rafał Miłecki @ 2021-04-18 17:03 ` Hauke Mehrtens 0 siblings, 0 replies; 9+ messages in thread From: Hauke Mehrtens @ 2021-04-18 17:03 UTC (permalink / raw) To: Rafał Miłecki, miquel.raynal, richard, vigneshr, robh+dt Cc: linux-mtd, devicetree, rafal, musashino.open On 3/18/21 7:45 AM, Rafał Miłecki wrote: > On 15.03.2021 18:07, Hauke Mehrtens wrote: >> Buffalo uses the TRX partition format also on Mediatek SoCs. >> >> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> >> --- >> drivers/mtd/parsers/Kconfig | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/mtd/parsers/Kconfig b/drivers/mtd/parsers/Kconfig >> index d90c30229052..6242903d8844 100644 >> --- a/drivers/mtd/parsers/Kconfig >> +++ b/drivers/mtd/parsers/Kconfig >> @@ -96,7 +96,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 >> help >> TRX is a firmware format used by Broadcom on their devices. It >> may contain up to 3/4 partitions (depending on the version). >> > > Please check Documentation/kbuild/kconfig-language.rst and commit > 18084e435ff6 ("Documentation/kbuild: Document platform dependency > practises") > > I think you should rather add platform to DEPENDS. Ok I will add a dependency to ARCH_MEDIATEK. I think Buffalo also used this on some Mediatek/ralink MIPS devices, but they are not supported upstream yet. Hauke ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-04-18 17:04 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-03-15 17:07 [PATCH 0/2] mtd: parsers: trx: Add support for Buffalo WSR-2533DHP2 Hauke Mehrtens 2021-03-15 17:07 ` [PATCH 1/2] mtd: parsers: trx: Allow to specify trx-magic in DT Hauke Mehrtens 2021-03-17 9:25 ` Miquel Raynal 2021-04-18 16:53 ` Hauke Mehrtens 2021-03-18 6:43 ` Rafał Miłecki 2021-04-18 16:59 ` Hauke Mehrtens 2021-03-15 17:07 ` [PATCH 2/2] mtd: parsers: trx: Remove dependency to BRCM architectures Hauke Mehrtens 2021-03-18 6:45 ` Rafał Miłecki 2021-04-18 17:03 ` Hauke Mehrtens
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).