Skip to contentSkip to conversation

Add support for Sercomm partitions

PATCH Superseded Mikhail Zhilkin 2 participants 6 messages May 16, 2022 – May 17, 2022

Subsystems (2)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover Add support for Sercomm partitions

This patch series add support for Sercomm mtd partition table parser. It's used in some Beeline, Netgear and Sercomm routers. The Sercomm partition map table contains real partition offsets, which may differ from device to device depending on the number and location of bad blocks on NAND.

Changes since:
v4:
- Add Acked-by to the first patch

v3:
- Fix commit message of the first patch
- Add Reviewed-by to the second patch

v2:
- Fix mistakes in dt-binding
- Add patch for new vendor prefix
- Add vendor prefix to scpart-id property

v1:
- Add dt-binding in a separate patch
- Remove redundant braces and logical NOT operator
- Define pr_fmt
- Replace kcalloc by kzalloc
- Use of_get_child_count() and alloc big enough array before the for_each_child_of_node()

Mikhail Zhilkin (3):
dt-bindings: Add Sercomm (Suzhou) Corporation vendor prefix
dt-bindings: mtd: partitions: Extend fixed-partitions binding
mtd: parsers: add support for Sercomm partitions

 .../mtd/partitions/fixed-partitions.yaml      |  55 +++-
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 drivers/mtd/parsers/Kconfig                   |   9 +
 drivers/mtd/parsers/Makefile                  |   1 +
 drivers/mtd/parsers/scpart.c                  | 240 ++++++++++++++++++
 5 files changed, 305 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mtd/parsers/scpart.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH v5 1/3 dt-bindings: Add Sercomm (Suzhou) Corporation vendor prefix

Add "sercomm" vendor prefix for "Sercomm (Suzhou) Corporation".

Company website:

---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index 01430973ecec..65ff22364fb3 100644
@@ -1082,6 +1082,8 @@ patternProperties:
     description: Sensirion AG
   "^sensortek,.*":
     description: Sensortek Technology Corporation
+  "^sercomm,.*":
+    description: Sercomm (Suzhou) Corporation
   "^sff,.*":
     description: Small Form Factor Committee
   "^sgd,.*":
Signature · 1 line
2.25.1
#2 lore raw

PATCH v5 2/3 dt-bindings: mtd: partitions: Extend fixed-partitions binding

In reply to Mikhail Zhilkin

Extend fixed-partitions binding for support of Sercomm partition parser (add "sercomm,sc-partitions" compatible).

---
 .../mtd/partitions/fixed-partitions.yaml      | 55 ++++++++++++++++++-
 1 file changed, 53 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml +53 -2
index ea4cace6a955..ad3ccd250802 100644
@@ -19,7 +19,11 @@ maintainers:
 
 properties:
   compatible:
-    const: fixed-partitions
+    oneOf:
+      - const: fixed-partitions
+      - items:
+          - const: sercomm,sc-partitions
+          - const: fixed-partitions
 
   "#address-cells": true
 
@@ -27,7 +31,24 @@ properties:
 
 patternProperties:
   "@[0-9a-f]+$":
-    $ref: "partition.yaml#"
+    allOf:
+      - $ref: "partition.yaml#"
+      - if:
+          properties:
+            compatible:
+              contains:
+                const: sercomm,sc-partitions
+        then:
+          properties:
+            sercomm,scpart-id:
+              description: Partition id in Sercomm partition map. Mtd
+                parser uses this id to find a record in the partition map
+                containing offset and size of the current partition. The
+                values from partition map overrides partition offset and
+                size defined in reg property of the dts. Frequently these
+                values are the same, but may differ if device has bad
+                eraseblocks on a flash.
+              $ref: /schemas/types.yaml#/definitions/uint32
 
 required:
   - "#address-cells"
@@ -52,6 +73,7 @@ examples:
             reg = <0x0100000 0x200000>;
         };
     };
+
   - |
     partitions {
         compatible = "fixed-partitions";
@@ -64,6 +86,7 @@ examples:
             reg = <0x00000000 0x1 0x00000000>;
         };
     };
+
   - |
     partitions {
         compatible = "fixed-partitions";
@@ -82,6 +105,7 @@ examples:
             reg = <0x2 0x00000000 0x1 0x00000000>;
         };
     };
+
   - |
     partitions {
         compatible = "fixed-partitions";
@@ -119,3 +143,30 @@ examples:
             };
         };
     };
+
+  - |
+    partitions {
+        compatible = "sercomm,sc-partitions", "fixed-partitions";
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        partition@0 {
+            label = "u-boot";
+            reg = <0x0 0x100000>;
+            sercomm,scpart-id = <0>;
+            read-only;
+        };
+
+        partition@100000 {
+            label = "dynamic partition map";
+            reg = <0x100000 0x100000>;
+            sercomm,scpart-id = <1>;
+        };
+
+        partition@200000 {
+            label = "Factory";
+            reg = <0x200000 0x100000>;
+            sercomm,scpart-id = <2>;
+            read-only;
+        };
+    };
Signature · 1 line
2.25.1
#3 lore raw

PATCH v5 3/3 mtd: parsers: add support for Sercomm partitions

In reply to Mikhail Zhilkin

This adds an MTD partition parser for the Sercomm partition table that is used in some Beeline, Netgear and Sercomm routers.

The Sercomm partition map table contains real partition offsets, which may differ from device to device depending on the number and location of bad blocks on NAND.

This is essentially the same code as proposed by NOGUCHI Hiroshi:

