Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

Linux Kernel 如何將 Device Tree 生成 platform_device

從節點到設備

Linux 開機時先解析 DTB,建立 device_node 樹。之後透過 of_platform_populate 取得根節點,逐一處理子節點,將符合條件的硬體描述轉成 platform_device。

關鍵函數

of_find_node_by_path 用來取得根節點。of_platform_bus_create 會判斷節點是否為 ARM PrimeCell,若是則建立 amba device,否則建立 platform device。若節點底下還有子節點,會遞迴處理。

資源解析

of_platform_device_create_pdata 會檢查 status 屬性,配置 platform_device 與 resource,解析 interrupt 與 memory address,最後加入設備模型。

總結

Device Tree 不只是資料描述,kernel 會把它轉成可匹配的設備結構,讓 driver 的 probe 能被正確呼叫。

Copyright © Linux教程網 All Rights Reserved