Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

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)
 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)
 Return a pointer to the ROM-based storage area for a device's MMIO information.
 
#define DEVICE_MMIO_ROM_INIT(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)
 Obtain the MMIO address for a device.
 

Detailed Description

For drivers which need to manage just one MMIO region, the most common case.

Macro Definition Documentation

◆ DEVICE_MMIO_GET

#define DEVICE_MMIO_GET ( dev)

#include <zephyr/sys/device_mmio.h>

Value:
#define DEVICE_MMIO_RAM_PTR(device)
Return a pointer to the RAM-based storage area for a device's MMIO address.
Definition device_mmio.h:197

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.

Parameters
devDevice object
Returns
mm_reg_t linear address of the MMIO region

◆ DEVICE_MMIO_MAP

#define DEVICE_MMIO_MAP ( dev,
flags )

#include <zephyr/sys/device_mmio.h>

Value:
DEVICE_MMIO_ROM_PTR(dev)->phys_addr, \
DEVICE_MMIO_ROM_PTR(dev)->size, \
(flags))
#define DEVICE_MMIO_ROM_PTR(dev)
Return a pointer to the ROM-based storage area for a device's MMIO information.
Definition device_mmio.h:241
static __boot_func void device_map(mm_reg_t *virt_addr, uintptr_t phys_addr, size_t size, uint32_t flags)
Set linear address for device MMIO access.
Definition device_mmio.h:97
flags
Definition parser.h:96

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.

Parameters
devDevice object instance
flagscache mode flags

◆ DEVICE_MMIO_RAM

#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":

struct foo_driver_data {
int wibble;
...
}
#define DEVICE_MMIO_RAM
Declare storage for MMIO information within a device's dev_data struct.
Definition device_mmio.h:181

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().

◆ DEVICE_MMIO_RAM_PTR

#define DEVICE_MMIO_RAM_PTR ( device)

#include <zephyr/sys/device_mmio.h>

Value:
(mm_reg_t *)((device)->data)
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
uintptr_t mm_reg_t
Definition sys_io.h:20

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.

Parameters
devicedevice node_id object
Return values
mm_reg_tpointer to storage location

◆ DEVICE_MMIO_ROM

#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":

struct foo_config {
int baz;
...
}
#define DEVICE_MMIO_ROM
Declare storage for MMIO data within a device's config struct.
Definition device_mmio.h:230
See also
DEVICE_MMIO_ROM_INIT()

◆ DEVICE_MMIO_ROM_INIT

#define DEVICE_MMIO_ROM_INIT ( node_id)

#include <zephyr/sys/device_mmio.h>

Value:
._mmio = Z_DEVICE_MMIO_ROM_INITIALIZER(node_id)

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:

struct foo_config my_config = {
.baz = 2;
...
}
#define DEVICE_MMIO_ROM_INIT(node_id)
Initialize a DEVICE_MMIO_ROM member.
Definition device_mmio.h:266
#define DT_DRV_INST(inst)
Node identifier for an instance of a DT_DRV_COMPAT compatible.
Definition devicetree.h:3809
See also
DEVICE_MMIO_ROM()
Parameters
node_idDTS node_id

◆ DEVICE_MMIO_ROM_PTR

#define DEVICE_MMIO_ROM_PTR ( dev)

#include <zephyr/sys/device_mmio.h>

Value:
((struct z_device_mmio_rom *)((dev)->config))

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.

Parameters
devdevice instance object
Return values
structdevice_mmio_rom * pointer to storage location