cavocado / pinout

7 stars 4 forks source link

How to come up with a mapping? #9

Closed serpent213 closed 1 year ago

serpent213 commented 1 year ago

https://github.com/cavocado/pinout/blob/2179104021a3aa844a2d2f5cb3b32f2721511538/lib/pinout/db/connectors.ex#L91

I had issues coming up with that mapping, great little helper this is!

Would you mind sharing where the information comes from? My MangoPi only exposes a single GPIO chip with sequential pin numbering, while the pins on the schematic are labeled like “P[A-G][0-9]+”. The example above matches PB4.

Thank you!

serpent213 commented 1 year ago

In hindsight, one way would be to refer to

https://github.com/torvalds/linux/blob/8b817fded42d8fe3a0eb47b1149d907851a3c942/drivers/pinctrl/sunxi/pinctrl-sunxi.h#L20

to get (PB = 32) + 4 = 36, I guess.

Edit: Another, easier way would be to refer to /sys/kernel/debug/pinctrl/2000000.pinctrl/pinmux-pins:

pin 36 (PB4): UNCLAIMED

or other files in that folder. I pretty much answered my question, it seems.

cavocado commented 1 year ago

Thanks for raising the issue. It looks like you found the answer, but I can see how having the P[A-G][0-9] format would be useful as well. I'll think about adding it and added #10.