openwrt - dts¶
dts设备数,用于描述硬件底层的信息
/* cat target/linux/ramips/dts/THINGOO-G1-E-GRAPES.dts */
/dts-v1/;
/* 包含THINGOO-G1.dtsi文件,类似 头文件 */
#include "THINGOO-G1.dtsi"
/ {
compatible = "yancy,thingoo-g1-e-grapes", "yancy,thingoo-g1", "mediatek,mt7628an-soc";
model = "THINGOO-G1-E-GRAPES";
gpio_export {
compatible = "gpio-export";
#size-cells = <0>;
/* 将GPIO 导出到文件中,相当于在系统中执行echo "37" > /sys/class/gpio/export */
BLE37 {
gpio-export,name = "BLE37";
gpio-export,output = <1>;
gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
};
BLE39 {
gpio-export,name = "BLE39";
gpio-export,output = <1>;
gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
};
BLE40 {
gpio-export,name = "BLE40";
gpio-export,output = <1>;
gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>;
};
BLE44 {
gpio-export,name = "BLE44";
gpio-export,output = <1>;
gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
};
BLE45 {
gpio-export,name = "BLE45";
gpio-export,output = <1>;
gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>;
};
BLE46 {
gpio-export,name = "BLE46";
gpio-export,output = <1>;
gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
};
};
};
&spi0 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&spi_pins>, <&spi_cs1_pins>;
m25p80@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <40000000>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
/* 指定mtd的分区 */
partition@0 {
label = "u-boot";
reg = <0x0 0x30000>;
};
partition@30000 {
label = "u-boot-env";
reg = <0x30000 0x10000>;
};
factory: partition@40000 {
label = "factory";
reg = <0x40000 0x10000>;
};
partition@50000 {
compatible = "denx,uimage";
label = "firmware";
reg = <0x50000 0x0fb0000>;
};
};
};
spidev@1 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "linux,spidev";
reg = <1>;
spi-max-frequency = <40000000>;
};
};
/* cat target/linux/ramips/dts/THINGOO-G1.dtsi */
#include "mt7628an.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
/ {
compatible = "yancy,thingoo-g1", "mediatek,mt7628an-soc";
chosen {
/* 加载内核时传递的参数,这里指定了串口控制台的设备号和波特率 */
bootargs = "console=ttyS0,57600";
};
memory@0 {
device_type = "memory";
/* 这里指定了RAM运行内存的大小为128MB(0x8000000) */
reg = <0x0 0x8000000>;
};
keys {
compatible = "gpio-keys-polled";
poll-interval = <20>;
/* 这里指定了reset按键所用的gpio为(&gpio1) + 6 = GPIO38 */
/* 为什么等于GPIO38,因为&gpio1的开始地址是GPIO32 */
reset {
label = "reset";
/* reset最终会调用hotplug.d中的reset脚本,脚本名字和这里的label名字要对应起来 */
gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};
};
};
&pinctrl {
state_default: pinctrl0 {
gpio {
/* 这里指定了这些特殊用途的gpio口全部用作纯gpio */
ralink,group = "gpio", "uart1", "perst", "refclk", "spis", "i2s", "wled_an", "wled_kn", "p0led_an", "p1led_an", "p2led_an", "p3led_an", "p4led_an", "wdt";
ralink,function = "gpio";
};
};
};
&i2c {
status = "okay";
};
ðernet {
/* 指定mac地址为factory分区开始的第0x28是mac地址存放位置 */
mtd-mac-address = <&factory 0x28>;
};
&sdhci {
status = "okay";
mediatek,cd-low;
};
&wmac {
status = "okay";
};