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.

TCA8418 - gpio is not supported ?

Guru 20755 points
Other Parts Discussed in Thread: TCA8418

Hello,

It seems that TCA8418 linux driver does not support gpio (only through matrx).
Is that correct ? How can I add gpio support ?

Regards,
Ran

  • Hello Ran,

    The TCA8418 Linux driver is not developed by TI.

    I am not sure which specific driver you are referring to, but you can modify the register writes performed in the driver to set the device up into GPIO mode. If you set up GPIO mode and then configure the keys to be part of the key event FIFO, the code should be very similar to what is performed for a key array.

    I would highly suggest taking a look at the new TCA8418 datasheet. I released a major overhaul to the datasheet two months ago, where I tried to explain the settings and steps for setup in much more detail.

    I won't be able to help too much with the Linux drivers, as I do not write Linux drivers. However, I can help with the correct register settings for a given setup. For the most part, your driver changes should be mostly a change to your register settings.
  • Hi Jonathan,

    Thank you for the time.

    I see the following comments in datasheet about GPIO_DAT_STAT* registers:
    "These registers show the GPIO state when read for inputs and outputs. Read these twice to clear them."

    What does it mean to read value of gpio and then "clear" the value? Do we always need to read these register twice ?

    Thank you,
    Ran
  • Hi Jonathan,

    In addition to the above comment/question , I also noticed the following in this linux driver code:
    1. Reading the keypad and insertion of event is done only after recieving interrupt.
    2. I also see that the driver user should give a table of event_number for each row-column.
    I find this a bit strange because according to datasheet the event number is already defined per row-column:

    Table 1. Key Event Table (Keypad Array)

    C0 C1 C2 C3 C4 C5 C6 C7 C8 C9
    R0 1 2 3 4 5 6 7 8 9 10
    R1 11 12 13 14 15 16 17 18 19 20
    R2 21 22 23 24 25 26 27 28 29 30
    R3 31 32 33 34 35 36 37 38 39 40
    R4 41 42 43 44 45 46 47 48 49 50
    R5 51 52 53 54 55 56 57 58 59 60
    R6 61 62 63 64 65 66 67 68 69 70
    R7 71 72 73 74 75 76 77 78 79 80

    So why should this information be given into the driver ?
    Anyway, this is the way I've done it from the board file :

    /* KEY(row, col, val) */
    static uint32_t tca8418_km_data[] = {
    KEY(0, 0, KEY_1), <-- KEY_1 is eqaul to 1
    KEY(0, 1, KEY_2), <-- KEY_2 is eqaul to 2
    KEY(0, 2, KEY_3),<-- KEY_3 is eqaul to 3

    KEY(1, 0, KEY_0), <-- KEY_0 is eqaul to 11
    KEY(1, 1, KEY_MINUS), <-- KEY_MINUS is eqaul to 12
    KEY(1, 2, KEY_EQUAL), <-- KEY_EQUAL is eqaul to 13

    KEY(2, 0, KEY_Y), <-- KEY_Y is eqaul to 21
    KEY(2, 1, KEY_U), <-- KEY_U is eqaul to 22
    KEY(2, 2, KEY_I), <-- KEY_I is eqaul to 23
    };

    Regards,
    Ran
  • Hello Ran,

    I'm not sure which linux driver you're referring to. TI did not write any linux drivers for the TCA8418. I believe you are referring to one of the open source drivers.

    Unfortunately, I cannot explain why they chose to require the key events be given to the driver.

    Your approach to doing the key map look like it will work, though.