From f7cbed0256414042680aa7a6c9dedffa8baaafc7 Mon Sep 17 00:00:00 2001 From: Janne Rosberg Date: Fri, 28 May 2021 14:32:23 +0300 Subject: [PATCH] risc-v/mpfs: enable up_systemreset() --- arch/risc-v/Kconfig | 1 + arch/risc-v/src/mpfs/Make.defs | 2 +- arch/risc-v/src/mpfs/mpfs_memorymap.h | 2 +- arch/risc-v/src/mpfs/mpfs_systemreset.c | 56 +++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 arch/risc-v/src/mpfs/mpfs_systemreset.c diff --git a/arch/risc-v/Kconfig b/arch/risc-v/Kconfig index 8adee3a09e..645d4014e1 100644 --- a/arch/risc-v/Kconfig +++ b/arch/risc-v/Kconfig @@ -64,6 +64,7 @@ config ARCH_CHIP_MPFS bool "MicroChip Polarfire (MPFS)" select ARCH_RV64GC select ARCH_HAVE_MPU + select ARCH_HAVE_RESET ---help--- MicroChip Polarfire processor (RISC-V 64bit core with GCVX extensions). diff --git a/arch/risc-v/src/mpfs/Make.defs b/arch/risc-v/src/mpfs/Make.defs index ec15c7482b..c2bfc098ea 100755 --- a/arch/risc-v/src/mpfs/Make.defs +++ b/arch/risc-v/src/mpfs/Make.defs @@ -52,7 +52,7 @@ CHIP_CSRCS = mpfs_allocateheap.c mpfs_clockconfig.c CHIP_CSRCS += mpfs_idle.c mpfs_irq.c mpfs_irq_dispatch.c CHIP_CSRCS += mpfs_lowputc.c mpfs_serial.c CHIP_CSRCS += mpfs_start.c mpfs_timerisr.c -CHIP_CSRCS += mpfs_gpio.c +CHIP_CSRCS += mpfs_gpio.c mpfs_systemreset.c ifeq ($(CONFIG_BUILD_PROTECTED),y) CMN_CSRCS += riscv_task_start.c riscv_pthread_start.c diff --git a/arch/risc-v/src/mpfs/mpfs_memorymap.h b/arch/risc-v/src/mpfs/mpfs_memorymap.h index 68620c06f2..df7e28ee53 100755 --- a/arch/risc-v/src/mpfs/mpfs_memorymap.h +++ b/arch/risc-v/src/mpfs/mpfs_memorymap.h @@ -28,7 +28,7 @@ #include "hardware/mpfs_clint.h" #include "hardware/mpfs_memorymap.h" #include "hardware/mpfs_plic.h" -#include "hardware/mpfs_sysctl.h" +#include "hardware/mpfs_sysreg.h" #include "hardware/mpfs_uart.h" /**************************************************************************** diff --git a/arch/risc-v/src/mpfs/mpfs_systemreset.c b/arch/risc-v/src/mpfs/mpfs_systemreset.c new file mode 100644 index 0000000000..6ad6aff024 --- /dev/null +++ b/arch/risc-v/src/mpfs/mpfs_systemreset.c @@ -0,0 +1,56 @@ +/**************************************************************************** + * arch/risc-v/src/mpfs/mpfs_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 + +#include + +#include +#include + +#include +#include "hardware/mpfs_memorymap.h" +#include "hardware/mpfs_sysreg.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_systemreset + * + * Description: + * Internal reset logic. + * + ****************************************************************************/ + +void up_systemreset(void) +{ + putreg32(0xdead, MPFS_SYSREG_BASE + MPFS_SYSREG_MSS_RESET_CR_OFFSET); + + /* Wait for the reset */ + + for (; ; ); +} +