blob: f92e4ed024ba7180697fbec77e3a03a20fbf1218 [file] [log] [blame]
David Wang805c2c72016-11-09 16:29:02 +00001/*
Dimitris Papastamos858bd612018-01-16 10:32:47 +00002 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
David Wang805c2c72016-11-09 16:29:02 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
David Wang805c2c72016-11-09 16:29:02 +00009#include <cortex_a75.h>
Dimitris Papastamos1be747f2018-02-14 10:28:36 +000010#include <cpuamu.h>
11#include <cpu_macros.S>
Dimitris Papastamosd7e2e9e2017-12-11 11:45:35 +000012
Dimitris Papastamosfcedb692017-10-16 11:40:10 +010013func cortex_a75_reset_func
Dimitris Papastamosc52ebdc2017-12-18 13:46:21 +000014#if IMAGE_BL31 && WORKAROUND_CVE_2017_5715
Dimitris Papastamos780cc952018-03-12 13:27:02 +000015 cpu_check_csv2 x0, 1f
Dimitris Papastamos570c06a2018-04-06 15:29:34 +010016 adr x0, wa_cve_2017_5715_bpiall_vbar
Dimitris Papastamosc52ebdc2017-12-18 13:46:21 +000017 msr vbar_el3, x0
Dimitris Papastamos43e05ec2018-01-02 15:53:01 +0000181:
Dimitris Papastamosc52ebdc2017-12-18 13:46:21 +000019#endif
20
Dimitris Papastamosfcedb692017-10-16 11:40:10 +010021#if ENABLE_AMU
22 /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */
23 mrs x0, actlr_el3
24 orr x0, x0, #CORTEX_A75_ACTLR_AMEN_BIT
25 msr actlr_el3, x0
26 isb
27
28 /* Make sure accesses from EL0/EL1 are not trapped to EL2 */
29 mrs x0, actlr_el2
30 orr x0, x0, #CORTEX_A75_ACTLR_AMEN_BIT
31 msr actlr_el2, x0
32 isb
33
34 /* Enable group0 counters */
35 mov x0, #CORTEX_A75_AMU_GROUP0_MASK
36 msr CPUAMCNTENSET_EL0, x0
37 isb
38
39 /* Enable group1 counters */
40 mov x0, #CORTEX_A75_AMU_GROUP1_MASK
41 msr CPUAMCNTENSET_EL0, x0
42 isb
43#endif
44 ret
45endfunc cortex_a75_reset_func
46
Dimitris Papastamos858bd612018-01-16 10:32:47 +000047func check_errata_cve_2017_5715
Dimitris Papastamos780cc952018-03-12 13:27:02 +000048 cpu_check_csv2 x0, 1f
Dimitris Papastamos858bd612018-01-16 10:32:47 +000049#if WORKAROUND_CVE_2017_5715
50 mov x0, #ERRATA_APPLIES
51#else
52 mov x0, #ERRATA_MISSING
53#endif
54 ret
551:
56 mov x0, #ERRATA_NOT_APPLIES
57 ret
58endfunc check_errata_cve_2017_5715
59
David Wang805c2c72016-11-09 16:29:02 +000060 /* ---------------------------------------------
61 * HW will do the cache maintenance while powering down
62 * ---------------------------------------------
63 */
64func cortex_a75_core_pwr_dwn
65 /* ---------------------------------------------
66 * Enable CPU power down bit in power control register
67 * ---------------------------------------------
68 */
69 mrs x0, CORTEX_A75_CPUPWRCTLR_EL1
70 orr x0, x0, #CORTEX_A75_CORE_PWRDN_EN_MASK
71 msr CORTEX_A75_CPUPWRCTLR_EL1, x0
72 isb
73 ret
74endfunc cortex_a75_core_pwr_dwn
75
Dimitris Papastamos858bd612018-01-16 10:32:47 +000076#if REPORT_ERRATA
77/*
78 * Errata printing function for Cortex A75. Must follow AAPCS.
79 */
80func cortex_a75_errata_report
81 stp x8, x30, [sp, #-16]!
82
83 bl cpu_get_rev_var
84 mov x8, x0
85
86 /*
87 * Report all errata. The revision-variant information is passed to
88 * checking functions of each errata.
89 */
90 report_errata WORKAROUND_CVE_2017_5715, cortex_a75, cve_2017_5715
91
92 ldp x8, x30, [sp], #16
93 ret
94endfunc cortex_a75_errata_report
95#endif
96
David Wang805c2c72016-11-09 16:29:02 +000097 /* ---------------------------------------------
98 * This function provides cortex_a75 specific
99 * register information for crash reporting.
100 * It needs to return with x6 pointing to
101 * a list of register names in ascii and
102 * x8 - x15 having values of registers to be
103 * reported.
104 * ---------------------------------------------
105 */
106.section .rodata.cortex_a75_regs, "aS"
107cortex_a75_regs: /* The ascii list of register names to be reported */
108 .asciz "cpuectlr_el1", ""
109
110func cortex_a75_cpu_reg_dump
111 adr x6, cortex_a75_regs
112 mrs x8, CORTEX_A75_CPUECTLR_EL1
113 ret
114endfunc cortex_a75_cpu_reg_dump
115
Dimitris Papastamos914757c2018-03-12 14:47:09 +0000116declare_cpu_ops_workaround_cve_2017_5715 cortex_a75, CORTEX_A75_MIDR, \
Dimitris Papastamosfcedb692017-10-16 11:40:10 +0100117 cortex_a75_reset_func, \
Dimitris Papastamos914757c2018-03-12 14:47:09 +0000118 check_errata_cve_2017_5715, \
David Wang805c2c72016-11-09 16:29:02 +0000119 cortex_a75_core_pwr_dwn