feat: add support for SP805 Trusted watchdog module helper APIs

We leverage this module to generate secure interrupts which we
plan to use for exercising secure interrupt handling support in
SPM(Hafnium) in co-ordination with Cactus SP

Correspondingly, a device region node is added to the Cactus primary
SP manifest which captures the base address as well as other related
properties such as interrupts.

Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
Change-Id: I410fdf926a23bd438e9899320f43a77e3697bc91
diff --git a/drivers/arm/sp805/sp805.c b/drivers/arm/sp805/sp805.c
index 6893ebb..85da43a 100644
--- a/drivers/arm/sp805/sp805.c
+++ b/drivers/arm/sp805/sp805.c
@@ -166,3 +166,18 @@
 {
 	sp805_wdog_refresh_(SP805_WDOG_BASE);
 }
+
+void sp805_twdog_start(uint32_t wdog_cycles)
+{
+	sp805_wdog_start_(SP805_TWDOG_BASE, wdog_cycles);
+}
+
+void sp805_twdog_stop(void)
+{
+	sp805_wdog_stop_(SP805_TWDOG_BASE);
+}
+
+void sp805_twdog_refresh(void)
+{
+	sp805_wdog_refresh_(SP805_TWDOG_BASE);
+}
diff --git a/include/drivers/arm/sp805.h b/include/drivers/arm/sp805.h
index c033ccf..75bcc12 100644
--- a/include/drivers/arm/sp805.h
+++ b/include/drivers/arm/sp805.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -47,9 +47,17 @@
 #define SP805_WDOG_PCELL_ID_SHIFT	0
 #define SP805_WDOG_PCELL_ID_MASK	0xff
 
+#define ARM_SP805_TWDG_CLK_HZ	32768
+
+/* Public APIs for non-trusted watchdog module. */
 void sp805_wdog_start(unsigned int wdog_cycles);
 void sp805_wdog_stop(void);
 void sp805_wdog_refresh(void);
 
+/* Public APIs for trusted watchdog module. */
+void sp805_twdog_start(unsigned int wdog_cycles);
+void sp805_twdog_stop(void);
+void sp805_twdog_refresh(void);
+
 #endif /* __SP805_H__ */
 
diff --git a/plat/arm/fvp/include/platform_def.h b/plat/arm/fvp/include/platform_def.h
index 3afc9b8..7fc147d 100644
--- a/plat/arm/fvp/include/platform_def.h
+++ b/plat/arm/fvp/include/platform_def.h
@@ -37,6 +37,10 @@
 /* Base address of non-trusted watchdog (SP805) */
 #define SP805_WDOG_BASE			0x1C0F0000
 
+/* Base address of trusted watchdog (SP805) */
+#define SP805_TWDOG_BASE		0x2A490000
+#define IRQ_TWDOG_INTID			56
+
 /*******************************************************************************
  * Base address and size of external NVM flash
  ******************************************************************************/
diff --git a/plat/arm/juno/include/platform_def.h b/plat/arm/juno/include/platform_def.h
index 0f9bb77..2de11fd 100644
--- a/plat/arm/juno/include/platform_def.h
+++ b/plat/arm/juno/include/platform_def.h
@@ -42,6 +42,10 @@
 /* Base address of non-trusted watchdog (SP805) */
 #define SP805_WDOG_BASE			0x1C0F0000
 
+/* Base address of trusted watchdog (SP805) */
+#define SP805_TWDOG_BASE		0x2A4A0000
+#define IRQ_TWDOG_INTID			86
+
 /* Memory mapped Generic timer interfaces  */
 #define SYS_CNT_BASE1		0x2a830000
 
diff --git a/spm/cactus/cactus.mk b/spm/cactus/cactus.mk
index 6252d2d..4109579 100644
--- a/spm/cactus/cactus.mk
+++ b/spm/cactus/cactus.mk
@@ -62,6 +62,7 @@
 	tftf/framework/${ARCH}/exception_report.c
 
 CACTUS_SOURCES	+= 	drivers/arm/pl011/${ARCH}/pl011_console.S	\
+			drivers/arm/sp805/sp805.c			\
 			lib/${ARCH}/cache_helpers.S			\
 			lib/${ARCH}/misc_helpers.S			\
 			lib/smc/${ARCH}/asm_smc.S			\
diff --git a/spm/cactus/plat/arm/fvp/fdts/cactus.dts b/spm/cactus/plat/arm/fvp/fdts/cactus.dts
index 298ca19..89c0d04 100644
--- a/spm/cactus/plat/arm/fvp/fdts/cactus.dts
+++ b/spm/cactus/plat/arm/fvp/fdts/cactus.dts
@@ -113,5 +113,13 @@
 			smmu-id = <0>;
 			stream-ids = <0x0 0x1>;
 		};
+
+		sec_wdog {
+			/* SP805 Trusted Watchdog Module */
+			base-address = <0x00000000 0x2a490000>;
+			pages-count = <32>; /* Two 64KB pages */
+			attributes = <0x3>; /* read-write */
+			interrupts = <56 0x900>;
+		};
 	};
 };