Manoj Kumar | 9b4e3d7 | 2020-07-09 09:56:02 +0100 | [diff] [blame] | 1 | /* |
Maksims Svecovs | 8df9b2d | 2023-04-19 16:48:05 +0100 | [diff] [blame] | 2 | * Copyright (c) 2020-2023, Arm Limited. All rights reserved. |
Manoj Kumar | 9b4e3d7 | 2020-07-09 09:56:02 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
| 9 | #include <context.h> |
| 10 | #include <cpu_macros.S> |
| 11 | #include <cpuamu.h> |
| 12 | #include <rainier.h> |
| 13 | |
| 14 | /* Hardware handled coherency */ |
| 15 | #if HW_ASSISTED_COHERENCY == 0 |
| 16 | #error "Rainier CPU must be compiled with HW_ASSISTED_COHERENCY enabled" |
| 17 | #endif |
| 18 | |
| 19 | /* 64-bit only core */ |
| 20 | #if CTX_INCLUDE_AARCH32_REGS == 1 |
| 21 | #error "Rainier CPU supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0" |
| 22 | #endif |
| 23 | |
Manoj Kumar | 9b4e3d7 | 2020-07-09 09:56:02 +0100 | [diff] [blame] | 24 | /* -------------------------------------------------- |
| 25 | * Disable speculative loads if Rainier supports |
| 26 | * SSBS. |
| 27 | * |
| 28 | * Shall clobber: x0. |
| 29 | * -------------------------------------------------- |
| 30 | */ |
| 31 | func rainier_disable_speculative_loads |
| 32 | /* Check if the PE implements SSBS */ |
| 33 | mrs x0, id_aa64pfr1_el1 |
| 34 | tst x0, #(ID_AA64PFR1_EL1_SSBS_MASK << ID_AA64PFR1_EL1_SSBS_SHIFT) |
| 35 | b.eq 1f |
| 36 | |
| 37 | /* Disable speculative loads */ |
| 38 | msr SSBS, xzr |
| 39 | |
| 40 | 1: |
| 41 | ret |
| 42 | endfunc rainier_disable_speculative_loads |
| 43 | |
Maksims Svecovs | 8df9b2d | 2023-04-19 16:48:05 +0100 | [diff] [blame] | 44 | /* Rainier R0P0 is based on Neoverse N1 R4P0. */ |
| 45 | workaround_reset_start rainier, ERRATUM(1868343), ERRATA_N1_1868343 |
| 46 | sysreg_bit_set RAINIER_CPUACTLR_EL1, RAINIER_CPUACTLR_EL1_BIT_13 |
| 47 | workaround_reset_end rainier, ERRATUM(1868343) |
Manoj Kumar | b787595 | 2022-01-05 14:33:52 +0000 | [diff] [blame] | 48 | |
Maksims Svecovs | 8df9b2d | 2023-04-19 16:48:05 +0100 | [diff] [blame] | 49 | check_erratum_ls rainier, ERRATUM(1868343), CPU_REV(0, 0) |
Manoj Kumar | 9b4e3d7 | 2020-07-09 09:56:02 +0100 | [diff] [blame] | 50 | |
Maksims Svecovs | 8df9b2d | 2023-04-19 16:48:05 +0100 | [diff] [blame] | 51 | cpu_reset_func_start rainier |
Manoj Kumar | 9b4e3d7 | 2020-07-09 09:56:02 +0100 | [diff] [blame] | 52 | bl rainier_disable_speculative_loads |
Manoj Kumar | 9b4e3d7 | 2020-07-09 09:56:02 +0100 | [diff] [blame] | 53 | /* Forces all cacheable atomic instructions to be near */ |
Maksims Svecovs | 8df9b2d | 2023-04-19 16:48:05 +0100 | [diff] [blame] | 54 | sysreg_bit_set RAINIER_CPUACTLR2_EL1, RAINIER_CPUACTLR2_EL1_BIT_2 |
Manoj Kumar | b787595 | 2022-01-05 14:33:52 +0000 | [diff] [blame] | 55 | |
Andre Przywara | 0b7f1b0 | 2023-03-21 13:53:19 +0000 | [diff] [blame] | 56 | #if ENABLE_FEAT_AMU |
Manoj Kumar | 9b4e3d7 | 2020-07-09 09:56:02 +0100 | [diff] [blame] | 57 | /* Make sure accesses from EL0/EL1 and EL2 are not trapped to EL3 */ |
Maksims Svecovs | 8df9b2d | 2023-04-19 16:48:05 +0100 | [diff] [blame] | 58 | sysreg_bit_set actlr_el3, RAINIER_ACTLR_AMEN_BIT |
Manoj Kumar | 9b4e3d7 | 2020-07-09 09:56:02 +0100 | [diff] [blame] | 59 | |
| 60 | /* Make sure accesses from EL0/EL1 are not trapped to EL2 */ |
Maksims Svecovs | 8df9b2d | 2023-04-19 16:48:05 +0100 | [diff] [blame] | 61 | sysreg_bit_set actlr_el2, RAINIER_ACTLR_AMEN_BIT |
Manoj Kumar | 9b4e3d7 | 2020-07-09 09:56:02 +0100 | [diff] [blame] | 62 | |
| 63 | /* Enable group0 counters */ |
| 64 | mov x0, #RAINIER_AMU_GROUP0_MASK |
| 65 | msr CPUAMCNTENSET_EL0, x0 |
| 66 | #endif |
Maksims Svecovs | 8df9b2d | 2023-04-19 16:48:05 +0100 | [diff] [blame] | 67 | cpu_reset_func_end rainier |
Manoj Kumar | 9b4e3d7 | 2020-07-09 09:56:02 +0100 | [diff] [blame] | 68 | |
| 69 | /* --------------------------------------------- |
| 70 | * HW will do the cache maintenance while powering down |
| 71 | * --------------------------------------------- |
| 72 | */ |
| 73 | func rainier_core_pwr_dwn |
| 74 | /* --------------------------------------------- |
| 75 | * Enable CPU power down bit in power control register |
| 76 | * --------------------------------------------- |
| 77 | */ |
Maksims Svecovs | 8df9b2d | 2023-04-19 16:48:05 +0100 | [diff] [blame] | 78 | sysreg_bit_set RAINIER_CPUPWRCTLR_EL1, RAINIER_CORE_PWRDN_EN_MASK |
Manoj Kumar | 9b4e3d7 | 2020-07-09 09:56:02 +0100 | [diff] [blame] | 79 | isb |
| 80 | ret |
| 81 | endfunc rainier_core_pwr_dwn |
| 82 | |
Maksims Svecovs | 8df9b2d | 2023-04-19 16:48:05 +0100 | [diff] [blame] | 83 | errata_report_shim rainier |
Manoj Kumar | 9b4e3d7 | 2020-07-09 09:56:02 +0100 | [diff] [blame] | 84 | |
| 85 | /* --------------------------------------------- |
| 86 | * This function provides Rainier specific |
| 87 | * register information for crash reporting. |
| 88 | * It needs to return with x6 pointing to |
| 89 | * a list of register names in ascii and |
| 90 | * x8 - x15 having values of registers to be |
| 91 | * reported. |
| 92 | * --------------------------------------------- |
| 93 | */ |
| 94 | .section .rodata.rainier_regs, "aS" |
| 95 | rainier_regs: /* The ascii list of register names to be reported */ |
| 96 | .asciz "cpuectlr_el1", "" |
| 97 | |
| 98 | func rainier_cpu_reg_dump |
| 99 | adr x6, rainier_regs |
| 100 | mrs x8, RAINIER_CPUECTLR_EL1 |
| 101 | ret |
| 102 | endfunc rainier_cpu_reg_dump |
| 103 | |
Manoj Kumar | fb4179c | 2021-01-27 16:29:03 +0000 | [diff] [blame] | 104 | declare_cpu_ops rainier, RAINIER_MIDR, \ |
Manoj Kumar | 9b4e3d7 | 2020-07-09 09:56:02 +0100 | [diff] [blame] | 105 | rainier_reset_func, \ |
Manoj Kumar | 9b4e3d7 | 2020-07-09 09:56:02 +0100 | [diff] [blame] | 106 | rainier_core_pwr_dwn |