Zephyr API Documentation
3.6.99
A Scalable Open Source RTOS
|
For drivers which need to manage just one MMIO region, the most common case. More...
Macros | |
#define | DEVICE_MMIO_RAM mm_reg_t _mmio |
Declare storage for MMIO information within a device's dev_data struct. | |
#define | DEVICE_MMIO_RAM_PTR(device) (mm_reg_t *)((device)->data) |
Return a pointer to the RAM-based storage area for a device's MMIO address. | |
#define | DEVICE_MMIO_ROM struct z_device_mmio_rom _mmio |
Declare storage for MMIO data within a device's config struct. | |
#define | DEVICE_MMIO_ROM_PTR(dev) ((struct z_device_mmio_rom *)((dev)->config)) |
Return a pointer to the ROM-based storage area for a device's MMIO information. | |
#define | DEVICE_MMIO_ROM_INIT(node_id) ._mmio = Z_DEVICE_MMIO_ROM_INITIALIZER(node_id) |
Initialize a DEVICE_MMIO_ROM member. | |
#define | DEVICE_MMIO_MAP(dev, flags) |
Map MMIO memory into the address space. | |
#define | DEVICE_MMIO_GET(dev) (*DEVICE_MMIO_RAM_PTR(dev)) |
Obtain the MMIO address for a device. | |
For drivers which need to manage just one MMIO region, the most common case.
#define DEVICE_MMIO_GET | ( | dev | ) | (*DEVICE_MMIO_RAM_PTR(dev)) |
#include <zephyr/sys/device_mmio.h>
Obtain the MMIO address for a device.
For most microcontrollers MMIO addresses can be fixed values known at build time, and we can store this in device->config, residing in ROM.
However, some devices can only know their MMIO addresses at runtime, because they need to be memory-mapped into the address space, enumerated from PCI, or both.
This macro returns the linear address of the driver's MMIO region. This is for drivers which have exactly one MMIO region. A call must have been made to device_map() in the driver init function.
dev | Device object |
#define DEVICE_MMIO_MAP | ( | dev, | |
flags | |||
) |
#include <zephyr/sys/device_mmio.h>
Map MMIO memory into the address space.
This is not intended for PCIe devices; these must be probed at runtime and you will want to make a device_map() call directly, using DEVICE_MMIO_RAM_PTR() as the target virtual address location.
The flags argument is currently used for caching mode, which should be one of the DEVICE_CACHE_* macros. Unused bits are reserved for future expansion.
dev | Device object instance |
flags | cache mode flags |
#define DEVICE_MMIO_RAM mm_reg_t _mmio |
#include <zephyr/sys/device_mmio.h>
Declare storage for MMIO information within a device's dev_data struct.
This gets accessed by the DEVICE_MMIO_MAP() and DEVICE_MMIO_GET() macros.
Depending on configuration, no memory may be reserved at all. This must be the first member of the data struct.
There must be a corresponding DEVICE_MMIO_ROM in config_info if the physical address is known at build time, but may be omitted if not (such as with PCIe)
Example for a driver named "foo":
No build-time initialization of this memory is necessary; it will be set up in the init function by DEVICE_MMIO_MAP().
A pointer to this memory may be obtained with DEVICE_MMIO_RAM_PTR().
#include <zephyr/sys/device_mmio.h>
Return a pointer to the RAM-based storage area for a device's MMIO address.
This is useful for the target MMIO address location when using device_map() directly.
device | device node_id object |
mm_reg_t | pointer to storage location |
#define DEVICE_MMIO_ROM struct z_device_mmio_rom _mmio |
#include <zephyr/sys/device_mmio.h>
Declare storage for MMIO data within a device's config struct.
This gets accessed by DEVICE_MMIO_MAP() and DEVICE_MMIO_GET() macros.
What gets stored here varies considerably by configuration. This must be the first member of the config struct. There must be a corresponding DEVICE_MMIO_RAM in data.
This storage is not used if the device is PCIe and may be omitted.
This should be initialized at build time with information from DTS using DEVICE_MMIO_ROM_INIT().
A pointer to this memory may be obtained with DEVICE_MMIO_ROM_PTR().
Example for a driver named "foo":
#define DEVICE_MMIO_ROM_INIT | ( | node_id | ) | ._mmio = Z_DEVICE_MMIO_ROM_INITIALIZER(node_id) |
#include <zephyr/sys/device_mmio.h>
Initialize a DEVICE_MMIO_ROM member.
Initialize MMIO-related information within a specific instance of a device config struct, using information from DTS.
Example for a driver belonging to the "foo" subsystem:
node_id | DTS node_id |
#define DEVICE_MMIO_ROM_PTR | ( | dev | ) | ((struct z_device_mmio_rom *)((dev)->config)) |
#include <zephyr/sys/device_mmio.h>
Return a pointer to the ROM-based storage area for a device's MMIO information.
This macro will not work properly if the ROM storage was omitted from the config struct declaration, and should not be used in this case.
dev | device instance object |
struct | device_mmio_rom * pointer to storage location |