比如 sun8i-v3s-licheepi-zero.dts
&ohci0 {
status = "okay";
};&uart0 {
pinctrl-0 = <&uart0_pins_a>;
pinctrl-names = "default";
status = "okay";
};&uart1 {
pinctrl-0 = <&uart1_pins_a>;
pinctrl-names = "default";
status = "okay";
};&uart2 {
pinctrl-0 = <&uart2_pins_a>;
pinctrl-names = "default";
status = "okay";
};&usb_otg {
dr_mode = "otg";
status = "okay";
};
就是上面这个 okay 和 & 没搞明白.
离线
$ grep \"okay\" -r ./drivers/of --include *.c
./drivers/of/dynamic.c: status_state = !strcmp(prop->value, "okay") ||
./drivers/of/dynamic.c: old_status_state = !strcmp(old_prop->value, "okay") ||
./drivers/of/fdt.c: if (status && strcmp(status, "okay") != 0 && strcmp(status, "ok") != 0)
./drivers/of/base.c: * Returns true if the status property is absent or set to "okay" or "ok",
./drivers/of/base.c: if (!strcmp(status, "okay") || !strcmp(status, "ok"))
./drivers/of/base.c: * Returns true if the status property is absent or set to "okay" or "ok",
我搜一下设备树相关代码,貌似有新发现.
离线
./drivers/of/fdt.c
static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname,
int depth, void *data)
{
... ...status = of_get_flat_dt_prop(node, "status", NULL);
if (status && strcmp(status, "okay") != 0 && strcmp(status, "ok") != 0)
return 0;err = __reserved_mem_reserve_reg(node, uname);
if (err == -ENOENT && of_get_flat_dt_prop(node, "size", NULL))
fdt_reserved_mem_save_node(node, uname, 0, 0);/* scan next node */
return 0;
}
如果设备树的 status 值不等于 okay 后者 ok, 那么就直接退出了。
所以,如果要启动这个设备,在设备树必须 status = okay 或者 ok.
离线
https://e-mailky.github.io/2016-12-06-dts-introduce#%E6%A6%82%E8%BF%B0
http://billauer.co.il/blog/2017/02/linux-dts-dtsi-status-ok/
https://developer.toradex.com/device-tree-customization
https://unix.stackexchange.com/questions/179078/meaning-of-an-ampersand-prefix-in-a-device-tree
下面是google自动翻译:
可以使用和号(&)字符和标签来引用节点。
覆盖属性
要覆盖属性,需要使用&符号和标签引用节点。以后的设备树条目会覆盖先前的条目(条目的顺序顺序是重要的,因此包含顺序很重要)。通常,较高层(例如载板设备树)覆盖较低层(例如SoC设备树),因为较高层在最开始时包括较低层。
例如,对于能够作为设备或主机(双角色)的USB控制器,可以使用dr_mode属性显式覆盖默认模式:
&usbdev0 {
dr_mode = "host";
};
https://github.com/Lichee-Pi/linux/tree/zero-4.13.y/arch/arm/boot/dts/sun8i-v3s-licheepi-zero.dts
&usb_otg {
dr_mode = "otg";
status = "okay";
};
https://github.com/Lichee-Pi/linux/blob/zero-4.13.y/arch/arm/boot/dts/sun8i-v3s.dtsi
usb_otg: usb@01c19000 {
compatible = "allwinner,sun8i-h3-musb";
reg = <0x01c19000 0x0400>;
clocks = <&ccu CLK_BUS_OTG>;
resets = <&ccu RST_BUS_OTG>;
interrupts = <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "mc";
phys = <&usbphy 0>;
phy-names = "usb";
extcon = <&usbphy 0>;
status = "disabled";
};
看上面这个 usb_otg, 这个符号&是把两个配置文件合并到一起.
dts 会覆盖他包含的 sun8i-v3s.dtsi 文件.
至于 okay 就是楼上 @路人甲 朋友所表述.
离线
这样差不多明白了,谢谢楼上两位.
离线
@晕哥 的 https://e-mailky.github.io/2016-12-06-dts-introduce#%E6%A6%82%E8%BF%B0
好东西,
很少见到 关于各平台的device tree的介绍,
离线