荔枝派 设备树添加节点
2018-12-26 技术交流
Nano 设备树简介
Nano源码 设备树linux ? arch ? arm ? boot ? dts ? suniv-f1c100s-licheepi-nano.dts;
本文件描述了各种外设的定义和配置,以下简要描述;
/ { … } 包装是定义各种总线和外设配置的根节点;
&xxx { … } 包裹的内容被引用,其定义来自 suniv.dtsi (suniv系列设备的一般定义)
compatible 属性将与驱动源代码中的 相匹配compatible 定义对应性,识别选择;
设备树各部分的编写可参考 linux ? Documentation ? devicetree ? bindings 下各模块
详细介绍设备树,请参考 Device_Tree ,zero文档 也有更详细的描述;
修改设备树LCD 配置
目前默认 LCD配置 为480X大小272的屏幕,
“qiaodian,qd43003c0-40”,“simple-panel”
如果修改为适应8000X这里应该有480屏:
/ { } 包裹的根节点目录,panel属性下的compatible,应修改为:
“lg,lb070wv8”,“simple-panel”
linux ? drivers ? gpu ? drm ? panel 屏幕配置多,可选择合适的配置;
在底板上加 RGB LED 节点配置
添加/ { } 包裹的根节点目录
leds
compatible = "gpio-leds";
blue_led
label = "licheepi:blue:usr";
gpios = ; /* PE4 */
};
green_led
label = "licheepi:green:usr";
gpios = ; /* PE5 */
default-state = "on";
};
red_led
label = "licheepi:red:usr";
gpios = ; /* PE6 */
};
};
支持添加电容触摸屏
电容触摸屏的控制芯片是GT911,使用I2C在设备树文件中添加界面定义;
(笔者此处直接在 suniv.dtsi 内修改。
//添加soc节点下
这里添加的属性和配置来自搜索用户手册和兼容设备
i2c0: i2c@1C270000 {
compatible = "allwinner,sun6i-a31-i2c";
reg = <0x01C27000 0x400>;
interrupts = <7>;
clocks = ;
resets = ;
pinctrl-names = "default";
pinctrl-0 = ;
status = "disabled";
#address-cells = <1>;
#size-cells = <0>;
};
// 在pio添加节点i2c引脚定义
i2c0_pins: i2c0 {
pins = "PE11","PE12";
function = "i2c0";
};
在suniv-f1c100s-licheepi-nano.dts中添加引用
/* 首先要添加的头文件: */
#include #include /* 添加引用 */
&i2c0 {
pinctrl-0 = ;
pinctrl-names = "default";
status = "okay";
gt911: touchscreen@14 {
compatible = "goodix,gt911";
reg = <0x14>;
interrupt-parent = ;
interrupts = <4 10 IRQ_TYPE_EDGE_FALLING>; /* (PE10) */
pinctrl-names = "default";
pinctrl-0 = ;
irq-gpios = ; /* (PE10) */
reset-gpios = ; /* RST (PE9) */
/* touchscreen-swapped-x-y */
};
};
&pio
ts_reset_pin: ts_reset_pin@0 {
pins = "PE9";
function = "gpio_out";
};
};
完成添加~如果测试的触摸屏xy方向颠倒,请添加或删除gt911节点下的 touchscreen-swapped-x-y 属性。
编译生成 dtb文件
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- dtbs -j4
生成的 dtb文件 在 dts在同级目录下,将其放入 TF卡第一分区。