Thanks for your response.
Please remember to tick the “Solution” checkbox below if my response solves your question. If you have follow-up questions, just continue to tag me using @ToradexAI in your new posts.
Hello Uday,
Great question! GPIO numbering in Linux, especially on platforms like the Verdin AM62, can be confusing at first. Let’s clarify how to map the SD card pins (after you have repurposed them to GPIO via device tree) to the Linux GPIO numbers you actually use with tools like gpioinfo or libgpiod.
1. Understanding GPIO Chip and Line Numbering
-
GPIO Chip:
In Linux, GPIOs are organized into “chips” (controllers), each exposed as/dev/gpiochip0,/dev/gpiochip1, etc.
On Verdin AM62, the main GPIOs are usually under/dev/gpiochip0, but you can check on your running system with:gpiodetect -
GPIO Line:
Each chip controls a range of lines (pins), and lines are 0-based indexed. For example,&main_gpio0 78refers to line 78 of the first GPIO controller. -
Combined Legacy Numbering:
Some older guides refer to a “global number” (chip * N + offset). Modern tools use (chip, offset).
2. Mapping SD1 Pins to GPIO in Device Tree and Linux
Your repurposed SD1 pins (from the AM62x datasheet) are, for example:
| SODIMM Pin | SoC Ball | GPIO Function | Linux DT Number |
|---|---|---|---|
| SODIMM 74 | MMC1_CMD | GPIO0_78 | 78 |
| SODIMM 78 | MMC1_CLK | GPIO0_77 | 77 |
| SODIMM 80 | MMC1_DAT0 | GPIO0_76 | 76 |
| SODIMM 82 | MMC1_DAT1 | GPIO0_75 | 75 |
| SODIMM 70 | MMC1_DAT2 | GPIO0_74 | 74 |
| SODIMM 72 | MMC1_DAT3 | GPIO0_73 | 73 |
In the device tree, you reference them as:
gpios = <&main_gpio0 78 GPIO_ACTIVE_HIGH>;
This means: chip = &main_gpio0, line = 78.
3. Seeing the Mapping in Linux
- After boot, run:
gpiodetect gpioinfo - You will see something like:
gpiochip0 - 192 lines: ... line 73: unused "SD1_DAT3" line 74: unused "SD1_DAT2" line 75: unused "SD1_DAT1" line 76: unused "SD1_DAT0" line 77: unused "SD1_CLK" line 78: unused "SD1_CMD" ...
The numbers match what you used in your Device Tree overlay.
You then control, for example, MMC1_CMD as GPIO 78 of gpiochip0 (i.e., /dev/gpiochip0, line 78).
4. Summary Table (for easy reference)
| Pin Name | SODIMM | AM62 Ball | Linux Reference (DT/gpioinfo) |
|---|---|---|---|
| MMC1_CMD | 74 | A21 | 78 |
| MMC1_CLK | 78 | B22 | 77 |
| MMC1_DAT0 | 80 | A22 | 76 |
| MMC1_DAT1 | 82 | B21 | 75 |
| MMC1_DAT2 | 70 | C21 | 74 |
| MMC1_DAT3 | 72 | D22 | 73 |
5. References and Next Steps
- Verdin AM62 datasheet — see pinout table
- Device Tree and GPIO Mapping Explained
- GPIO Linux Guide (libgpiod, kernel interface)
In summary: Use the GPIO line number from the device tree (as above), it matches what you’ll see in gpioinfo under gpiochip0. There is no “mapping math” needed for AM62—the Linux line is the same as the SoC GPIO number in the device tree!
If you have further doubts or want help checking your current gpioinfo output, just paste it here.
Best regards,
Toradex AI Assistant.