Merge changes from topic "aa-sbsa-watchdog" into integration

* changes:
  plat/arm: introduce wrapper functions to setup secure watchdog
  drivers/sbsa: add sbsa watchdog driver
This commit is contained in:
Antonio Niño Díaz 2019-04-23 09:24:55 +00:00 committed by TrustedFirmware Code Review
commit 7e8f52ed7d
18 changed files with 157 additions and 10 deletions

42
drivers/arm/sbsa/sbsa.c Normal file
View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2019, ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <plat/common/platform.h>
#include <drivers/arm/sbsa.h>
#include <lib/mmio.h>
#include <stdint_.h>
#include <assert.h>
void sbsa_watchdog_offset_reg_write(uintptr_t base, uint64_t value)
{
assert((value >> SBSA_WDOG_WOR_WIDTH) == 0);
mmio_write_32(base + SBSA_WDOG_WOR_LOW_OFFSET,
((uint32_t)value & UINT32_MAX));
mmio_write_32(base + SBSA_WDOG_WOR_HIGH_OFFSET, (uint32_t)(value >> 32));
}
/*
* Start the watchdog timer at base address "base" for a
* period of "ms" milliseconds.The watchdog has to be
* refreshed within this time period.
*/
void sbsa_wdog_start(uintptr_t base, uint64_t ms)
{
uint64_t counter_freq;
uint64_t offset_reg_value;
counter_freq = (uint64_t)plat_get_syscnt_freq2();
offset_reg_value = ms * counter_freq / 1000;
sbsa_watchdog_offset_reg_write(base, offset_reg_value);
mmio_write_32(base + SBSA_WDOG_WCS_OFFSET, SBSA_WDOG_WCS_EN);
}
/* Stop the watchdog */
void sbsa_wdog_stop(uintptr_t base)
{
mmio_write_32(base + SBSA_WDOG_WCS_OFFSET, (0x0));
}

View File

@ -0,0 +1,24 @@
/*
* Copyright (c) 2019, ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef SBSA_H
#define SBSA_H
#include <stdint.h>
/* Register Offsets */
#define SBSA_WDOG_WCS_OFFSET UL(0x000)
#define SBSA_WDOG_WOR_LOW_OFFSET UL(0x008)
#define SBSA_WDOG_WOR_HIGH_OFFSET UL(0x00C)
#define SBSA_WDOG_WCS_EN U(0x1)
#define SBSA_WDOG_WOR_WIDTH UL(48)
void sbsa_wdog_start(uintptr_t base, uint64_t ms);
void sbsa_wdog_stop(uintptr_t base);
#endif /* SBSA_H */

View File

@ -295,4 +295,8 @@ extern plat_psci_ops_t plat_arm_psci_pm_ops;
extern const mmap_region_t plat_arm_mmap[]; extern const mmap_region_t plat_arm_mmap[];
extern const unsigned int arm_pm_idle_states[]; extern const unsigned int arm_pm_idle_states[];
/* secure watchdog */
void plat_arm_secure_wdt_start(void);
void plat_arm_secure_wdt_stop(void);
#endif /* PLAT_ARM_H */ #endif /* PLAT_ARM_H */

View File

@ -5,9 +5,10 @@
*/ */
#include <common/tbbr/tbbr_img_def.h> #include <common/tbbr/tbbr_img_def.h>
#include <drivers/arm/sp805.h>
#include <plat/arm/common/plat_arm.h> #include <plat/arm/common/plat_arm.h>
#include <plat/arm/common/arm_def.h>
#include <plat/common/platform.h> #include <plat/common/platform.h>
#include "fvp_private.h" #include "fvp_private.h"
/******************************************************************************* /*******************************************************************************
@ -30,3 +31,13 @@ void bl1_early_platform_setup(void)
*/ */
fvp_interconnect_enable(); fvp_interconnect_enable();
} }
void plat_arm_secure_wdt_start(void)
{
sp805_start(ARM_SP805_TWDG_BASE, ARM_TWDG_LOAD_VAL);
}
void plat_arm_secure_wdt_stop(void)
{
sp805_stop(ARM_SP805_TWDG_BASE);
}

View File

