How are pins mapped?

Hello

AFAIK on many systems running embedded linux the rule of thumb for knowing which address to use for a certain pin is:

eg. GPIO3_PIN5: (3-1)*32+5 = 69

However by going through the jetson docs I found the following example which doesn’t seem to follow this rule.

     const int GPIO_LED = 57;  // GPIO_PH1 (Pin 50 on J3A1 of Jetson TK1 board)
     gpio_export(GPIO_LED);    // Start using the LED pin
     gpio_set_dir(GPIO_LED, OUTPUT_PIN);   // The LED is an output
     if (detections_num > 0) {
         gpio_set_value(GPIO_LED, HIGH);   // Turn the LED on
     }
     else {
        gpio_set_value(GPIO_LED, LOW);    // Turn the LED off
     }
     gpio_unexport(GPIO_LED);  // Stop using the LED pin for now

Could someone explain me eg how they went from physiscal pinnumber 50 to internal linux mapped pin number 57?
I would have expected this (although I am not sure it does make any sense…):
pin bank = H = 8
pin number = 50

formula: (pinbank - 1)* 32 + pinnumber = linux address
(8-1)*32 + 50 = 274

Thanks

hello linengmiao,

where did you come out the linux address formula?
i would suggest you refer tegra gpio definitions as below, thanks

$TOP/kernel/arch/arm/mach-tegra/gpio-names.h

for example,

#define TEGRA_GPIO_PH1          57

Thanks didn’t download the kernel sources…