You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/06/21 14:44:14 UTC
(nuttx) branch master updated (85a7b94a2e -> ab693f8aee)
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
from 85a7b94a2e driver: add note when driver registers
new c429438f0d arch/arm: add up_systempoweroff()
new aabc458bcd arch/arm/psci: Fixed the poweroff command blocking problem.
new ab693f8aee arm64/qemu: add support poweroff/reboot command
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
arch/arm/src/armv7-a/arm_cpu_psci.c | 66 +++++++++++++++++-----
arch/arm/src/armv7-a/arm_cpu_psci.h | 1 -
arch/arm64/src/common/CMakeLists.txt | 2 +-
arch/arm64/src/common/Make.defs | 2 +-
arch/arm64/src/common/arm64_cpu_psci.c | 66 +++++++++++++++++-----
arch/arm64/src/common/arm64_cpu_psci.h | 1 -
arch/arm64/src/common/arm64_systemreset.c | 63 ---------------------
.../qemu/qemu-armv8a/configs/nsh_smp/defconfig | 2 +
boards/arm64/qemu/qemu-armv8a/src/CMakeLists.txt | 3 +-
boards/arm64/qemu/qemu-armv8a/src/Makefile | 2 +-
.../qemu/qemu-armv8a/src/qemu_power.c} | 14 ++++-
include/nuttx/arch.h | 12 ++++
12 files changed, 131 insertions(+), 103 deletions(-)
delete mode 100644 arch/arm64/src/common/arm64_systemreset.c
copy boards/{arm/imxrt/imxrt1064-evk/src/imxrt_reset.c => arm64/qemu/qemu-armv8a/src/qemu_power.c} (93%)
(nuttx) 01/03: arch/arm: add up_systempoweroff()
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit c429438f0d835870f788acadf455811cbd991c4e
Author: Peter Bee <bi...@xiaomi.com>
AuthorDate: Tue Feb 6 15:01:12 2024 +0800
arch/arm: add up_systempoweroff()
Co-authored-by: Neo Xu <ne...@gmail.com>
Signed-off-by: Peter Bee <bi...@xiaomi.com>
---
arch/arm/src/armv7-a/arm_cpu_psci.c | 50 ++++++++++++++++++++++++
arch/arm64/src/common/CMakeLists.txt | 2 +-
arch/arm64/src/common/Make.defs | 2 +-
arch/arm64/src/common/arm64_cpu_psci.c | 50 ++++++++++++++++++++++++
arch/arm64/src/common/arm64_systemreset.c | 63 -------------------------------
include/nuttx/arch.h | 12 ++++++
6 files changed, 114 insertions(+), 65 deletions(-)
diff --git a/arch/arm/src/armv7-a/arm_cpu_psci.c b/arch/arm/src/armv7-a/arm_cpu_psci.c
index ef494e647e..3cd4df1c57 100644
--- a/arch/arm/src/armv7-a/arm_cpu_psci.c
+++ b/arch/arm/src/armv7-a/arm_cpu_psci.c
@@ -230,3 +230,53 @@ int arm_psci_init(const char *method)
return psci_detect();
}
+
+/***************************************************************************
+ * Name: up_systempoweroff
+ *
+ * Description:
+ * Internal, arm poweroff logic.
+ *
+ ***************************************************************************/
+
+void up_systempoweroff(void)
+{
+ int ret;
+
+ /* Set up for the system poweroff */
+
+ ret = psci_cpu_off();
+ if (ret)
+ {
+ sinfo("Failed to power off CPU, error code: %d\n", ret);
+ }
+
+ /* Wait for power off */
+
+ for (; ; );
+}
+
+/***************************************************************************
+ * Name: up_systemreset
+ *
+ * Description:
+ * Internal, arm reset logic.
+ *
+ ***************************************************************************/
+
+void up_systemreset(void)
+{
+ int ret;
+
+ /* Set up for the system reset */
+
+ ret = psci_cpu_reset();
+ if (ret)
+ {
+ sinfo("Failed to reset CPU, error code: %d\n", ret);
+ }
+
+ /* Wait for the reset */
+
+ for (; ; );
+}
diff --git a/arch/arm64/src/common/CMakeLists.txt b/arch/arm64/src/common/CMakeLists.txt
index 8180691a60..86be271a90 100644
--- a/arch/arm64/src/common/CMakeLists.txt
+++ b/arch/arm64/src/common/CMakeLists.txt
@@ -64,7 +64,7 @@ if(CONFIG_ARCH_HAVE_MPU)
endif()
if(CONFIG_ARM64_PSCI)
- list(APPEND SRCS arm64_cpu_psci.c arm64_systemreset.c)
+ list(APPEND SRCS arm64_cpu_psci.c)
endif()
if(CONFIG_SMP)
diff --git a/arch/arm64/src/common/Make.defs b/arch/arm64/src/common/Make.defs
index 0e7411b6d5..14f7eb1193 100644
--- a/arch/arm64/src/common/Make.defs
+++ b/arch/arm64/src/common/Make.defs
@@ -76,7 +76,7 @@ CMN_CSRCS += arm64_mpu.c
endif
ifeq ($(CONFIG_ARM64_PSCI),y)
-CMN_CSRCS += arm64_cpu_psci.c arm64_systemreset.c
+CMN_CSRCS += arm64_cpu_psci.c
endif
ifeq ($(CONFIG_SMP),y)
diff --git a/arch/arm64/src/common/arm64_cpu_psci.c b/arch/arm64/src/common/arm64_cpu_psci.c
index 50c47656b0..068158e56a 100644
--- a/arch/arm64/src/common/arm64_cpu_psci.c
+++ b/arch/arm64/src/common/arm64_cpu_psci.c
@@ -232,3 +232,53 @@ int arm64_psci_init(const char * method)
return psci_detect();
}
+
+/***************************************************************************
+ * Name: up_systempoweroff
+ *
+ * Description:
+ * Internal, arm64 poweroff logic.
+ *
+ ***************************************************************************/
+
+void up_systempoweroff(void)
+{
+ int ret;
+
+ /* Set up for the system poweroff */
+
+ ret = psci_cpu_off();
+ if (ret)
+ {
+ serr("Failed to power off CPU, error code: %d\n", ret);
+ }
+
+ /* Wait for power off */
+
+ for (; ; );
+}
+
+/***************************************************************************
+ * Name: up_systemreset
+ *
+ * Description:
+ * Internal, arm64 reset logic.
+ *
+ ***************************************************************************/
+
+void up_systemreset(void)
+{
+ int ret;
+
+ /* Set up for the system reset */
+
+ ret = psci_cpu_reset();
+ if (ret)
+ {
+ serr("Failed to reset CPU, error code: %d\n", ret);
+ }
+
+ /* Wait for the reset */
+
+ for (; ; );
+}
diff --git a/arch/arm64/src/common/arm64_systemreset.c b/arch/arm64/src/common/arm64_systemreset.c
deleted file mode 100644
index 86c97ca198..0000000000
--- a/arch/arm64/src/common/arm64_systemreset.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
- * arch/arm64/src/common/arm64_systemreset.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 <nuttx/config.h>
-
-#include <stdint.h>
-#include <debug.h>
-
-#include <nuttx/arch.h>
-#include <nuttx/board.h>
-
-#include "arm64_internal.h"
-#include "arm64_cpu_psci.h"
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: up_systemreset
- *
- * Description:
- * Internal, arm64 reset logic.
- *
- ****************************************************************************/
-
-void up_systemreset(void)
-{
- int ret;
-
- /* Set up for the system reset */
-
- ret = psci_cpu_reset();
- if (ret)
- {
- sinfo("Failed to reset CPU, error code: %d\n", ret);
- }
-
- /* Wait for the reset */
-
- for (; ; );
-}
diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h
index 11971e54cd..8ae0303b8f 100644
--- a/include/nuttx/arch.h
+++ b/include/nuttx/arch.h
@@ -213,6 +213,18 @@ pid_t up_fork(void);
void up_initialize(void);
+/****************************************************************************
+ * Name: up_systempoweroff
+ *
+ * Description:
+ * The function up_systempoweroff() will power down the MCU. Optional!
+ * Availability of this function is dependent upon the architecture
+ * support.
+ *
+ ****************************************************************************/
+
+void up_systempoweroff(void) noreturn_function;
+
/****************************************************************************
* Name: up_systemreset
*
(nuttx) 02/03: arch/arm/psci: Fixed the poweroff command blocking problem.
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit aabc458bcd9b364d6c3210ea33c06f765d11bb4f
Author: wangming9 <wa...@xiaomi.com>
AuthorDate: Wed Apr 24 15:58:10 2024 +0800
arch/arm/psci: Fixed the poweroff command blocking problem.
Summary:
1. Delete redundant psci_cpu_reset interfaces
2. Adjust the correct interfaces for poweroff and reset
Signed-off-by: wangming9 <wa...@xiaomi.com>
---
arch/arm/src/armv7-a/arm_cpu_psci.c | 20 +++-----------------
arch/arm/src/armv7-a/arm_cpu_psci.h | 1 -
arch/arm64/src/common/arm64_cpu_psci.c | 20 +++-----------------
arch/arm64/src/common/arm64_cpu_psci.h | 1 -
4 files changed, 6 insertions(+), 36 deletions(-)
diff --git a/arch/arm/src/armv7-a/arm_cpu_psci.c b/arch/arm/src/armv7-a/arm_cpu_psci.c
index 3cd4df1c57..ca5af51538 100644
--- a/arch/arm/src/armv7-a/arm_cpu_psci.c
+++ b/arch/arm/src/armv7-a/arm_cpu_psci.c
@@ -162,20 +162,6 @@ int psci_cpu_off(void)
return psci_to_dev_err(ret);
}
-int psci_cpu_reset(void)
-{
- int ret;
-
- if (psci_data.conduit == SMCCC_CONDUIT_NONE)
- {
- return -EINVAL;
- }
-
- ret = psci_data.invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
-
- return psci_to_dev_err(ret);
-}
-
int psci_cpu_on(unsigned long cpuid, uintptr_t entry_point)
{
int ret;
@@ -185,7 +171,7 @@ int psci_cpu_on(unsigned long cpuid, uintptr_t entry_point)
return -EINVAL;
}
- ret = psci_data.invoke_psci_fn(PSCI_FN_NATIVE(0_2, CPU_ON),
+ ret = psci_data.invoke_psci_fn(PSCI_0_2_FN_CPU_ON,
cpuid, (unsigned long)entry_point, 0);
return psci_to_dev_err(ret);
@@ -245,7 +231,7 @@ void up_systempoweroff(void)
/* Set up for the system poweroff */
- ret = psci_cpu_off();
+ ret = psci_sys_poweroff();
if (ret)
{
sinfo("Failed to power off CPU, error code: %d\n", ret);
@@ -270,7 +256,7 @@ void up_systemreset(void)
/* Set up for the system reset */
- ret = psci_cpu_reset();
+ ret = psci_sys_reset();
if (ret)
{
sinfo("Failed to reset CPU, error code: %d\n", ret);
diff --git a/arch/arm/src/armv7-a/arm_cpu_psci.h b/arch/arm/src/armv7-a/arm_cpu_psci.h
index a63299bb3e..0dd8f1c25e 100644
--- a/arch/arm/src/armv7-a/arm_cpu_psci.h
+++ b/arch/arm/src/armv7-a/arm_cpu_psci.h
@@ -150,7 +150,6 @@ void arm_smccc_smc(unsigned long a0, unsigned long a1,
uint32_t psci_version(void);
int psci_cpu_off(void);
-int psci_cpu_reset(void);
int psci_cpu_on(unsigned long cpuid, uintptr_t entry_point);
int psci_sys_poweroff(void);
int psci_sys_reset(void);
diff --git a/arch/arm64/src/common/arm64_cpu_psci.c b/arch/arm64/src/common/arm64_cpu_psci.c
index 068158e56a..3612c4918b 100644
--- a/arch/arm64/src/common/arm64_cpu_psci.c
+++ b/arch/arm64/src/common/arm64_cpu_psci.c
@@ -164,20 +164,6 @@ int psci_cpu_off(void)
return psci_to_dev_err(ret);
}
-int psci_cpu_reset(void)
-{
- int ret;
-
- if (psci_data.conduit == SMCCC_CONDUIT_NONE)
- {
- return -EINVAL;
- }
-
- ret = psci_data.invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
-
- return psci_to_dev_err(ret);
-}
-
int psci_cpu_on(unsigned long cpuid, uintptr_t entry_point)
{
int ret;
@@ -187,7 +173,7 @@ int psci_cpu_on(unsigned long cpuid, uintptr_t entry_point)
return -EINVAL;
}
- ret = psci_data.invoke_psci_fn(PSCI_FN_NATIVE(0_2, CPU_ON),
+ ret = psci_data.invoke_psci_fn(PSCI_0_2_FN_CPU_ON,
cpuid, (unsigned long)entry_point, 0);
return psci_to_dev_err(ret);
@@ -247,7 +233,7 @@ void up_systempoweroff(void)
/* Set up for the system poweroff */
- ret = psci_cpu_off();
+ ret = psci_sys_poweroff();
if (ret)
{
serr("Failed to power off CPU, error code: %d\n", ret);
@@ -272,7 +258,7 @@ void up_systemreset(void)
/* Set up for the system reset */
- ret = psci_cpu_reset();
+ ret = psci_sys_reset();
if (ret)
{
serr("Failed to reset CPU, error code: %d\n", ret);
diff --git a/arch/arm64/src/common/arm64_cpu_psci.h b/arch/arm64/src/common/arm64_cpu_psci.h
index 8fe2a4cedf..abd18be6c7 100644
--- a/arch/arm64/src/common/arm64_cpu_psci.h
+++ b/arch/arm64/src/common/arm64_cpu_psci.h
@@ -99,7 +99,6 @@ struct psci_interface
uint32_t psci_version(void);
int psci_cpu_off(void);
-int psci_cpu_reset(void);
int psci_cpu_on(unsigned long cpuid, uintptr_t entry_point);
int psci_sys_poweroff(void);
int psci_sys_reset(void);
(nuttx) 03/03: arm64/qemu: add support poweroff/reboot command
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit ab693f8aee8afc89876244c30cf06c5b2d3ed870
Author: xuxingliang <xu...@xiaomi.com>
AuthorDate: Tue Jun 18 12:15:33 2024 +0800
arm64/qemu: add support poweroff/reboot command
Signed-off-by: xuxingliang <xu...@xiaomi.com>
---
.../qemu/qemu-armv8a/configs/nsh_smp/defconfig | 2 +
boards/arm64/qemu/qemu-armv8a/src/CMakeLists.txt | 3 +-
boards/arm64/qemu/qemu-armv8a/src/Makefile | 2 +-
boards/arm64/qemu/qemu-armv8a/src/qemu_power.c | 70 ++++++++++++++++++++++
4 files changed, 74 insertions(+), 3 deletions(-)
diff --git a/boards/arm64/qemu/qemu-armv8a/configs/nsh_smp/defconfig b/boards/arm64/qemu/qemu-armv8a/configs/nsh_smp/defconfig
index 0927ffb6fe..3ccb399cd1 100644
--- a/boards/arm64/qemu/qemu-armv8a/configs/nsh_smp/defconfig
+++ b/boards/arm64/qemu/qemu-armv8a/configs/nsh_smp/defconfig
@@ -18,6 +18,8 @@ CONFIG_ARCH_INTERRUPTSTACK=8192
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARM64_STRING_FUNCTION=y
CONFIG_BENCHMARK_OSPERF=y
+CONFIG_BOARDCTL_POWEROFF=y
+CONFIG_BOARDCTL_RESET=y
CONFIG_BUILTIN=y
CONFIG_DEBUG_ASSERTIONS=y
CONFIG_DEBUG_FEATURES=y
diff --git a/boards/arm64/qemu/qemu-armv8a/src/CMakeLists.txt b/boards/arm64/qemu/qemu-armv8a/src/CMakeLists.txt
index cdae09b23b..30fc3ba38a 100644
--- a/boards/arm64/qemu/qemu-armv8a/src/CMakeLists.txt
+++ b/boards/arm64/qemu/qemu-armv8a/src/CMakeLists.txt
@@ -20,8 +20,7 @@
set(SRCS qemu_boardinit.c qemu_bringup.c)
if(CONFIG_BOARDCTL)
- list(APPEND SRCS qemu_appinit.c)
-
+ list(APPEND SRCS qemu_appinit.c qemu_power.c)
endif()
if(CONFIG_LIBC_FDT)
diff --git a/boards/arm64/qemu/qemu-armv8a/src/Makefile b/boards/arm64/qemu/qemu-armv8a/src/Makefile
index a663eb14b5..b594a278bc 100644
--- a/boards/arm64/qemu/qemu-armv8a/src/Makefile
+++ b/boards/arm64/qemu/qemu-armv8a/src/Makefile
@@ -23,7 +23,7 @@ include $(TOPDIR)/Make.defs
CSRCS = qemu_boardinit.c qemu_bringup.c
ifeq ($(CONFIG_BOARDCTL),y)
-CSRCS += qemu_appinit.c
+CSRCS += qemu_appinit.c qemu_power.c
endif
ifeq ($(CONFIG_LIBC_FDT),y)
diff --git a/boards/arm64/qemu/qemu-armv8a/src/qemu_power.c b/boards/arm64/qemu/qemu-armv8a/src/qemu_power.c
new file mode 100644
index 0000000000..1fa90fb131
--- /dev/null
+++ b/boards/arm64/qemu/qemu-armv8a/src/qemu_power.c
@@ -0,0 +1,70 @@
+/****************************************************************************
+ * boards/arm64/qemu/qemu-armv8a/src/qemu_power.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 <nuttx/config.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/board.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_BOARDCTL_POWEROFF
+int board_power_off(int status)
+{
+ up_systempoweroff();
+ return 0;
+}
+#endif
+
+#ifdef CONFIG_BOARDCTL_RESET
+
+/****************************************************************************
+ * 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 */