This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Accessing input device TCA6424 from User Space.

Other Parts Discussed in Thread: TCA6424, TCA6416

3124.4113.tca6424_matrix.c

Hi,


I am referring the attached Client-driver file for TCA6424. I can see the device register as input in the source code .

        input->id.bustype = BUS_HOST;
        input->id.vendor = 0x0001;
        input->id.product = 0x0001;
        input->id.version = 0x0100;

        /* Enable auto repeat feature of Linux input subsystem */
        if (pdata->rep)
                __set_bit(EV_REP, input->evbit);

        for (i = 0; i < pdata->nbuttons; i++) {
                unsigned int type;

                chip->buttons[i] = pdata->buttons[i];
                type = (pdata->buttons[i].type) ?: EV_KEY;
                input_set_capability(input, type, pdata->buttons[i].code);
        }

        input_set_drvdata(input, chip);

        /*
         * Initialize cached registers from their original values.
         * we can't share this chip with another i2c master.
         */
        error = tca6416_setup_registers(chip);
        if (error)
                goto fail1;

        if (!chip->use_polling) {
                if (pdata->irq_is_gpio)
                        chip->irqnum = gpio_to_irq(client->irq);
                else
                        chip->irqnum = client->irq;

                error = request_threaded_irq(chip->irqnum, NULL,
                                             tca6416_keys_isr,
                                             IRQF_TRIGGER_FALLING,
                                             "tca6416-keypad", chip);
                if (error) {
                        dev_dbg(&client->dev,
                                "Unable to claim irq %d; error %d\n",
                                chip->irqnum, error);
                        goto fail1;
                }
                disable_irq(chip->irqnum);
        }

        error = input_register_device(input);

Can some one guide me how i can see the register input device on target board & access it from user space. I am expecting for every key press to print the value of keys in userspace. Please suggest your views.

Thanks in advance,

Hrishikesh

  • Moving this to the Linux forum.

  • Hi Hrishikesh,

    Have you enabled & registered "TCA6424" support in linux ?

    Are you added the platform data in board or dts file ?

    Please refer to the following links.

    https://www.mail-archive.com/linux-omap@vger.kernel.org/msg25655.html

    http://markmail.org/message/722qeanq6jshy74b

  • Try to apply the patch for TCA6424 support.

    http://www.gossamer-threads.com/lists/linux/kernel/1525215#1525215

    https://groups.google.com/forum/#!topic/linux.kernel/DPVO7QKPldg

  • Yes .. i have added it in board file . as the linux kernel is 2.6.35.

    /* Keypad Initialization */
    #define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
     {                                                               \
             .type           = ev_type,                              \
             .code           = ev_code,                              \
             .active_low     = act_low,                              \
     }

    #define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1)
     
    static struct tca6416_button m704_gpio_keys[] = {
             KEYPAD_BUTTON_LOW(KEY_HOME),
             KEYPAD_BUTTON_LOW(KEY_MENU),
             KEYPAD_BUTTON_LOW(KEY_BACK),
             KEYPAD_BUTTON_LOW(KEY_POWER),
             KEYPAD_BUTTON_LOW(KEY_LEFT),
             KEYPAD_BUTTON_LOW(KEY_RIGHT),
             KEYPAD_BUTTON_LOW(KEY_UP),
             KEYPAD_BUTTON_LOW(KEY_DOWN),
    };

    static struct tca6416_keys_platform_data m704_tca6416_keys_info = {
             .buttons        = m704_gpio_keys,
             .nbuttons       = ARRAY_SIZE(m704_gpio_keys),
             .rep            = 0,
             .use_polling    = 0,
             .pinmask        = 0x00FF,
         .irq_is_gpio    = 1,
    };

    static struct i2c_board_info __initdata m335x_i2c_device_1[] = {
        {
            I2C_BOARD_INFO("tca6424-keys", 0x22), // Added By Hrishi : I2C IO Expander
            .platform_data = &m704_tca6416_keys_info,
        },
    };

    should this generate events @ /dev/input/event0 or i have to some additional settings.

  • Hi,

    After referring the attached file. the input device was registered under /dev/input/event2 for my board.

    Thanks TI for the support.

  • Hi Hrishikesh,

    Sounds good.

    Thanks for your update.