plat/arm: introduce wrapper functions to setup secure watchdog
authorAditya Angadi <aditya.angadi@arm.com>
Tue, 16 Apr 2019 05:59:14 +0000 (11:29 +0530)
committerAditya Angadi <aditya.angadi@arm.com>
Wed, 17 Apr 2019 13:12:48 +0000 (18:42 +0530)
The BL1 stage setup code for ARM platforms sets up the SP805 watchdog
controller as the secure watchdog. But not all ARM platforms use SP805
as the secure watchdog controller.

So introduce two new ARM platform code specific wrapper functions to
start and stop the secure watchdog. These functions then replace the
calls to SP805 driver in common BL1 setup code. All the ARM platforms
implement these wrapper functions by either calling into SP805 driver
or the SBSA watchdog driver.

Change-Id: I1a9a11b124cf3fac2a84f22ca40acd440a441257
Signed-off-by: Aditya Angadi <aditya.angadi@arm.com>
16 files changed:
include/plat/arm/common/plat_arm.h
plat/arm/board/fvp/fvp_bl1_setup.c
plat/arm/board/fvp/platform.mk
plat/arm/board/fvp_ve/fvp_ve_bl1_setup.c
plat/arm/board/juno/juno_bl1_setup.c
plat/arm/board/juno/platform.mk
plat/arm/board/n1sdp/include/platform_def.h
plat/arm/board/n1sdp/n1sdp_plat.c
plat/arm/board/n1sdp/platform.mk
plat/arm/common/arm_bl1_setup.c
plat/arm/common/arm_common.mk
plat/arm/css/sgi/include/sgi_base_platform_def.h
plat/arm/css/sgi/sgi-common.mk
plat/arm/css/sgi/sgi_plat.c
plat/arm/css/sgm/sgm-common.mk
plat/arm/css/sgm/sgm_bl1_setup.c

index 527375f6a438ed82e6ee84513c51bb3845b477d7..97e67225285123b31248bb983179fc4c23cf8ead 100644 (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 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 */
index 75090e87cb5040ab2c90bdd6cb1535063bc14d49..aa567166a1cf239fff424340dc177adfed300bff 100644 (file)
@@ -5,9 +5,10 @@
  */
 
 #include <common/tbbr/tbbr_img_def.h>
+#include <drivers/arm/sp805.h>
 #include <plat/arm/common/plat_arm.h>
+#include <plat/arm/common/arm_def.h>
 #include <plat/common/platform.h>
-
 #include "fvp_private.h"
 
 /*******************************************************************************
@@ -30,3 +31,13 @@ void bl1_early_platform_setup(void)
         */
        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);
+}
index 1a63e874c9d1ecd3559e9ee13e10e2bdd600abd7..c11d848ea011b16f48411435eb74e5dde0a2b350 100644 (file)
@@ -112,7 +112,8 @@ else
 FVP_CPU_LIBS           +=      lib/cpus/aarch32/cortex_a32.S
 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/${ARCH}/semihosting_call.S      \
                                plat/arm/board/fvp/${ARCH}/fvp_helpers.S        \
index 47cd87627cce08f555ea1762cc2442fc636d18df..4338f6f2a0a3826c24ab4319f7f98dac93b70089 100644 (file)
@@ -4,8 +4,10 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
+#include <drivers/arm/sp805.h>
 #include <plat/arm/common/plat_arm.h>
 #include <plat/common/platform.h>
+#include <platform_def.h>
 
 /*******************************************************************************
  * Perform any BL1 specific platform actions.
@@ -14,3 +16,13 @@ void bl1_early_platform_setup(void)
 {
        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);
+}
index 33f5c47912eb20566b01cbc45d1e930188f7c863..7a3d22dedc827b67bf0bbd484bf27c8b4f6b2ce4 100644 (file)
@@ -12,6 +12,7 @@
 #include <drivers/arm/css/sds.h>
 #include <drivers/arm/sp805.h>
 #include <plat/arm/common/plat_arm.h>
+#include <plat/arm/common/arm_def.h>
 #include <plat/common/platform.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();
 }
 #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);
+}
index e44791b49831fc91e332e5d2a9f382b2a7a4ba20..40e62644b078548ffb83ffe621fdcac50f6ab22c 100644 (file)
@@ -62,6 +62,7 @@ BL1_SOURCES           +=      lib/cpus/aarch64/cortex_a53.S           \
                                lib/cpus/aarch64/cortex_a72.S           \
                                plat/arm/board/juno/juno_err.c          \
                                plat/arm/board/juno/juno_bl1_setup.c    \
+                               drivers/arm/sp805/sp805.c               \
                                ${JUNO_INTERCONNECT_SOURCES}            \
                                ${JUNO_SECURITY_SOURCES}
 
index 03bd3803aeda16d2a3b575b48a2712d50a7c98a0..adb957e5dd548b851d3aa09549deebd2e85e5085 100644 (file)
@@ -87,4 +87,8 @@
 /* Platform ID address */
 #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 */
