Skip to content

Commit 81c33ad

Browse files
committed
scripts: dts: Add handling for *-map property
This change introduces generating definitions corresponding to `*-map` property, which was currently discarded. For `*-map` properties are made able to be treated as a variation of phandle-array, assign sequential cell names for each group of specifiers (child_specifier_0, child_specifier_1, ..., parent_specifier_0, ...). The `*-map` data is like a two-dimensional array, so it is difficult to handle with the existing APIs, so we will also provide new APIs. Signed-off-by: TOKITA Hiroshi <[email protected]>
1 parent 71b9134 commit 81c33ad

File tree

5 files changed

+749
-0
lines changed

5 files changed

+749
-0
lines changed

doc/build/dts/macros.bnf

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ node-macro = property-macro
2222
node-macro =/ pinctrl-macro
2323
; A macro about the GPIO hog properties in a node.
2424
node-macro =/ gpiohogs-macro
25+
; A macro about the map properties in a node.
26+
node-macro =/ map-macro
2527
; EXISTS macro: node exists in the devicetree
2628
node-macro =/ %s"DT_N" path-id %s"_EXISTS"
2729
; Bus macros: the plain BUS is a way to access a node's bus controller.
@@ -231,6 +233,71 @@ gpiohogs-macro =/ %s"DT_N" path-id %s"_GPIO_HOGS_IDX_" DIGIT %s"_VAL_flags_EXIST
231233
; #define DT_N_<node-2 path>_GPIO_HOGS_IDX_0_VAL_flags 0x30
232234
gpiohogs-macro =/ %s"DT_N" path-id %s"_GPIO_HOGS_IDX_" DIGIT %s"_VAL_flags"
233235

236+
237+
; --------------------------------------------------------------------
238+
; map-macro: a macro related to map properties
239+
;
240+
; Macros are generated when there is a property ending with '-map' as shown below.
241+
;
242+
; connector {
243+
; ...
244+
; interrupt-map = <0 1 &intc0 2 3>;
245+
; };
246+
;
247+
; The existence of map entry;
248+
;
249+
; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_EXISTS 1
250+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT "_EXISTS"
251+
;
252+
; The child addrsss length, value, and existence.
253+
;
254+
; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_ADDRESS_LEN 1
255+
; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_ADDRESS_IDX_0 0
256+
; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_ADDRESS_IDX_0_EXISTS 1
257+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_ADDRESS_LEN"
258+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_ADDRESS_IDX_" DIGIT
259+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_ADDRESS_IDX_" DIGIT %s"_EXISTS"
260+
;
261+
; The length of child specifiers length, value, and existence.
262+
;
263+
; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_SPECIFIER_LEN 1
264+
; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_SPECIFIER_IDX_0_EXISTS 1
265+
; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_SPECIFIER_IDX_0 0
266+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_SPECIFIER_LEN"
267+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_SPECIFIER_IDX_" DIGIT
268+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_SPECIFIER_IDX_" DIGIT "_EXISTS"
269+
;
270+
; The parent node of this map.
271+
;
272+
; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT DT_N_S_gpio_emul
273+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT"
274+
;
275+
; The length of parent addrsss, value, and existence.
276+
;
277+
; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_ADDRESS_LEN 1
278+
; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_ADDRESS_IDX_0 2
279+
; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_ADDRESS_IDX_0_EXISTS 1
280+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_ADDRESS_LEN"
281+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_ADDRESS_IDX_" DIGIT
282+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_ADDRESS_IDX_" DIGIT "_EXISTS"
283+
;
284+
; The length of parent specifiers length, value, and existence.
285+
;
286+
; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_SPECIFIER_LEN 1
287+
; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_SPECIFIER_IDX_0_EXISTS 1
288+
; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_SPECIFIER_IDX_0 3
289+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_SPECIFIER_LEN"
290+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_SPECIFIER_IDX_" DIGIT
291+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_SPECIFIER_IDX_" DIGIT "_EXISTS"
292+
;
293+
; Iteration helpers for map.
294+
;
295+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_FOREACH_MAP_ENTRY"
296+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_FOREACH_MAP_ENTRY_SEP"
297+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_FOREACH_MAP_ENTRY_VARGS"
298+
map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_FOREACH_MAP_ENTRY_SEP_VARGS"
299+
300+
234301
; --------------------------------------------------------------------
235302
; property-macro: a macro related to a node property
236303
;

include/zephyr/devicetree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5571,5 +5571,6 @@
55715571
#include <zephyr/devicetree/port-endpoint.h>
55725572
#include <zephyr/devicetree/display.h>
55735573
#include <zephyr/devicetree/hwspinlock.h>
5574+
#include <zephyr/devicetree/map.h>
55745575

55755576
#endif /* ZEPHYR_INCLUDE_DEVICETREE_H_ */

0 commit comments

Comments
 (0)