Jetson TX2 Power Button Event Not working

I have Jetson Tx2 Developer kit. & fe-pi audio z v2 (SGTL5000 Audio Module)
JetPack 4.3 was installed using SDK Manager.
Fe-Pi audio z v2 was added using the /opt/nvidia/jetson-io/jetson-io.py script.
The Audio module works, but no event occurs when the Power button is pressed.
As a result of debugging, when the SGTL5000 driver is activated, the Power Button event does not work.
How to fix it?

Not sure what you mean by “power button event”. Can you explain more, e.g., power on or off is not working?

It’s Dialog Box.

If you press the power button, the Dialog Box is not visible.

1 Like

Hi,

The Audio module works, but no event occurs when the Power button is pressed.
As a result of debugging, when the SGTL5000 driver is activated, the Power Button event does not work.

Sorry but I cannot understand your purpose either. Do you mean the SGTL5000 module is connected (what interface is that?), then the power button event is not triggered?

BTW, is it TX2 or TX2i?

When the SGTL5000 driver is loaded, the Dialog Box is not visible when the Power button is pressed.
(Power button interrupt works fine)

$ cat /proc/interrupts  | grep Power
373:          4          0          0          0  tegra-gpio-aon  56 Edge      Power

Hi,

Ok, could you share what interfaces and the driver source of SGTL5000? Any extra patch you’ve added ?

Also, are you able to receive the gpio-keys event from sysfs when you press the power button?

Hello WayneWWW

SGTL5000 Driver is included JetPack 4.3
PATH: kernel-4.9/sound/soc/codecs/sgtl5000.c

JetPack v4.3 was installed through SDK Manager. (P3310-1000 + P2597-0000 Board)
Not Change source code.
Using the /opt/nvidia/jetson-io/jetson-io.py script.
(Welcome — Jetson Linux<br/>Developer Guide 34.1 documentation)

And How to recive the gpio-keys event from sysfs?

I checked gpio-keys (Power) event as below. but Dialog Box is not visible.

# cat /proc/bus/input/devices
...
I: Bus=0019 Vendor=0001 Product=0001 Version=0100
N: Name="gpio-keys"
P: Phys=gpio-keys/input0
S: Sysfs=/devices/gpio-keys/input/input2
U: Uniq=
E: Enabled=0
H: Handlers=kbd event2
B: PROP=0
B: EV=3
B: KEY=1c000000000000 0
...

# cat /sys/devices/gpio-keys/input/input2/event2/uevent
MAJOR=13
MINOR=66
DEVNAME=input/event2

# hexdump /dev/input/event2
// (Press Power Button)
0000000 cd13 5e8e 0000 0000 5a82 0007 0000 0000
0000010 0001 0074 0001 0000 cd13 5e8e 0000 0000
0000020 5a82 0007 0000 0000 0000 0000 0000 0000

# apt install evtest -y
# evtest /dev/input/event2
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "gpio-keys"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 114 (KEY_VOLUMEDOWN)
    Event code 115 (KEY_VOLUMEUP)
    Event code 116 (KEY_POWER)
Properties:
Testing ... (interrupt to exit)
Event: time 1586418628.498282, type 1 (EV_KEY), code 116 (KEY_POWER), value 1
Event: time 1586418628.498282, -------------- SYN_REPORT ------------
Event: time 1586418628.543315, type 1 (EV_KEY), code 116 (KEY_POWER), value 0
Event: time 1586418628.543315, -------------- SYN_REPORT ------------

# cat /proc/interrupts | grep Power
373:         18          0          0          0  tegra-gpio-aon  56 Edge      Power

As a result of debugging, if the SGTL5000 driver is registered, the Dialog Box is not visible when the Power button is pressed.

If the SGTL5000 driver fails to register, the Dialog Box is displayed when the Power button is pressed.

