Enable access to memory resources not only via I/O address using reg,
but also through a portion of main memory using memory-region. To
achieve this, new compatible strings have been introduced: mtd-mem and
mtd-memro.
Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
---
.../devicetree/bindings/mtd/mtd-physmap.yaml | 59 +++++++++++++++-------
1 file changed, 40 insertions(+), 19 deletions(-)
diff --git a/Documentation/devicetree/bindings/mtd/mtd-physmap.yaml b/Documentation/devicetree/bindings/mtd/mtd-physmap.yaml
index 1b375dee83b0c..0f75a1204b263 100644
--- a/Documentation/devicetree/bindings/mtd/mtd-physmap.yaml
+++ b/Documentation/devicetree/bindings/mtd/mtd-physmap.yaml
@@ -13,10 +13,6 @@ description: |
Flash chips (Memory Technology Devices) are often used for solid state
file systems on embedded devices.
-allOf:
- - $ref: mtd.yaml#
- - $ref: /schemas/memory-controllers/mc-peripheral-props.yaml#
-
properties:
compatible:
oneOf:
@@ -61,6 +57,8 @@ properties:
- jedec-flash
- mtd-ram
- mtd-rom
+ - mtd-mem
+ - mtd-memro
reg:
description: |
@@ -116,6 +114,10 @@ properties:
minItems: 1
maxItems: 8
+ memory-region:
+ items:
+ - description: Memory regions to map into mtd
+
'#address-cells':
const: 1
@@ -129,21 +131,25 @@ properties:
required:
- compatible
- - reg
-
-if:
- properties:
- compatible:
- contains:
- const: cortina,gemini-flash
-then:
- properties:
- syscon:
- $ref: /schemas/types.yaml#/definitions/phandle
- description:
- Phandle to the syscon controller
- required:
- - syscon
+
+allOf:
+ - $ref: mtd.yaml#
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - mtd-mem
+ - mtd-memro
+ then:
+ required:
+ - memory-region
+ properties:
+ addr-gpios: false
+ else:
+ $ref: /schemas/memory-controllers/mc-peripheral-props.yaml#
+ required:
+ - reg
unevaluatedProperties: false
@@ -223,4 +229,19 @@ examples:
reg = <0 0x04000000>;
};
};
+
+ - |
+ /* An example using mtd-mem */
+ mem_logs: mem_logs@10000800 {
+ reg = <0x1 0x0000800 0x0 0x000f800>;
+ no-map;
+ };
+
+ sram {
+ compatible = "mtd-mem";
+ memory-region = <&mem_log>;
+ bank-width = <4>;
+ device-width = <1>;
+ };
+
...
--
2.51.0
On Mon, Nov 17, 2025 at 06:00:15PM +0100, Gregory CLEMENT wrote:
> Enable access to memory resources not only via I/O address using reg,
> but also through a portion of main memory using memory-region. To
> achieve this, new compatible strings have been introduced: mtd-mem and
> mtd-memro.
>
> Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
> ---
> .../devicetree/bindings/mtd/mtd-physmap.yaml | 59 +++++++++++++++-------
> 1 file changed, 40 insertions(+), 19 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/mtd/mtd-physmap.yaml b/Documentation/devicetree/bindings/mtd/mtd-physmap.yaml
> index 1b375dee83b0c..0f75a1204b263 100644
> --- a/Documentation/devicetree/bindings/mtd/mtd-physmap.yaml
> +++ b/Documentation/devicetree/bindings/mtd/mtd-physmap.yaml
> @@ -13,10 +13,6 @@ description: |
> Flash chips (Memory Technology Devices) are often used for solid state
> file systems on embedded devices.
>
> -allOf:
> - - $ref: mtd.yaml#
> - - $ref: /schemas/memory-controllers/mc-peripheral-props.yaml#
> -
> properties:
> compatible:
> oneOf:
> @@ -61,6 +57,8 @@ properties:
> - jedec-flash
> - mtd-ram
> - mtd-rom
> + - mtd-mem
> + - mtd-memro
I thought we had a flag for read only.
>
> reg:
> description: |
> @@ -116,6 +114,10 @@ properties:
> minItems: 1
> maxItems: 8
>
> + memory-region:
> + items:
> + - description: Memory regions to map into mtd
> +
> '#address-cells':
> const: 1
>
> @@ -129,21 +131,25 @@ properties:
>
> required:
> - compatible
> - - reg
> -
> -if:
> - properties:
> - compatible:
> - contains:
> - const: cortina,gemini-flash
> -then:
> - properties:
> - syscon:
> - $ref: /schemas/types.yaml#/definitions/phandle
> - description:
> - Phandle to the syscon controller
> - required:
> - - syscon
> +
> +allOf:
> + - $ref: mtd.yaml#
> + - if:
> + properties:
> + compatible:
> + contains:
> + enum:
> + - mtd-mem
> + - mtd-memro
> + then:
> + required:
> + - memory-region
> + properties:
> + addr-gpios: false
> + else:
> + $ref: /schemas/memory-controllers/mc-peripheral-props.yaml#
> + required:
> + - reg
>
> unevaluatedProperties: false
>
> @@ -223,4 +229,19 @@ examples:
> reg = <0 0x04000000>;
> };
> };
> +
> + - |
> + /* An example using mtd-mem */
> + mem_logs: mem_logs@10000800 {
> + reg = <0x1 0x0000800 0x0 0x000f800>;
> + no-map;
> + };
> +
> + sram {
It's really an abuse of /reserved-memory to define regions outside of
what's defined in /memory nodes (or whatever defines system memory). Is
that the case here with the suspicious 'sram'?
If we do keep this, I'd rather just add the properties below into the
/reserved-memory node itself. Devices are created for those nodes if
they have 'compatible'.
> + compatible = "mtd-mem";
> + memory-region = <&mem_log>;
> + bank-width = <4>;
> + device-width = <1>;
> + };
> +
> ...
>
> --
> 2.51.0
>
Rob Herring <robh@kernel.org> writes:
> On Mon, Nov 17, 2025 at 06:00:15PM +0100, Gregory CLEMENT wrote:
>> Enable access to memory resources not only via I/O address using reg,
>> but also through a portion of main memory using memory-region. To
>> achieve this, new compatible strings have been introduced: mtd-mem and
>> mtd-memro.
>>
>> Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
>> ---
>> .../devicetree/bindings/mtd/mtd-physmap.yaml | 59 +++++++++++++++-------
>> 1 file changed, 40 insertions(+), 19 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/mtd/mtd-physmap.yaml b/Documentation/devicetree/bindings/mtd/mtd-physmap.yaml
>> index 1b375dee83b0c..0f75a1204b263 100644
>> --- a/Documentation/devicetree/bindings/mtd/mtd-physmap.yaml
>> +++ b/Documentation/devicetree/bindings/mtd/mtd-physmap.yaml
>> @@ -13,10 +13,6 @@ description: |
>> Flash chips (Memory Technology Devices) are often used for solid state
>> file systems on embedded devices.
>>
>> -allOf:
>> - - $ref: mtd.yaml#
>> - - $ref: /schemas/memory-controllers/mc-peripheral-props.yaml#
>> -
>> properties:
>> compatible:
>> oneOf:
>> @@ -61,6 +57,8 @@ properties:
>> - jedec-flash
>> - mtd-ram
>> - mtd-rom
>> + - mtd-mem
>> + - mtd-memro
>
> I thought we had a flag for read only.
The read-only flag is set at the partition level, not the device level.
>
>>
>> reg:
>> description: |
>> @@ -116,6 +114,10 @@ properties:
>> minItems: 1
>> maxItems: 8
>>
>> + memory-region:
>> + items:
>> + - description: Memory regions to map into mtd
>> +
>> '#address-cells':
>> const: 1
>>
>> @@ -129,21 +131,25 @@ properties:
>>
>> required:
>> - compatible
>> - - reg
>> -
>> -if:
>> - properties:
>> - compatible:
>> - contains:
>> - const: cortina,gemini-flash
>> -then:
>> - properties:
>> - syscon:
>> - $ref: /schemas/types.yaml#/definitions/phandle
>> - description:
>> - Phandle to the syscon controller
>> - required:
>> - - syscon
>> +
>> +allOf:
>> + - $ref: mtd.yaml#
>> + - if:
>> + properties:
>> + compatible:
>> + contains:
>> + enum:
>> + - mtd-mem
>> + - mtd-memro
>> + then:
>> + required:
>> + - memory-region
>> + properties:
>> + addr-gpios: false
>> + else:
>> + $ref: /schemas/memory-controllers/mc-peripheral-props.yaml#
>> + required:
>> + - reg
>>
>> unevaluatedProperties: false
>>
>> @@ -223,4 +229,19 @@ examples:
>> reg = <0 0x04000000>;
>> };
>> };
>> +
>> + - |
>> + /* An example using mtd-mem */
>> + mem_logs: mem_logs@10000800 {
>> + reg = <0x1 0x0000800 0x0 0x000f800>;
>> + no-map;
>> + };
>> +
>> + sram {
>
> It's really an abuse of /reserved-memory to define regions outside of
> what's defined in /memory nodes (or whatever defines system memory). Is
> that the case here with the suspicious 'sram'?
>
> If we do keep this, I'd rather just add the properties below into the
> /reserved-memory node itself. Devices are created for those nodes if
> they have 'compatible'.
The name is indeed misleading. I drew inspiration from the example
above, but the actual use case was to share data between the kernel and
bootloader, for instance. Therefore, it is truly part of the main
memory. I will modify the name accordingly.
Thanks,
Gregory
>
>
>> + compatible = "mtd-mem";
>> + memory-region = <&mem_log>;
>> + bank-width = <4>;
>> + device-width = <1>;
>> + };
>> +
>> ...
>>
>> --
>> 2.51.0
>>
--
Grégory CLEMENT, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
© 2016 - 2025 Red Hat, Inc.