@ -112,7 +112,8 @@ else
FVP_CPU_LIBS += lib/cpus/aarch32/cortex_a32.S FVP_CPU_LIBS += lib/cpus/aarch32/cortex_a32.S
endif endif
BL1_SOURCES += drivers/io/io_semihosting.c \ BL1_SOURCES += drivers/arm/sp805/sp805.c \
drivers/io/io_semihosting.c \
lib/semihosting/semihosting.c \ lib/semihosting/semihosting.c \
lib/semihosting/${ARCH}/semihosting_call.S \ lib/semihosting/${ARCH}/semihosting_call.S \
plat/arm/board/fvp/${ARCH}/fvp_helpers.S \ plat/arm/board/fvp/${ARCH}/fvp_helpers.S \

View File

@ -4,8 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
#include <drivers/arm/sp805.h>
#include <plat/arm/common/plat_arm.h> #include <plat/arm/common/plat_arm.h>
#include <plat/common/platform.h> #include <plat/common/platform.h>
#include <platform_def.h>
/******************************************************************************* /*******************************************************************************
* Perform any BL1 specific platform actions. * Perform any BL1 specific platform actions.
@ -14,3 +16,13 @@ void bl1_early_platform_setup(void)
{ {
arm_bl1_early_platform_setup(); arm_bl1_early_platform_setup();
} }
void plat_arm_secure_wdt_start(void)
{
sp805_start(ARM_SP805_TWDG_BASE, ARM_TWDG_LOAD_VAL);
}
void plat_arm_secure_wdt_stop(void)
{
sp805_stop(ARM_SP805_TWDG_BASE);
}

View File

@ -12,6 +12,7 @@
#include <drivers/arm/css/sds.h> #include <drivers/arm/css/sds.h>
#include <drivers/arm/sp805.h> #include <drivers/arm/sp805.h>
#include <plat/arm/common/plat_arm.h> #include <plat/arm/common/plat_arm.h>
#include <plat/arm/common/arm_def.h>
#include <plat/common/platform.h> #include <plat/common/platform.h>
#include <platform_def.h> #include <platform_def.h>
@ -112,3 +113,13 @@ void bl1_plat_prepare_exit(entry_point_info_t *ep_info)
juno_reset_to_aarch32_state(); juno_reset_to_aarch32_state();
} }
#endif /* JUNO_AARCH32_EL3_RUNTIME */ #endif /* JUNO_AARCH32_EL3_RUNTIME */
void plat_arm_secure_wdt_start(void)
{
sp805_start(ARM_SP805_TWDG_BASE, ARM_TWDG_LOAD_VAL);
}
void plat_arm_secure_wdt_stop(void)
{
sp805_stop(ARM_SP805_TWDG_BASE);
}

View File

@ -62,6 +62,7 @@ BL1_SOURCES += lib/cpus/aarch64/cortex_a53.S \
lib/cpus/aarch64/cortex_a72.S \ lib/cpus/aarch64/cortex_a72.S \
plat/arm/board/juno/juno_err.c \ plat/arm/board/juno/juno_err.c \
plat/arm/board/juno/juno_bl1_setup.c \ plat/arm/board/juno/juno_bl1_setup.c \
drivers/arm/sp805/sp805.c \
${JUNO_INTERCONNECT_SOURCES} \ ${JUNO_INTERCONNECT_SOURCES} \
${JUNO_SECURITY_SOURCES} ${JUNO_SECURITY_SOURCES}

View File

@ -87,4 +87,8 @@
/* Platform ID address */ /* Platform ID address */
#define SSC_VERSION (SSC_REG_BASE + SSC_VERSION_OFFSET) #define SSC_VERSION (SSC_REG_BASE + SSC_VERSION_OFFSET)
/* Secure Watchdog Constants */
#define SBSA_SECURE_WDOG_BASE UL(0x2A480000)
#define SBSA_SECURE_WDOG_TIMEOUT UL(100)
#endif /* PLATFORM_DEF_H */ #endif /* PLATFORM_DEF_H */

View File