According to your log, the gpio key event from the power button is still working but somehow the ubuntu desktop does not trigger the box.

  1. May I know what you’ve changed in jetson-io and anything changed in kernel or device tree?
  2. Is it necessary to plug the device to reproduce this issue? I mean is it possible that load up driver only would also hit this issue?
  1. May I know what you’ve changed in jetson-io and anything changed in kernel or device tree?

I haven’t changed anything.
Only JetPack v4.3 OS Image was installed using SDK Manager.

  1. Is it necessary to plug the device to reproduce this issue? I mean is it possible that load up driver only would also hit this issue?

I’ll check and answer tomorrow.

The log from “/var/log/Xorg.0.log” could help. I say this because much of the I/O for events from mouse/keyboard and GPU are loaded as modules (XInput driver for mouse/keyboard). To illustrate, if an ABI of one mismatches (from different releases), then that module will fail and any event related to that device will also fail. There are a number of “gpio-keys” saying how keyboard, mouse or so on is mapped. Perhaps the log from a boot without the device failing, and a log with the device failing, would differ in ways which would tell us what is going on.

I haven’t changed anything.
Only JetPack v4.3 OS Image was installed using SDK Manager.

Ok, so the jetson-io is only used for enabling “FE-PI Audio Z V2 (SGTL5000 I2S audio codec)”, right?

Actually, it is kind of change too… Anyway, I will wait for your answer for the remaining questions. Thanks.

Hello

It is not necessary to plug in the device to reproduce this problem.
If only SGTL5000 driver is registered normally, the issue is reproduced.
I connected the EEPROM (= 24AA02E48) to the extended I2C and changed the Device Address in the Device Tree to load the SGTL5000 driver and confirmed that the problem was reproduced.

Hi larche,

Thanks for your confirm. I am going to reproduce this issue with pure devkit with jetson-io modifying the pinmux and add SGTL5000 driver only.

It may take time to do it. In the meantime, you could also try the suggestion of linuxdev and see if any error log.

As a result of debugging, I confirmed that the issue occurred only when the sgtl5000_probe () function of the SGTL5000 driver was called normally and completed.

Thanks.

Hi larche,

Thanks for quick update. I just wonder if we could even narrow down the cause. Is it necessary to use jetson-IO?
Maybe just load up this driver would hit this issue?

It is not necessary to use jetson-IO
Just load up sgtl5000 driver.

Hi larche,

I just saw something. There is a specific sgtl5000 driver.for tegra.

kernel/kernel-4.9/sound/soc/tegra/tegra_sgtl5000.c. Could you also try to use that driver too?
You could enable it in tegra_defconfig by adding “CONFIG_SND_SOC_TEGRA_SGTL5000=y”.

If there is no SGTL5000 device, you can load the SGTL5000 driver using another I2C device.

in my case I connected the EEPROM(=24AA02E48) to the Expansion I2C. <I2C Device Address = 0x50 ~ 0x57>

# i2cdetect -y -r 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --  
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
50: UU 51 52 53 54 55 56 57 -- -- -- -- -- -- -- --  
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
70: -- -- -- -- -- -- -- --

Then, edit the sgtl5000 Driver and DT file of the P2597 board as follows.

<kernel/kernel-4.9/sound/soc/codecs/sgtl5000.c>

--- kernel_org/kernel-4.9/sound/soc/codecs/sgtl5000.c   2019-12-10 15:40:27.000000000 +0900
+++ kernel/kernel-4.9/sound/soc/codecs/sgtl5000.c   2020-04-10 16:24:40.888726880 +0900
@@ -1102,6 +1102,8 @@
    int ret;
    struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
+   printk("LINE[%04d]: func(%s)\n",__LINE__,__func__);
+#if 0
    /* power up sgtl5000 */
    ret = sgtl5000_set_power_regs(codec);
    if (ret)
@@ -1148,7 +1150,9 @@
     * Enable DAP in kcontrol and dapm.
     */
    snd_soc_write(codec, SGTL5000_DAP_CTRL, 0);
