diff options
| author | Ben Zong-You Xie <ben717@andestech.com> | 2025-12-29 15:19:10 +0800 |
|---|---|---|
| committer | Anup Patel <anup@brainfault.org> | 2026-02-11 12:03:50 +0530 |
| commit | 9ffacc8ae1ca07ed36d57f887d62a65ae7a44223 (patch) | |
| tree | 5afcb8ec6848672d817dffc27462c5f6f8429357 /lib/utils/sys | |
| parent | 74434f255873d74e56cc50aa762d1caf24c099f8 (diff) | |
| download | opensbi-9ffacc8ae1ca07ed36d57f887d62a65ae7a44223.tar.gz opensbi-9ffacc8ae1ca07ed36d57f887d62a65ae7a44223.tar.bz2 opensbi-9ffacc8ae1ca07ed36d57f887d62a65ae7a44223.zip | |
lib: utils/hsm: factor out ATCSMU code into an HSM driver
Refactor ATCSMU (System Management Unit) support by moving it from a
system utility into a dedicated FDT-based HSM driver.
Key changes include:
- Moving the functions in lib/utils/sys/atcsmu.c into the new HSM driver
- Moving hart start and stop operations on AE350 platform into the new
HSM driver
- Converting the assembly-based functions in sleep.S to C code for the
readability
- Updating the ATCWDT200 driver
Signed-off-by: Ben Zong-You Xie <ben717@andestech.com>
Signed-off-by: Leo Yu-Chi Liang <ycliang@andestech.com>
Link: https://lore.kernel.org/r/20251229071914.1451587-2-ben717@andestech.com
Signed-off-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'lib/utils/sys')
| -rw-r--r-- | lib/utils/sys/Kconfig | 4 | ||||
| -rw-r--r-- | lib/utils/sys/atcsmu.c | 89 | ||||
| -rw-r--r-- | lib/utils/sys/objects.mk | 1 |
3 files changed, 0 insertions, 94 deletions
diff --git a/lib/utils/sys/Kconfig b/lib/utils/sys/Kconfig index a22191cd..fc388665 100644 --- a/lib/utils/sys/Kconfig +++ b/lib/utils/sys/Kconfig @@ -2,10 +2,6 @@ menu "System Device Support" -config SYS_ATCSMU - bool "Andes System Management Unit (SMU) support" - default n - config SYS_HTIF bool "Host transfere interface (HTIF) support" default n diff --git a/lib/utils/sys/atcsmu.c b/lib/utils/sys/atcsmu.c deleted file mode 100644 index 2cba0eb7..00000000 --- a/lib/utils/sys/atcsmu.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2023 Andes Technology Corporation - * - * Authors: - * Yu Chien Peter Lin <peterlin@andestech.com> - */ - -#include <sbi_utils/sys/atcsmu.h> -#include <sbi/riscv_io.h> -#include <sbi/sbi_console.h> -#include <sbi/sbi_error.h> -#include <sbi/sbi_bitops.h> - -inline int smu_set_wakeup_events(struct smu_data *smu, u32 events, u32 hartid) -{ - if (smu) { - writel(events, (void *)(smu->addr + PCSm_WE_OFFSET(hartid))); - return 0; - } else - return SBI_EINVAL; -} - -inline bool smu_support_sleep_mode(struct smu_data *smu, u32 sleep_mode, - u32 hartid) -{ - u32 pcs_cfg; - - if (!smu) { - sbi_printf("%s(): Failed to access smu_data\n", __func__); - return false; - } - - pcs_cfg = readl((void *)(smu->addr + PCSm_CFG_OFFSET(hartid))); - - switch (sleep_mode) { - case LIGHTSLEEP_MODE: - if (EXTRACT_FIELD(pcs_cfg, PCS_CFG_LIGHT_SLEEP) == 0) { - sbi_printf("SMU: hart%d (PCS%d) does not support light sleep mode\n", - hartid, hartid + 3); - return false; - } - break; - case DEEPSLEEP_MODE: - if (EXTRACT_FIELD(pcs_cfg, PCS_CFG_DEEP_SLEEP) == 0) { - sbi_printf("SMU: hart%d (PCS%d) does not support deep sleep mode\n", - hartid, hartid + 3); - return false; - } - break; - } - - return true; -} - -inline int smu_set_command(struct smu_data *smu, u32 pcs_ctl, u32 hartid) -{ - if (smu) { - writel(pcs_ctl, (void *)(smu->addr + PCSm_CTL_OFFSET(hartid))); - return 0; - } else - return SBI_EINVAL; -} - -inline int smu_set_reset_vector(struct smu_data *smu, ulong wakeup_addr, - u32 hartid) -{ - u32 vec_lo, vec_hi; - u64 reset_vector; - - if (!smu) - return SBI_EINVAL; - - writel(wakeup_addr, (void *)(smu->addr + HARTn_RESET_VEC_LO(hartid))); - writel((u64)wakeup_addr >> 32, - (void *)(smu->addr + HARTn_RESET_VEC_HI(hartid))); - - vec_lo = readl((void *)(smu->addr + HARTn_RESET_VEC_LO(hartid))); - vec_hi = readl((void *)(smu->addr + HARTn_RESET_VEC_HI(hartid))); - reset_vector = ((u64)vec_hi << 32) | vec_lo; - - if (reset_vector != (u64)wakeup_addr) { - sbi_printf("hart%d (PCS%d): Failed to program the reset vector.\n", - hartid, hartid + 3); - return SBI_EFAIL; - } else - return 0; -} diff --git a/lib/utils/sys/objects.mk b/lib/utils/sys/objects.mk index 409d7e8c..d9c67077 100644 --- a/lib/utils/sys/objects.mk +++ b/lib/utils/sys/objects.mk @@ -8,4 +8,3 @@ # libsbiutils-objs-$(CONFIG_SYS_HTIF) += sys/htif.o -libsbiutils-objs-$(CONFIG_SYS_ATCSMU) += sys/atcsmu.o |
