linux 设备树
作者:互联网
一、设备树作用
设备树存在的目的是将soc的uart、i2c、spi等外设信息以设备树文件的形式独立出内核,系统启动时,内核会将设备树读入。
二、dts、dtsi、dtb、dtc关系
设备树有.dts和.dtsi两种文件形式,.dtsi是.dts的公共部分,被dts包含。dtc是dts的编译器,将dtsi和dts编译成dtb。最终内核是读取dtb文件将设备树度进内核。dtc工具在linux源码/scripts/dtc 目录下。
三、设备树结构
uart0是节点标签,serial是节点名称,12100000是uart0寄存器首地址,在dts中可以通过@uart0来访问这个节点
下面是hi3559av100-demb.dts的部分设备树
#include "hi3559av100.dtsi"
/ { 以“/”开头
model = "Hisilicon HI3559AV100 DEMO Board"; model指定制造商的设备型号
compatible = "hisilicon,hi3559av100"; compatible指定了系统的名称
aliases {
serial0 = &uart0;
serial1 = &uart1;
i2c0 = &i2c_bus0;
i2c1 = &i2c_bus1;
spi0 = &spi_bus0;
spi1 = &spi_bus1;
gpio0 = &gpio_chip0;
gpio1 = &gpio_chip1;
};
chosen {
bootargs = "mem=512M console=ttyAMA0,115200 clk_ignore_unused root=/dev/mtdblock2 rootfstype=yaffs2 rw mtdparts=hinand:1M(boot),9M(kernel),32M(rootfs),1M(this_bootargs_string_is_reserved_for_bootargs_form_uboot!!!_it_must_be_longer_than_bootargs_form_uboot!!!_this_bootargs_string_is_reserved_for_bootargs_form_uboot!!!_it_must_be_longer_than_bootargs_form_uboot!!!_this_bootargs_string_is_reserved_for_bootargs_form_uboot!!!_it_must_be_longer_than_bootargs_form_uboot!!!_this_bootargs_string_is_reserved_for_bootargs_form_uboot!!!_it_must_be_longer_than_bootargs_form_uboot!!!_this_bootargs_string_is_reserved_for_bootargs_form_uboot!!!_it_must_be_longer_than_bootargs_form_uboot!!!)";
linux,initrd-start = <0x60000040>;
linux,initrd-end = <0x61000000>;
};
cpus {
#address-cells = <2>;
#size-cells = <0>;
cpu@0 {
compatible = "arm,cortex-a53";
device_type = "cpu";
reg = <0x0 0x0>;
enable-method = "psci";
clock-latency = <100000>; /* From legacy driver */
cpu-idle-states = <&CPU_POWERDOWN &CPU_STANDBY>;
};
cpu@1 {
compatible = "arm,cortex-a53";
device_type = "cpu";
reg = <0x0 0x1>;
enable-method = "psci";
clock-latency = <200000>; /* From legacy driver */
cpu-idle-states = <&CPU_POWERDOWN &CPU_STANDBY>;
};
cpu@2 {
compatible = "arm,cortex-a73";
device_type = "cpu";
reg = <0x0 0x100>;
enable-method = "psci";
cpu-idle-states = <&CPU_POWERDOWN &CPU_STANDBY>;
vcc-supply = <&a73_regulator>;
};
cpu@3 {
compatible = "arm,cortex-a73";
device_type = "cpu";
reg = <0x0 0x101>;
enable-method = "psci";
operating-points = <
792000 796000
1296000 888000
1608000 988000
>;
clocks = <&clock HI3559AV100_A73_MUX>,
<&clock HI3559AV100_FIXED_24M>,
<&clock HI3559AV100_APLL_CLK>,
<&clock HI3559AV100_FIXED_1000M>;
clock-names = "a73_mux","24m","apll","1000m";
clock-latency = <400000>; /* From legacy driver */
cpu-idle-states = <&CPU_POWERDOWN &CPU_STANDBY>;
vcc-supply = <&a73_regulator>;
};
};
memory {
device_type = "memory";
reg = <0x0 0x44000000 0x2 0x0>; /* system memory base */
};
};
&uart0 { "&"表示追加节点属性,在"hi3516dv200.dtsi"文件中已经有uart0节点的描述,这里追加一个"status"属性,如果dtsi中已经有status属性,将会替换,如果没有则追加。
status = "okay";
};
&uart1 {
status = "okay";
};
四、设备树在系统中的位置
设备树会被内核解析到/sys/firmware/devicetree/base,以hi3559为例,改目录下的文件如下所示:
标签:uboot,form,linux,dts,设备,dtsi,cpu,bootargs 来源: https://www.cnblogs.com/YYFaGe/p/14415445.html