linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] mtd: parsers: trx: Add support for Buffalo WSR-2533DHP2
@ 2021-04-18 21:46 Hauke Mehrtens
  2021-04-18 21:46 ` [PATCH v2 1/3] dt-bindings: mtd: brcm,trx: Add brcm,trx-magic Hauke Mehrtens
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Hauke Mehrtens @ 2021-04-18 21:46 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.

Changes since:
v1:
 - Split dt-bindings into own patch
 - Rename trx-magic to brcm,trx-magic
 - Do not check np for NULL
 - inline parser_trx_get_magic()
 - Add depends for ARCH_MEDIATEK

Hauke Mehrtens (3):
  dt-bindings: mtd: brcm,trx: Add brcm,trx-magic
  mtd: parsers: trx: Allow to specify brcm,trx-magic in DT
  mtd: parsers: trx: Allow to use TRX parser on Mediatek SoCs

 .../devicetree/bindings/mtd/partitions/brcm,trx.txt      | 5 +++++
 drivers/mtd/parsers/Kconfig                              | 2 +-
 drivers/mtd/parsers/parser_trx.c                         | 9 ++++++++-
 3 files changed, 14 insertions(+), 2 deletions(-)

-- 
2.30.2


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/3] dt-bindings: mtd: brcm,trx: Add brcm,trx-magic
  2021-04-18 21:46 [PATCH v2 0/3] mtd: parsers: trx: Add support for Buffalo WSR-2533DHP2 Hauke Mehrtens
@ 2021-04-18 21:46 ` Hauke Mehrtens
  2021-04-20 18:56   ` Rob Herring
  2021-05-10 10:19   ` Miquel Raynal
  2021-04-18 21:46 ` [PATCH v2 2/3] mtd: parsers: trx: Allow to specify brcm, trx-magic in DT Hauke Mehrtens
  2021-04-18 21:46 ` [PATCH v2 3/3] mtd: parsers: trx: Allow to use TRX parser on Mediatek SoCs Hauke Mehrtens
  2 siblings, 2 replies; 8+ messages in thread
From: Hauke Mehrtens @ 2021-04-18 21:46 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, robh+dt
  Cc: linux-mtd, devicetree, rafal, musashino.open, Hauke Mehrtens

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 <hauke@hauke-m.de>
---
 .../devicetree/bindings/mtd/partitions/brcm,trx.txt          | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt b/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt
index b677147ca4e1..c2175d3c82ec 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:
+
+- brcm,trx-magic: TRX magic, if it is different from the default magic
+		  0x30524448 as a u32.
+
 Example:
 
 flash@0 {
-- 
2.30.2


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/3] mtd: parsers: trx: Allow to specify brcm, trx-magic in DT
  2021-04-18 21:46 [PATCH v2 0/3] mtd: parsers: trx: Add support for Buffalo WSR-2533DHP2 Hauke Mehrtens
  2021-04-18 21:46 ` [PATCH v2 1/3] dt-bindings: mtd: brcm,trx: Add brcm,trx-magic Hauke Mehrtens
@ 2021-04-18 21:46 ` Hauke Mehrtens
  2021-05-10 10:19   ` Miquel Raynal
  2021-04-18 21:46 ` [PATCH v2 3/3] mtd: parsers: trx: Allow to use TRX parser on Mediatek SoCs Hauke Mehrtens
  2 siblings, 1 reply; 8+ messages in thread
From: Hauke Mehrtens @ 2021-04-18 21:46 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>
---
 drivers/mtd/parsers/parser_trx.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/parsers/parser_trx.c b/drivers/mtd/parsers/parser_trx.c
index 8541182134d4..4814cf218e17 100644
--- 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_info *mtd,
 			    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_info *mtd,
 		return err;
 	}
 
-	if (trx.magic != TRX_MAGIC) {
+	if (trx.magic != trx_magic) {
 		kfree(parts);
 		return -ENOENT;
 	}
-- 
2.30.2


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/3] mtd: parsers: trx: Allow to use TRX parser on Mediatek SoCs
  2021-04-18 21:46 [PATCH v2 0/3] mtd: parsers: trx: Add support for Buffalo WSR-2533DHP2 Hauke Mehrtens
  2021-04-18 21:46 ` [PATCH v2 1/3] dt-bindings: mtd: brcm,trx: Add brcm,trx-magic Hauke Mehrtens
  2021-04-18 21:46 ` [PATCH v2 2/3] mtd: parsers: trx: Allow to specify brcm, trx-magic in DT Hauke Mehrtens
