- 用来查找在dtb中的根节点
unsigned long __init of_get_flat_dt_root(void)
- 根据deice_node结构的full_name参数,在全局链表of_allnodes中,查找合适的device_node
struct device_node *of_find_node_by_path(const char *path)
例如:
struct device_node *cpus;
cpus=of_find_node_by_path("/cpus");
- 若from=NULL,则在全局链表of_allnodes中根据name查找合适的device_node
struct device_node *of_find_node_by_name(struct device_node *from,const char *name)
例如:
struct device_node *np;
np = of_find_node_by_name(NULL,"firewire");
- 根据设备类型查找相应的device_node
struct device_node *of_find_node_by_type(struct device_node *from,const char *type)
例如:
struct device_node *tsi_pci;
tsi_pci= of_find_node_by_type(NULL,"pci");
- 根据compatible字符串查找device_node
struct device_node *of_find_compatible_node(struct device_node *from,
const char *type, const char *compatible)
- 根据节点属性的name查找device_node
struct device_node *of_find_node_with_property(struct device_node *from,
const char *prop_name)
- 根据phandle查找device_node
struct device_node *of_find_node_by_phandle(phandle handle)
- 根据alias的name获得设备id号
int of_alias_get_id(struct device_node *np, const char *stem)
- device node计数增加/减少
struct device_node *of_node_get(struct device_node *node)
void of_node_put(struct device_node *node)
- 根据property结构的name参数,在指定的device node中查找合适的property
struct property *of_find_property(const struct device_node *np,const char *name,int *lenp)
- 根据property结构的name参数,返回该属性的属性值
const void *of_get_property(const struct device_node *np, const char *name,int *lenp)
- 根据compat参数与device node的compatible匹配,返回匹配度
int of_device_is_compatible(const struct device_node *device,const char *compat)
- 获得父节点的device node
struct device_node *of_get_parent(const struct device_node *node)
- 将matches数组中of_device_id结构的name和type与device node的compatible和type匹配,返回匹配度最高的of_device_id结构
const struct of_device_id *of_match_node(const struct of_device_id *matches,
const struct device_node *node)
- 根据属性名propname,读出属性值中的第index个u32数值给out_value
int of_property_read_u32_index(const struct device_node *np,
const char *propname,u32 index, u32 *out_value)
- 根据属性名propname,读出该属性的数组中sz个属性值给out_values
int of_property_read_u8_array(const struct device_node *np,
const char *propname, u8 *out_values, size_t sz)
//----------------------------------------------------------------------------------------//
int of_property_read_u16_array(const struct device_node *np,
const char *propname, u16 *out_values, size_t sz)
//----------------------------------------------------------------------------------------//
int of_property_read_u32_array(const struct device_node *np,
const char *propname, u32 *out_values,size_t sz)
- 根据属性名propname,读出该属性的u64属性值
int of_property_read_u64(const struct device_node *np, const char *propname,u64 *out_value)
- 根据属性名propname,读出该属性的字符串属性值
int of_property_read_string(struct device_node *np,
const char *propname,const char **out_string)
- 根据属性名propname,读出该字符串属性值数组中的第index个字符串
int of_property_read_string_index(struct device_node *np,
const char *propname,int index, const char **output)
- 读取属性名propname中,字符串属性值的个数
int of_property_count_strings(struct device_node *np, const char *propname)
- 读取该设备的第index个irq号
unsigned int irq_of_parse_and_map(struct device_node *dev, int index)
- 读取该设备的第index个irq号,并填充一个irq资源结构体
int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
- 获取该设备的irq个数
int of_irq_count(struct device_node *dev)
- 获取设备寄存器地址,并填充寄存器资源结构体
int of_address_to_resource(struct device_node *dev, int index,struct resource *r)
//----------------------------------------------------------------------------------------//
const __be32 *of_get_address(struct device_node *dev, int index, u64 *size,unsigned int *flags)
- 获取经过映射的寄存器虚拟地址
void __iomem *of_iomap(struct device_node *np, int index)
- 根据device_node查找返回该设备对应的platform_device结构
struct platform_device *of_find_device_by_node(struct device_node *np)
- 根据device node,bus id以及父节点创建该设备的platform_device结构
struct platform_device *of_device_alloc(struct device_node *np,
const char *bus_id,struct device *parent)
//----------------------------------------------------------------------------------------//
static struct platform_device *of_platform_device_create_pdata(struct device_node *np,
const char *bus_id,
void *platform_data,
struct device *parent)
- 遍历of_allnodes中的节点挂接到of_platform_bus_type总线上,由于此时of_platform_bus_type总线上还没有驱动,所以此时不进行匹配
int of_platform_bus_probe(struct device_node *root,
const struct of_device_id *matches,struct device *parent)