BeagleBoneBlack 设备树修改添加i2c设备驱动()

BeagleBoneBlack 设备树修改添加i2c设备驱动()

我正在尝试使用 i2c2 引脚 [P9] 在 BeagleBoneBlack 上运行 i2c 设备驱动程序:(19) I2C2_SCL,(20) I2C2_SDA。

我可以从用户空间成功使用 i2c2 来控制相同的 atmel 触摸屏设备,但是当从设备驱动程序使用它时,在探测时,我不断收到错误 -16(资源繁忙)。

设备驱动程序是https://github.com/ssl-maxtouch/linux-device-driver/blob/master/atmel_mxt_ts.c我将其静态构建到内核中(drivers/input/touchscreen/atmel_mxt_ts.c)。

我将以下内容添加到设备树源文件中拱门/arm/boot/dts/am335x-boneblack.dts:

&i2c2 {
    atmel_mxt_ts@4b {
        compatible = "atmel,atmel_mxt_ts";
        #address-cells = <1>;
        #size-cells = <0>;
        reg = <0x4b>;
        atmel,reset-gpio = <&gpio1 28 0x00>;
        atmel,irq-gpio = <&gpio1 16 0x00>;
        atmel,suspend-mode = <0x01>;
        atmel,input_name = "SSLUK";
    };
};

哪个正在延伸拱门/arm/boot/dts/am33xx.dtsi拱门/arm/boot/dts/am335x-bone-common.dtsi:

    i2c2: i2c@4819c000 {
        compatible = "ti,omap4-i2c";
        #address-cells = <1>;
        #size-cells = <0>;
        ti,hwmods = "i2c3";
        reg = <0x4819c000 0x1000>;
        interrupts = <30>;
        status = "disabled";
    };

&i2c2 {
    pinctrl-names = "default";
    pinctrl-0 = <>;

    status = "okay";
    clock-frequency = <100000>;

设备驱动程序似乎已成功添加到总线上,但每个 i2c_transfer 均失败并返回值 -16,因此探测失败。

从内核日志:

[    0.879536] atmel_mxt_ts 2-004b: mxt_probe i2c-2-004b/input0
[    0.879546] atmel_mxt_ts 2-004b: mxt_probe mxtdata->fw_name: (null), mxtdata->cfg_name: (null)
[    0.879581] atmel_mxt_ts 2-004b: mxt_initialize
[    1.887051] omap_i2c 4819c000.i2c: timeout waiting for bus ready
[    1.887069] atmel_mxt_ts 2-004b: __mxt_read_reg: i2c_transfer ret_val -16
[    2.935039] omap_i2c 4819c000.i2c: timeout waiting for bus ready
[    2.935049] atmel_mxt_ts 2-004b: __mxt_read_reg: i2c_transfer ret_val -16
[    3.947044] omap_i2c 4819c000.i2c: timeout waiting for bus ready
[    3.947059] atmel_mxt_ts 2-004b: mxt_bootloader_read: i2c_transfer ret_val -16
[    3.954340] atmel_mxt_ts 2-004b: mxt_bootloader_read: retry 1
[    5.007040] omap_i2c 4819c000.i2c: timeout waiting for bus ready
[    5.007050] atmel_mxt_ts 2-004b: mxt_bootloader_read: i2c_transfer ret_val -16
[    5.014329] atmel_mxt_ts 2-004b: mxt_probe_bootloader, 907, buf[0] = 68, buf[1] = 2e, buf[2] = c0, error = -16
[    5.014337] atmel_mxt_ts 2-004b: Trying alternate bootloader address
[    6.019042] omap_i2c 4819c000.i2c: timeout waiting for bus ready
[    6.019059] i2c i2c-2: SCL is stuck low, exit recovery
[    6.024248] atmel_mxt_ts 2-004b: mxt_bootloader_read: i2c_transfer ret_val -16
[    6.031521] atmel_mxt_ts 2-004b: mxt_bootloader_read: retry 1
[    7.083040] omap_i2c 4819c000.i2c: timeout waiting for bus ready
[    7.083050] atmel_mxt_ts 2-004b: mxt_bootloader_read: i2c_transfer ret_val -16
[    7.090329] atmel_mxt_ts 2-004b: mxt_probe_bootloader, 907, buf[0] = dc, buf[1] = 13, buf[2] = dc, error = -16
[    7.090630] atmel_mxt_ts 2-004b: mxt_probe error
[    7.090657] atmel_mxt_ts: probe of 2-004b failed with error -16

内核是 4.14.25 从https://elinux.org/BeagleBoardUbuntu

更新 将设备驱动程序构建为模块并从其工作的用户空间执行 insmod:

sudo insmod atmel_mxt_ts.ko

与内核日志:

[  150.125216] atmel_mxt_ts 2-004b: mxt_probe i2c-2-004b/input0
[  150.125235] atmel_mxt_ts 2-004b: mxt_probe mxtdata->fw_name: (null), mxtdata->cfg_name: (null)
[  150.125295] atmel_mxt_ts 2-004b: mxt_initialize
[  150.167071] atmel_mxt_ts 2-004b: Family: 164 Variant: 11 Firmware V1.6.01 Objects: 34
[  150.167092] atmel_mxt_ts 2-004b: mxt_parse_object_table, object_num = 34
...
[  150.168174] atmel_mxt_ts 2-004b: Enabling RETRIGEN workaround
[  150.168617] atmel_mxt_ts 2-004b: mxt_acquire_irq mxtdata->irq = 86
[  150.224908] atmel_mxt_ts 2-004b: mxt_acquire_irq OK
[  150.224993] atmel_mxt_ts 2-004b: mxt_configure_objects
[  150.228762] atmel_mxt_ts 2-004b: Touchscreen size X1023Y1023
[  150.229141] input: SSLUK as /devices/platform/ocp/4819c000.i2c/i2c-2/2-004b/input/input1
[  150.229170] atmel_mxt_ts 2-004b: mxt_initialize OK
[  150.229178] atmel_mxt_ts 2-004b: mxt_probe OK

相关内容