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.

SK-AM62: SK-AM62: gpio_request number

Part Number: SK-AM62

Hello TI,
          I have a am62x problem ,
          i write a kernel driver, and i want to use gpio0_0 as gpio interrupt.
          in code, i use gpio_request() funtion Request a GPIO ,  but i do not know gpio0_0  number?

          i study AM62x Processors Silicon Revision 1.0 Texas Instruments Families of Products Technical Reference Manual,
          10.1.6 GPIO Interrupt Handling

          have  GPIO0 ,GPIO1,GPIO_MCU0 group, how can i know gpio0_0 number and assignation use gpio0_0  in code ?

  • Hi Mars,

    In general, the kernel drivers, which uses GPIO pins, should use kernel gpiod framework API, instead of directly call gpio API, such as gpio_request().

    For examples of using gpiod framework, please see the vdd_sd_dv DT node in kernel device tree k3-am62x-sk-common.dtsi:

    vdd_sd_dv node defines the GPIO pin to be used:

            gpio = <&main_gpio0 31 GPIO_ACTIVE_HIGH>;

    Then in driver regulator/gpio-regulator.c, function gpio_regulator_probe() uses devm_gpiod_get_index() to query the GPIO, then later function gpio_regulator_set_voltage() uses gpiod_set_value_cansleep() to set the GPIO value.

    The kernel gpiod framework has other API for callers to control the GPIO.

  • Hi Bin,
              Thanks your reply,let me know have gpiod control gpio method.
              This driver is porting from NXP i.mx6 platform. It no use devicetree, direct use gpio_request ro request gpio.
               i already porting to am62x , but gpio_request  use gpio number should chnage to am62x 
               gpio0_0 gpio number. 
               Where can i know gpio_request gpio0_0 number? 

  • Hi Mars,

    The gpio number is its module base + pin index, but sorry I don't have an easy way to show you how to get the gpio0_0 number without using device tree. It is out of the support scope on this forum.

  • Hi Bin,

              Thanks your reply,
              For find gpio0_0 number, I try to use dts pass  
                 kick-gpios = <&main_gpio0 0 IRQ_TYPE_EDGE_BOTH>; 
              then in driver use 
                  int kick_gpio = of_get_named_gpio_flags(np, "kick-gpios", 0, NULL);
                  pr_err( " kick_gpio= (%d) \n", kick_gpio );
              to print gpio0_0 number , get 394.
              I look some platform have GPIO_TO_PIN define, can easy convert get gpio number.
              TI AM62X do not support?


  • Hi Mars,

    GPIO_TO_PIN is only used in some Davinci devices which have one GPIO controller, in which case all the GPIO numbers are fixed.

    However, AM62x has multiple GPIO controllers. Depending on which GPIO controllers are enabled in kernel DT and the order that kernel initialize these GPIO controllers, all the GPIO numbers are dynamically allocated, the GPIO_TO_PIN macro is not applicable.

    The easy way to solve it is to use kernel gpiod framework.