Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Top-level MMIO region macros

For drivers which do not use Zephyr's driver model and do not associate struct device with a driver instance. More...

Macros

#define DEVICE_MMIO_TOPLEVEL(name, node_id)
 Declare top-level storage for MMIO information, global scope.
 
#define DEVICE_MMIO_TOPLEVEL_DECLARE(name)
 Provide an extern reference to a top-level MMIO region.
 
#define DEVICE_MMIO_TOPLEVEL_STATIC(name, node_id)
 Declare top-level storage for MMIO information, static scope.
 
#define DEVICE_MMIO_TOPLEVEL_RAM_PTR(name)
 Return a pointer to the RAM storage for a device's toplevel MMIO address.
 
#define DEVICE_MMIO_TOPLEVEL_ROM_PTR(name)
 Return a pointer to the ROM-based storage area for a toplevel MMIO region.
 
#define DEVICE_MMIO_TOPLEVEL_MAP(name, flags)
 Set up memory for a driver'sMMIO region.
 
#define DEVICE_MMIO_TOPLEVEL_GET(name)
 Obtain the MMIO address for a device declared top-level.
 

Detailed Description

For drivers which do not use Zephyr's driver model and do not associate struct device with a driver instance.

Top-level storage is used instead, with either global or static scope.

This is often useful for interrupt controller and timer drivers.

Currently PCIe devices are not well-supported with this set of macros. Either use Zephyr's driver model for these kinds of devices, or manage memory manually with calls to device_map().

Macro Definition Documentation

◆ DEVICE_MMIO_TOPLEVEL

#define DEVICE_MMIO_TOPLEVEL ( name,
node_id )

#include <zephyr/sys/device_mmio.h>

Value:
__pinned_bss \
mm_reg_t Z_TOPLEVEL_RAM_NAME(name); \
__pinned_rodata \
const struct z_device_mmio_rom Z_TOPLEVEL_ROM_NAME(name) = \
Z_DEVICE_MMIO_ROM_INITIALIZER(node_id)

Declare top-level storage for MMIO information, global scope.

This is intended for drivers which do not use Zephyr's driver model of config/dev_data linked to a struct device.

Instead, this is a top-level declaration for the driver's C file. The scope of this declaration is global and may be referenced by other C files, using DEVICE_MMIO_TOPLEVEL_DECLARE.

Parameters
nameBase symbol name
node_idDevice-tree node identifier for this region

◆ DEVICE_MMIO_TOPLEVEL_DECLARE

#define DEVICE_MMIO_TOPLEVEL_DECLARE ( name)

#include <zephyr/sys/device_mmio.h>

Value:
extern mm_reg_t Z_TOPLEVEL_RAM_NAME(name); \
extern const struct z_device_mmio_rom Z_TOPLEVEL_ROM_NAME(name)
uintptr_t mm_reg_t
Definition sys_io.h:20

Provide an extern reference to a top-level MMIO region.

If a top-level MMIO region defined with DEVICE_MMIO_DEFINE needs to be referenced from other C files, this macro provides the necessary extern definitions.

See also
DEVICE_MMIO_TOPLEVEL
Parameters
nameName of the top-level MMIO region

◆ DEVICE_MMIO_TOPLEVEL_GET

#define DEVICE_MMIO_TOPLEVEL_GET ( name)

#include <zephyr/sys/device_mmio.h>

Value:
((mm_reg_t)Z_TOPLEVEL_RAM_NAME(name))

Obtain the MMIO address for a device declared top-level.

See also
DEVICE_MMIO_GET
Parameters
nameName of the top-level MMIO region
Returns
mm_reg_t linear address of the MMIO region

◆ DEVICE_MMIO_TOPLEVEL_MAP

#define DEVICE_MMIO_TOPLEVEL_MAP ( name,
flags )

#include <zephyr/sys/device_mmio.h>

Value:
device_map(&Z_TOPLEVEL_RAM_NAME(name), \
Z_TOPLEVEL_ROM_NAME(name).phys_addr, \
Z_TOPLEVEL_ROM_NAME(name).size, (flags))
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

Set up memory for a driver'sMMIO region.

This performs the necessary MMU virtual memory mapping such that DEVICE_MMIO_GET() returns a suitable linear memory address for the MMIO region.

If such operations are not required by the target hardware, this expands to nothing.

This should be called once from the driver's init function.

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
nameName of the top-level MMIO region
flagsOne of the DEVICE_CACHE_* caching modes

◆ DEVICE_MMIO_TOPLEVEL_RAM_PTR

#define DEVICE_MMIO_TOPLEVEL_RAM_PTR ( name)

#include <zephyr/sys/device_mmio.h>

Value:
&Z_TOPLEVEL_RAM_NAME(name)

Return a pointer to the RAM storage for a device's toplevel MMIO address.

Parameters
nameName of toplevel MMIO region
Return values
mm_reg_tpointer to storage location

◆ DEVICE_MMIO_TOPLEVEL_ROM_PTR

#define DEVICE_MMIO_TOPLEVEL_ROM_PTR ( name)

#include <zephyr/sys/device_mmio.h>

Value:
&Z_TOPLEVEL_ROM_NAME(name)

Return a pointer to the ROM-based storage area for a toplevel MMIO region.

Parameters
nameMMIO region name
Return values
structdevice_mmio_rom * pointer to storage location

◆ DEVICE_MMIO_TOPLEVEL_STATIC

#define DEVICE_MMIO_TOPLEVEL_STATIC ( name,
node_id )

#include <zephyr/sys/device_mmio.h>

Value:
__pinned_bss \
static mm_reg_t Z_TOPLEVEL_RAM_NAME(name); \
__pinned_rodata \
static const struct z_device_mmio_rom Z_TOPLEVEL_ROM_NAME(name) = \
Z_DEVICE_MMIO_ROM_INITIALIZER(node_id)

Declare top-level storage for MMIO information, static scope.

This is intended for drivers which do not use Zephyr's driver model of config/dev_data linked to a struct device.

Instead, this is a top-level declaration for the driver's C file. The scope of this declaration is static.

Parameters
nameName of the top-level MMIO region
node_idDevice-tree node identifier for this region