cancel
Showing results for 
Search instead for 
Did you mean: 

Detecting Wakeup Source of STM32MP151 in Linux Userspace

AShar.10
Associate III

Hello ST Community,

 

We are developing a product based on STM32MP151 which requires detecting what caused the device to wakeup from sleep. With this device, we are setting up 2 wakeup sources - RTC and 2 WKUP GPIOs and we have to execute specific functions in our C application based on which GPIO triggered wakeup (or if it was RTC).

 

We are using latest openstlinux distribution package. Right now, we have no clue as to if it is even possible somehow, some help will be appreciated a lot from ST regarding this...

 

Best Regards,

Ayush Sharma

2 REPLIES 2
Christophe Guibout
ST Employee

Hi @AShar.10,

 

Regarding WKUP, please check PWR_WKUPCRx register where WKUPF bit informs if the associated WKUP caused the wakeup.

Edit: This answer is for MP2x, for MP15, please check PWR_WKUPFR register.

 

Concerning RTC, the bit WUTF in RTC_SR can help as well.

BR,

Christophe

 

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi @Christophe Guibout ,

 

Thanks a lot for taking some time to reply to my query. I tried your suggestion but the value of PWR_WKUPFR register always returns 0x00000000. I'm testing as follows:

 

1. Shutting down the board by executing "shutdown now" in SSH

2. Pressing GPIOI8 button (active low - external pullup to 5v) to wake up our board

3. Executing "devmem2 0x50001024" to get the PWR_WKUPFR value.

 

Here's the complete devmem2 output:

~# devmem2 0x50001024
/dev/mem opened.
Memory mapped at address 0xb6f2d000.
Read at address  0x50001024 (0xb6f2d024): 0x00000000

 

Any idea why this could be happening? Also, the linux-stm32mp device tree entry of wakeup gpio is as follows, I'm not sure if this is correct:

 

gpio-keys {
		compatible = "gpio-keys";
		user_button {
			label = "user_button";
			interrupts-extended = <&exti 58 IRQ_TYPE_EDGE_FALLING>;
			linux,code = <28>; /* KEY_ENTER */
			wakeup-source;
		};
	};

 

Best Regards,

Ayush