How to register touchscreen edt-ft5x06?

Dear Sir,

I have touchscreen FT5446 connected to the I2c2 and GPIO7 interrupt, gpio8 - reset and back ported kernel driver edt-ft5x06 for toradex 3.1.10 linux kernel. I have added touchscreen definition as bellow:

static struct edt_ft5x06_platform_data edt_ft5x06_pdata = {
          .irq_pin = APALIS_GPIO7,
          .reset_pin = APALIS_GPIO8,
  };


static struct i2c_board_info apalis_t30_i2c_bus1_board_info[] __initdata = {
        {
                /* M41T0M6 real time clock on carrier board */
                I2C_BOARD_INFO("rtc-ds1307", 0x68),
                        .type = "m41t00",
        },
        {
                /* Touchscreen focaltech */
                I2C_BOARD_INFO("edt-ft5x06", 0x38),
                      .platform_data = &edt_ft5x06_pdata,
        },
};

additionally I have added device registration as bellow:

static struct platform_device apalis_t30_edt_ft5x06_device = {
        .dev = {
                .platform_data = &edt_ft5x06_pdata,
        },
        .id     = 543,
        .name   = "edt-ft5x06",
};


static void __init apalis_t30_i2c_init(void)
{
        tegra_i2c_device1.dev.platform_data = &apalis_t30_i2c1_platform_data;
        tegra_i2c_device3.dev.platform_data = &apalis_t30_i2c3_platform_data;
        tegra_i2c_device4.dev.platform_data = &apalis_t30_i2c4_platform_data;
        tegra_i2c_device5.dev.platform_data = &apalis_t30_i2c5_platform_data;
        //tegra_i2c_device2.dev.platform_data = &apalis_t30_edt_ft5x06_device;

        platform_device_register(&tegra_i2c_device1);
        platform_device_register(&tegra_i2c_device3);
        platform_device_register(&tegra_i2c_device4);
        platform_device_register(&tegra_i2c_device5);
        //platform_device_register(&tegra_i2c_device2);
        platform_device_register(&apalis_t30_edt_ft5x06_device);

        i2c_register_board_info(0, apalis_t30_i2c_bus1_board_info,
                                ARRAY_SIZE(apalis_t30_i2c_bus1_board_info));

        /* enable touch interrupt GPIO */
        gpio_request(TOUCH_PEN_INT, "TOUCH_PEN_INT");
        gpio_direction_input(TOUCH_PEN_INT);

        apalis_t30_i2c_bus5_board_info[1].irq = gpio_to_irq(TOUCH_PEN_INT);
        i2c_register_board_info(4, apalis_t30_i2c_bus5_board_info,
                                ARRAY_SIZE(apalis_t30_i2c_bus5_board_info));
}

but still facing the error:

588:[   10.797155] gpio_request: gpio-151 (edt-ft5x06 irq) status -16
589:[   10.801551] edt_ft5x06 0-0038: Failed to request GPIO 151, error -16

command i2cdetect -y -r 0 is not detecting any devices. Can you tell me if my way, of registering device is correct, or if not how to do it correctly?

Best regards
Kamil

Concerning your GPIO issue: error -16 means busy e.g. most possibly those GPIOs are already registered for something else. Have a look e.g. here.

Concerning the I2C detection: have you now connected it to the regular bus together with the RTC or not? Plus should your chip’s reset not work properly due to e.g. the GPIO issue it might of course also not be detectable like that.

Dear Sir,

The pins shouldn`t been initialised because I have already commented the code as bellow:

/*      {APALIS_GPIO7,          GPIOF_IN,               "GPIO7 X1-13"}, */
/*      {APALIS_GPIO8,          GPIOF_IN,               "GPIO8 X1-15, FAN"}, */

%|-266268328_3|%

What is strange, that during the system start the error is as bellow

[   10.841432] gpio_request: gpio-151 (edt-ft5x06 irq) status -16
[   10.845447] edt_ft5x06 0-0038: Failed to request GPIO 151, error -16
[   10.865669] edt_ft5x06: probe of 0-0038 failed with error -16

but when I`m removing module with command modprobe -r edt-ft5x06, modprobe edt-ft5x06 the error is as bellow:
[ 108.274487] gpio_request: gpio-129 (edt-ft5x06 reset) status -16
[ 108.274537] edt_ft5x06 0-0038: Failed to request GPIO 129 as reset pin, error -16
[ 108.282596] edt_ft5x06: probe of 0-0038 failed with error -16

Why gpio number changes from 151 to 129?

Dear Marcel,
We are using custom board and we don`t have RTC on our board.

Best regards,
Kamil

Dear Sir,

Thanks to your suggestion, that gpio can be busy I found the problem. The PEX_PERST_N is also defined as APALIS_GPIO7 and was initialised during pci_init. I have commented the pci switch initialisation from eval board and now gpio works correctly. Many thanks for your help.

Best regards,

Kamil