+#endif
+   printk("LINE[%04d]: func(%s) SGTL Driver Load \n",__LINE__,__func__);
    return 0;
err:
@@ -1224,6 +1228,7 @@
    u32 value;
    u16 ana_pwr;
+   printk("LINE[%04d]: func(%s)\n",__LINE__,__func__);
    sgtl5000 = devm_kzalloc(&client->dev, sizeof(*sgtl5000), GFP_KERNEL);
    if (!sgtl5000)
        return -ENOMEM;
@@ -1260,6 +1265,7 @@
    /* Need 8 clocks before I2C accesses */
    udelay(1);
+#if 0
    /* read chip information */
    ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ID, &reg);
    if (ret) {
@@ -1317,6 +1323,7 @@
            "Error %d setting CHIP_ANA_POWER to %04x\n",
            ret, ana_pwr);
+#endif
    if (np) {
        if (!of_property_read_u32(np,
            "micbias-resistor-k-ohms", &value)) {
@@ -1359,13 +1366,14 @@
    }
    /* Ensure sgtl5000 will start with sane register values */
-   sgtl5000_fill_defaults(client);
+// sgtl5000_fill_defaults(client);
    ret = snd_soc_register_codec(&client->dev,
            &sgtl5000_driver, &sgtl5000_dai, 1);
    if (ret)
        goto disable_clk;
+   printk("LINE[%04d]: func(%s)\n",__LINE__,__func__);
    return 0;
disable_clk:

<hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-base.dts>

--- hardware_org/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-base.dts    2019-12-10 15:39:33.000000000 +0900
+++ hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-base.dts    2020-04-10 15:51:01.814609920 +0900
@@ -49,6 +49,16 @@
                 };  
    };  
+   clocks {
+       sgtl5000_mclk: sgtl5000_mclk {
+           compatible = "fixed-clock";
+           #clock-cells = <0>;
+           clock-frequency = <12288000>;
+           clock-output-names = "sgtl5000-mclk";
+           status = "okay";
+       };
+   };
+
    sdhci@3400000 {
        cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 5) 0>;
        nvidia,cd-wakeup-capable;
@@ -78,6 +88,18 @@
    };  
    hdr40_i2c1: i2c@c240000 {
+       #address-cells = <1>;
+       #size-cells = <0>;
+       sgtl5000: sgtl5000@50 {
+           compatible = "fsl,sgtl5000";
+           reg = <0x50>;
+           clocks = <&sgtl5000_mclk>;
+           micbias-resistor-k-ohms = <2>;
+           micbias-voltage-m-volts = <3000>;
+           VDDA-supply = <&hdr40_vdd_3v3>;
+           VDDIO-supply = <&hdr40_vdd_3v3>;
+           status = "okay";
+       };
        bmi160@69 {
            compatible = "bmi,bmi160";
            reg = <0x69>;
@@ -187,6 +209,12 @@
    };  
    sound {
-       hdr40_snd_link_i2s: nvidia,dai-link-1 { };
+       hdr40_snd_link_i2s: nvidia,dai-link-1 {
+           link-name = "fe-pi-audio-z-v2";
+           codec-dai = <&sgtl5000>;
+           codec-dai-name = "sgtl5000";
+           bitclock-master;
+           frame-master;
+       };
    };  
};

After compiling, after fusing Kernel and DT images, check if the sgtl5000 driver is loaded.

# dmesg | grep LINE
[    1.650853] LINE[1231]: func(sgtl5000_i2c_probe)
[    1.651593] LINE[1376]: func(sgtl5000_i2c_probe)
[    1.776563] LINE[1105]: func(sgtl5000_probe)
[    1.776566] LINE[1155]: func(sgtl5000_probe) SGTL Driver Load Complete

As far as I know, the tegra_sgtl5000.c driver is not used.

Ok I see. The dts change you shared here is same as jetson-io did, right?