mtd: bcm63xxpart: add device tree support
Subsystems (2)
v2 cover mtd: bcm63xxpart: add device tree support
This patchset adds appropriate bindings for parsing various bcm963xx NOR flash layouts found in the wild.
The image header is quite limited, and only has fixed fields for the offsets and sizes of the kernel and rootfs partitions. If any additional partitions exist, they need to be described externally, e.g. through fixed partition layouts.
The first two patches add the bindings for the full flash parser for the "common" case: first erase block bootloader, last erase block nvram, reminder available for firmware.
The third patch splits out the image header parsing into its own parser.
Then patches four and five add bindings for the split out parser, to support non-trivial cases with additional partitions, or a non-standard offset of the firmware partition.
These patches have been in used since a while in OpenWrt.
Changes V1 -> V2:
* dropped the second example from brcm,bcm963xx-imagetag.txt
* added reviewed bys from Rob Herring
Jonas Gorski (5):
dt-bindings: mtd: describe the simple BCM963XX NOR flash layout
mtd: bcm63xxpart: add of_match_table support
mtd: bcm63xxpart: move imagetag parsing to its own parser
dt-bindings: mtd: describe BCM963XX ImageTag format and usage
mtd: parser_imagetag: add of_match_table support
.../brcm,bcm963xx-cfe-nor-partitions.txt | 24 +++ .../mtd/partitions/brcm,bcm963xx-imagetag.txt | 45 +++++ drivers/mtd/Kconfig | 1 + drivers/mtd/bcm63xxpart.c | 163 ++------------- drivers/mtd/parsers/Kconfig | 11 + drivers/mtd/parsers/Makefile | 1 + drivers/mtd/parsers/parser_imagetag.c | 222 +++++++++++++++++++++ 7 files changed, 320 insertions(+), 147 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/partitions/brcm,bcm963xx-cfe-nor-partitions.txt create mode 100644 Documentation/devicetree/bindings/mtd/partitions/brcm,bcm963xx-imagetag.txt create mode 100644 drivers/mtd/parsers/parser_imagetag.c
Signature · 6 lines
2.13.2 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v2 1/5 dt-bindings: mtd: describe the simple BCM963XX NOR flash layout
Add binding documentation for the standard CFE based BCM963XX flash layout, found in most devices using a BCM63XX SoC with NOR flash.
--- .../brcm,bcm963xx-cfe-nor-partitions.txt | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/partitions/brcm,bcm963xx-cfe-nor-partitions.txt
Documentation/devicetree/bindings/mtd/partitions/brcm,bcm963xx-cfe-nor-partitions.txt new file +24 -0
@@ -0,0 +1,24 @@ +Broadcom BCM963XX CFE Loader NOR Flash Partitions +================================================= + +Most Broadcom BCM63XX SoC based devices follow the Broadcom reference layout for +NOR. The first erase block used for the CFE bootloader, the last for an +NVRAM partition, and the remainder in-between for one to two firmware partitions +at fixed offsets. A valid firmware partition is identified by the ImageTag +header found at beginning of the second erase block, containing the rootfs and +kernel offsets and sizes within the firmware partition. + +Required properties: +- compatible : must be "brcm,bcm963xx-cfe-nor-partitions" + +Example: + +flash@1fc00000 { + compatible = "cfi-flash"; + reg = <0x1fc00000 0x400000>; + bank-width = <2>; + + partitions { + compatible = "brcm,bcm963xx-cfe-nor-partitions"; + }; +};
Signature · 6 lines
2.13.2 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH V2 1/5] dt-bindings: mtd: describe the simple BCM963XX NOR flash layout
Quoted 5 lines · Jonas Gorski
Add binding documentation for the standard CFE based BCM963XX flash layout, found in most devices using a BCM63XX SoC with NOR flash.
Reviewed-by Rob Herring <[email protected]>Signed-off-by Jonas Gorski <[email protected]>
Signature · 5 lines
Florian ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v2 2/5 mtd: bcm63xxpart: add of_match_table support
In reply to Jonas GorskiAdd of_match_table support to allow using bcm63xxpart as a full flash layout parser from device tree.
--- drivers/mtd/bcm63xxpart.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/mtd/bcm63xxpart.c +8 -0
@@ -34,6 +34,7 @@#include <linux/vmalloc.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> +#include <linux/of.h> #define BCM963XX_CFE_BLOCK_SIZE SZ_64K/* always at least 64KiB */
@@ -311,9 +312,16 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,return ret; }; +static const struct of_device_id parse_bcm63xx_cfe_match_table[] = { + { .compatible ="brcm,bcm963xx-cfe-nor-partitions" }, + {}, +}; +MODULE_DEVICE_TABLE (of, parse_bcm63xx_cfe_match_table); +static struct mtd_part_parser bcm63xx_cfe_parser = { .parse_fn = bcm63xx_parse_cfe_partitions, .name ="bcm63xxpart" , + .of_match_table = parse_bcm63xx_cfe_match_table, };module_mtd_part_parser (bcm63xx_cfe_parser);
Signature · 6 lines
2.13.2 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH V2 2/5] mtd: bcm63xxpart: add of_match_table support
Quoted 5 lines · Jonas Gorski
Add
of_match_tablesupport to allow using bcm63xxpart as a full flash layout parser from device tree.Reviewed-by Rob Herring <[email protected]>Signed-off-by Jonas Gorski <[email protected]>
Signature · 5 lines
Florian ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v2 3/5 mtd: bcm63xxpart: move imagetag parsing to its own parser
In reply to Jonas GorskiMove the bcm963xx Image Tag parsing into its own partition parser. This Allows reusing the parser with different full flash parsers.
While moving it, rename it to bcm963* to better reflect it isn't chip, but reference implementation specific.
--- drivers/mtd/Kconfig | 1 + drivers/mtd/bcm63xxpart.c | 155 ++---------------------- drivers/mtd/parsers/Kconfig | 11 ++ drivers/mtd/parsers/Makefile | 1 + drivers/mtd/parsers/parser_imagetag.c | 214 ++++++++++++++++++++++++++++++++++ 5 files changed, 235 insertions(+), 147 deletions(-) create mode 100644 drivers/mtd/parsers/parser_imagetag.c
drivers/mtd/Kconfig +1 -0
@@ -94,6 +94,7 @@ config MTD_BCM63XX_PARTS tristate "BCM63XX CFE partitioning support" depends on BCM63XX || BMIPS_GENERIC || COMPILE_TEST select CRC32 + select MTD_PARSER_IMAGETAG help This provides partition parsing for BCM63xx devices with CFE bootloaders.
drivers/mtd/bcm63xxpart.c +8 -147
194 lines not on this page · raw message
drivers/mtd/parsers/Kconfig +11 -0
@@ -1,3 +1,14 @@ +config MTD_PARSER_IMAGETAG + tristate "Parser for BCM963XX Image Tag format partitions" + depends on BCM63XX || BMIPS_GENERIC || COMPILE_TEST + select CRC32 + help + Image Tag is the firmware header used by broadcom on their xDSL line + of devices. It is used to describe the offsets and lengths of kernel + and rootfs partitions. + This driver adds support for parsing a partition with an Image Tag + header and creates up to two partitions, kernel and rootfs. + config MTD_PARSER_TRX tristate "Parser for TRX format partitions" depends on MTD && (BCM47XX || ARCH_BCM_5301X || COMPILE_TEST)
drivers/mtd/parsers/Makefile +1 -0
@@ -1,3 +1,4 @@ +obj-$(CONFIG_MTD_PARSER_IMAGETAG) += parser_imagetag.o obj-$(CONFIG_MTD_PARSER_TRX) += parser_trx.o obj-$(CONFIG_MTD_SHARPSL_PARTS) += sharpslpart.o obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o
drivers/mtd/parsers/parser_imagetag.c new file +214 -0
214 lines not on this page · raw message
Signature · 6 lines
2.13.2 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH V2 3/5] mtd: bcm63xxpart: move imagetag parsing to its own parser
Quoted 8 lines · Jonas Gorski
Move the bcm963xx Image Tag parsing into its own partition parser. This Allows reusing the parser with different full flash parsers.
While moving it, rename it to bcm963* to better reflect it isn't chip, but reference implementation specific.
Reviewed-by Rob Herring <[email protected]>Signed-off-by Jonas Gorski <[email protected]>
Signature · 5 lines
Florian ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v2 4/5 dt-bindings: mtd: describe BCM963XX ImageTag format and usage
In reply to Jonas GorskiDescribe how to use the BCM963XX ImageTag format in a mixed flash layout environment.
--- .../mtd/partitions/brcm,bcm963xx-imagetag.txt | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/partitions/brcm,bcm963xx-imagetag.txt
Documentation/devicetree/bindings/mtd/partitions/brcm,bcm963xx-imagetag.txt new file +45 -0
@@ -0,0 +1,45 @@ +Broadcom BCM963XX ImageTag Partition Container +============================================== + +Some Broadcom BCM63XX SoC based devices contain additional, non discoverable +partitions or non standard bootloader partition sizes. For these a mixed layout +needs to be used with an explicit firmware partition. + +The BCM963XX ImageTag is a simple firmware header describing the offsets and +sizes of the rootfs and kernel parts contained in the firmware. + +Required properties: +- compatible : must be "brcm,bcm963xx-imagetag" + +Example: + +flash@1e000000 { + compatible = "cfi-flash"; + reg = <0x1e000000 0x2000000>; + bank-width = <2>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + cfe@0 { + reg = <0x0 0x10000>; + read-only; + }; + + firmware@10000 { + reg = <0x10000 0x7d0000>; + compatible = "brcm,bcm963xx-imagetag"; + }; + + caldata@7e0000 { + reg = <0x7e0000 0x10000>; + read-only; + }; + + nvram@7f0000 { + reg = <0x7f0000 0x10000>; + }; + }; +};
Signature · 6 lines
2.13.2 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH V2 4/5] dt-bindings: mtd: describe BCM963XX ImageTag format and usage
Quoted 5 lines · Jonas Gorski
Describe how to use the BCM963XX ImageTag format in a mixed flash layout environment.
Reviewed-by Rob Herring <[email protected]>Signed-off-by Jonas Gorski <[email protected]>
Signature · 5 lines
Florian ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH v2 5/5 mtd: parser_imagetag: add of_match_table support
In reply to Jonas GorskiAllow matching the imagetag parser for fixed partitions defined in the device tree.
--- drivers/mtd/parsers/parser_imagetag.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/mtd/parsers/parser_imagetag.c +8 -0
@@ -24,6 +24,7 @@#include <linux/vmalloc.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> +#include <linux/of.h> /* Ensure strings read from flash structs are null terminated */ #define STR_NULL_TERMINATE (x) \
@@ -200,9 +201,16 @@ static int bcm963xx_parse_imagetag_partitions(struct mtd_info *master,return nrparts; } +static const struct of_device_id parse_bcm963xx_imagetag_match_table[] = { + { .compatible ="brcm,bcm963xx-imagetag" }, + {}, +}; +MODULE_DEVICE_TABLE (of, parse_bcm963xx_imagetag_match_table); +static struct mtd_part_parser bcm963xx_imagetag_parser = { .parse_fn = bcm963xx_parse_imagetag_partitions, .name ="bcm963xx-imagetag" , + .of_match_table = parse_bcm963xx_imagetag_match_table, };module_mtd_part_parser (bcm963xx_imagetag_parser);
Signature · 6 lines
2.13.2 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH V2 5/5] mtd: parser_imagetag: add of_match_table support
Quoted 5 lines · Jonas Gorski
Allow matching the imagetag parser for fixed partitions defined in the device tree.
Reviewed-by Rob Herring <[email protected]>Signed-off-by Jonas Gorski <[email protected]>
Signature · 5 lines
Florian ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/