SlideShare a Scribd company logo
1 of 15
Download to read offline
Device Tree
Rouyun Pan
緣起
• 某年某⽉月的某⼀一天... 

神⼈人Linus Torvalds寫了⼀一封信
有⼀一堆闌尾在⽴立法院, 可割可棄!!!
So, 割闌尾~
• 科科跟宅宅們參考了PowerPC等其他體系架構下
已經使⽤用的Flattened Device Tree(FDT).起源於
OpenFirmware IEEE 1275 device-tree notion.
• ⽇日後決定採⽤用Device Tree為描述硬體平台的資料
結構.
Device Tree
• 由⼀一系列被命名的結點(Node)和屬性
(Property)來組成. Node可包含Sub-Node.
Property是成對的name和value. 可讀性⾼高.
• 可以在開機的時候, 在透過它將訊息傳遞給作業系
統,⽽而不需要在把這些資訊放在程式碼中.
• 未來也很⽅方便增減修改Device Tree, 容易⽀支援不同
的Soc或硬體週邊.
Z > B!!!
How to work with device tree
complier
Device tree
description
binary data
bootloader kernel
platform
probe
carry
HW configuration
pass
DTS
DTC
DTB
Device tree misc.
• DTS

- device tree source file
• DTC

- device tree compiler, It compiles DTS to DTB.
• DTB

- device tree blob, the binary data to store the
information of DTS.
DTS Format(1)
/{!
! properties = ”value as string” | <value as u32 list> | [ value as byte stream ] |
<&node name>!
! child_node[@address] {!
! ! child_properties!
! }!
}!
!
&node_name {!
! compatible = "<manufacturer>,<model>"!
! properties!
}!
“/“ 表⽰示根節點, 不需要寫節點名稱
屬性Properties可以⽤用混合格式表⽰示,
如“字串”,或<32位元整數列表>,或[位元組流]或

<&其他參考節點名稱>
每個 Node 都會有⼀一個’compatible’ property. 格式為
"<manufacturer>,<model>",第⼀一個字串表⽰示確切名
稱,第⼆二個字串表⽰示可兼容的其他設備。
DTS Format(2)
/{!
! properties = ”value as string” | <value as u32 list> | [ value as byte stream ] |
<&node name>!
! child_node[@address] {!
! ! child_properties!
! }!
}!
!
&node_name {!
! compatible = "<manufacturer>,<model>"!
! properties!
}!
結點的命名,遵循的格式為:
<name>[@address]

