![]() |
RT-Thread RTOS
An open source embedded real-time operating system
|
RT-Thread OFW parses the boot DTB into **struct rt_ofw_node**, then exposes property I/O, addressing, interrupts, and platform device enumeration. Implementation mirrors **components/drivers/ofw/** source layout.
| Source / header | Documentation |
|---|---|
**base.c**, **ofw.c** — ofw.h | OFW nodes and properties |
**fdt.c** — ofw_fdt.h | OFW boot and FDT |
**io.c** — ofw_io.h | OFW addressing and MMIO |
**irq.c** — ofw_irq.h | OFW interrupts |
**raw.c** — ofw_raw.h | OFW raw FDT helpers |
**core/platform_ofw.c** | OFW platform enumeration |
| Build DTS → DTB | Devicetree Compiler |
| Option | Role |
|---|---|
**RT_USING_OFW** | OFW + libfdt; requires **RT_USING_DM** |
**RT_USING_BUILTIN_FDT** | Link **RT_BUILTIN_FDT_PATH** (default rtthread.dtb) |
**RT_FDT_EARLYCON_MSG_SIZE** | Early console ring (KB, default 128) |
**RT_USING_OFW_BUS_RANGES_NUMBER** | Cached **ranges** slots (4 or 8) |
Most DM subsystems share the same parse sequence:
rt_ofw_parse_phandle_cells(np, "clocks", "#clock-cells", index, &args)**provider_np = args.data**; if **!rt_ofw_data(provider_np)** → **rt_platform_ofw_request(provider_np)**rt_clk_get_by_index**, **rt_mbox_request_channel**, …)| Property | #*-cells | See also |
|---|---|---|
**clocks** | **#clock-cells** | Clock framework (CLK) |
**resets** | **#reset-cells** | reset DM |
**mboxes** | **#mbox-cells** | Mailbox device model (DM) |
**io-channels** | **#io-channel-cells** | IIO device model (DM) |
**nvmem-cells** | **#nvmem-cell-cells** | NVMEM device model (DM) |
**rt_ofw_parse_object(np, obj_name, "#clock-cells")** resolves composite objects in **rt_ofw_data** when one node exports multiple controllers.
| Topic | Guidance |
|---|---|
**status** | Use **rt_ofw_node_is_available** before attaching hardware |
**reg** | Use **rt_ofw_io_*** / **rt_ofw_get_address** — never hard-code parent **#address-cells** |
| IRQ | Direct **interrupts** vs bridge **interrupt-map** — see OFW interrupts |
| Refs | Pair **rt_ofw_node_get** / **rt_ofw_node_put** when caching **np** |
**compatible** | Most specific string first in DTS and **rt_ofw_node_id** table |
components/drivers/include/dt-bindings/** — include from DTS via cppcomponents/drivers/ofw/ — implementation