Discussion:
[PATCH 2/3 v2] mtd: partitions: Add RedBoot FIS DT bindings
Linus Walleij
2018-11-10 20:01:26 UTC
Permalink
This adds device tree bindings for the RedBoot FIS partition
format.

Cc: ***@vger.kernel.org
Reviewed-by: Rob Herring <***@kernel.org>
Signed-off-by: Linus Walleij <***@linaro.org>
---
ChangeLog v1->v2:
- Rebased on linux-mtd-next for v4.21
- Collected Rob's ACK
---
.../bindings/mtd/partitions/redboot-fis.txt | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 Documentation/devicetree/bindings/mtd/partitions/redboot-fis.txt

diff --git a/Documentation/devicetree/bindings/mtd/partitions/redboot-fis.txt b/Documentation/devicetree/bindings/mtd/partitions/redboot-fis.txt
new file mode 100644
index 000000000000..fd0ebe4e3415
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/partitions/redboot-fis.txt
@@ -0,0 +1,27 @@
+RedBoot FLASH Image System (FIS) Partitions
+===========================================
+
+The FLASH Image System (FIS) directory is a flash description
+format closely associated with the RedBoot boot loader.
+
+It uses one single flash eraseblock in the flash to store an index of
+all images in the flash.
+
+This block size will vary depending on flash but is typically
+32 KB in size.
+
+Required properties:
+- compatible : (required) must be "redboot-fis"
+- fis-index-block : (required) a index to the eraseblock containing
+ the FIS directory on this device. On a flash memory with 32KB
+ eraseblocks, 0 means the first eraseblock at 0x00000000, 1 means the
+ second eraseblock at 0x00008000 and so on.
+
+Example:
+
+***@0 {
+ partitions {
+ compatible = "redboot-fis";
+ fis-index-block = <0>;
+ };
+};
--
2.19.1
Linus Walleij
2018-11-10 20:01:27 UTC
Permalink
This adds device tree support for RedBoot partitioning. We
read out the FIS directory block information from the device
tree and then parse the partition table from there.

Signed-off-by: Linus Walleij <***@linaro.org>
---
ChangeLog v1->v2:
- Rebased on linux-mtd-next for v4.21
---
drivers/mtd/parsers/redboot.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/parsers/redboot.c b/drivers/mtd/parsers/redboot.c
index 7623ac5fc586..fb816825aa19 100644
--- a/drivers/mtd/parsers/redboot.c
+++ b/drivers/mtd/parsers/redboot.c
@@ -25,7 +25,7 @@
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/vmalloc.h>
-
+#include <linux/of.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/module.h>
@@ -56,6 +56,31 @@ static inline int redboot_checksum(struct fis_image_desc *img)
return 1;
}

+#ifdef CONFIG_OF
+static void parse_redboot_of(struct mtd_info *master)
+{
+ struct device_node *np;
+ u32 dirblock;
+ int ret;
+
+ np = mtd_get_of_node(master);
+ if (!np)
+ return;
+ ret = of_property_read_u32(np, "fis-index-block", &dirblock);
+ if (ret)
+ return;
+ /*
+ * Assign the block found in the device tree to the local
+ * directory block pointer.
+ */
+ directory = dirblock;
+}
+#else
+static void parse_redboot_of(struct mtd_info *master)
+{
+}
+#endif
+
static int parse_redboot_partitions(struct mtd_info *master,
const struct mtd_partition **pparts,
struct mtd_part_parser_data *data)
@@ -75,6 +100,7 @@ static int parse_redboot_partitions(struct mtd_info *master,
#ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
static char nullstring[] = "unallocated";
#endif
+ parse_redboot_of(master);

if ( directory < 0 ) {
offset = master->size + directory * master->erasesize;
@@ -289,9 +315,16 @@ static int parse_redboot_partitions(struct mtd_info *master,
return ret;
}

+static const struct of_device_id mtd_parser_redboot_of_match_table[] = {
+ { .compatible = "redboot-fis" },
+ {},
+};
+MODULE_DEVICE_TABLE(of, mtd_parser_trx_of_match_table);
+
static struct mtd_part_parser redboot_parser = {
.parse_fn = parse_redboot_partitions,
.name = "RedBoot",
+ .of_match_table = mtd_parser_redboot_of_match_table,
};
module_mtd_part_parser(redboot_parser);
--
2.19.1
Boris Brezillon
2018-11-15 19:19:26 UTC
Permalink
This moves the Redboot partition parser down to the parsers
subdirectory.
Applied to http://git.infradead.org/linux-mtd.git mtd/next, thanks.

Boris
Boris Brezillon
2018-11-15 19:19:21 UTC
Permalink
Post by Linus Walleij
This adds device tree bindings for the RedBoot FIS partition
format.
Applied to http://git.infradead.org/linux-mtd.git mtd/next, thanks.

Boris

Loading...