2.3.1 Devices declaration Device instance [link] 

In order to use a device in MutekH, an instance of a struct device_s object must be available for that device. This object may be dynamically allocated by calling the device_alloc function or declared as a global variable by using the DEV_DECLARE_STATIC macro.

Application usually do not need to create device objects themselves. Devices objects are generally dynamically created by enumerator devices on system startup or statically declared in a board description source file. They can however be declared in any C file.

#include <device/device.h>

DEV_DECLARE_STATIC(uart0_dev, "uart0", 0, my_uart_drv);

See also DEV_DECLARE_STATIC, DEV_DECLARE_STATIC, device_alloc, device_cleanup, struct device_s and device_set_name. Device tree [link] 

Device objects usually lives in the MutekH device tree. This structure allows to lookup a device by path and helps writing application code which works cross platforms.

Hierarchy in the device tree is related to device enumeration order. The tree hierarchy may not reflect the hardware interconnection of buses, which may be a graph anyway and may also be different for memory, irq, clocks... Parent devices in the tree are actually enumerator device that create child devices when the enumeration takes place. When device hierarchy is used, aliases nodes can be created.

When the CONFIG_DEVICE_TREE token is not defined, a read only device registry is still available so that device lookup by path can be performed in the same way. In this case device objects can only be declared statically and the tree becomes a flat list. This greatly reduce memory usage on embedded platforms where dynamic device enumeration is not required.

See also device_attach, device_detach and device_get_by_path. Device resources [link] 

Various predefined types of resource entries may be attached to devices. These entries carry information about device addresses, identifiers and connections with other devices in the system.

Resource can be created dynamically by calling appropriate functions or declared statically along with the device declaration when the DEV_DECLARE_STATIC macro is used:

#include <device/resources.h>

DEV_DECLARE_STATIC(uart0_dev, "uart0", 0, my_uart_drv,
/* memory address range */
DEV_STATIC_RES_MEM(0x4000e000, 0x4000e400)

Some types of resource embed a path references to an other device in the tree, stating dependencies between device drivers. For instance, a timer device usually have an irq resource along with a reference to the appropriate interrupt controller device.

#include <device/irq.h>

DEV_DECLARE_STATIC(timer_dev, "timer", 0, my_timer_drv,

See also enum dev_resource_type_e.

Valid XHTML 1.0 StrictGenerated by diaxen on Thu Aug 4 15:44:05 2022 using MkDoc