1

I'm trying to run an i2c device driver on the BeagleBoneBlack using i2c2 pins [P9]: (19) I2C2_SCL, (20) I2C2_SDA.

I can use i2c2 successfully from user space to control the same atmel touchscreen device but when it comes to use it from the device driver, at probe time, I keep getting error -16 (resource busy).

The device driver is https://github.com/ssl-maxtouch/linux-device-driver/blob/master/atmel_mxt_ts.c which I'm building statically into the kernel (drivers/input/touchscreen/atmel_mxt_ts.c).

I added the following to the device tree source file arch/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";
    };
};

Which is extending arch/arm/boot/dts/am33xx.dtsi and arch/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>;

And the device driver seems to be added successfully on the bus but every i2c_transfer fails with return value -16 so the probe fails.

From the kernel log:

[    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

The kernel is 4.14.25 from https://elinux.org/BeagleBoardUbuntu

UPDATE Building the device driver as a module and performing the insmod from user space it worked:

sudo insmod atmel_mxt_ts.ko

With kernel log:

[  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
  • 1
    Where are you setting the pins for I2C2_SCL and I2C2_SDA? The default pin map? – jc__ Apr 4 '18 at 16:45
  • from am335x-bone-common.dtsi it is using pinctrl-names = "default"; pinctrl-0 = <>; I didn't know this part was essential I will investigate further – giuspen Apr 4 '18 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.