index 6905896c8e4540de7f8d220b14db53b058a1f56b..f36f9e2532139e187b546d799678c3efdf3dd62c 100644 (file)
@@ -10,6 +10,7 @@
 #include <common/debug.h>
 #include <plat/arm/common/plat_arm.h>
 #include <plat/common/platform.h>
+#include <drivers/arm/sbsa.h>
 
 /*
  * Table of regions to map using the MMU.
@@ -22,3 +23,12 @@ const mmap_region_t plat_arm_mmap[] = {
        {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);
+}
index 653d081062a43ee8f567a8cfc132c6d6ae4b3789..d0c34c8fc291aca477f5b228760382f29d783003 100644 (file)
@@ -25,6 +25,7 @@ N1SDP_GIC_SOURCES     :=      drivers/arm/gic/common/gic_common.c     \
 PLAT_BL_COMMON_SOURCES :=      ${N1SDP_BASE}/n1sdp_plat.c              \
                                ${N1SDP_BASE}/aarch64/n1sdp_helper.S
 
+BL1_SOURCES            +=      drivers/arm/sbsa/sbsa.c
 
 BL31_SOURCES           :=      ${N1SDP_CPU_SOURCES}                    \
                                ${INTERCONNECT_SOURCES}                 \
index 1e9edefd50f5da8aff7c45b1e90259591e06d90c..8e0c046f9ad3472b98dbc2dd55fe8482ad5ef958 100644 (file)
@@ -11,7 +11,6 @@
 #include <arch.h>
 #include <bl1/bl1.h>
 #include <common/bl_common.h>
-#include <drivers/arm/sp805.h>
 #include <lib/utils.h>
 #include <lib/xlat_tables/xlat_tables_compat.h>
 #include <plat/arm/common/plat_arm.h>
@@ -67,7 +66,7 @@ void arm_bl1_early_platform_setup(void)
 
 #if !ARM_DISABLE_TRUSTED_WDOG
        /* Enable watchdog */
-       sp805_start(ARM_SP805_TWDG_BASE, ARM_TWDG_LOAD_VAL);
+       plat_arm_secure_wdt_start();
 #endif
 
        /* 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
        /* Disable watchdog before leaving BL1 */
-       sp805_stop(ARM_SP805_TWDG_BASE);
+       plat_arm_secure_wdt_stop();
 #endif
 
 #ifdef EL3_PAYLOAD_BASE
index 5e890ed176ee9cdf16e35a43d54754cc0b6700b0..c3d9e030c19b4d36702d3457dcd3bc5aa8d23a5d 100644 (file)
@@ -158,8 +158,7 @@ include lib/xlat_tables_v2/xlat_tables.mk
 PLAT_BL_COMMON_SOURCES +=      ${XLAT_TABLES_LIB_SRCS}
 endif
 
-BL1_SOURCES            +=      drivers/arm/sp805/sp805.c                       \
-                               drivers/io/io_fip.c                             \
+BL1_SOURCES            +=      drivers/io/io_fip.c                             \
                                drivers/io/io_memmap.c                          \
                                drivers/io/io_storage.c                         \
                                plat/arm/common/arm_bl1_setup.c                 \
index c0e655586137f674b42c2412ff1be796d45e9fb3..032a1f473f82f0aaa1ff4b3ae68ce31e2c900a1a 100644 (file)
 #define PLAT_ARM_MEM_PROT_ADDR         (V2M_FLASH0_BASE + \
                                         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 */
index 613d3d5fa32915210c93ccaee70d91691c9e30f6..b736b0bb6e87f5f099ee65b44cdff577ed631d49 100644 (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      \
                                ${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
 
index 42eff866a5f0fbc112e1394d8ba8e3ed7d1d1c5f..3e207ecc2a53ca684c3d93ebf63950f4811a6f14 100644 (file)
@@ -13,6 +13,8 @@
 #include <drivers/arm/ccn.h>
 #include <plat/arm/common/plat_arm.h>
 #include <plat/common/platform.h>
+#include <drivers/arm/sbsa.h>
+#include <sgi_base_platform_def.h>
 #include <services/secure_partition.h>
 
 #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);
 }
 #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);
+}
index 0a136e6366e836141db61b93d1e2f3b2e624d15a..34e78b2f4f968379499fbf7433837239a5b923d1 100644 (file)
@@ -31,7 +31,8 @@ SGM_GIC_SOURCES               :=      drivers/arm/gic/common/gic_common.c     \
 BL1_SOURCES            +=      $(SGM_CPU_SOURCES)                      \
                                ${INTERCONNECT_SOURCES}                 \
                                ${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}                     \
                                ${CSS_SGM_BASE}/sgm_plat_config.c
index 203651598d0ee125d6204351d3b9f22592b438df..5fd965520e4cb33c2670fe66e8d5db16c1e411eb 100644 (file)
@@ -8,7 +8,8 @@
 #include <common/debug.h>
 #include <plat/arm/common/plat_arm.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>
 
 void bl1_early_platform_setup(void)
@@ -32,3 +33,13 @@ void bl1_early_platform_setup(void)
        plat_arm_interconnect_enter_coherency();
 #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);
+}