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.

AM335x EVM daughter board push buttons



I would like to hijack some of the push buttons on the daughter board of the AM335x EVM. I've reviewed the schematics and I see they're all used for something right now:

SW1-6 - Keypad           - gpio 53/54 - 57/58/59
SW7    - Wakeup          -  EXT_WAKEUP (I think)
SW9    - Volume up      -  gpio 2
SW10  - Volume down  - gpio 3

I wanted to export control of a few of these GPIO's to the sysfs so I could read them, but it looks like all the GPIO tied buttons are in use:

root@am335x-evm:/#cat /sys/kernel/debug/gpio
GPIOs 0-31, gpio:
 gpio-2   (volume-up           ) in  hi
 gpio-3   (volume-down         ) in  hi
 gpio-6   (mmc_cd              ) in  lo

GPIOs 32-63, gpio:
 gpio-48  (wlan_en             ) out lo
 gpio-53  (matrix_kbd_col      ) out hi
 gpio-54  (matrix_kbd_col      ) out hi
 gpio-57  (matrix_kbd_row      ) in  lo
 gpio-58  (matrix_kbd_row      ) in  lo
 gpio-59  (matrix_kbd_row      ) in  lo

So there are a few points here I'm trying to understand:

1) the keypad buttons (SW1-6) are in use by the matrix_kbd for row and col. If I kill the matrix:
/etc/init.d/matrix-gui-2.0 stop
    the GPIO's are not released. Is there anyway I can release the buttons in use for the matrix keyboard?

2) WRT the keys, the v1.2 schematic page 10 shows the KEYPAD_SCNX outputs from the buttons. The way it's wired it looks like there's no way to tell differentiate between a SW1 and SW4 press. (Assuming both KEYPAD_PWRA and KEYPAD_PWRB are active). Is that correct? (Same with SW2/SW5 and SW3/SW6)

3) Am I correct in assuming that output from SW7 (remote wakeup switch), that is AM335X_WAKEUP, is tied to C5 (EXT_WAKEUP) on the AM335X? I don't see anything correlating those two names, but it seems logical.

  • Hi Mike,
     
    I can only answer your last two questions:
     
    Mike Worster said:

    2) WRT the keys, the v1.2 schematic page 10 shows the KEYPAD_SCNX outputs from the buttons. The way it's wired it looks like there's no way to tell differentiate between a SW1 and SW4 press. (Assuming both KEYPAD_PWRA and KEYPAD_PWRB are active). Is that correct? (Same with SW2/SW5 and SW3/SW6)

     
    The trick is that KEYPAD_PWRA and KEYPAD_PWRB should NOT active at the same time. Otherwise there would be no way to scan the keypad.
     
    Mike Worster said:

    3) Am I correct in assuming that output from SW7 (remote wakeup switch), that is AM335X_WAKEUP, is tied to C5 (EXT_WAKEUP) on the AM335X? I don't see anything correlating those two names, but it seems logical.

     
    Yes, this is correct. The signal goes down to the baseboard through the EXP2 connector (pin 18). On the baseboard the net name is AM335X_EXT_WAKEUP.
  • Mike Worster said:
    1) the keypad buttons (SW1-6) are in use by the matrix_kbd for row and col. If I kill the matrix:
    /etc/init.d/matrix-gui-2.0 stop
        the GPIO's are not released. Is there anyway I can release the buttons in use for the matrix keyboard?

    Matrix gui (Qt Browser + Web Application) does not use the keypads on the board.

  • Brad Griffis said:
    Matrix gui (Qt Browser + Web Application) does not use the keypads on the board.

    It may not use the keypads on the board, but it does take the GPIOs:

    .../drivers/input/keyboard.c

    static int __devinit init_matrix_gpio(struct platform_device *pdev,
                                          struct matrix_keypad *keypad) 
    {
      const struct matrix_keypad_platform_data *pdata = keypad->pdata;
      int i, err = -EINVAL; 
      /* initialized strobe lines as outputs, activated */
      for (i = 0; i < pdata->num_col_gpios; i++) {
        err = gpio_request(pdata->col_gpios[i], "matrix_kbd_col");
        if (err) {
           dev_err(&pdev->dev,
                   "failed to request GPIO%d for COL%d\n",
                    pdata->col_gpios[i], i);
           goto err_free_cols;
        }
        gpio_direction_output(pdata->col_gpios[i], !pdata->active_low);  
      }
    

    Directly following this the same code is run to get the GPIOs for the rows. From this point on the GPIOs for the keypad buttons are now "owned" by the matrix keyboard, hence when I check the:

    /sys/kernel/debug/gpio

    Entry we can see see they are reserved (gpio-53  (matrix_kbd_col      ) out hi) and can't be exported. I assumed that they would be released when the matrix was killed but that wasn't the case. So that's why I was asking if they could be released in any way from user space

    Now I am making an assumption here that the "matrix_kbd" and the "matrix gui" are somehow related. Are you saying this is not true?

  • Mike Worster said:
    Now I am making an assumption here that the "matrix_kbd" and the "matrix gui" are somehow related. Are you saying this is not true?

    Correct.  Take a look at the header of drivers/input/keyboard/matrix_keypad.c and you'll see it's copyright 2008 by a non-TI person.  By "matrix keypad" they really are referring to the structure, i.e. it's a "grid" or "matrix".  It's completely unrelated to the Matrix GUI developed by TI.  As far as I can tell, you can't "take" a GPIO from user space if it is claimed by the kernel.  So I think you would need to remove that keypad altogether in order to individually access the gpio.