我正在开发一个利用 Digi ConnectCore 6UL SBC Pro 的嵌入式项目,我知道dmesg
启动后应该会显示三个 I2C 接口,如下所示:
i2c i2c-0: IMX I2C adapter registered
i2c i2c-0: can't use DMA, using PIO instead.
i2c i2c-1: IMX I2C adapter registered
i2c i2c-1: can't use DMA, using PIO instead.
i2c i2c-2: IMX I2C adapter registered
i2c i2c-2: can't use DMA, using PIO instead.
我启动了自己的映像,该映像可以正常启动,但不是三个,而是只有两个接口:
i2c i2c-0: IMX I2C adapter registered
i2c i2c-0: can't use DMA, using PIO instead.
i2c i2c-1: IMX I2C adapter registered
i2c i2c-1: can't use DMA, using PIO instead.
我想知道第三个接口在哪里?另外,i2cdetect
给出以下结果: 原始图像:
# i2cdetect -l
i2c-1 i2c 21a4000.i2c I2C adapter
i2c-2 i2c 21a8000.i2c I2C adapter
i2c-0 i2c 21a0000.i2c I2C adapter
与新图像对比:
# i2cdetect -l
i2c-1 i2c 21a4000.i2c I2C adapter
i2c-0 i2c 21a0000.i2c I2C adapter
看起来,内核无法看到地址 21a8000 处的 I2C 接口。我如何修改我的构建,以便它也能看到第三个 I2C 设备?我一直在研究设备树文件,但不确定在哪里查看、修改和修复这个问题。
欢迎任何提示、指示和建议!
/usr/local/dey-2.2~/tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/Documentation/devicetree/bindings/i2c/i2c-imx。 TXT:
* Freescale Inter IC (I2C) and High Speed Inter IC (HS-I2C) for i.MX
Required properties:
- compatible :
- "fsl,imx1-i2c" for I2C compatible with the one integrated on i.MX1 SoC
- "fsl,imx21-i2c" for I2C compatible with the one integrated on i.MX21 SoC
- "fsl,vf610-i2c" for I2C compatible with the one integrated on Vybrid vf610 SoC
- reg : Should contain I2C/HS-I2C registers location and length
- interrupts : Should contain I2C/HS-I2C interrupt
- clocks : Should contain the I2C/HS-I2C clock specifier
Optional properties:
- clock-frequency : Constains desired I2C/HS-I2C bus clock frequency in Hz.
The absence of the property indicates the default frequency 100 kHz.
- dmas: A list of two dma specifiers, one for each entry in dma-names.
- dma-names: should contain "tx" and "rx".
- scl-gpios: specify the gpio related to SCL pin
- sda-gpios: specify the gpio related to SDA pin
- pinctrl: add extra pinctrl to configure i2c pins to gpio function for i2c
bus recovery, call it "gpio" state
Examples:
i2c@83fc4000 { /* I2C2 on i.MX51 */
compatible = "fsl,imx51-i2c", "fsl,imx21-i2c";
reg = <0x83fc4000 0x4000>;
interrupts = <63>;
};
i2c@70038000 { /* HS-I2C on i.MX51 */
compatible = "fsl,imx51-i2c", "fsl,imx21-i2c";
reg = <0x70038000 0x4000>;
interrupts = <64>;
clock-frequency = <400000>;
};
i2c0: i2c@40066000 { /* i2c0 on vf610 */
compatible = "fsl,vf610-i2c";
reg = <0x40066000 0x1000>;
interrupts =<0 71 0x04>;
dmas = <&edma0 0 50>,
<&edma0 0 51>;
dma-names = "rx","tx";
pinctrl-names = "default", "gpio";
pinctrl-0 = <&pinctrl_i2c1>;
pinctrl-1 = <&pinctrl_i2c1_gpio>;
scl-gpios = <&gpio5 26 GPIO_ACTIVE_HIGH>;
sda-gpios = <&gpio5 27 GPIO_ACTIVE_HIGH>;
};
您好,对于这么长时间的缺席,我深表歉意,并希望从这里继续使用这张票。正如 @dirkt 在他/她的评论中建议的那样,我在内核源代码中搜索了 dts 和 dtsi 文件,但发现了太多文件:
$ locate .dts | grep /arch/arm | grep /boot/dts | grep /usr/local/dey-2.2 | wc -l
1541
并添加| grep -i i2c
代替| wc -l
上述内容没有给我任何结果。那么我想知道如何将I2C
设备添加到设备树的正确位置?
我可以找到以下相关*.dts
文件:
$ find . -name "*imx6ul*.dts"
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-pico-hobbit.dts
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-tx6ul-0011.dts
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-14x14-evk.dts
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-tx6ul-0010.dts
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-tx6ul-mainboard.dts
在 grep 后i2c
,看起来这些文件都不与我在上面看到的 i2c 输出对齐......:
$ find . -name "*imx6ul*.dts" | xargs grep -i i2c
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-pico-hobbit.dts:&i2c1 {
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-pico-hobbit.dts: pinctrl-0 = <&pinctrl_i2c1>;
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-pico-hobbit.dts:&i2c2 {
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-pico-hobbit.dts: pinctrl-0 = <&pinctrl_i2c2>;
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-pico-hobbit.dts:&i2c3 {
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-pico-hobbit.dts: pinctrl-0 = <&pinctrl_i2c3>;
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-pico-hobbit.dts: pinctrl_i2c1: i2c1grp {
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-pico-hobbit.dts: MX6UL_PAD_GPIO1_IO02__I2C1_SCL 0x4001b8b0
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-pico-hobbit.dts: MX6UL_PAD_GPIO1_IO03__I2C1_SDA 0x4001b8b0
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-pico-hobbit.dts: pinctrl_i2c2: i2c2grp {
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-pico-hobbit.dts: MX6UL_PAD_UART5_TX_DATA__I2C2_SCL 0x4001b8b0
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-pico-hobbit.dts: MX6UL_PAD_UART5_RX_DATA__I2C2_SDA 0x4001b8b0
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-pico-hobbit.dts: pinctrl_i2c3: i2c3grp {
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-pico-hobbit.dts: MX6UL_PAD_UART1_TX_DATA__I2C3_SCL 0x4001b8b0
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-pico-hobbit.dts: MX6UL_PAD_UART1_RX_DATA__I2C3_SDA 0x4001b8b0
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-14x14-evk.dts:&i2c2 {
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-14x14-evk.dts: pinctrl-0 = <&pinctrl_i2c2>;
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-14x14-evk.dts: pinctrl_i2c1: i2c1grp {
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-14x14-evk.dts: MX6UL_PAD_UART4_TX_DATA__I2C1_SCL 0x4001b8b0
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-14x14-evk.dts: MX6UL_PAD_UART4_RX_DATA__I2C1_SDA 0x4001b8b0
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-14x14-evk.dts: pinctrl_i2c2: i2c2grp {
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-14x14-evk.dts: MX6UL_PAD_UART5_TX_DATA__I2C2_SCL 0x4001b8b0
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-14x14-evk.dts: MX6UL_PAD_UART5_RX_DATA__I2C2_SDA 0x4001b8b0
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-tx6ul-mainboard.dts:&i2c_gpio {
./tmp/work/cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul-tx6ul-mainboard.dts:&i2c2 {
我发现: i2c1: i2c@021a0000 { #address-cells = <1>; #size-cells = <0>;兼容=“fsl,imx6ul-i2c”,“fsl,imx21-i2c”; reg = <0x021a0000 0x4000>;中断=<GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;时钟= <&clks IMX6UL_CLK_I2C1>;状态=“已禁用”; };
i2c2: i2c@021a4000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,imx6ul-i2c", "fsl,imx21-i2c";
reg = <0x021a4000 0x4000>;
interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX6UL_CLK_I2C2>;
status = "disabled";
};
i2c3: i2c@021a8000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,imx6ul-i2c", "fsl,imx21-i2c";
reg = <0x021a8000 0x4000>;
interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX6UL_CLK_I2C3>;
status = "disabled";
};
其中
cortexa7hf-neon-dey-linux-gnueabi/linux-libc-headers/4.8-r0/linux-4.8/arch/arm/boot/dts/imx6ul.dtsi
可能是我正在处理的设备树文件。值得注意的是,所有 i2c 接口的状态都设置为"disabled"
答案1
如果您从 SD 卡启动,您应该能够*.dtb
在其中找到一个文件。这个编译后的设备树文件告诉内核哪些硬件可用。您可以将其替换为从文件编译的自定义版本*.dts
。
在上游Linux源代码中我看到imx6ul-ccimx6ulsbcpro.dts这应该是您董事会的选择。不过,它似乎只能启用i2c1
.在包含的imx6ul.dtsi我们看到实际上有四个 I2C 接口。
至少如果您使用上游 Linux 内核,您应该能够通过添加以下内容来启用第三个 I2C 接口mx6ul-ccimx6ulsbcpro.dts
:
&i2c3 {
status = "okay";
};
然后运行make dtbs
构建 DTB。
还可以使用以下命令反编译/编译 DTB直达。