@ 2021-04-18 21:46 ` Hauke Mehrtens
  2021-05-10 10:19   ` Miquel Raynal
  2 siblings, 1 reply; 8+ messages in thread
From: Hauke Mehrtens @ 2021-04-18 21:46 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 MT7622 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..c2af062fdca7 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 && (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).
-- 
2.30.2


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/3] dt-bindings: mtd: brcm,trx: Add brcm,trx-magic
  2021-04-18 21:46 ` [PATCH v2 1/3] dt-bindings: mtd: brcm,trx: Add brcm,trx-magic Hauke Mehrtens
@ 2021-04-20 18:56   ` Rob Herring
  2021-05-10 10:19   ` Miquel Raynal
  1 sibling, 0 replies; 8+ messages in thread
From: Rob Herring @ 2021-04-20 18:56 UTC (permalink / raw)
  To: Hauke Mehrtens
  Cc: miquel.raynal, rafal, vigneshr, devicetree, musashino.open,
	richard, linux-mtd, robh+dt

On Sun, 18 Apr 2021 23:46:14 +0200, Hauke Mehrtens wrote:
> 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 <hauke@hauke-m.de>
> ---
>  .../devicetree/bindings/mtd/partitions/brcm,trx.txt          | 5 +++++
>  1 file changed, 5 insertions(+)
> 

Acked-by: Rob Herring <robh@kernel.org>

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/3] mtd: parsers: trx: Allow to use TRX parser on Mediatek SoCs
  2021-04-18 21:46 ` [PATCH v2 3/3] mtd: parsers: trx: Allow to use TRX parser on Mediatek SoCs Hauke Mehrtens
@ 2021-05-10 10:19   ` Miquel Raynal
  0 siblings, 0 replies; 8+ messages in thread
From: Miquel Raynal @ 2021-05-10 10:19 UTC (permalink / raw)
  To: Hauke Mehrtens, miquel.raynal, richard, vigneshr, robh+dt
  Cc: linux-mtd, devicetree, rafal, musashino.open

On Sun, 2021-04-18 at 21:46:16 UTC, Hauke Mehrtens wrote:
> Buffalo uses the TRX partition format also on Mediatek MT7622 SoCs.
> 
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/3] mtd: parsers: trx: Allow to specify brcm, trx-magic in DT
  2021-04-18 21:46 ` [PATCH v2 2/3] mtd: parsers: trx: Allow to specify brcm, trx-magic in DT Hauke Mehrtens
@ 2021-05-10 10:19   ` Miquel Raynal
  0 siblings, 0 replies; 8+ messages in thread
From: Miquel Raynal @ 2021-05-10 10:19 UTC (permalink / raw)
  To: Hauke Mehrtens, miquel.raynal, richard, vigneshr, robh+dt
  Cc: linux-mtd, devicetree, rafal, musashino.open

On Sun, 2021-04-18 at 21:46:15 UTC, 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>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/3] dt-bindings: mtd: brcm,trx: Add brcm,trx-magic
  2021-04-18 21:46 ` [PATCH v2 1/3] dt-bindings: mtd: brcm,trx: Add brcm,trx-magic Hauke Mehrtens
  2021-04-20 18:56   ` Rob Herring
@ 2021-05-10 10:19   ` Miquel Raynal
  1 sibling, 0 replies; 8+ messages in thread
From: Miquel Raynal @ 2021-05-10 10:19 UTC (permalink / raw)
  To: Hauke Mehrtens, miquel.raynal, richard, vigneshr, robh+dt
  Cc: linux-mtd, devicetree, rafal, musashino.open

On Sun, 2021-04-18 at 21:46:14 UTC, Hauke Mehrtens wrote:
> 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 <hauke@hauke-m.de>
> Acked-by: Rob Herring <robh@kernel.org>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-05-10 10:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-18 21:46 [PATCH v2 0/3] mtd: parsers: trx: Add support for Buffalo WSR-2533DHP2 Hauke Mehrtens
2021-04-18 21:46 ` [PATCH v2 1/3] dt-bindings: mtd: brcm,trx: Add brcm,trx-magic Hauke Mehrtens
2021-04-20 18:56   ` Rob Herring
2021-05-10 10:19   ` Miquel Raynal
2021-04-18 21:46 ` [PATCH v2 2/3] mtd: parsers: trx: Allow to specify brcm, trx-magic in DT Hauke Mehrtens
2021-05-10 10:19   ` Miquel Raynal
2021-04-18 21:46 ` [PATCH v2 3/3] mtd: parsers: trx: Allow to use TRX parser on Mediatek SoCs Hauke Mehrtens
2021-05-10 10:19   ` Miquel Raynal

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).