zephyr/tests/kernel/device/app.overlay
Carlo Caione b6a3d598f3 device_mmio: Introduce DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME
Currently the device MMIO APIs is only able to map single DT-defined
regions and also the _NAMED variant is assuming that each DT-defined
device has only one single region to map.

This is a limitation and a problem when in the DT are defined devices
with multiple regions that need to be mapped.

This patch is trying to overcome this limitation by introducing the
DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME macro that leveraged the 'reg-names'
DT property to map multiple regions defined by a single device.

So for example in the DT we can have a device like:

  driver@c4000000 {
    reg = <0xc4000000 0x1000>, <0xc4001000 0x1000>;
    reg-names = "region0", "region1";
  };

and then we can use DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME doing:

  struct driver_config config = {
    DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME(region0, DT_DRV_INST(0)),
    DEVICE_MMIO_NAMED_ROM_INIT_BY_NAME(region1, DT_DRV_INST(0)),
  };

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-16 11:26:10 +02:00

55 lines
1.2 KiB
Plaintext

/*
* Copyright (c) 2020 Nordic Semiconductor ASA
* Copyright (c) 2020 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*
* Application overlay for creating a fake device instance we
* can use to test DEVICE_MMIO APIs, which get raw data about
* memory ranges from DTS instances.
*
* Names in this file should be chosen in a way that won't conflict
* with real-world devicetree nodes, to allow these tests to run on
* (and be extended to test) real hardware.
*/
/ {
#address-cells = <1>;
#size-cells = <1>;
fakedriver@E0000000 {
compatible = "fakedriver";
reg = <0xE0000000 0x2000>;
status = "okay";
};
fakedriver@E1000000 {
compatible = "fakedriver";
reg = <0xE1000000 0x2000>;
status = "okay";
};
fakedriver@E2000000 {
compatible = "fakedriver";
reg = <0xE2000000 0x2000>;
status = "okay";
};
fakedriver@E3000000 {
compatible = "fakedriver";
reg = <0xE3000000 0x2000>;
status = "okay";
};
fakedriver@E4000000 {
compatible = "fakedriver";
reg = <0xE4000000 0x2000>;
status = "okay";
};
fakedriver_multireg@E5000000 {
compatible = "fakedriver_multireg";
reg = <0xE5000000 0x1000>,
<0xE6000000 0x1000>;
reg-names = "chip",
"dale";
status = "okay";
};
};