@ -10,6 +10,7 @@
#include <common/debug.h> #include <common/debug.h>
#include <plat/arm/common/plat_arm.h> #include <plat/arm/common/plat_arm.h>
#include <plat/common/platform.h> #include <plat/common/platform.h>
#include <drivers/arm/sbsa.h>
/* /*
* Table of regions to map using the MMU. * Table of regions to map using the MMU.
@ -22,3 +23,12 @@ const mmap_region_t plat_arm_mmap[] = {
{0} {0}
}; };
void plat_arm_secure_wdt_start(void)
{
sbsa_wdog_start(SBSA_SECURE_WDOG_BASE, SBSA_SECURE_WDOG_TIMEOUT);
}
void plat_arm_secure_wdt_stop(void)
{
sbsa_wdog_stop(SBSA_SECURE_WDOG_BASE);
}

View File

@ -25,6 +25,7 @@ N1SDP_GIC_SOURCES := drivers/arm/gic/common/gic_common.c \
PLAT_BL_COMMON_SOURCES := ${N1SDP_BASE}/n1sdp_plat.c \ PLAT_BL_COMMON_SOURCES := ${N1SDP_BASE}/n1sdp_plat.c \
${N1SDP_BASE}/aarch64/n1sdp_helper.S ${N1SDP_BASE}/aarch64/n1sdp_helper.S
BL1_SOURCES += drivers/arm/sbsa/sbsa.c
BL31_SOURCES := ${N1SDP_CPU_SOURCES} \ BL31_SOURCES := ${N1SDP_CPU_SOURCES} \
${INTERCONNECT_SOURCES} \ ${INTERCONNECT_SOURCES} \

View File

@ -11,7 +11,6 @@
#include <arch.h> #include <arch.h>
#include <bl1/bl1.h> #include <bl1/bl1.h>
#include <common/bl_common.h> #include <common/bl_common.h>
#include <drivers/arm/sp805.h>
#include <lib/utils.h> #include <lib/utils.h>
#include <lib/xlat_tables/xlat_tables_compat.h> #include <lib/xlat_tables/xlat_tables_compat.h>
#include <plat/arm/common/plat_arm.h> #include <plat/arm/common/plat_arm.h>
@ -67,7 +66,7 @@ void arm_bl1_early_platform_setup(void)
#if !ARM_DISABLE_TRUSTED_WDOG #if !ARM_DISABLE_TRUSTED_WDOG
/* Enable watchdog */ /* Enable watchdog */
sp805_start(ARM_SP805_TWDG_BASE, ARM_TWDG_LOAD_VAL); plat_arm_secure_wdt_start();
#endif #endif
/* Initialize the console to provide early debug support */ /* Initialize the console to provide early debug support */
@ -172,7 +171,7 @@ void bl1_plat_prepare_exit(entry_point_info_t *ep_info)
{ {
#if !ARM_DISABLE_TRUSTED_WDOG #if !ARM_DISABLE_TRUSTED_WDOG
/* Disable watchdog before leaving BL1 */ /* Disable watchdog before leaving BL1 */
sp805_stop(ARM_SP805_TWDG_BASE); plat_arm_secure_wdt_stop();
#endif #endif
#ifdef EL3_PAYLOAD_BASE #ifdef EL3_PAYLOAD_BASE

View File

@ -158,8 +158,7 @@ include lib/xlat_tables_v2/xlat_tables.mk
PLAT_BL_COMMON_SOURCES += ${XLAT_TABLES_LIB_SRCS} PLAT_BL_COMMON_SOURCES += ${XLAT_TABLES_LIB_SRCS}
endif endif
BL1_SOURCES += drivers/arm/sp805/sp805.c \ BL1_SOURCES += drivers/io/io_fip.c \
drivers/io/io_fip.c \
drivers/io/io_memmap.c \ drivers/io/io_memmap.c \
drivers/io/io_storage.c \ drivers/io/io_storage.c \
plat/arm/common/arm_bl1_setup.c \ plat/arm/common/arm_bl1_setup.c \

View File

@ -208,5 +208,8 @@
#define PLAT_ARM_MEM_PROT_ADDR (V2M_FLASH0_BASE + \ #define PLAT_ARM_MEM_PROT_ADDR (V2M_FLASH0_BASE + \
V2M_FLASH0_SIZE - V2M_FLASH_BLOCK_SIZE) V2M_FLASH0_SIZE - V2M_FLASH_BLOCK_SIZE)
/*Secure Watchdog Constants */
#define SBSA_SECURE_WDOG_BASE UL(0x2A480000)
#define SBSA_SECURE_WDOG_TIMEOUT UL(100)
#endif /* SGI_BASE_PLATFORM_DEF_H */ #endif /* SGI_BASE_PLATFORM_DEF_H */