---
 drivers/mtd/parsers/Kconfig  |   9 ++
 drivers/mtd/parsers/Makefile |   1 +
 drivers/mtd/parsers/scpart.c | 240 +++++++++++++++++++++++++++++++++++
 3 files changed, 250 insertions(+)
 create mode 100644 drivers/mtd/parsers/scpart.c
drivers/mtd/parsers/Kconfig +9 -0
index 23763d16e4f9..851f4670d89b 100644
@@ -186,3 +186,12 @@ config MTD_QCOMSMEM_PARTS
 	help
 	  This provides support for parsing partitions from Shared Memory (SMEM)
 	  for NAND and SPI flash on Qualcomm platforms.
+
+config MTD_SERCOMM_PARTS
+	tristate "Sercomm partition table parser"
+	depends on MTD
+	help
+	  This provides partitions table parser for devices with Sercomm
+	  partition map. This partition table contains real partition
+	  offsets, which may differ from device to device depending on the
+	  number and location of bad blocks on NAND.
drivers/mtd/parsers/Makefile +1 -0
index 2e98aa048278..2fcf0ab9e7da 100644
@@ -10,6 +10,7 @@ ofpart-$(CONFIG_MTD_OF_PARTS_LINKSYS_NS)+= ofpart_linksys_ns.o
 obj-$(CONFIG_MTD_PARSER_IMAGETAG)	+= parser_imagetag.o
 obj-$(CONFIG_MTD_AFS_PARTS)		+= afs.o
 obj-$(CONFIG_MTD_PARSER_TRX)		+= parser_trx.o
+obj-$(CONFIG_MTD_SERCOMM_PARTS)		+= scpart.o
 obj-$(CONFIG_MTD_SHARPSL_PARTS)		+= sharpslpart.o
 obj-$(CONFIG_MTD_REDBOOT_PARTS)		+= redboot.o
 obj-$(CONFIG_MTD_QCOMSMEM_PARTS)	+= qcomsmempart.o
drivers/mtd/parsers/scpart.c new file +240 -0

240 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#4 lore raw
In reply to Mikhail Zhilkin

Hi Mikhail,

[email protected] wrote on Mon, 16 May 2022 15:12:28 +0000:

Quoted 4 lines

This patch series add support for Sercomm mtd partition table parser. It's used in some Beeline, Netgear and Sercomm routers. The Sercomm partition map table contains real partition offsets, which may differ from device to device depending on the number and location of bad blocks on NAND.

Series applied in place of the previous version on mtd/next.

Quoted 27 lines

Changes since:
v4:
- Add Acked-by to the first patch

v3:
- Fix commit message of the first patch
- Add Reviewed-by to the second patch

v2:
- Fix mistakes in dt-binding
- Add patch for new vendor prefix
- Add vendor prefix to scpart-id property

v1:
- Add dt-binding in a separate patch
- Remove redundant braces and logical NOT operator
- Define pr_fmt
- Replace kcalloc by kzalloc
- Use of_get_child_count() and alloc big enough array before the for_each_child_of_node()

Mikhail Zhilkin (3):
dt-bindings: Add Sercomm (Suzhou) Corporation vendor prefix
dt-bindings: mtd: partitions: Extend fixed-partitions binding
mtd: parsers: add support for Sercomm partitions

Quoted 8 lines
 .../mtd/partitions/fixed-partitions.yaml      |  55 +++-
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 drivers/mtd/parsers/Kconfig                   |   9 +
 drivers/mtd/parsers/Makefile                  |   1 +
 drivers/mtd/parsers/scpart.c                  | 240 ++++++++++++++++++
 5 files changed, 305 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mtd/parsers/scpart.c

Thanks,
Miquèl

maintainer
#5 lore raw

Hello,

[email protected] wrote on Mon, 16 May 2022 18:42:17 +0200:

Quoted 10 lines

Hi Mikhail,

[email protected] wrote on Mon, 16 May 2022 15:12:28 +0000:

Quoted 4 lines

This patch series add support for Sercomm mtd partition table parser. It's used in some Beeline, Netgear and Sercomm routers. The Sercomm partition map table contains real partition offsets, which may differ from device to device depending on the number and location of bad blocks on NAND.

Series applied in place of the previous version on mtd/next.

Actually we have a new robot warning, so I've dropped patch 3/3 and kept the bindings for this release.

Thanks,
Miquèl

Quoted 40 lines
Quoted 28 lines

Changes since:
v4:
- Add Acked-by to the first patch

v3:
- Fix commit message of the first patch
- Add Reviewed-by to the second patch

v2:
- Fix mistakes in dt-binding
- Add patch for new vendor prefix
- Add vendor prefix to scpart-id property

v1:
- Add dt-binding in a separate patch
- Remove redundant braces and logical NOT operator
- Define pr_fmt
- Replace kcalloc by kzalloc
- Use of_get_child_count() and alloc big enough array before the for_each_child_of_node()

Mikhail Zhilkin (3):
dt-bindings: Add Sercomm (Suzhou) Corporation vendor prefix
dt-bindings: mtd: partitions: Extend fixed-partitions binding
mtd: parsers: add support for Sercomm partitions

Quoted 8 lines
 .../mtd/partitions/fixed-partitions.yaml      |  55 +++-
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 drivers/mtd/parsers/Kconfig                   |   9 +
 drivers/mtd/parsers/Makefile                  |   1 +
 drivers/mtd/parsers/scpart.c                  | 240 ++++++++++++++++++
 5 files changed, 305 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mtd/parsers/scpart.c

Thanks,
Miquèl