Skip to content

Commit

Permalink
soc: atmel_sam: Add sys_poweroff support
Browse files Browse the repository at this point in the history
This commit adds an implementation of sys_poweroff() which
will either enter backup mode.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
  • Loading branch information
Bjarki Arge Andreasen committed Oct 16, 2023
1 parent de66def commit 8b6af25
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions soc/arm/atmel_sam/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
zephyr_include_directories(.)
zephyr_library_sources_ifndef(CONFIG_SOC_SERIES_SAM4L soc_pmc.c)
zephyr_library_sources_ifndef(CONFIG_SOC_SERIES_SAM4L soc_gpio.c)
zephyr_library_sources_ifndef(CONFIG_SOC_SERIES_SAM4L soc_poweroff.c)

zephyr_library_sources_ifdef(CONFIG_SOC_SERIES_SAM4L soc_sam4l_pm.c)
zephyr_library_sources_ifdef(CONFIG_SOC_SERIES_SAM4L soc_sam4l_gpio.c)
17 changes: 17 additions & 0 deletions soc/arm/atmel_sam/common/soc_poweroff.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2023 Bjarki Arge Andreasen
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/sys/poweroff.h>
#include <soc.h>

#define SUPC_CR_KEY_PASSWORD (0xA5 << 24)

void z_sys_poweroff(void)
{
/* Switch off voltage regulator to enter backup mode */
SUPC->SUPC_CR = SUPC_CR_KEY_PASSWD | SUPC_CR_VROFF_STOP_VREG;

CODE_UNREACHABLE;
}
1 change: 1 addition & 0 deletions soc/arm/atmel_sam/sam3x/Kconfig.series
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ config SOC_SERIES_SAM3X
select SOC_FAMILY_SAM
select PLATFORM_SPECIFIC_INIT
select ASF
select HAS_POWEROFF
help
Enable support for Atmel SAM3X Cortex-M3 microcontrollers.
Part No.: SAM3X8E
1 change: 1 addition & 0 deletions soc/arm/atmel_sam/sam4e/Kconfig.series
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ config SOC_SERIES_SAM4E
select SOC_FAMILY_SAM
select PLATFORM_SPECIFIC_INIT
select ASF
select HAS_POWEROFF
help
Enable support for Atmel SAM4E Cortex-M4 microcontrollers.
Part No.: SAM4E16E, SAM4E16C, SAM4E8E, SAM4E8C
1 change: 1 addition & 0 deletions soc/arm/atmel_sam/sam4s/Kconfig.series
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ config SOC_SERIES_SAM4S
select SOC_FAMILY_SAM
select PLATFORM_SPECIFIC_INIT
select ASF
select HAS_POWEROFF
help
Enable support for Atmel SAM4S Cortex-M4 microcontrollers.
Part No.: SAM4S16C, SAM4S16B, SAM4S8C, SAM4S8B,
Expand Down
1 change: 1 addition & 0 deletions soc/arm/atmel_sam/same70/Kconfig.series
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ config SOC_SERIES_SAME70
select ASF
select HAS_SWO
select XIP
select HAS_POWEROFF
help
Enable support for Atmel SAM E70 ARM Cortex-M7 Microcontrollers.
Part No.: SAME70J19, SAME70J20, SAME70J21, SAME70N19, SAME70N20,
Expand Down
1 change: 1 addition & 0 deletions soc/arm/atmel_sam/samv71/Kconfig.series
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ config SOC_SERIES_SAMV71
select ASF
select HAS_SWO
select XIP
select HAS_POWEROFF
help
Enable support for Atmel SAM V71 ARM Cortex-M7 Microcontrollers.
Part No.: SAMV71J19, SAMV71J20, SAMV71J21, SAMV71N19, SAMV71N20,
Expand Down

0 comments on commit 8b6af25

Please sign in to comment.