Power off and power on via button the iMX6ULL module

Hi everyone.

I would like to turn on and turn off the iMX6ULL by pressing a button, like happening in a laptop. I saw that the Colibri Evaluation Board board has the chip LTC2954 to control the power supply and send the information to the SOM proceeds to power off when the button is pressed. How can I use the pins INT and KILL connected to SOM to achieve the goal?

Thanks!

Charles Dias.

Hi @CharlesDias,

Sorry for the delay. To clarify, do you intend to use the button to power on/off by hardware or software?

The Colibri Evaluation Board uses a hardware approach. Although it uses the LTC2954 to power on/off the module, it does not make use of neither the INT nor KILL pins (see “Operation Without μP” in the LTC2954 datasheet). Both pins are not physically connected to module as it can be seen in its schematic, page 3, which can be downloaded here. If you intend to proceed with this route it is recommended to follow the schematic.

If you still plan to use both the INT and KILL pins, do know that they must be connected to module (e.g. to the GPIO pins) and their handling must be done in software (see Read GPIO Using Events), following what is written in the LTC2954 datasheet.

Please let me know if need any further assistance.

Best regards,
André

Hi @andre_m.tx,

Thank you for your support. I have some questions. My plan is to use an external button to power on/off the system. I don’t know if the better approach is to power on/off by hardware or software. Which one do you suggest?

Using the LTC2954, I imagine in the following steps. Please, check if it is this approach makes sense:

  1. While the system is power off (the power supply doesn’t provide the 3.3V to SOM);
  2. The user presses the external button connected to LTC2954. At this moment, the LCT2954 will activate the MOSFET to power on the power supply and provide the 3.3V to SOM. After this, the SOM will be running and applies high-level signal to KILL pin in a period of time less than 512ms (requirement of LTC2954). Which pin do you recommend connecting to KILL to achieve this time requirement?
  3. While the system is running, if a user presses the external button, the LCT2954 will send an INT signal to SOM and the SOM will execute the poweroff command;
  4. When the system finishes the poweroff the SOM applies low-level signal to KILL pin. At this moment, the LCT2954 deactivates the MOSFET and poweroff the power supply;
  5. The system is ready to repeat Step 1.

In this case describe above, I have some concern about if the iMX6ULL:

  1. Does the iMX6ULL is able to identify a signal provide by INT pin that has a pulse with 32ms of max duration? Which pin do you recommend connecting to INT to achieve this time requirement?
  2. Is it possible to iMX6ULL apply the high-level signal to KILL pin in a period of time less than 512ms after apply 3.3V to SOM? Which pin do you recommend connecting to KILL to achieve this time requirement?

I read in the iMX6ULL datasheet when I execute the poweroff command on iMX6ULL the only way to reactivate the system from the Shut-Down state is by pressing the reset button or removing and reapplying the 3V3 main supply voltage rail.

Sorry for many questions! And thank you so much!

Charles Dias

Hi @CharlesDias,

It depends on the amount of control you intend to have on your system regarding its power cycle. Software gives you more control, but it requires work to set it up. Hardware requires less work to set up, but it gives you less control.

It is indeed a correct software approach setup.

I believe it should be possible to use GPIO pins to read the INT pin. Since a GPIO interrupt read requires two wait states, which is a function of a selected Burst clock (which is in the order of MHz, meaning periods in the order of μs), any GPIO pin should be able to read a 32ms signal without any problems. Refer to iMX6ULL’s Reference Manual (specifically pages 1368, 875, 825, 827) for more information.

There is a “poweroff” command implementation in our official documentation which uses a GPIO pin connected to the KILL pin (called FORCE_OFF#). In the Colibri Evaluation Board schematic previously stated, note that the KILL pin is directly brought up by a 3.3V source connected to the LCT2954. Hence, the 512ms requirement should be fulfilled by the circuit itself. I believe this is the only way to comply with such constraint since Linux boot times can take significantly more than 512ms.

This is indeed is correct.

Please let me know if need any further assistance.

Best regards,
André

Hi @andre_m.tx.

Thanks for all the information. I’ll check and make some testes.

Best regards,
Charles Dias.

Hello @andre_m.tx.

I changed the DTS to implement the GPIO Power-Off. However, I got the following debug message shown below:

root@colibri-imx6ull:~# dmesg | grep poweroff
[    1.831265] syscon-poweroff 20cc000.snvs:snvs-poweroff: pm_power_off already claimed 805e156c gpio_poweroff_do_poweroff
[    1.850948] syscon-poweroff: probe of 20cc000.snvs:snvs-poweroff failed with error -16
root@colibri-imx6ull:~# 

Could you help me with this? This is the DTS that I’m using:

Linux kernel source: toradex_4.9-2.3.x-imx
Kernel config: colibri-imx6ull_defconfig

/dts-v1/;

#include "imx6ull-colibri-nonwifi.dtsi"
#include "imx6ull-colibri-aster.dtsi"

/ {
	model = "Toradex Colibri iMX6ULL 512MB Display Control Board V1.1";
	compatible = "toradex,colibri_imx6ull-aster", "fsl,imx6ull";

	gpio-poweroff {
		compatible = "gpio-poweroff";
		gpios = <&gpio4 14 GPIO_ACTIVE_LOW>;
		status = "okay";
	};
};

&atmel_mxt_ts {
	status = "okay";
};

p.s. the touch screen works fine with this DTS.

Thank for you support.

System and Hardware:

  • Angstrom v2017.12 - Kernel
  • Colibri-iMX6ULL_LXDE-Image 2.8b7. 20200610
  • Linux colibri-imx6ull 4.9.220-2.8.7+g57229263ff65 #1 SMP Wed Jun 10 17:07:44 UTC 2020 armv7l GNU/Linux
  • Colibri iMX6ULL 512MB IT V1.1A
  • Aster V1.1B
  • Capacitive Touch Display 7" Parallel V1.0B

Hi @CharlesDias,

Have you tried adding status = "disabled" in the snvs_poweroff node? E.g.:

....

&atmel_mxt_ts {
	status = "okay";
};

&snvs_poweroff {
	status = "disabled";
};

Also, can you please provide us the output of the following command:

# dmesg | grep -i iomux

Best regards,
André

Hi @andre_m.tx.

I disabled the snvs_poweroff as recommended it and the previous message disappear. However, I realize that when I enter the command poweroff in this new DTS, I got a kernel crash message at the end of logs. Please check the message below for three test condition:

  1. Log output normal DTS
root@colibri-imx6ull:~# dmesg | grep -i iomux                                                                                   
[    0.113032] imx6ul-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver                                                    
[    0.113960] imx6ul-pinctrl 2290000.iomuxc-snvs: initialized IMX pinctrl driver 
. . . 

root@colibri-imx6ull:~# dmesg | grep -i poweroff
root@colibri-imx6ull:~# 
root@colibri-imx6ull:~# poweroff 
. . .  
                                                         
[   75.888210] usb usb2: USB disconnect, device number 1                                                                        
[   75.894284] ci_hdrc ci_hdrc.1: USB bus 2 deregistered                                                                        
[   75.899956] reboot: Power down   
  1. Output with gpio-poweroff in DTS
	gpio-poweroff {
		compatible = "gpio-poweroff";
		gpios = <&gpio4 14 GPIO_ACTIVE_LOW>;
		status = "okay";
	};
root@colibri-imx6ull:~# dmesg | grep -i iomux                                                                                   
[    0.113220] imx6ul-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver                                                    
[    0.114149] imx6ul-pinctrl 2290000.iomuxc-snvs: initialized IMX pinctrl driver 
. . . 
root@colibri-imx6ull:~# dmesg | grep -i poweroff                                                                                
[    1.831614] syscon-poweroff 20cc000.snvs:snvs-poweroff: pm_power_off already claimed 805e156c gpio_poweroff_do_poweroff      
[    1.851282] syscon-poweroff: probe of 20cc000.snvs:snvs-poweroff failed with error -16  
root@colibri-imx6ull:~# poweroff 
. . .

[  186.364841] usb usb2: USB disconnect, device number 1                                                                        
[  186.371060] ci_hdrc ci_hdrc.1: USB bus 2 deregistered                                                                        
[  186.376579] reboot: Power down                                                                                               
[  189.579858] ------------[ cut here ]------------                                                                             
[  189.584603] WARNING: CPU: 0 PID: 1 at /workdir/oe/tmp-glibc/work-shared/colibri-imx6ull/kernel-source/drivers/power/reset/gp0
[  189.600605] Modules linked in: bluetooth(E) usb_f_rndis(E) u_ether(E) atmel_mxt_ts(E) libcomposite(E) configfs(E)            
[  189.611228] CPU: 0 PID: 1 Comm: systemd-shutdow Tainted: G            E   4.9.220-2.8.7+g57229263ff65 #1                     
[  189.620873] Hardware name: Freescale i.MX6 UltraLite (Device Tree)                                                           
[  189.627162] Backtrace:                                                                                                       
[  189.629690] [<8010b62c>] (dump_backtrace) from [<8010b904>] (show_stack+0x18/0x1c)                                           
[  189.652762]  r7:00000009 r6:600f0093 r5:00000000 r4:80c1cdc0                                                                 
[  189.674075] [<8010b8ec>] (show_stack) from [<804355d0>] (dump_stack+0x9c/0xb0)                                               
[  189.697024] [<80435534>] (dump_stack) from [<80124eec>] (__warn+0xec/0x104)                                                  
[  189.719524]  r7:00000009 r6:809cccf4 r5:00000000 r4:00000000                                                                 
[  189.740924] [<80124e00>] (__warn) from [<80124fbc>] (warn_slowpath_null+0x28/0x30)                                           
[  189.764609]  r9:94068000 r8:fee1dead r7:80cb8c00 r6:0ccccb60 r5:00000000 r4:809ee220                                         
[  189.788581] [<80124f94>] (warn_slowpath_null) from [<805e1624>] (gpio_poweroff_do_poweroff+0xb8/0xc0)                        
[  189.831118] [<805e156c>] (gpio_poweroff_do_poweroff) from [<80109d88>] (machine_power_off+0x2c/0x44)                         
[  189.875939]  r7:81a1a000 r6:80c0e880 r5:4321fedc r4:00000000                                                                 
[  189.900103] [<80109d5c>] (machine_power_off) from [<80146190>] (kernel_power_off+0x74/0x78)                                  
[  189.927474] [<8014611c>] (kernel_power_off) from [<80146318>] (SyS_reboot+0x134/0x1c4)                                       
[  189.954610] [<801461e4>] (SyS_reboot) from [<80107ae0>] (ret_fast_syscall+0x0/0x48)                                          
[  189.981673]  r8:80107cc4 r7:00000058 r6:00000000 r5:ffffffff r4:00000000                                                     
[  190.008032] ---[ end trace 41c53dd13138c834 ]---                                                                             
[  190.032645] machine_power_off pm_power_off() did return  
  1. Output with gpio-poweroff and disable snvs_poweroff in DTS
	gpio-poweroff {
		compatible = "gpio-poweroff";
		gpios = <&gpio4 14 GPIO_ACTIVE_LOW>;
		status = "okay";
	};
};

