-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
soc: sam: Add poweroff implementation
This commit adds an implementation of poweroff, which first uses SUPC to enable all defined wakeup sources (except for sam4l), followed by entering backup mode. Signed-off-by: Bjarki Arge Andreasen <[email protected]>
- Loading branch information
Bjarki Arge Andreasen
committed
Oct 19, 2023
1 parent
39ac19e
commit 5944121
Showing
9 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2023 Bjarki Arge Andreasen | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/sys/poweroff.h> | ||
#include <soc.h> | ||
|
||
/* | ||
* Poweroff will make the chip enter the backup low-power mode, which | ||
* achieves the lowest possible power consumption. Wakeup from this mode | ||
* requires enabling a wakeup source or input, or power cycling the device. | ||
*/ | ||
|
||
static void soc_core_sleepdeep_enable(void) | ||
{ | ||
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; | ||
} | ||
|
||
static void soc_core_sleepdeep_wait(void) | ||
{ | ||
__WFE(); | ||
__WFI(); | ||
} | ||
|
||
void z_sys_poweroff(void) | ||
{ | ||
soc_supc_configure_wakeup_sources(); | ||
soc_supc_configure_wakeup_inputs(); | ||
soc_core_sleepdeep_enable(); | ||
soc_supc_core_voltage_regulator_off(); | ||
soc_core_sleepdeep_wait(); | ||
|
||
CODE_UNREACHABLE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2023 Bjarki Arge Andreasen | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/sys/poweroff.h> | ||
#include <soc.h> | ||
|
||
/* | ||
* Poweroff will make the chip enter the backup low-power mode, which | ||
* achieves the lowest possible power consumption. Wakeup from this mode | ||
* requires enabling a wakeup source or input, or power cycling the device. | ||
*/ | ||
|
||
static void soc_core_sleepdeep_enable(void) | ||
{ | ||
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; | ||
} | ||
|
||
static void soc_core_sleepdeep_wait(void) | ||
{ | ||
__WFE(); | ||
__WFI(); | ||
} | ||
|
||
void z_sys_poweroff(void) | ||
{ | ||
core_sleepdeep_enable(); | ||
BMP->PMCON |= BPM_PMCON_BKUP; | ||
soc_core_sleepdeep_wait(); | ||
|
||
CODE_UNREACHABLE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters