1 /*
2  * Copyright 2014, General Dynamics C4 Systems
3  *
4  * SPDX-License-Identifier: GPL-2.0-only
5  */
6 
7 #include <config.h>
8 #include <api/types.h>
9 #include <arch/machine.h>
10 #include <arch/machine/hardware.h>
11 #include <util.h>
12 
13 /* Prototyped here as this is referenced from assembly */
14 void arm_errata(void);
15 
16 #ifdef CONFIG_ARM_ERRATA_773022
17 /*
18  * There is an errata for Cortex-A15 up to r0p4 where the loop buffer
19  * may deliver incorrect instructions. The work around is to disable
20  * the loop buffer. Errata is number 773022.
21  */
errata_armA15_773022(void)22 BOOT_CODE static void errata_armA15_773022(void)
23 {
24     /* Fetch the processor primary part number. */
25     uint32_t proc_id = getProcessorID();
26     uint32_t variant = (proc_id >> 20) & MASK(4);
27     uint32_t revision = proc_id & MASK(4);
28     uint32_t part = (proc_id >> 4) & MASK(12);
29 
30     /* Check that we are running A15 and a revision upto r0p4. */
31     if (part == 0xc0f && variant == 0 && revision <= 4) {
32         /* Disable loop buffer in the auxiliary control register */
33         writeAuxiliaryControlRegister(
34             readAuxiliaryControlRegister() | BIT(1));
35     }
36 }
37 #endif
38 
arm_errata(void)39 BOOT_CODE void VISIBLE arm_errata(void)
40 {
41 #ifdef CONFIG_ARM_ERRATA_773022
42     errata_armA15_773022();
43 #endif
44 }
45 
46