&atmel_mxt_ts {
	status = "okay";
};

&snvs_poweroff {
	status = "disabled";
};
root@colibri-imx6ull:~# dmesg | grep -i iomux                                                                                   
[    0.112782] imx6ul-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver                                                    
[    0.113726] imx6ul-pinctrl 2290000.iomuxc-snvs: initialized IMX pinctrl driver 
. . . 

root@colibri-imx6ull:~# dmesg | grep -i poweroff                                                                                
root@colibri-imx6ull:~# 
root@colibri-imx6ull:~# poweroff 
. . .

[  129.930491] usb usb2: USB disconnect, device number 1                                                                        
[  129.936728] ci_hdrc ci_hdrc.1: USB bus 2 deregistered                                                                        
[  129.942393] reboot: Power down                                                                                               
[  133.145556] ------------[ cut here ]------------                                                                             
[  133.150285] WARNING: CPU: 0 PID: 1 at /workdir/oe/tmp-glibc/work-shared/colibri-imx6ull/kernel-source/drivers/power/reset/gp0
[  133.166287] Modules linked in: bluetooth(E) usb_f_rndis(E) u_ether(E) atmel_mxt_ts(E) libcomposite(E) configfs(E)            
[  133.176910] CPU: 0 PID: 1 Comm: systemd-shutdow Tainted: G            E   4.9.220-2.8.7+g57229263ff65 #1                     
[  133.186556] Hardware name: Freescale i.MX6 UltraLite (Device Tree)                                                           
[  133.192844] Backtrace:                                                                                                       
[  133.195373] [<8010b62c>] (dump_backtrace) from [<8010b904>] (show_stack+0x18/0x1c)                                           
[  133.218450]  r7:00000009 r6:600f0093 r5:00000000 r4:80c1cdc0                                                                 
[  133.239787] [<8010b8ec>] (show_stack) from [<804355d0>] (dump_stack+0x9c/0xb0)                                               
[  133.262760] [<80435534>] (dump_stack) from [<80124eec>] (__warn+0xec/0x104)                                                  
[  133.285271]  r7:00000009 r6:809cccf4 r5:00000000 r4:00000000                                                                 
[  133.306699] [<80124e00>] (__warn) from [<80124fbc>] (warn_slowpath_null+0x28/0x30)                                           
[  133.330429]  r9:94068000 r8:fee1dead r7:80cb8c00 r6:0ccccb60 r5:00000000 r4:809ee220                                         
[  133.354434] [<80124f94>] (warn_slowpath_null) from [<805e1624>] (gpio_poweroff_do_poweroff+0xb8/0xc0)                        
[  133.397011] [<805e156c>] (gpio_poweroff_do_poweroff) from [<80109d88>] (machine_power_off+0x2c/0x44)                         
[  133.441917]  r7:31356b00 r6:80c0e880 r5:4321fedc r4:00000000                                                                 
[  133.466132] [<80109d5c>] (machine_power_off) from [<80146190>] (kernel_power_off+0x74/0x78)                                  
[  133.493545] [<8014611c>] (kernel_power_off) from [<80146318>] (SyS_reboot+0x134/0x1c4)                                       
[  133.520723] [<801461e4>] (SyS_reboot) from [<80107ae0>] (ret_fast_syscall+0x0/0x48)                                          
[  133.547827]  r8:80107cc4 r7:00000058 r6:00000000 r5:ffffffff r4:00000000                                                     
[  133.574235] ---[ end trace 5a5a40f2c272a452 ]---                                                                             
[  133.598867] machine_power_off pm_power_off() did return 

