zephyr/tests/drivers
Carlo Caione e4a125b6a4 dt: Make zephyr,memory-attr a capabilities bitmask
This is the final step in making the `zephyr,memory-attr` property
actually useful.

The problem with the current implementation is that `zephyr,memory-attr`
is an enum type, this is making very difficult to use that to actually
describe the memory capabilities. The solution proposed in this PR is to
use the `zephyr,memory-attr` property as an OR-ed bitmask of memory
attributes.

With the change proposed in this PR it is possible in the DeviceTree to
mark the memory regions with a bitmask of attributes by using the
`zephyr,memory-attr` property. This property and the related memory
region can then be retrieved at run-time by leveraging a provided helper
library or the usual DT helpers.

The set of general attributes that can be specified in the property are
defined and explained in
`include/zephyr/dt-bindings/memory-attr/memory-attr.h` (the list can be
extended when needed).

For example, to mark a memory region in the DeviceTree as volatile,
non-cacheable, out-of-order:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_VOLATILE |
			       DT_MEM_NON_CACHEABLE |
			       DT_MEM_OOO )>;
   };

The `zephyr,memory-attr` property can also be used to set
architecture-specific custom attributes that can be interpreted at run
time. This is leveraged, among other things, to create MPU regions out
of DeviceTree defined memory regions on ARM, for example:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-region = "NOCACHE_REGION";
       zephyr,memory-attr = <( DT_ARM_MPU(ATTR_MPU_RAM_NOCACHE) )>;
   };

See `include/zephyr/dt-bindings/memory-attr/memory-attr-mpu.h` to see
how an architecture can define its own special memory attributes (in
this case ARM MPU).

The property can also be used to set custom software-specific
attributes. For example we can think of marking a memory region as
available to be used for memory allocation (not yet implemented):

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_NON_CACHEABLE |
			       DT_MEM_SW_ALLOCATABLE )>;
   };

Or maybe we can leverage the property to specify some alignment
requirements for the region:

   mem: memory@10000000 {
       compatible = "mmio-sram";
       reg = <0x10000000 0x1000>;
       zephyr,memory-attr = <( DT_MEM_CACHEABLE |
			       DT_MEM_SW_ALIGN(32) )>;
   };

The conventional and recommended way to deal and manage with memory
regions marked with attributes is by using the provided `mem-attr`
helper library by enabling `CONFIG_MEM_ATTR` (or by using the usual DT
helpers).

When this option is enabled the list of memory regions and their
attributes are compiled in a user-accessible array and a set of
functions is made available that can be used to query, probe and act on
regions and attributes, see `include/zephyr/mem_mgmt/mem_attr.h`

Note that the `zephyr,memory-attr` property is only a descriptive
property of the capabilities of the associated memory  region, but it
does not result in any actual setting for the memory to be set. The
user, code or subsystem willing to use this information to do some work
(for example creating an MPU region out of the property) must use either
the provided `mem-attr` library or the usual DeviceTree helpers to
perform the required work / setting.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-09-15 12:46:54 +02:00
..
adc dt: Make zephyr,memory-attr a capabilities bitmask 2023-09-15 12:46:54 +02:00
bbram
bc12
build_all tests: drivers: adc: increase RODATA region size 2023-09-14 08:32:46 -05:00
can tests: drivers: can: api: add esp32 wrover board 2023-08-16 10:25:49 +02:00
charger/sbs_charger charger: Sample sbs charger driver with tests 2023-09-07 13:03:13 -04:00
clock_control tests: drivers: clock_control: nrf_lf_clock_start: Clean up 2023-09-13 11:36:30 +02:00
console
coredump/coredump_api tests: coredump: unify identifiers of tests 2023-08-01 13:24:09 -04:00
counter tests: counter: counter_basic_api: Add support for rpi_pico boards 2023-09-13 16:18:44 +02:00
dac tests: drivers: dac: Verify dac on lpcxpresso55s36 board 2023-09-11 19:55:26 +02:00
disk test: arch: x86: update with new acpica interface 2023-09-07 09:42:38 +02:00
dma dt: Make zephyr,memory-attr a capabilities bitmask 2023-09-15 12:46:54 +02:00
eeprom tests: drivers: enable tests eeprom and i2c for mr_canhubk3 2023-07-27 12:32:07 -05:00
entropy/api tests: drivers: rename shadow variables 2023-08-10 08:14:12 +00:00
espi
ethernet/eth_ivshmem_queue
flash test: drivers: flash: build spi_nor.c wp & hold 2023-09-13 12:07:27 +02:00
flash_simulator tests flash simulator: Enable for native_sim 2023-07-10 09:50:56 +02:00
fuel_gauge drivers: fuelgauge: Add TI BQ27z746 driver 2023-09-13 12:05:04 +02:00
gpio tests: drivers: gpio: gpio_basic_api: Added intel_adl_crb overlay 2023-08-29 10:24:03 +02:00
hwinfo/api
i2c boards: arm: nucleo_f091rc: enable CAN support 2023-09-11 11:09:26 +02:00
i2s kernel: Modify the signature of k_mem_slab_free() 2023-09-03 18:20:59 -04:00
input/gpio_keys include: always use <> for Zephyr includes 2023-09-14 13:49:58 +02:00
ipm
kscan samples: subsys: display: lvgl: Remove lvgl-pointer-input in overlays 2023-09-05 10:05:50 +02:00
led/led_api
memc/ram
mipi_dsi/api
mm
pinctrl
pwm boards: arm: mimxrt1060_evk: added additional PWM outputs 2023-09-13 12:06:23 +02:00
regulator drivers: regulator: Added ship mode to API 2023-07-19 09:30:22 +00:00
retained_mem/api
rtc test: drivers: rtc: shell: Unittest of rtc_shell 2023-08-24 22:06:51 +01:00
sdhc
sensor drivers: sensor: ina230: fix current sign issue 2023-08-29 09:44:20 -05:00
smbus smbus: Remove unneeded board overlay configurations 2023-08-10 13:59:15 +03:00
spi include: always use <> for Zephyr includes 2023-09-14 13:49:58 +02:00
syscon
timer/nrf_rtc_timer
uart tests: drivers: uart: Adding wide data async tests 2023-08-30 10:17:17 +02:00
udc
virtualization/ivshmem/plain
w1/w1_api
watchdog tests: drivers: watchdog: wdt_basic_api: add nucleo_wba52cg board 2023-08-29 10:25:23 +02:00