From 4996f0cd167b7dbebaa74c5a341fc979488efa60 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Fri, 2 Feb 2024 20:31:09 +0100 Subject: [PATCH] boards/nrf{52|53|91}/common: add reset logic --- boards/arm/nrf52/common/src/CMakeLists.txt | 4 ++ boards/arm/nrf52/common/src/Make.defs | 4 ++ boards/arm/nrf52/common/src/nrf52_reset.c | 62 ++++++++++++++++++++++ boards/arm/nrf53/common/src/CMakeLists.txt | 4 ++ boards/arm/nrf53/common/src/Make.defs | 4 ++ boards/arm/nrf53/common/src/nrf53_reset.c | 62 ++++++++++++++++++++++ boards/arm/nrf91/common/src/CMakeLists.txt | 4 ++ boards/arm/nrf91/common/src/Make.defs | 4 ++ boards/arm/nrf91/common/src/nrf91_reset.c | 62 ++++++++++++++++++++++ 9 files changed, 210 insertions(+) create mode 100644 boards/arm/nrf52/common/src/nrf52_reset.c create mode 100644 boards/arm/nrf53/common/src/nrf53_reset.c create mode 100644 boards/arm/nrf91/common/src/nrf91_reset.c diff --git a/boards/arm/nrf52/common/src/CMakeLists.txt b/boards/arm/nrf52/common/src/CMakeLists.txt index 7c3d75b759..fa869af2fd 100644 --- a/boards/arm/nrf52/common/src/CMakeLists.txt +++ b/boards/arm/nrf52/common/src/CMakeLists.txt @@ -36,6 +36,10 @@ if(CONFIG_ARCH_BOARD_COMMON) list(APPEND SRCS nrf52_lsm9ds1.c) endif() + if(CONFIG_BOARDCTL_RESET) + list(APPEND SRCS nrf52_reset.c) + endif() + target_sources(board PRIVATE ${SRCS}) endif() diff --git a/boards/arm/nrf52/common/src/Make.defs b/boards/arm/nrf52/common/src/Make.defs index 07994dc14a..f7870690a7 100644 --- a/boards/arm/nrf52/common/src/Make.defs +++ b/boards/arm/nrf52/common/src/Make.defs @@ -36,6 +36,10 @@ ifeq ($(CONFIG_SENSORS_LSM9DS1),y) CSRCS += nrf52_lsm9ds1.c endif +ifeq ($(CONFIG_BOARDCTL_RESET),y) +CSRCS += nrf52_reset.c +endif + DEPPATH += --dep-path src VPATH += :src CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src diff --git a/boards/arm/nrf52/common/src/nrf52_reset.c b/boards/arm/nrf52/common/src/nrf52_reset.c new file mode 100644 index 0000000000..b701315f27 --- /dev/null +++ b/boards/arm/nrf52/common/src/nrf52_reset.c @@ -0,0 +1,62 @@ +/**************************************************************************** + * boards/arm/nrf52/common/src/nrf52_reset.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#ifdef CONFIG_BOARDCTL_RESET + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_reset + * + * Description: + * Reset board. Support for this function is required by board-level + * logic if CONFIG_BOARDCTL_RESET is selected. + * + * Input Parameters: + * status - Status information provided with the reset event. This + * meaning of this status information is board-specific. If not + * used by a board, the value zero may be provided in calls to + * board_reset(). + * + * Returned Value: + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value int this case is a + * board-specific reason for the failure to shutdown. + * + ****************************************************************************/ + +int board_reset(int status) +{ + up_systemreset(); + return 0; +} + +#endif /* CONFIG_BOARDCTL_RESET */ diff --git a/boards/arm/nrf53/common/src/CMakeLists.txt b/boards/arm/nrf53/common/src/CMakeLists.txt index b09c210700..2dafcbe790 100644 --- a/boards/arm/nrf53/common/src/CMakeLists.txt +++ b/boards/arm/nrf53/common/src/CMakeLists.txt @@ -32,6 +32,10 @@ if(CONFIG_ARCH_BOARD_COMMON) list(APPEND SRCS nrf53_progmem.c) endif() + if(CONFIG_BOARDCTL_RESET) + list(APPEND SRCS nrf53_reset.c) + endif() + target_sources(board PRIVATE ${SRCS}) endif() diff --git a/boards/arm/nrf53/common/src/Make.defs b/boards/arm/nrf53/common/src/Make.defs index 79e720c8d6..a850bac42b 100644 --- a/boards/arm/nrf53/common/src/Make.defs +++ b/boards/arm/nrf53/common/src/Make.defs @@ -32,6 +32,10 @@ ifeq ($(CONFIG_NRF53_PROGMEM),y) CSRCS += nrf53_progmem.c endif +ifeq ($(CONFIG_BOARDCTL_RESET),y) + CSRCS += nrf53_reset.c +endif + DEPPATH += --dep-path src VPATH += :src CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src diff --git a/boards/arm/nrf53/common/src/nrf53_reset.c b/boards/arm/nrf53/common/src/nrf53_reset.c new file mode 100644 index 0000000000..625b615bc9 --- /dev/null +++ b/boards/arm/nrf53/common/src/nrf53_reset.c @@ -0,0 +1,62 @@ +/**************************************************************************** + * boards/arm/nrf53/common/src/nrf53_reset.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#ifdef CONFIG_BOARDCTL_RESET + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_reset + * + * Description: + * Reset board. Support for this function is required by board-level + * logic if CONFIG_BOARDCTL_RESET is selected. + * + * Input Parameters: + * status - Status information provided with the reset event. This + * meaning of this status information is board-specific. If not + * used by a board, the value zero may be provided in calls to + * board_reset(). + * + * Returned Value: + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value int this case is a + * board-specific reason for the failure to shutdown. + * + ****************************************************************************/ + +int board_reset(int status) +{ + up_systemreset(); + return 0; +} + +#endif /* CONFIG_BOARDCTL_RESET */ diff --git a/boards/arm/nrf91/common/src/CMakeLists.txt b/boards/arm/nrf91/common/src/CMakeLists.txt index 9492508ab4..b3b52600a3 100644 --- a/boards/arm/nrf91/common/src/CMakeLists.txt +++ b/boards/arm/nrf91/common/src/CMakeLists.txt @@ -32,6 +32,10 @@ if(CONFIG_ARCH_BOARD_COMMON) list(APPEND SRCS nrf91_progmem.c) endif() + if(CONFIG_BOARDCTL_RESET) + list(APPEND SRCS nrf91_reset.c) + endif() + target_sources(board PRIVATE ${SRCS}) endif() diff --git a/boards/arm/nrf91/common/src/Make.defs b/boards/arm/nrf91/common/src/Make.defs index 21036b1bb5..77695532bd 100644 --- a/boards/arm/nrf91/common/src/Make.defs +++ b/boards/arm/nrf91/common/src/Make.defs @@ -32,6 +32,10 @@ ifeq ($(CONFIG_NRF91_PROGMEM),y) CSRCS += nrf91_progmem.c endif +ifeq ($(CONFIG_BOARDCTL_RESET),y) + CSRCS += nrf91_reset.c +endif + DEPPATH += --dep-path src VPATH += :src CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src diff --git a/boards/arm/nrf91/common/src/nrf91_reset.c b/boards/arm/nrf91/common/src/nrf91_reset.c new file mode 100644 index 0000000000..2fc95eb2d2 --- /dev/null +++ b/boards/arm/nrf91/common/src/nrf91_reset.c @@ -0,0 +1,62 @@ +/**************************************************************************** + * boards/arm/nrf91/common/src/nrf91_reset.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#ifdef CONFIG_BOARDCTL_RESET + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_reset + * + * Description: + * Reset board. Support for this function is required by board-level + * logic if CONFIG_BOARDCTL_RESET is selected. + * + * Input Parameters: + * status - Status information provided with the reset event. This + * meaning of this status information is board-specific. If not + * used by a board, the value zero may be provided in calls to + * board_reset(). + * + * Returned Value: + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value int this case is a + * board-specific reason for the failure to shutdown. + * + ****************************************************************************/ + +int board_reset(int status) +{ + up_systemreset(); + return 0; +} + +#endif /* CONFIG_BOARDCTL_RESET */