Kimber
July 26, 2023, 8:03am
1
I am using the TX2 NX module (P3636) and I set the default output level of GPIO3_PEE.02 in the device tree tegra186-p3636-0001-p3509-0000-a01.dts to low, but the actual test result is high 1.8V.
gpio@2200000 {
w-disable1 {
gpio-hog;
output-high;
gpios = <TEGRA_MAIN_GPIO(L, 0) GPIO_ACTIVE_LOW>;
label = "w-disable1";
status = "okay";
};
w-disable2 {
gpio-hog;
output-high;
gpios = <TEGRA_MAIN_GPIO(L, 2) GPIO_ACTIVE_LOW>;
label = "w-disable2";
status = "okay";
};
w-disable3 {
gpio-hog;
output-high;
gpios = <TEGRA_MAIN_GPIO(J, 4) GPIO_ACTIVE_LOW>;
label = "w-disable3";
status = "okay";
};
w-disable4 {
gpio-hog;
output-high;
gpios = <TEGRA_MAIN_GPIO(C, 1) GPIO_ACTIVE_LOW>;
label = "w-disable4";
status = "okay";
};
w-disable5 {
gpio-hog;
output-high;
gpios = <TEGRA_AON_GPIO(EE,2) GPIO_ACTIVE_LOW>;
label = "w-disable5";
status = "okay";
};
};
May I ask how I should modify this GPIO to ensure the default output low level?
set it to GPIO_ACTIVE_HIGH and then set output-low;.
Kimber
July 26, 2023, 8:25am
3
I made the corresponding modification, the phenomenon is still the same, the default output high level 1.8v.
gpio@2200000 {
w-disable1 {
gpio-hog;
output-high;
gpios = <TEGRA_MAIN_GPIO(L, 0) GPIO_ACTIVE_LOW>;
label = "w-disable1";
status = "okay";
};
w-disable2 {
gpio-hog;
output-high;
gpios = <TEGRA_MAIN_GPIO(L, 2) GPIO_ACTIVE_LOW>;
label = "w-disable2";
status = "okay";
};
w-disable3 {
gpio-hog;
output-high;
gpios = <TEGRA_MAIN_GPIO(J, 4) GPIO_ACTIVE_LOW>;
label = "w-disable3";
status = "okay";
};
w-disable4 {
gpio-hog;
output-high;
gpios = <TEGRA_MAIN_GPIO(C, 1) GPIO_ACTIVE_LOW>;
label = "w-disable4";
status = "okay";
};
w-disable5 {
gpio-hog;
output-low;
gpios = <TEGRA_AON_GPIO(EE,2) GPIO_ACTIVE_HIGH>;
label = "w-disable5";
status = "okay";
};
};
what is the result of cat /sys/kernel/debug/gpio?
Kimber
July 26, 2023, 8:39am
5
This is the result. The port I calculated should be GPIO-304, which is not in the list.
Hi,
Your calculation is most likely wrong because w-disable5 is already shown there…
Kimber
July 26, 2023, 9:43am
7
When I control this pin with the following command, the output voltage is always high.
echo 370 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio370/direction
echo 0> /sys/class/gpio/gpio370/value
HI,
Could you remove your gpio-hog from device tree and only control the gpio through sysfs and see if the result is what you want?
Kimber
July 26, 2023, 9:59am
9
I tried this method and the phenomenon was the same, it remained high all the time.
gpio@2200000 {
w-disable1 {
gpio-hog;
output-high;
gpios = <TEGRA_MAIN_GPIO(L, 0) GPIO_ACTIVE_LOW>;
label = "w-disable1";
status = "okay";
};
w-disable2 {
gpio-hog;
output-high;
gpios = <TEGRA_MAIN_GPIO(L, 2) GPIO_ACTIVE_LOW>;
label = "w-disable2";
status = "okay";
};
w-disable3 {
gpio-hog;
output-high;
gpios = <TEGRA_MAIN_GPIO(J, 4) GPIO_ACTIVE_LOW>;
label = "w-disable3";
status = "okay";
};
w-disable4 {
gpio-hog;
output-high;
gpios = <TEGRA_MAIN_GPIO(C, 1) GPIO_ACTIVE_LOW>;
label = "w-disable4";
status = "okay";
};
w-disable5 {
//gpio-hog;
output-low;
gpios = <TEGRA_AON_GPIO(EE,2) GPIO_ACTIVE_HIGH>;
label = "w-disable5";
status = "okay";
};
};
Kimber
July 26, 2023, 10:29am
10
I have checked tegra186-gpio.h, this pin should belong to the TEGRA_AON_GPIO group, the base index should be 256, the calculation should be 256+6*8+2=306, But if you type cat /sys/kernel/debug/gpio, the result is 370. Look at the result. This pin belongs to the TEGRA186_MAIN_GPIO group.
May I ask why this is?
#ifndef _DT_BINDINGS_GPIO_TEGRA_GPIO_H
#define _DT_BINDINGS_GPIO_TEGRA_GPIO_H
#include <dt-bindings/gpio/gpio.h>
/* GPIOs implemented by main GPIO controller */
#define TEGRA_MAIN_GPIO_PORT_A 0
#define TEGRA_MAIN_GPIO_PORT_B 1
#define TEGRA_MAIN_GPIO_PORT_C 2
#define TEGRA_MAIN_GPIO_PORT_D 3
#define TEGRA_MAIN_GPIO_PORT_E 4
#define TEGRA_MAIN_GPIO_PORT_F 5
#define TEGRA_MAIN_GPIO_PORT_G 6
#define TEGRA_MAIN_GPIO_PORT_H 7
#define TEGRA_MAIN_GPIO_PORT_I 8
#define TEGRA_MAIN_GPIO_PORT_J 9
#define TEGRA_MAIN_GPIO_PORT_K 10
#define TEGRA_MAIN_GPIO_PORT_L 11
#define TEGRA_MAIN_GPIO_PORT_M 12
#define TEGRA_MAIN_GPIO_PORT_N 13
#define TEGRA_MAIN_GPIO_PORT_O 14
#define TEGRA_MAIN_GPIO_PORT_P 15
#define TEGRA_MAIN_GPIO_PORT_Q 16
#define TEGRA_MAIN_GPIO_PORT_R 17
#define TEGRA_MAIN_GPIO_PORT_T 18
#define TEGRA_MAIN_GPIO_PORT_X 19
#define TEGRA_MAIN_GPIO_PORT_Y 20
#define TEGRA_MAIN_GPIO_PORT_BB 21
#define TEGRA_MAIN_GPIO_PORT_CC 22
#define TEGRA_MAIN_GPIO_PORT_DD 23
#define TEGRA_MAIN_GPIO(port, offset) \
((TEGRA_MAIN_GPIO_PORT_##port * 8) + offset)
/* GPIOs implemented by AON GPIO controller */
#define TEGRA_AON_GPIO_PORT_S 0
#define TEGRA_AON_GPIO_PORT_U 1
#define TEGRA_AON_GPIO_PORT_V 2
#define TEGRA_AON_GPIO_PORT_W 3
#define TEGRA_AON_GPIO_PORT_Z 4
#define TEGRA_AON_GPIO_PORT_AA 5
#define TEGRA_AON_GPIO_PORT_EE 6
#define TEGRA_AON_GPIO_PORT_FF 7
#define TEGRA_AON_GPIO(port, offset) \
((TEGRA_AON_GPIO_PORT_##port * 8) + offset)
/* All pins */
#define TEGRA_PIN_BASE_ID_A 0
#define TEGRA_PIN_BASE_ID_B 1
#define TEGRA_PIN_BASE_ID_C 2
#define TEGRA_PIN_BASE_ID_D 3
#define TEGRA_PIN_BASE_ID_E 4
#define TEGRA_PIN_BASE_ID_F 5
#define TEGRA_PIN_BASE_ID_G 6
#define TEGRA_PIN_BASE_ID_H 7
#define TEGRA_PIN_BASE_ID_I 8
#define TEGRA_PIN_BASE_ID_J 9
#define TEGRA_PIN_BASE_ID_K 10
#define TEGRA_PIN_BASE_ID_L 11
#define TEGRA_PIN_BASE_ID_M 12
#define TEGRA_PIN_BASE_ID_N 13
#define TEGRA_PIN_BASE_ID_O 14
#define TEGRA_PIN_BASE_ID_P 15
#define TEGRA_PIN_BASE_ID_Q 16
#define TEGRA_PIN_BASE_ID_R 17
#define TEGRA_PIN_BASE_ID_S 18
#define TEGRA_PIN_BASE_ID_T 19
#define TEGRA_PIN_BASE_ID_U 20
#define TEGRA_PIN_BASE_ID_V 21
#define TEGRA_PIN_BASE_ID_W 22
#define TEGRA_PIN_BASE_ID_X 23
#define TEGRA_PIN_BASE_ID_Y 24
#define TEGRA_PIN_BASE_ID_Z 25
#define TEGRA_PIN_BASE_ID_AA 26
#define TEGRA_PIN_BASE_ID_BB 27
#define TEGRA_PIN_BASE_ID_CC 28
#define TEGRA_PIN_BASE_ID_DD 29
#define TEGRA_PIN_BASE_ID_EE 30
#define TEGRA_PIN_BASE_ID_FF 31
#define TEGRA_PIN_BASE(port) (TEGRA_PIN_BASE_ID_##port * 8)
#define TEGRA_MAIN_GPIO_RANGE(st, end) \
((TEGRA_MAIN_GPIO_PORT_##end - TEGRA_MAIN_GPIO_PORT_##st + 1) * 8)
#define TEGRA_MAIN_GPIO_BASE(port) (TEGRA_MAIN_GPIO_PORT_##port * 8)
#define TEGRA_AON_GPIO_RANGE(st, end) \
((TEGRA_AON_GPIO_PORT_##end - TEGRA_AON_GPIO_PORT_##st + 1) * 8)
#define TEGRA_AON_GPIO_BASE(port) (TEGRA_AON_GPIO_PORT_##port * 8)
#endif
Hi,
I just read your code again and notice the problem
You put w-disable5 in the same gpio controller as the main GPIO. You should put it in the AON gpio controller so that it will meet your calculation.
Kimber
July 28, 2023, 1:59am
12
I tried putting this pin into the AON GPIO controller, but it didn’t work. When I use cat /sys/kernel/debug/gpio, there is no GPIO-306.
After the system was started, I tried to use the following instructions for control, which was effective.
echo 306 > export
echo out > /sys/class/gpio/gpio306/direction
echo 0> /sys/class/gpio/gpio306/value
devicetree is as follows :
tegra186-gpio-aon@c2f0000 {
GPIO_OUT3 {
compatible = "nvidia,tegra186-gpio-aon";
gpio-hog;
output-low;
gpios = <&tegra_aon_gpio TEGRA_AON_GPIO(EE,2) GPIO_ACTIVE_HIGH>;
label = "GPIO_OUT3";
status = "okay";
};
};
你要不要直接先不要加任何w-disable然後單純用gpio sysfs在這種狀況下控制看看… 看這樣有沒有達到你的預期
Kimber
July 28, 2023, 3:04am
14
After the system was started, I tried to use the following instructions for control, which was effective,it is ok.
echo 306 > export
echo out > /sys/class/gpio/gpio306/direction
echo 0> /sys/class/gpio/gpio306/value
這個時候gpio306下面是active-low還是active-high?
Is it active low or active high in that gpio306 sysfs?
Kimber
August 7, 2023, 8:26am
16
What command should I use to view this feature?
just run ls -al in /sys/class/gpio/gpio306/…
Kimber
August 7, 2023, 9:34am
18
The active_low is displayed.
這樣的話你前面的gpio-hog就要照跟sysfs一樣的設定… output-low + active low…
Then your gpio-hog should use same setting as your sysfs… output low + active low…
Kimber
August 8, 2023, 5:54am
20
I modified my devicetree file:
tegra186-gpio-aon@c2f0000 {
GPIO_OUT3 {
compatible = "nvidia,tegra186-gpio-aon";
gpio-hog;
output-low;
gpios = <&tegra_aon_gpio TEGRA_AON_GPIO(EE,2) GPIO_ACTIVE_LOW>;
label = "GPIO_OUT3";
status = "okay";
};
};
No effect, cat /sys/kernel/debug/gpio still no gPIO-306.
What command should I use to update the.cfg file?