Add workaround for a Juno platform errata

This patch adds the recommended workaround for defect id 831273 by triggering
the event stream every 65536 cycles.

Change-Id: I62c947e64396f10af62af495e413d0af846d6628
diff --git a/include/lib/aarch64/arch.h b/include/lib/aarch64/arch.h
index 9186094..82a04c9 100644
--- a/include/lib/aarch64/arch.h
+++ b/include/lib/aarch64/arch.h
@@ -167,6 +167,10 @@
 #define EL0VTEN_BIT		(1 << 8)
 #define EL0PCTEN_BIT		(1 << 0)
 #define EL0VCTEN_BIT		(1 << 1)
+#define EVNTEN_BIT		(1 << 2)
+#define EVNTDIR_BIT		(1 << 3)
+#define EVNTI_SHIFT		4
+#define EVNTI_MASK		0xf
 
 /* CPTR_EL3 definitions */
 #define TCPAC_BIT		(1 << 31)
diff --git a/lib/aarch64/cpu_helpers.S b/lib/aarch64/cpu_helpers.S
index 8d063c4..b85e743 100644
--- a/lib/aarch64/cpu_helpers.S
+++ b/lib/aarch64/cpu_helpers.S
@@ -64,6 +64,14 @@
 	msr	s3_1_c11_c0_2, x0
 
 smp_setup_begin:
+	/* ---------------------------------------------
+	 * Enable the event stream every 65536 cycles
+	 * ---------------------------------------------
+	 */
+	mov     x0, #(0xf << EVNTI_SHIFT)
+	orr	x0, x0, #EVNTEN_BIT
+	msr     CNTKCTL_EL1, x0
+
 	mrs	x0, CPUECTLR_EL1
 	orr	x0, x0, #CPUECTLR_SMP_BIT
 	msr	CPUECTLR_EL1, x0