View File

@ -33,7 +33,8 @@ ENT_GIC_SOURCES := drivers/arm/gic/common/gic_common.c \
PLAT_BL_COMMON_SOURCES += ${CSS_ENT_BASE}/sgi_plat.c \ PLAT_BL_COMMON_SOURCES += ${CSS_ENT_BASE}/sgi_plat.c \
${CSS_ENT_BASE}/aarch64/sgi_helper.S ${CSS_ENT_BASE}/aarch64/sgi_helper.S
BL1_SOURCES += ${INTERCONNECT_SOURCES} BL1_SOURCES += ${INTERCONNECT_SOURCES} \
drivers/arm/sbsa/sbsa.c
BL2_SOURCES += ${CSS_ENT_BASE}/sgi_image_load.c BL2_SOURCES += ${CSS_ENT_BASE}/sgi_image_load.c

View File

@ -13,6 +13,8 @@
#include <drivers/arm/ccn.h> #include <drivers/arm/ccn.h>
#include <plat/arm/common/plat_arm.h> #include <plat/arm/common/plat_arm.h>
#include <plat/common/platform.h> #include <plat/common/platform.h>
#include <drivers/arm/sbsa.h>
#include <sgi_base_platform_def.h>
#include <services/secure_partition.h> #include <services/secure_partition.h>
#define SGI_MAP_FLASH0_RO MAP_REGION_FLAT(V2M_FLASH0_BASE,\ #define SGI_MAP_FLASH0_RO MAP_REGION_FLAT(V2M_FLASH0_BASE,\
@ -139,3 +141,13 @@ int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
return arm_get_mbedtls_heap(heap_addr, heap_size); return arm_get_mbedtls_heap(heap_addr, heap_size);
} }
#endif #endif
void plat_arm_secure_wdt_start(void)
{
sbsa_wdog_start(SBSA_SECURE_WDOG_BASE, SBSA_SECURE_WDOG_TIMEOUT);
}
void plat_arm_secure_wdt_stop(void)
{
sbsa_wdog_stop(SBSA_SECURE_WDOG_BASE);
}

View File

@ -31,7 +31,8 @@ SGM_GIC_SOURCES := drivers/arm/gic/common/gic_common.c \
BL1_SOURCES += $(SGM_CPU_SOURCES) \ BL1_SOURCES += $(SGM_CPU_SOURCES) \
${INTERCONNECT_SOURCES} \ ${INTERCONNECT_SOURCES} \
${CSS_SGM_BASE}/sgm_bl1_setup.c \ ${CSS_SGM_BASE}/sgm_bl1_setup.c \
${CSS_SGM_BASE}/sgm_plat_config.c ${CSS_SGM_BASE}/sgm_plat_config.c \
drivers/arm/sp805/sp805.c
BL2_SOURCES += ${SECURITY_SOURCES} \ BL2_SOURCES += ${SECURITY_SOURCES} \
${CSS_SGM_BASE}/sgm_plat_config.c ${CSS_SGM_BASE}/sgm_plat_config.c

View File

@ -8,7 +8,8 @@
#include <common/debug.h> #include <common/debug.h>
#include <plat/arm/common/plat_arm.h> #include <plat/arm/common/plat_arm.h>
#include <plat/arm/soc/common/soc_css.h> #include <plat/arm/soc/common/soc_css.h>
#include <plat/arm/common/arm_def.h>
#include <drivers/arm/sp805.h>
#include <sgm_plat_config.h> #include <sgm_plat_config.h>
void bl1_early_platform_setup(void) void bl1_early_platform_setup(void)
@ -32,3 +33,13 @@ void bl1_early_platform_setup(void)
plat_arm_interconnect_enter_coherency(); plat_arm_interconnect_enter_coherency();
#endif #endif
} }
void plat_arm_secure_wdt_start(void)
{
sp805_start(ARM_SP805_TWDG_BASE, ARM_TWDG_LOAD_VAL);
}
void plat_arm_secure_wdt_stop(void)
{
sp805_stop(ARM_SP805_TWDG_BASE);
}