标签:dts 编写 writable clock ges img tab module input
首先要明白一点,就是i2c设备是挂载在总线上的,所以一定得先先加入总线驱动,现加设备驱动。
虽然是初步接触dts,也不懂dts的语法,但是之前有过丰富的驱动开发经验,进行迁移:
对于i2c总线来说,有两点需要注意的: 第一:引脚的初始化 第二:总线时钟的设定
总线初始化第一点:
i2c0_pins: pinmux_i2c0_pins {
pinctrl-single,pins = <
AM33XX_IOPAD(0x988, PIN_INPUT_PULLUP | MUX_MODE0) /* i2c0_sda.i2c0_sda */
AM33XX_IOPAD(0x98c, PIN_INPUT_PULLUP | MUX_MODE0) /* i2c0_scl.i2c0_scl */
>;
};
如何得出引脚的初始化
->引脚初始化操作的肯定是PIN MUX寄存器
->然后查看数据手册,在其9.3章节当有有对CONTROL MODULES Register 的说明
-->对比原理图,0x988 0x98c就是CONTROL MODULES Register的偏移地址
总线初始化第二点:
&i2c0 {
pinctrl-names = "default";
pinctrl-0 = <&i2c0_pins>;
status = "okay";
clock-frequency = <400000>;
总线成功初始化之后,就是要编写 rtc (RX8025)及 eeprom (AT24C08)对应的节点,
针对i2c 设备来说,最关键的就是i2c的地址信息
我们可以参考内核的相关文档来编写对应的dts结点,有了基于硬件特性的识认,就非常的简单了:
Documentation/devicetree/bindings/rtc/epson,rx8900.txt
Documentation/devicetree/bindings/eeprom/eeprom.txt
&i2c0 {
pinctrl-names = "default";
pinctrl-0 = <&i2c0_pins>;
status = "okay";
clock-frequency = <400000>;
tps: tps@2d {
reg = <0x2d>;
};
at24c08@50 {
compatible = "atmel,24c08";
pagesize = <16>;
reg = <0x50>;
};
rtc@32 {
compatible = "epson,rx8025";
reg = <0x32>;
};
};
重新编写,测试之后可得
[ 1.992222] at24 0-0050: 1024 byte 24c08 EEPROM, writable, 16 bytes/write
[ 2.000072] rtc-rx8025 0-0032: rx8025_get_time: read 0x40 0x59 0x05 0x02 0x27 0x11 0x18
[ 2.000092] rtc-rx8025 0-0032: rx8025_get_time: date 40s 59m 5h 27md 10m 118y
[ 2.000376] rtc rtc0: rx8025: dev (253:0)
[ 2.000407] rtc-rx8025 0-0032: rtc core: registered rx8025 as rtc0
am335x系统升级之kernel i2c rtc eeprom(六)
标签:dts 编写 writable clock ges img tab module input
原文地址:https://www.cnblogs.com/lianghong881018/p/10026334.html