name是⼀一個ASCII字串,⽤用於描述結點對應的
裝置類型. 如果⼀一個結點描述的裝置有記憶體地
址,則填⼊入@address。多個相同類型設備結點
的name可以⼀一樣,只要address不同即可
DTS format(3)
/ {
compatible = "acme,coyotes-revenge";
#address-cells = <1>;
#size-cells = <1>;
interrupt-parent = <&intc>;
cpus {
#address-cells = <1>;
#size-cells = <0>;
cpu@0 {
compatible = "arm,cortex-a9";
reg = <0>;
};
cpu@1 {
compatible = "arm,cortex-a9";
reg = <1>;
};
};
serial@1010adbd {
compatible = "arm,pl011";
reg = <0x101abcd 0x1000>;
reg_name = “”
};
節點1
節點2!
⼦子節點1!
⼦子節點2!
根節點
DTS format(4)/ {
compatible = "acme,coyotes-revenge";
#address-cells = <1>; !
#size-cells = <1>;
interrupt-parent = <&intc>;
cpus {
#address-cells = <1>; !
#size-cells = <0>;
cpu@0 {
compatible = "arm,cortex-a9";
reg = <0>;
};
cpu@1 {
compatible = "arm,cortex-a9";
reg = <1>;
};
};
serial@1010adbd {
compatible = "arm,pl011";
reg = <0x101abcd 0x1000>;!
! reg_name = “”!
};
有位址的裝置會使⽤用
#address-cells 和 #size-cells 來決定⼦子結點
的’reg’屬性的格式怎麼填
reg = <address1 length1 [address2 length2] ... >
#size-cells = <0>; 表⽰示只填⼊入Reg的starting address
#address-cells = <1>; !
#size-cells = <1>; !
填⼊入格式為 Reg = <Starting_address Size>
.dts & dtsi
• .dts 是採⽤用ASCII 格式的Device Tree描述檔⽂文件.
⼀一般放置位在 kernel/arch/arm/boot/dts/。
• ⼀一個SoC可能拿來開發多個產品線,為了⽅方便,
把SoC公⽤用的硬體設定或不同產品的共同部分提
煉為.dtsi,類似C語⾔言的.h。其他不同產品的.dts
可以引⽤用這些共通的.dtsi。
Modularization
msm1234-abc.dts
msm1234-abc.dtsi
panel-abc.dtsi msm1234.dtsi
msm1234-gpu.dtsi
msm1234-
iommu.dtsi
msm1234-
mdss.dtsi
for example - Driver probe
@mdss_mdp.cpp
static const struct of_device_id mdss_mdp_dt_match[] =
.compatible = "qcom,mdss_mdp"
MODULE_DEVICE_TABLE (of, mdss_mdp_dt_match);
!
static struct platform_driver mdss_mdp_driver = {
.probe = mdss_mdp_probe,
.driver = {
.name = "mdp",
.of_match_table = mdss_mdp_dt_match,
}
}
!
static int __init mdss_mdp_driver_init (void) {
platform_driver_register( &mdss_mdp_driver );
}
@msm1234-mdss.dtsi
&soc {
!
mdss_mdp: qcom,mdss_mdp@12340000 {
compatible = "qcom,mdss_mdp";
reg = <0x12340000 0xff00>
reg-names = "mdp_phys", "vbif_phys";
…
!
mdss_dsi0: qcom,mdss_dsi@12345000 {
compatible = "qcom,mdss-dsi-ctrl";
qcom,mdss-mdp = <&mdss_mdp>;
…
!
qcom,mdss_wb_panel {
compatible = "qcom,mdss_wb";
…
…
Parsing APIs of Device Tree
property * of_find_property();
device_node * of_find_node_by_name();
of_find_node_by_type();

of_find_compatible_node();

of_find_matching_node_and_match();

of_find_node_by_path(); 

of_find_node_by_phandle();
void * of_get_property();
int of_property_read_u32_index() 

of_property_read_u8_array();

of_property_read_u16_array(); 

of_property_read_u32_array();

of_property_read_string();

of_property_read_string_index();
int of_parse_phandle_with_args(),
of_parse_phandle_with_fixed_args(),
of_count_phandle_with_args()
Reference
• http://www.devicetree.org/Main_Page
• http://www.devicetree.org/Device_Tree_Usage
• Device Tree Support on ARM Linux

Chih-Min Chao) http://gplus.to/cmchao COSCUP
2011 in Taiwan
• http://blog.csdn.net/21cnbao/article/details/
8457546

More Related Content

What's hot

Building Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCBuilding Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCC
Kernel TLV
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
hugo lu
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_Booting
Rashila Rr
 
netfilter and iptables
netfilter and iptablesnetfilter and iptables
netfilter and iptables
Kernel TLV
 

What's hot (20)

Device Tree for Dummies (ELC 2014)
Device Tree for Dummies (ELC 2014)Device Tree for Dummies (ELC 2014)
Device Tree for Dummies (ELC 2014)
 
Building Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCBuilding Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCC
 
Summary of linux kernel security protections
Summary of linux kernel security protectionsSummary of linux kernel security protections
Summary of linux kernel security protections
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
 
淺談探索 Linux 系統設計之道
淺談探索 Linux 系統設計之道 淺談探索 Linux 系統設計之道
淺談探索 Linux 系統設計之道
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
Device tree support on arm linux
Device tree support on arm linuxDevice tree support on arm linux
Device tree support on arm linux
 
0章 Linuxカーネルを読む前に最低限知っておくべきこと
0章 Linuxカーネルを読む前に最低限知っておくべきこと0章 Linuxカーネルを読む前に最低限知っておくべきこと
0章 Linuxカーネルを読む前に最低限知っておくべきこと
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_Booting
 
A Journey to Boot Linux on Raspberry Pi
A Journey to Boot Linux on Raspberry PiA Journey to Boot Linux on Raspberry Pi
A Journey to Boot Linux on Raspberry Pi
 
I2c drivers
I2c driversI2c drivers
I2c drivers
 
Slab Allocator in Linux Kernel
Slab Allocator in Linux KernelSlab Allocator in Linux Kernel
Slab Allocator in Linux Kernel
 
netfilter and iptables
netfilter and iptablesnetfilter and iptables
netfilter and iptables
 
あるコンテキストスイッチの話
あるコンテキストスイッチの話あるコンテキストスイッチの話
あるコンテキストスイッチの話
 
GDB Rocks!
GDB Rocks!GDB Rocks!
GDB Rocks!
 
DPDK In Depth
DPDK In DepthDPDK In Depth
DPDK In Depth
 
Board support package_on_linux
Board support package_on_linuxBoard support package_on_linux
Board support package_on_linux
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013
 
I2C Drivers
I2C DriversI2C Drivers
I2C Drivers
 

Similar to Device tree

Oracle Database Appliance - RAC in a box Some strings attached
Oracle Database Appliance - RAC in a box Some strings attached Oracle Database Appliance - RAC in a box Some strings attached
Oracle Database Appliance - RAC in a box Some strings attached
Fuad Arshad
 

Similar to Device tree (20)

LAS16-300: Mini Conference 2 Cortex-M Software - Device Configuration
LAS16-300: Mini Conference 2 Cortex-M Software - Device ConfigurationLAS16-300: Mini Conference 2 Cortex-M Software - Device Configuration
LAS16-300: Mini Conference 2 Cortex-M Software - Device Configuration
 
System Device Tree and Lopper: Concrete Examples - ELC NA 2022
System Device Tree and Lopper: Concrete Examples - ELC NA 2022System Device Tree and Lopper: Concrete Examples - ELC NA 2022
System Device Tree and Lopper: Concrete Examples - ELC NA 2022
 
Nick Stephens-how does someone unlock your phone with nose
Nick Stephens-how does someone unlock your phone with noseNick Stephens-how does someone unlock your phone with nose
Nick Stephens-how does someone unlock your phone with nose
 
HPCC Systems vs Hadoop
HPCC Systems vs HadoopHPCC Systems vs Hadoop
HPCC Systems vs Hadoop
 
Cassandra & Python - Springfield MO User Group
Cassandra & Python - Springfield MO User GroupCassandra & Python - Springfield MO User Group
Cassandra & Python - Springfield MO User Group
 
Ui disk & terminal drivers
Ui disk & terminal driversUi disk & terminal drivers
Ui disk & terminal drivers
 
RHCSA EX200 - Summary
RHCSA EX200 - SummaryRHCSA EX200 - Summary
RHCSA EX200 - Summary
 
Cassandra for Sysadmins
Cassandra for SysadminsCassandra for Sysadmins
Cassandra for Sysadmins
 
Script of Scripts Polyglot Notebook and Workflow System
Script of ScriptsPolyglot Notebook and Workflow SystemScript of ScriptsPolyglot Notebook and Workflow System
Script of Scripts Polyglot Notebook and Workflow System
 
High Availability in 37 Easy Steps
High Availability in 37 Easy StepsHigh Availability in 37 Easy Steps
High Availability in 37 Easy Steps
 
Oracle Database Appliance - RAC in a box Some strings attached
Oracle Database Appliance - RAC in a box Some strings attached Oracle Database Appliance - RAC in a box Some strings attached
Oracle Database Appliance - RAC in a box Some strings attached
 
Attack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and KibanaAttack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and Kibana
 
1 network intro
1 network intro1 network intro
1 network intro
 
System Device Tree update: Bus Firewalls and Lopper
System Device Tree update: Bus Firewalls and LopperSystem Device Tree update: Bus Firewalls and Lopper
System Device Tree update: Bus Firewalls and Lopper
 
Linux Conference Australia 2018 : Device Tree, past, present, future
Linux Conference Australia 2018 : Device Tree, past, present, futureLinux Conference Australia 2018 : Device Tree, past, present, future
Linux Conference Australia 2018 : Device Tree, past, present, future
 
When 7 bit-ascii ain't enough - about NLS, collation, charsets, unicode and s...
When 7 bit-ascii ain't enough - about NLS, collation, charsets, unicode and s...When 7 bit-ascii ain't enough - about NLS, collation, charsets, unicode and s...
When 7 bit-ascii ain't enough - about NLS, collation, charsets, unicode and s...
 
Linux Networking Commands
Linux Networking CommandsLinux Networking Commands
Linux Networking Commands
 
2012-03-15 What's New at Red Hat
2012-03-15 What's New at Red Hat2012-03-15 What's New at Red Hat
2012-03-15 What's New at Red Hat
 
Introduction to char device driver
Introduction to char device driverIntroduction to char device driver
Introduction to char device driver
 
Tutorial On Database Management System
Tutorial On Database Management SystemTutorial On Database Management System
Tutorial On Database Management System
 

More from Rouyun Pan

Android 待機與操作耗電檢查
Android 待機與操作耗電檢查Android 待機與操作耗電檢查
Android 待機與操作耗電檢查
Rouyun Pan
 
Analyzing Display and Performance with Systrace
Analyzing Display and Performance with SystraceAnalyzing Display and Performance with Systrace
Analyzing Display and Performance with Systrace
Rouyun Pan
 

More from Rouyun Pan (20)

調色筆記
調色筆記調色筆記
調色筆記
 
有點硬又不會太硬的DNN加速器
有點硬又不會太硬的DNN加速器有點硬又不會太硬的DNN加速器
有點硬又不會太硬的DNN加速器
 
深度學習工作流程
深度學習工作流程深度學習工作流程
深度學習工作流程
 
Tensorflow lite for microcontroller
Tensorflow lite for microcontrollerTensorflow lite for microcontroller
Tensorflow lite for microcontroller
 
Google edge tpu
Google edge tpuGoogle edge tpu
Google edge tpu
 
用Adobe Camera raw 進行膚色校正
用Adobe Camera raw 進行膚色校正用Adobe Camera raw 進行膚色校正
用Adobe Camera raw 進行膚色校正
 
給攝影師的古典藝術構圖
給攝影師的古典藝術構圖給攝影師的古典藝術構圖
給攝影師的古典藝術構圖
 
照片直方圖解析
照片直方圖解析照片直方圖解析
照片直方圖解析
 
Deep Learning Hardware: Past, Present, & Future
Deep Learning Hardware: Past, Present, & FutureDeep Learning Hardware: Past, Present, & Future
Deep Learning Hardware: Past, Present, & Future
 
Deep learning
Deep learningDeep learning
Deep learning
 
VR解密
VR解密VR解密
VR解密
 
「轉貼」移動互聯網行業盤點
「轉貼」移動互聯網行業盤點「轉貼」移動互聯網行業盤點
「轉貼」移動互聯網行業盤點
 
The overview of VR solutions
The overview of VR solutionsThe overview of VR solutions
The overview of VR solutions
 
Render thead of hwui
Render thead of hwuiRender thead of hwui
Render thead of hwui
 
Project Tango
Project TangoProject Tango
Project Tango
 
[轉貼] 社群大數據 - 輿情觀測及分析應用
[轉貼] 社群大數據 - 輿情觀測及分析應用[轉貼] 社群大數據 - 輿情觀測及分析應用
[轉貼] 社群大數據 - 輿情觀測及分析應用
 
財報分析1
財報分析1財報分析1
財報分析1
 
WebRTC overview
WebRTC overviewWebRTC overview
WebRTC overview
 
Android 待機與操作耗電檢查
Android 待機與操作耗電檢查Android 待機與操作耗電檢查
Android 待機與操作耗電檢查
 
Analyzing Display and Performance with Systrace
Analyzing Display and Performance with SystraceAnalyzing Display and Performance with Systrace
Analyzing Display and Performance with Systrace
 

Recently uploaded

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Recently uploaded (20)

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 

Device tree

  • 2. 緣起 • 某年某⽉月的某⼀一天... 
 神⼈人Linus Torvalds寫了⼀一封信 有⼀一堆闌尾在⽴立法院, 可割可棄!!!
  • 3. So, 割闌尾~ • 科科跟宅宅們參考了PowerPC等其他體系架構下 已經使⽤用的Flattened Device Tree(FDT).起源於 OpenFirmware IEEE 1275 device-tree notion. • ⽇日後決定採⽤用Device Tree為描述硬體平台的資料 結構.
  • 4. Device Tree • 由⼀一系列被命名的結點(Node)和屬性 (Property)來組成. Node可包含Sub-Node. Property是成對的name和value. 可讀性⾼高. • 可以在開機的時候, 在透過它將訊息傳遞給作業系 統,⽽而不需要在把這些資訊放在程式碼中. • 未來也很⽅方便增減修改Device Tree, 容易⽀支援不同 的Soc或硬體週邊. Z > B!!!
  • 5. How to work with device tree complier Device tree description binary data bootloader kernel platform probe carry HW configuration pass DTS DTC DTB
  • 6. Device tree misc. • DTS
 - device tree source file • DTC
 - device tree compiler, It compiles DTS to DTB. • DTB
 - device tree blob, the binary data to store the information of DTS.
  • 7. DTS Format(1) /{! ! properties = ”value as string” | <value as u32 list> | [ value as byte stream ] | <&node name>! ! child_node[@address] {! ! ! child_properties! ! }! }! ! &node_name {! ! compatible = "<manufacturer>,<model>"! ! properties! }! “/“ 表⽰示根節點, 不需要寫節點名稱 屬性Properties可以⽤用混合格式表⽰示, 如“字串”,或<32位元整數列表>,或[位元組流]或
 <&其他參考節點名稱> 每個 Node 都會有⼀一個’compatible’ property. 格式為 "<manufacturer>,<model>",第⼀一個字串表⽰示確切名 稱,第⼆二個字串表⽰示可兼容的其他設備。
  • 8. DTS Format(2) /{! ! properties = ”value as string” | <value as u32 list> | [ value as byte stream ] | <&node name>! ! child_node[@address] {! ! ! child_properties! ! }! }! ! &node_name {! ! compatible = "<manufacturer>,<model>"! ! properties! }! 結點的命名,遵循的格式為: <name>[@address]
 name是⼀一個ASCII字串,⽤用於描述結點對應的 裝置類型. 如果⼀一個結點描述的裝置有記憶體地 址,則填⼊入@address。多個相同類型設備結點 的name可以⼀一樣,只要address不同即可
  • 9. DTS format(3) / { compatible = "acme,coyotes-revenge"; #address-cells = <1>; #size-cells = <1>; interrupt-parent = <&intc>; cpus { #address-cells = <1>; #size-cells = <0>; cpu@0 { compatible = "arm,cortex-a9"; reg = <0>; }; cpu@1 { compatible = "arm,cortex-a9"; reg = <1>; }; }; serial@1010adbd { compatible = "arm,pl011"; reg = <0x101abcd 0x1000>; reg_name = “” }; 節點1 節點2! ⼦子節點1! ⼦子節點2! 根節點
  • 10. DTS format(4)/ { compatible = "acme,coyotes-revenge"; #address-cells = <1>; ! #size-cells = <1>; interrupt-parent = <&intc>; cpus { #address-cells = <1>; ! #size-cells = <0>; cpu@0 { compatible = "arm,cortex-a9"; reg = <0>; }; cpu@1 { compatible = "arm,cortex-a9"; reg = <1>; }; }; serial@1010adbd { compatible = "arm,pl011"; reg = <0x101abcd 0x1000>;! ! reg_name = “”! }; 有位址的裝置會使⽤用 #address-cells 和 #size-cells 來決定⼦子結點 的’reg’屬性的格式怎麼填 reg = <address1 length1 [address2 length2] ... > #size-cells = <0>; 表⽰示只填⼊入Reg的starting address #address-cells = <1>; ! #size-cells = <1>; ! 填⼊入格式為 Reg = <Starting_address Size>
  • 11. .dts & dtsi • .dts 是採⽤用ASCII 格式的Device Tree描述檔⽂文件. ⼀一般放置位在 kernel/arch/arm/boot/dts/。 • ⼀一個SoC可能拿來開發多個產品線,為了⽅方便, 把SoC公⽤用的硬體設定或不同產品的共同部分提 煉為.dtsi,類似C語⾔言的.h。其他不同產品的.dts 可以引⽤用這些共通的.dtsi。
  • 13. for example - Driver probe @mdss_mdp.cpp static const struct of_device_id mdss_mdp_dt_match[] = .compatible = "qcom,mdss_mdp" MODULE_DEVICE_TABLE (of, mdss_mdp_dt_match); ! static struct platform_driver mdss_mdp_driver = { .probe = mdss_mdp_probe, .driver = { .name = "mdp", .of_match_table = mdss_mdp_dt_match, } } ! static int __init mdss_mdp_driver_init (void) { platform_driver_register( &mdss_mdp_driver ); } @msm1234-mdss.dtsi &soc { ! mdss_mdp: qcom,mdss_mdp@12340000 { compatible = "qcom,mdss_mdp"; reg = <0x12340000 0xff00> reg-names = "mdp_phys", "vbif_phys"; … ! mdss_dsi0: qcom,mdss_dsi@12345000 { compatible = "qcom,mdss-dsi-ctrl"; qcom,mdss-mdp = <&mdss_mdp>; … ! qcom,mdss_wb_panel { compatible = "qcom,mdss_wb"; … …
  • 14. Parsing APIs of Device Tree property * of_find_property(); device_node * of_find_node_by_name(); of_find_node_by_type();
 of_find_compatible_node();
 of_find_matching_node_and_match();
 of_find_node_by_path(); 
 of_find_node_by_phandle(); void * of_get_property(); int of_property_read_u32_index() 
 of_property_read_u8_array();
 of_property_read_u16_array(); 
 of_property_read_u32_array();
 of_property_read_string();
 of_property_read_string_index(); int of_parse_phandle_with_args(), of_parse_phandle_with_fixed_args(), of_count_phandle_with_args()
  • 15. Reference • http://www.devicetree.org/Main_Page • http://www.devicetree.org/Device_Tree_Usage • Device Tree Support on ARM Linux
 Chih-Min Chao) http://gplus.to/cmchao COSCUP 2011 in Taiwan • http://blog.csdn.net/21cnbao/article/details/ 8457546