Thank you for your help.

Hi @andre_m.tx.

I checked this message on kernel documentation gpio-poweroff.txt.

After a delay of 100ms,
the GPIO is set to inactive, thus causing an active->inactive edge,
triggering negative edge triggered power off. After another 100ms
delay the GPIO is driver active again. If the power is still on and
the CPU still running after a 3000ms delay, a WARN_ON(1) is emitted.

Maybe the kernel warning it’s expected because the board is not powered off from outside. This does make sense?

The period of time between the out log message reboot: Power down and ------------[ cut here ]------------ is close to 3s, as described in the documentation. I check also the gpio-poweroff signal and the width is close to 100ms each edge.

Hi @CharlesDias,

Thank you very much for the detailed inputs. I was able to reproduce your error.

It does indeed. From the documentation you’ve sent, when the command poweroff is typed, the GPIO power-off driver expects the used GPIO pin to be connected to some power controller IC, which will then be responsible for actually powering off the SoM. The driver itself cannot power off the module - it only sends the signals to do so, as seen in your oscilloscope capture.

The kernel warning you are seeing is the WARN_ON(1) signal sent after the 3000ms delay. Hence, if the used GPIO pin is properly connected to the KILL pin of the LTC2954 the module should properly power off and, consequently, the kernel warning should disappear.

I’ve successfully tested this on a Colibri Evaluation Board by using your device tree with snvs_poweroff disabled and by connecting the SODIMM_133 (GPIO4, 14) pin to the FORCE_OFF# (X4, 5) pin.

Do note that the Aster Carrier Board does not feature a power controller IC. Hence it is not possible to use the above configuration with it alone. In this case, you can use the gpio-keys driver to make use of a GPIO pin to read an external push button to power off the module.

Best regards,
André

I’ve successfully tested this on a Colibri Evaluation Board by using your device tree with snvs_poweroff disabled and by connecting the SODIMM_133 (GPIO4, 14) pin to the FORCE_OFF# (X4, 5) pin.

I am really glad to hear that the device tree worked on Colibri Evaluation Board. I’ll continue the developer using the LTC2954 on my custom board.

Thank you so much for your help and the great reply.