@RichT
Hi,
The DTSI doesn’t list all the GPIOs explicitly but you can get the name from Column V which is what you have pointed out.
Just to let you know, I’m not an expert, but I have been able to use GPIOs from userland using the following method:
1. Go into the spreadsheet and find the GPIO Port and offset from Column V
As an example:
Line 189 in the spreadsheet looks like this:
(Column of interest) Name
(A) A0_DMIC_IN_DAT... (J) DMIC5_DAT... (V) can_gpio0_paa0
The last section of the name in column ‘V’ is ‘PAA0’, this is the GPIO Port and offset
Set Column ‘AQ’ as ‘unused’
2. Generate the outputted GPIO pinmux dtsi and add it to your DTS configuration
3. If the peripheral that is using that GPIO is enabled you should disable it
I just looked up dmic5 within the address table of the TX2 TRM and it’s on the AON processor at address 0x0C330000. After grepping around the ‘hardware’ source directory it doesn’t look like it’s enabled so you shouldn’t need to disable it. If, for example, it was dmic1 then you would need to add a block inside your base DTS file that would disable it like this:
dmic@290400 {
status = "disabled";
};
4. Hog out your GPIO
You will need to know if you are using the GPIO from the main processor or from the AON processor. You can find out which port goes on which processor by looking in the file:
Linux_for_Tegra/sources/kernel/kernel-4.4/include/dt-bindings/gpio/tegra186-gpio.h
but to simplify your life here is the mapping (I’ll reference the numbers down below):
[b]
Main Processor:
A = 0
B = 1
C = 2
D = 3
E = 4
F = 5
G = 6
H = 7
I = 8
J = 9
K = 10
L = 11
M = 12
N = 13
O = 14
P = 15
Q = 16
R = 17
T = 18
X = 19
Y = 20
BB = 21
CC = 22
DD = 23
AON:
S = 0
U = 1
V = 2
W = 3
Z = 4
AA = 5
EE = 6
FF = 7
[/b]
Since the Port for DMIC5 is ‘AA’ then it’s on the AON processor and the hog out will be for the GPIO controller on the AON processor.
For reference here are the addresses for the GPIO controller on the main processor and the AON processor (found within the TRM).
Main GPIO Controller: 0x02200000
AON GPIO Controller: 0x0C2F0000
I’ll just show how to do it for both of the controllers:
Hogging out for the main processor:
This is for GPIO M1
gpio@2200000 {
my_gpio_name {
gpio-hog; //Take over a pin
status = "okay";
input; //This can be 'input', 'output-low' or 'output-high'
gpios = <TEGRA_MAIN_GPIO(M, 1) 0>;
label = "my_gpio";
};
};
This is for GPIO AA0
gpio@c2f0000 {
my_aon_gpio_name {
gpio-hog;
status = "okay";
output-low;
gpios = <TEGRA_AON_GPIO(AA, 0) 0>;
label = "my_aon_gpio";
};
};
Thanks @akmal.ali for catching that error
5. Find your GPIO number that you will let you access it within userland.
(This was taken from this thread: https://devtalk.nvidia.com/default/topic/1003613/?comment=5143299)
In order to access your GPIO device you need to get your GPIO number. To do this:
- Find the processor base value:
- Main Processor base value is: 320
- AON Processor base value is: 256
- From the port listing above find the index of your port.
As an example AA would be: 5
- Get the offset from your port, which is the number after your port.
AA0 → Offset 0
- Use the following formula to to calculate the userland GPIO:
+ <8 * Port Index> + Offset
256 + 8 * 5 + 0 = 296
This is value you should put into /sys/class/gpio/export
Finally, you can check your work by searching ‘hog’ in a dump of dmesg. The kernel will tell you what the GPIO number is while it boots.
Just to reiterate, I have gotten these to work but I’m not sure if there is a better way. If there is a mistake please let me know.
Dave