devicetree: flash-partitions: expose helper macros
Make generally available the macro that provides the flash device in which a particular partition can be found. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
ba24cd2f0f
commit
e571c88565
3 changed files with 36 additions and 13 deletions
|
@ -10,19 +10,10 @@
|
|||
#include <zephyr.h>
|
||||
#include <storage/flash_map.h>
|
||||
|
||||
/* Get the grand parent of a node */
|
||||
#define GPARENT(node_id) DT_PARENT(DT_PARENT(node_id))
|
||||
|
||||
/* return great-grandparent label if 'soc-nv-flash' else grandparent label */
|
||||
#define DT_FLASH_DEV_FROM_PARTITION(part) \
|
||||
DT_LABEL(COND_CODE_1(DT_NODE_HAS_COMPAT(GPARENT(part), soc_nv_flash), \
|
||||
(DT_PARENT(GPARENT(part))), \
|
||||
(GPARENT(part))))
|
||||
|
||||
#define FLASH_AREA_FOO(part) \
|
||||
{.fa_id = DT_FIXED_PARTITION_ID(part), \
|
||||
.fa_off = DT_REG_ADDR(part), \
|
||||
.fa_dev_name = DT_FLASH_DEV_FROM_PARTITION(part), \
|
||||
#define FLASH_AREA_FOO(part) \
|
||||
{.fa_id = DT_FIXED_PARTITION_ID(part), \
|
||||
.fa_off = DT_REG_ADDR(part), \
|
||||
.fa_dev_name = DT_LABEL(DT_MTD_FROM_FIXED_PARTITION(part)), \
|
||||
.fa_size = DT_REG_SIZE(part),},
|
||||
|
||||
#define FOREACH_PARTITION(n) DT_FOREACH_CHILD(DT_DRV_INST(n), FLASH_AREA_FOO)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue