Platform Device, Device Tree, and Open Firmware¶
APIs¶
從 driver 獲得硬體 resource 的 API 來觀察.
platform
platform_get_resource(): memory + irq
platform_get_irq(): irq
of
of_address_to_resource()
of_irq_get()
從 device tree 獲得資料的進行, 有些是 kernel 開機初始化就 access 轉成 data structure [1], 有些則是 lazy access, 在取用硬體資源前才去跟 device tree 要資料 [2].
[1] device tree in kernel init:
__init customize_machine() => of_platform_populate() => of_dev_lookup() => of_address_to_resource()
[2] lazy access:
platform_get_irq() => of_irq_get()
source code:
driver/base/platform.c
driver/of/*
driver/of/platform.c
device tree format¶
Documentation/devicetree/usage-model.txt
notes¶
compatible
property: Every node represents a device havecompatible
property.list of strings
first string: the exact device, format is
"<manufacturer>,<model>"
following strings: other devices that the device is compatible with
node name:
<name>[@<unit-address>]
address
reg
parent’s
#address-cells
and#size-cells
interrupt
interrupt-controller
: empty property. this device receive interrupt.#interrupt-cells
,interrupts
: like#address-cells
andreg
interrupt-parent