Skip to content

Commit a02056c

Browse files
committed
[nrf fromlist] dts: bindings: Update Nordic owned memory bindings
Upstream PR: zephyrproject-rtos/zephyr#72273 This concerns both `nordic,owned-memory` and `nordic,owned-partitions`. Introduce a property named `nordic,access`, which is meant to replace the `owner-id` and `perm-*` properties. It allows for describing how multiple domains should access a single memory region, possibly with different permissions per owner, but without having to create more than one DT node for this purpose. This change is also motivated by updated memory protection requirements on the nRF54H20, which mandate that a given memory region must only be reserved by one domain, even if multiple domains can have access to it. This restriction is now described in the binding itself. Signed-off-by: Grzegorz Swiderski <[email protected]> (cherry picked from commit 2b6fe5ea89034f4b1a0222edaa2b1434ac70b78c)
1 parent ae75e9e commit a02056c

File tree

5 files changed

+125
-10
lines changed

5 files changed

+125
-10
lines changed

dts/bindings/mtd/nordic,owned-partitions.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ description: |
2424
2525
rx-partitions {
2626
compatible = "nordic,owned-partitions";
27-
perm-read;
28-
perm-execute;
27+
nordic,access = <NRF_OWNER_ID_APPLICATION NRF_PERM_RX>;
2928
#address-cells = <1>;
3029
#size-cells = <1>;
3130
@@ -37,8 +36,7 @@ description: |
3736
3837
rw-partitions {
3938
compatible = "nordic,owned-partitions";
40-
perm-read;
41-
perm-write;
39+
nordic,access = <NRF_OWNER_ID_APPLICATION NRF_PERM_RW>;
4240
#address-cells = <1>;
4341
#size-cells = <1>;
4442

dts/bindings/reserved-memory/nordic,owned-memory.yaml

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,64 @@ description: |
88
will be recorded in the UICR of the compiled domain. Memory ownership and
99
access is then configured for the domain at boot time, based on the UICR.
1010
11+
Example:
12+
13+
reserved-memory {
14+
memory@2fc00000 {
15+
compatible = "nordic,owned-memory";
16+
reg = <0x2fc00000 0x1000>;
17+
status = "okay";
18+
nordic,access = <NRF_OWNER_ID_APPLICATION NRF_PERM_R>,
19+
<NRF_OWNER_ID_RADIOCORE NRF_PERM_W>;
20+
};
21+
};
22+
23+
A single local domain can request a memory region to be reserved on behalf of
24+
multiple access owners. A single memory region shall be reserved by at most
25+
one domain, by setting status "okay" on the associated node. For example, if
26+
the region defined above is enabled by Application on behalf of Radiocore,
27+
then the Radiocore's devicetree must set status "disabled" on that node.
28+
29+
Each of the different owners may have a different set of permissions granted,
30+
as also shown above.
31+
32+
Note: one domain can also reserve memory for another domain and not itself.
33+
Whichever domain has status "okay" set on the node does not need to be listed
34+
as one of the access owners.
35+
1136
compatible: "nordic,owned-memory"
1237

13-
include: base.yaml
38+
include: [base.yaml, "zephyr,memory-common.yaml"]
1439

1540
properties:
1641
reg:
1742
required: true
1843

44+
nordic,access:
45+
type: array
46+
description: |
47+
Array of (owner-id, permission-flags) pairs, where:
48+
49+
- Owner ID represents the domain that will have access to this memory.
50+
Valid values can be found in dts/common/nordic/<soc>.dtsi,
51+
where they are defined as NRF_OWNER_ID_*
52+
53+
- Permissions are encoded as a 32-bit bitfield, using the flags found in
54+
include/zephyr/dt-bindings/reserved-memory/nordic-owned-memory.h,
55+
where they are defined as NRF_PERM_*
56+
57+
The same file defines all possible permission flag combinations.
58+
For example, one can use:
59+
<NRF_OWNER_ID_APPLICATION NRF_PERM_RWX>
60+
61+
as a shorthand for:
62+
<NRF_OWNER_ID_APPLICATION (NRF_PERM_R | NRF_PERM_W | NRF_PERM_X)>
63+
1964
owner-id:
2065
type: int
66+
deprecated: true
2167
description: |
68+
Deprecated, applies only if 'nordic,access' is not defined.
2269
Owner ID of the domain that will own this memory region. If not defined,
2370
the ownership will default to the domain being compiled.
2471
@@ -27,20 +74,35 @@ properties:
2774
2875
perm-read:
2976
type: boolean
30-
description: Owner has read access to the region.
77+
deprecated: true
78+
description: |
79+
Deprecated, applies only if 'nordic,access' is not defined.
80+
Owner has read access to the region.
3181
3282
perm-write:
3383
type: boolean
34-
description: Owner has write access to the region.
84+
deprecated: true
85+
description: |
86+
Deprecated, applies only if 'nordic,access' is not defined.
87+
Owner has write access to the region.
3588
3689
perm-execute:
3790
type: boolean
38-
description: Owner can execute code from the region.
91+
deprecated: true
92+
description: |
93+
Deprecated, applies only if 'nordic,access' is not defined.
94+
Owner can execute code from the region.
3995
4096
perm-secure:
4197
type: boolean
42-
description: Owner has secure-only access to the region.
98+
deprecated: true
99+
description: |
100+
Deprecated, applies only if 'nordic,access' is not defined.
101+
Owner has secure-only access to the region.
43102
44103
non-secure-callable:
45104
type: boolean
46-
description: Memory region is used for non-secure-callable code.
105+
deprecated: true
106+
description: |
107+
Deprecated, applies only if 'nordic,access' is not defined.
108+
Memory region is used for non-secure-callable code.

dts/common/nordic/nrf54h20.dtsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <zephyr/dt-bindings/misc/nordic-domain-id-nrf54h20.h>
1212
#include <zephyr/dt-bindings/misc/nordic-owner-id-nrf54h20.h>
1313
#include <zephyr/dt-bindings/misc/nordic-tddconf.h>
14+
#include <zephyr/dt-bindings/reserved-memory/nordic-owned-memory.h>
1415

1516
/delete-node/ &sw_pwm;
1617

dts/common/nordic/nrf9280.dtsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <zephyr/dt-bindings/misc/nordic-nrf-ficr-nrf9230-engb.h>
1111
#include <zephyr/dt-bindings/misc/nordic-domain-id-nrf9230.h>
1212
#include <zephyr/dt-bindings/misc/nordic-owner-id-nrf9230.h>
13+
#include <zephyr/dt-bindings/reserved-memory/nordic-owned-memory.h>
1314

1415
/delete-node/ &sw_pwm;
1516

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_RESERVED_MEMORY_NORDIC_OWNED_MEMORY_H_
7+
#define ZEPHYR_INCLUDE_DT_BINDINGS_RESERVED_MEMORY_NORDIC_OWNED_MEMORY_H_
8+
9+
#include <zephyr/dt-bindings/dt-util.h>
10+
11+
/**
12+
* @name Basic memory permission flags.
13+
* @{
14+
*/
15+
16+
/** Readable. */
17+
#define NRF_PERM_R BIT(0)
18+
/** Writable. */
19+
#define NRF_PERM_W BIT(1)
20+
/** Executable. */
21+
#define NRF_PERM_X BIT(2)
22+
/** Secure-only. */
23+
#define NRF_PERM_S BIT(3)
24+
/** Non-secure-callable. */
25+
#define NRF_PERM_NSC BIT(4)
26+
27+
/**
28+
* @}
29+
*/
30+
31+
/**
32+
* @name Memory permission flag combinations.
33+
* @note NRF_PERM_NSC overrides all other flags, so it is not included here.
34+
* @{
35+
*/
36+
37+
#define NRF_PERM_RW (NRF_PERM_R | NRF_PERM_W)
38+
#define NRF_PERM_RX (NRF_PERM_R | NRF_PERM_X)
39+
#define NRF_PERM_RS (NRF_PERM_R | NRF_PERM_S)
40+
#define NRF_PERM_WX (NRF_PERM_W | NRF_PERM_X)
41+
#define NRF_PERM_WS (NRF_PERM_W | NRF_PERM_S)
42+
#define NRF_PERM_XS (NRF_PERM_X | NRF_PERM_S)
43+
#define NRF_PERM_RWX (NRF_PERM_R | NRF_PERM_W | NRF_PERM_X)
44+
#define NRF_PERM_RWS (NRF_PERM_R | NRF_PERM_W | NRF_PERM_S)
45+
#define NRF_PERM_RXS (NRF_PERM_R | NRF_PERM_X | NRF_PERM_S)
46+
#define NRF_PERM_WXS (NRF_PERM_W | NRF_PERM_X | NRF_PERM_S)
47+
#define NRF_PERM_RWXS (NRF_PERM_R | NRF_PERM_W | NRF_PERM_X | NRF_PERM_S)
48+
49+
/**
50+
* @}
51+
*/
52+
53+
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_RESERVED_MEMORY_NORDIC_OWNED_MEMORY_H_ */

0 commit comments

Comments
 (0)