移植网卡失败,所以先来学习一下dts的使用方法。
keypad是最简单的设备之一,所以先拿这个开刀。
在s5pv210.dtsi里列举了s5pv210的soc上面的所有设备资源,注意这里是soc上的,没有描述实际连接的外设,实际的外设需要在主dts也就是s5pv210-smdkv210.dts中描述。
-
/ {
-
.....................
-
-
pinctrl0: pinctrl@e0200000 {
-
compatible = "samsung,s5pv210-pinctrl";
-
reg = <0xe0200000 0x1000>;
-
interrupt-parent = <&vic0>;
-
interrupts = <30>;
-
-
wakeup-interrupt-controller {
-
compatible = "samsung,exynos4210-wakeup-eint";
-
interrupts = <16>;
-
interrupt-parent = <&vic0>;
-
};
-
};
-
-
keypad: keypad@e1600000 {
-
compatible = "samsung,s5pv210-keypad";
-
reg = <0xe1600000 0x1000>;
-
interrupt-parent = <&vic2>;
-
interrupts = <25>;
-
clocks = <&clocks CLK_KEYIF>;
-
clock-names = "keypad";
-
status = "disabled";
-
};
pinctrl是GPIO设备为什么长度只有0x1000,我猜测这个pinctrl的作用只是给驱动源码提供一个GPIO的base address。
这里定义了一个标签keypad,方便其他地方引用。
keypad的寄存器地址是e1600000,这和手册是一致的。属性指定了中断,时钟。
但是具体用到那些gpio呢,这就要看
s5pv210-smdkv210.dts了。
-
&keypad {
-
linux,input-no-autorepeat;
-
linux,input-wakeup;
-
samsung,keypad-num-rows = <8>;
-
samsung,keypad-num-columns = <8>;
-
pinctrl-names = "default";
-
pinctrl-0 = <&keypad_row0>, <&keypad_row1>, <&keypad_row2>,
-
<&keypad_row3>, <&keypad_row4>, <&keypad_row5>,
-
<&keypad_row6>, <&keypad_row7>,
-
<&keypad_col0>, <&keypad_col1>, <&keypad_col2>,
-
<&keypad_col3>, <&keypad_col4>, <&keypad_col5>,
-
<&keypad_col6>, <&keypad_col7>;
-
status = "okay";
-
-
key_1 {
-
keypad,row = <0>;
-
keypad,column = <3>;
-
linux,code = <KEY_1>;
-
};
-
-
key_2 {
-
keypad,row = <0>;
-
keypad,column = <4>;
-
linux,code = <KEY_2>;
-
};
-
-
key_3 {
-
keypad,row = <0>;
-
keypad,column = <5>;
-
linux,code = <KEY_3>;
-
};
-
-
key_4 {
-
keypad,row = <0>;
-
keypad,column = <6>;
-
linux,code = <KEY_4>;
-
};
-
-
key_5 {
-
keypad,row = <0
-
>;
-
keypad,column = <7>;
-
linux,code = <KEY_5>;
-
};
-
-
key_6 {
-
keypad,row = <1>;
-
keypad,column = <3>;
-
linux,code = <KEY_A>;
-
};
-
key_7 {
-
keypad,row = <1>;
-
keypad,column = <4>;
-
linux,code = <KEY_B>;
-
};
-
-
key_8 {
-
keypad,row = <1>;
-
keypad,column = <5>;
-
linux,code = <KEY_C>;
-
};
-
-
key_9 {
-
keypad,row = <1>;
-
keypad,column = <6>;
-
linux,code = <KEY_D>;
-
};
-
-
key_10 {
-
keypad,row = <1>;
-
keypad,column = <7>;
-
linux,code = <KEY_E>;
-
};
-
};
通过&keypad引用s5pv210.dtsi中的keypad结点。我的理解就是对s5pv210.dtsi中的keypad结点添加更多属性。
这个keypad的设置为:
禁止重复按键输入,输入唤醒,8行8列。注意pinctrl-0=<&keypad_row0> ~ <&keypad_col7>,这是重头戏,通过标签引用了16根引脚结点,这些引脚在s5pv210-pinctrl.dts中定义。
这是一个典型的client device结点(pinctrl子系统中的概念),state只有一个"default",相关知识参考 style="white-space:normal;" />
default的状态对应了pinctrl-0的配置,也就是当keypad这个设备被激活的时候,将这16根引脚设置成pinctrl-0的配置。pinctrl-0是一个句柄(phandle)列表,指向<&keypad_row0> ~ <&keypad_col7>。
s5pv210-pinctrl.dts列出了pinctrl0的全部结点,这里只给出keypad相关的结点:
-
&pinctrl0 {
-
-
........
-
-
keypad_row0: keypad-row-0 {
-
samsung,pins = "gph3-0";
-
samsung,pin-function = <3>;
-
samsung,pin-pud = <0>;
-
samsung,pin-drv = <0>;
-
};
-
-
keypad_row1: keypad-row-1 {
-
samsung,pins = "gph3-1";
-
samsung,pin-function = <3>;
-
samsung,pin-pud = <0>;
-
samsung,pin-drv = <0>;
-
};
-
-
keypad_row2: keypad-row-2 {
-
samsung,pins = "gph3-2";
-
samsung,pin-function = <3>;
-
samsung,pin-pud = <0>;
-
samsung,pin-drv = <0>;
-
};
-
-
keypad_row3: keypad-row-3 {
-
samsung,pins = "gph3-3";
-
samsung,pin-function = <3>;
-
samsung,pin-pud = <0>;
-
samsung,pin-drv = <0>;
-
};
-
-
keypad_row4: keypad-row-4 {
-
samsung,pins = "gph3-4";
-
samsung,pin-function = <3>;
-
samsung,pin-pud = <0>;
-
samsung,pin-drv = <0>;
-
};
-
-
keypad_row5: keypad-row-5 {
-
samsung,pins = "gph3-5";
-
samsung,pin-function = <3>;
-
samsung,pin-pud = <0>;
-
samsung,pin-drv = <0>;
-
};
-
-
keypad_row6: keypad-row-6 {
-
samsung,pins = "gph3-6";
-
samsung,pin-function = <3>;
-
samsung,pin-pud = <0>;
-
samsung,pin-drv = <0>;
-
};
-
-
keypad_row7: keypad-row-7 {
-
samsung,pins = "gph3-7";
-
samsung,pin-function = <3>;
-
samsung,pin-pud = <0>;
-
samsung,pin-drv = <0>;
-
};
-
-
keypad_col0: keypad-col-0 {
-
samsung,pins = "gph2-0";
-
samsung,pin-function = <3>;
-
samsung,pin-pud = <0>;
-
samsung,pin-drv = <0>;
-
};
-
-
keypad_col1: keypad-col-1 {
-
samsung,pins = "gph2-1";
-
samsung,pin-function = <3>;
-
samsung,pin-pud = <0>;
-
samsung,pin-drv = <0>;
-
};
-
-
keypad_col2: keypad-col-2 {
-
samsung,pins = "gph2-2";
-
samsung,pin-function = <3>;
-
samsung,pin-pud = <0>;
-
samsung,pin-drv = <0>;
-
};
-
-
keypad_col3: keypad-col-3 {
-
samsung,pins = "gph2-3";
-
samsung,pin-function = <3>;
-
samsung,pin-pud = <0>;
-
samsung,pin-drv = <0>;
-
};
-
-
keypad_col4: keypad-col-4 {
-
samsung,pins = "gph2-4";
-
samsung,pin-function = <3>;
-
samsung,pin-pud = <0>;
-
samsung,pin-drv = <0>;
-
};
-
-
keypad_col5: keypad-col-5 {
-
samsung,pins = "gph2-5";
-
samsung,pin-function = <3>;
-
samsung,pin-pud = <0>;
-
samsung,pin-drv = <0>;
-
};
-
-
keypad_col6: keypad-col-6 {
-
samsung,pins = "gph2-6";
-
samsung,pin-function = <3>;
-
samsung,pin-pud = <0>;
-
samsung,pin-drv = <0>;
-
};
-
-
keypad_col7: keypad-col-7 {
-
samsung,pins = "gph2-7";
-
samsung,pin-function = <3>;
-
samsung,pin-pud = <0>;
-
samsung,pin-drv = <0>;
-
};
这里定义了keypad_row0 ~ keypad_col7 共16个标签,就是刚才的&keypad中的pinctrl-0引用了,这里详细列出了当使用keypad时,16个io的配置。
到这里就分析完成了。
补充说明一下s5pv210.dts中的aliaes(别名)。
-
/ {
-
aliases {
-
csis0 = &csis0;
-
fimc0 = &fimc0;
-
fimc1 = &fimc1;
-
fimc2 = &fimc2;
-
i2c0 = &i2c0;
-
i2c1 = &i2c1;
-
i2c2 = &i2c2;
-
i2s0 = &i2s0;
-
i2s1 = &i2s1;
-
i2s2 = &i2s2;
-
pinctrl0 = &pinctrl0;
-
spi0 = &spi0;
-
spi1 = &spi1;
-
};
注意这里pinctrl0 = &pinctrl0; 这行代码相当于C语言中的宏定义。可以理解为#define pinctrl0 &pinctrl0;
这样当我们在属性中写pinctrl0时,就是用&符号引用标签pinctrl0,乍一看可能感觉没什么卵用,直接写&pinctrl0不就完了,事实并非如此,对于dts文件可以用&pinctrl0的方式引用结点,但是在内核驱动源码中,就必须指定全路径了,所以这里用别名来替代全路径,方便驱动源码的识别。在根据device tree usage,别名应当是用来替代全路径的。
阅读(3211) | 评论(2) | 转发(0) |