mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-10 09:44:13 +00:00
chickens: Refactor and update M1 bits
This adds some missing fixes for M1/T8103 and reworks the code to split off common parts, and also handle per-revision bits. Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
7ff48f6201
commit
ed21a80bc3
3 changed files with 120 additions and 73 deletions
112
src/chickens.c
112
src/chickens.c
|
@ -6,20 +6,26 @@
|
|||
#include "utils.h"
|
||||
|
||||
/* Part IDs in MIDR_EL1 */
|
||||
#define MIDR_PART_M1_ICESTORM 34
|
||||
#define MIDR_PART_M1_FIRESTORM 35
|
||||
#define MIDR_PART_A14_ICESTORM 0x20
|
||||
#define MIDR_PART_A14_FIRESTORM 0x21
|
||||
#define MIDR_PART_M1_ICESTORM 0x22
|
||||
#define MIDR_PART_M1_FIRESTORM 0x23
|
||||
|
||||
void init_m1_common(void)
|
||||
#define MIDR_REV_LOW GENMASK(3, 0)
|
||||
#define MIDR_PART GENMASK(15, 4)
|
||||
#define MIDR_REV_HIGH GENMASK(23, 20)
|
||||
|
||||
void init_common(void)
|
||||
{
|
||||
int core = mrs(MPIDR_EL1) & 0xff;
|
||||
|
||||
// Unknown, related to SMP?
|
||||
msr(s3_4_c15_c5_0, core);
|
||||
msr(s3_4_c15_c1_4, 0x100);
|
||||
msr(SYS_IMP_APL_AMX_CTL_EL1, 0x100);
|
||||
sysop("isb");
|
||||
}
|
||||
|
||||
void init_m1_icestorm(void)
|
||||
void init_common_icestorm(void)
|
||||
{
|
||||
// "Sibling Merge in LLC can cause UC load to violate ARM Memory Ordering Rules."
|
||||
reg_set(SYS_IMP_APL_HID5, HID5_DISABLE_FILL_2C_MERGE);
|
||||
|
@ -32,22 +38,11 @@ void init_m1_icestorm(void)
|
|||
|
||||
// FIXME: do we actually need this?
|
||||
reg_set(SYS_IMP_APL_EHID20, EHID20_TRAP_SMC);
|
||||
|
||||
reg_set(SYS_IMP_APL_EHID20, EHID20_FORCE_NONSPEC_IF_OLDEST_REDIR_VALID_AND_OLDER |
|
||||
EHID20_FORCE_NONSPEC_IF_SPEC_FLUSH_POINTER_NE_BLK_RTR_POINTER);
|
||||
|
||||
reg_mask(SYS_IMP_APL_EHID20, EHID20_FORCE_NONSPEC_TARGETED_TIMER_SEL_MASK,
|
||||
EHID20_FORCE_NONSPEC_TARGETED_TIMER_SEL(3));
|
||||
|
||||
init_m1_common();
|
||||
}
|
||||
|
||||
void init_m1_firestorm(void)
|
||||
void init_common_firestorm(void)
|
||||
{
|
||||
// "Cross-beat Crypto(AES/PMUL) ICache fusion is not disabled for branch
|
||||
// uncondtional "recoded instruction."
|
||||
reg_set(SYS_IMP_APL_HID0,
|
||||
HID0_SAME_PG_POWER_OPTIMIZATION | HID0_FETCH_WIDTH_DISABLE | HID0_CACHE_FUSION_DISABLE);
|
||||
reg_set(SYS_IMP_APL_HID0, HID0_SAME_PG_POWER_OPTIMIZATION);
|
||||
|
||||
// FIXME: do we actually need this?
|
||||
reg_set(SYS_IMP_APL_HID1, HID1_TRAP_SMC);
|
||||
|
@ -57,6 +52,56 @@ void init_m1_firestorm(void)
|
|||
// "Post-silicon tuning of STNT widget contiguous counter threshold"
|
||||
reg_mask(SYS_IMP_APL_HID4, HID4_STNT_COUNTER_THRESHOLD_MASK, HID4_STNT_COUNTER_THRESHOLD(3));
|
||||
|
||||
// "Sibling Merge in LLC can cause UC load to violate ARM Memory Ordering Rules."
|
||||
reg_set(SYS_IMP_APL_HID5, HID5_DISABLE_FILL_2C_MERGE);
|
||||
|
||||
reg_set(SYS_IMP_APL_HID9, HID9_TSO_ALLOW_DC_ZVA_WC);
|
||||
|
||||
reg_set(SYS_IMP_APL_HID11, HID11_DISABLE_LD_NT_WIDGET);
|
||||
|
||||
// "configure dummy cycles to work around incorrect temp sensor readings on
|
||||
// NEX power gating"
|
||||
reg_mask(SYS_IMP_APL_HID13, HID13_PRE_CYCLES_MASK, HID13_PRE_CYCLES(4));
|
||||
|
||||
// Best bit names...
|
||||
// Maybe: "RF bank and Multipass conflict forward progress widget does not
|
||||
// handle 3+ cycle livelock"
|
||||
reg_set(SYS_IMP_APL_HID16, HID16_SPAREBIT0 | HID16_SPAREBIT3 | HID16_ENABLE_MPX_PICK_45 |
|
||||
HID16_ENABLE_MP_CYCLONE_7);
|
||||
}
|
||||
|
||||
void init_m1_icestorm(int rev)
|
||||
{
|
||||
UNUSED(rev);
|
||||
|
||||
init_common_icestorm();
|
||||
|
||||
reg_set(SYS_IMP_APL_EHID20, EHID20_FORCE_NONSPEC_IF_OLDEST_REDIR_VALID_AND_OLDER |
|
||||
EHID20_FORCE_NONSPEC_IF_SPEC_FLUSH_POINTER_NE_BLK_RTR_POINTER);
|
||||
|
||||
reg_mask(SYS_IMP_APL_EHID20, EHID20_FORCE_NONSPEC_TARGETED_TIMER_SEL_MASK,
|
||||
EHID20_FORCE_NONSPEC_TARGETED_TIMER_SEL(3));
|
||||
|
||||
init_common();
|
||||
}
|
||||
|
||||
void init_m1_firestorm(int rev)
|
||||
{
|
||||
if (rev < 0x10)
|
||||
printf(" Revisions <0x10 not supported!\n");
|
||||
|
||||
init_common_firestorm();
|
||||
|
||||
// "Cross-beat Crypto(AES/PMUL) ICache fusion is not disabled for branch
|
||||
// uncondtional "recoded instruction."
|
||||
reg_set(SYS_IMP_APL_HID0, HID0_FETCH_WIDTH_DISABLE | HID0_CACHE_FUSION_DISABLE);
|
||||
|
||||
if (rev == 0x11)
|
||||
reg_set(SYS_IMP_APL_HID1, HID1_ENABLE_MDSB_STALL_PIPELINE_ECO | HID1_ENABLE_BR_KILL_LIMIT);
|
||||
|
||||
reg_set(SYS_IMP_APL_HID4,
|
||||
HID4_ENABLE_LFSR_STALL_LOAD_PIPE_2_ISSUE | HID4_ENABLE_LFSR_STALL_STQ_REPLAY);
|
||||
|
||||
// "Sibling Merge in LLC can cause UC load to violate ARM Memory Ordering
|
||||
// Rules."
|
||||
reg_set(SYS_IMP_APL_HID5, HID5_DISABLE_FILL_2C_MERGE);
|
||||
|
@ -70,25 +115,16 @@ void init_m1_firestorm(void)
|
|||
HID7_FORCE_NONSPEC_TARGET_TIMER_SEL(3));
|
||||
|
||||
reg_set(SYS_IMP_APL_HID9,
|
||||
HID9_TSO_ALLOW_DC_ZVA_WC | HID9_TSO_SERIALIZE_VLD_MICROOPS | HID9_FIX_BUG_51667805);
|
||||
|
||||
reg_set(SYS_IMP_APL_HID11, HID11_DISABLE_LD_NT_WIDGET);
|
||||
|
||||
// "configure dummy cycles to work around incorrect temp sensor readings on
|
||||
// NEX power gating"
|
||||
reg_mask(SYS_IMP_APL_HID13, HID13_PRE_CYCLES_MASK, HID13_PRE_CYCLES(4));
|
||||
|
||||
// Best bit names...
|
||||
// Maybe: "RF bank and Multipass conflict forward progress widget does not
|
||||
// handle 3+ cycle livelock"
|
||||
reg_set(SYS_IMP_APL_HID16, HID16_SPAREBIT0 | HID16_SPAREBIT3 | HID16_ENABLE_MPX_PICK_45 |
|
||||
HID16_ENABLE_MP_CYCLONE_7);
|
||||
HID9_TSO_SERIALIZE_VLD_MICROOPS | HID9_FIX_BUG_51667805 | HID9_FIX_BUG_55719865);
|
||||
|
||||
reg_set(SYS_IMP_APL_HID18, HID18_HVC_SPECULATION_DISABLE);
|
||||
|
||||
if (rev >= 0x11)
|
||||
reg_set(SYS_IMP_APL_HID18, HID18_SPAREBIT17);
|
||||
|
||||
reg_clr(SYS_IMP_APL_HID21, HID21_ENABLE_LDREX_FILL_REPLY);
|
||||
|
||||
init_m1_common();
|
||||
init_common();
|
||||
}
|
||||
|
||||
const char *init_cpu(void)
|
||||
|
@ -103,21 +139,25 @@ const char *init_cpu(void)
|
|||
else
|
||||
reg_set(SYS_IMP_APL_HID4, HID4_DISABLE_DC_MVA | HID4_DISABLE_DC_SW_L2_OPS);
|
||||
|
||||
int part = (mrs(MIDR_EL1) >> 4) & 0xfff;
|
||||
uint64_t midr = mrs(MIDR_EL1);
|
||||
int part = FIELD_GET(MIDR_PART, midr);
|
||||
int rev = (FIELD_GET(MIDR_REV_HIGH, midr) << 4) | FIELD_GET(MIDR_REV_LOW, midr);
|
||||
|
||||
printf(" CPU part: 0x%x rev: 0x%x\n", part, rev);
|
||||
|
||||
switch (part) {
|
||||
case MIDR_PART_M1_FIRESTORM:
|
||||
cpu = "M1 Firestorm";
|
||||
init_m1_firestorm();
|
||||
init_m1_firestorm(rev);
|
||||
break;
|
||||
|
||||
case MIDR_PART_M1_ICESTORM:
|
||||
cpu = "M1 Icestorm";
|
||||
init_m1_icestorm();
|
||||
init_m1_icestorm(rev);
|
||||
break;
|
||||
|
||||
default:
|
||||
uart_puts("Unknown CPU type");
|
||||
uart_puts(" Unknown CPU type");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,80 +9,87 @@
|
|||
|
||||
#define SYS_IMP_APL_ACTLR_EL12 sys_reg(3, 6, 15, 14, 6)
|
||||
|
||||
#define SYS_IMP_APL_AMX_CTL_EL1 sys_reg(3, 4, 15, 1, 4)
|
||||
#define SYS_IMP_APL_AMX_CTL_EL2 sys_reg(3, 4, 15, 4, 7)
|
||||
#define AMX_CTL_EN BIT(63)
|
||||
#define AMX_CTL_EN_EL1 BIT(62)
|
||||
|
||||
/* HID registers */
|
||||
#define SYS_IMP_APL_HID0 sys_reg(3, 0, 15, 0, 0)
|
||||
#define HID0_FETCH_WIDTH_DISABLE (1UL << 28)
|
||||
#define HID0_CACHE_FUSION_DISABLE (1UL << 36)
|
||||
#define HID0_SAME_PG_POWER_OPTIMIZATION (1UL << 45)
|
||||
#define HID0_FETCH_WIDTH_DISABLE BIT(28)
|
||||
#define HID0_CACHE_FUSION_DISABLE BIT(36)
|
||||
#define HID0_SAME_PG_POWER_OPTIMIZATION BIT(45)
|
||||
|
||||
#define SYS_IMP_APL_HID1 sys_reg(3, 0, 15, 1, 0)
|
||||
#define HID1_TRAP_SMC (1UL << 54)
|
||||
#define SYS_IMP_APL_HID1 sys_reg(3, 0, 15, 1, 0)
|
||||
#define HID1_TRAP_SMC BIT(54)
|
||||
#define HID1_ENABLE_MDSB_STALL_PIPELINE_ECO BIT(58)
|
||||
#define HID1_ENABLE_BR_KILL_LIMIT BIT(60)
|
||||
|
||||
#define SYS_IMP_APL_HID3 sys_reg(3, 0, 15, 3, 0)
|
||||
#define HID3_DEV_PCIE_THROTTLE_ENABLE (1UL << 63)
|
||||
#define HID3_DISABLE_ARBITER_FIX_BIF_CRD (1UL << 44)
|
||||
#define HID3_DEV_PCIE_THROTTLE_ENABLE BIT(63)
|
||||
#define HID3_DISABLE_ARBITER_FIX_BIF_CRD BIT(44)
|
||||
|
||||
#define SYS_IMP_APL_HID4 sys_reg(3, 0, 15, 4, 0)
|
||||
#define SYS_IMP_APL_EHID4 sys_reg(3, 0, 15, 4, 1)
|
||||
#define HID4_DISABLE_DC_MVA (1UL << 11)
|
||||
#define HID4_DISABLE_DC_SW_L2_OPS (1UL << 44)
|
||||
#define HID4_STNT_COUNTER_THRESHOLD(x) (((unsigned long)x) << 40)
|
||||
#define HID4_STNT_COUNTER_THRESHOLD_MASK (3UL << 40)
|
||||
#define SYS_IMP_APL_HID4 sys_reg(3, 0, 15, 4, 0)
|
||||
#define SYS_IMP_APL_EHID4 sys_reg(3, 0, 15, 4, 1)
|
||||
#define HID4_DISABLE_DC_MVA BIT(11)
|
||||
#define HID4_DISABLE_DC_SW_L2_OPS BIT(44)
|
||||
#define HID4_STNT_COUNTER_THRESHOLD(x) (((unsigned long)x) << 40)
|
||||
#define HID4_STNT_COUNTER_THRESHOLD_MASK (3UL << 40)
|
||||
#define HID4_ENABLE_LFSR_STALL_LOAD_PIPE_2_ISSUE BIT(49)
|
||||
#define HID4_ENABLE_LFSR_STALL_STQ_REPLAY BIT(53)
|
||||
|
||||
#define SYS_IMP_APL_HID5 sys_reg(3, 0, 15, 5, 0)
|
||||
#define HID5_DISABLE_FILL_2C_MERGE (1UL << 61)
|
||||
#define HID5_DISABLE_FILL_2C_MERGE BIT(61)
|
||||
|
||||
#define SYS_IMP_APL_HID6 sys_reg(3, 0, 15, 6, 0)
|
||||
#define HID6_UP_CRD_TKN_INIT_C2(x) (((unsigned long)x) << 5)
|
||||
#define HID6_UP_CRD_TKN_INIT_C2_MASK (0x1FUL << 5)
|
||||
|
||||
#define SYS_IMP_APL_HID7 sys_reg(3, 0, 15, 7, 0)
|
||||
#define HID7_FORCE_NONSPEC_IF_SPEC_FLUSH_POINTER_INVALID_AND_MP_VALID (1UL << 16)
|
||||
#define HID7_FORCE_NONSPEC_IF_STEPPING (1UL << 20)
|
||||
#define HID7_FORCE_NONSPEC_IF_SPEC_FLUSH_POINTER_INVALID_AND_MP_VALID BIT(16)
|
||||
#define HID7_FORCE_NONSPEC_IF_STEPPING BIT(20)
|
||||
#define HID7_FORCE_NONSPEC_TARGET_TIMER_SEL(x) (((unsigned long)x) << 24)
|
||||
#define HID7_FORCE_NONSPEC_TARGET_TIMER_SEL_MASK (3UL << 24)
|
||||
|
||||
#define SYS_IMP_APL_HID9 sys_reg(3, 0, 15, 9, 0)
|
||||
#define HID9_TSO_ALLOW_DC_ZVA_WC (1UL << 26)
|
||||
#define HID9_TSO_SERIALIZE_VLD_MICROOPS (1UL << 29)
|
||||
#define HID9_FIX_BUG_51667805 (1UL << 48)
|
||||
#define HID9_TSO_ALLOW_DC_ZVA_WC BIT(26)
|
||||
#define HID9_TSO_SERIALIZE_VLD_MICROOPS BIT(29)
|
||||
#define HID9_FIX_BUG_51667805 BIT(48)
|
||||
#define HID9_FIX_BUG_55719865 BIT(55)
|
||||
|
||||
#define SYS_IMP_APL_EHID9 sys_reg(3, 0, 15, 9, 1)
|
||||
#define EHID9_DEV_THROTTLE_2_ENABLE (1UL << 5)
|
||||
#define EHID9_DEV_THROTTLE_2_ENABLE BIT(5)
|
||||
|
||||
#define SYS_IMP_APL_EHID10 sys_reg(3, 0, 15, 10, 1)
|
||||
#define HID10_FORCE_WAIT_STATE_DRAIN_UC (1UL << 32)
|
||||
#define HID10_DISABLE_ZVA_TEMPORAL_TSO (1UL << 49)
|
||||
#define HID10_FORCE_WAIT_STATE_DRAIN_UC BIT(32)
|
||||
#define HID10_DISABLE_ZVA_TEMPORAL_TSO BIT(49)
|
||||
|
||||
#define SYS_IMP_APL_HID11 sys_reg(3, 0, 15, 11, 0)
|
||||
#define HID11_DISABLE_LD_NT_WIDGET (1UL << 59)
|
||||
#define HID11_DISABLE_LD_NT_WIDGET BIT(59)
|
||||
|
||||
#define SYS_IMP_APL_HID13 sys_reg(3, 0, 15, 14, 0)
|
||||
#define HID13_PRE_CYCLES(x) (((unsigned long)x) << 14)
|
||||
#define HID13_PRE_CYCLES_MASK (0xFUL << 14)
|
||||
|
||||
#define SYS_IMP_APL_HID16 sys_reg(3, 0, 15, 15, 2)
|
||||
#define HID16_SPAREBIT0 (1UL << 56)
|
||||
#define HID16_SPAREBIT3 (1UL << 59)
|
||||
#define HID16_ENABLE_MPX_PICK_45 (1UL << 61)
|
||||
#define HID16_ENABLE_MP_CYCLONE_7 (1UL << 62)
|
||||
#define HID16_SPAREBIT0 BIT(56)
|
||||
#define HID16_SPAREBIT3 BIT(59)
|
||||
#define HID16_ENABLE_MPX_PICK_45 BIT(61)
|
||||
#define HID16_ENABLE_MP_CYCLONE_7 BIT(62)
|
||||
|
||||
#define SYS_IMP_APL_HID18 sys_reg(3, 0, 15, 11, 2)
|
||||
#define HID18_HVC_SPECULATION_DISABLE (1UL << 14)
|
||||
#define HID18_HVC_SPECULATION_DISABLE BIT(14)
|
||||
#define HID18_SPAREBIT17 BIT(49)
|
||||
|
||||
#define SYS_IMP_APL_EHID20 sys_reg(3, 0, 15, 1, 2)
|
||||
#define EHID20_TRAP_SMC (1UL << 8)
|
||||
#define EHID20_FORCE_NONSPEC_IF_OLDEST_REDIR_VALID_AND_OLDER (1UL << 15)
|
||||
#define EHID20_FORCE_NONSPEC_IF_SPEC_FLUSH_POINTER_NE_BLK_RTR_POINTER (1UL << 16)
|
||||
#define EHID20_TRAP_SMC BIT(8)
|
||||
#define EHID20_FORCE_NONSPEC_IF_OLDEST_REDIR_VALID_AND_OLDER BIT(15)
|
||||
#define EHID20_FORCE_NONSPEC_IF_SPEC_FLUSH_POINTER_NE_BLK_RTR_POINTER BIT(16)
|
||||
#define EHID20_FORCE_NONSPEC_TARGETED_TIMER_SEL(x) (((unsigned long)x) << 21)
|
||||
#define EHID20_FORCE_NONSPEC_TARGETED_TIMER_SEL_MASK (3UL << 21)
|
||||
|
||||
#define SYS_IMP_APL_HID21 sys_reg(3, 0, 15, 1, 3)
|
||||
#define HID21_ENABLE_LDREX_FILL_REPLY (1UL << 19)
|
||||
#define HID21_ENABLE_LDREX_FILL_REPLY BIT(19)
|
||||
|
||||
#define SYS_IMP_APL_PMCR0 sys_reg(3, 1, 15, 0, 0)
|
||||
#define PMCR0_CNT_EN_MASK (MASK(8) | GENMASK(33, 32))
|
||||
|
@ -122,9 +129,9 @@
|
|||
|
||||
#define SYS_IMP_APL_L2C_ERR_STS sys_reg(3, 3, 15, 8, 0)
|
||||
|
||||
#define L2C_ERR_STS_RECURSIVE_FAULT (1UL << 1)
|
||||
#define L2C_ERR_STS_ACCESS_FAULT (1UL << 7)
|
||||
#define L2C_ERR_STS_ENABLE_W1C (1UL << 56)
|
||||
#define L2C_ERR_STS_RECURSIVE_FAULT BIT(1)
|
||||
#define L2C_ERR_STS_ACCESS_FAULT BIT(7)
|
||||
#define L2C_ERR_STS_ENABLE_W1C BIT(56)
|
||||
|
||||
#define SYS_IMP_APL_L2C_ERR_ADR sys_reg(3, 3, 15, 9, 0)
|
||||
#define SYS_IMP_APL_L2C_ERR_INF sys_reg(3, 3, 15, 10, 0)
|
||||
|
|
|
@ -91,9 +91,9 @@ void _start_c(void *boot_args, void *base)
|
|||
}
|
||||
|
||||
uart_puts("Initializing");
|
||||
printf("CPU init... ");
|
||||
printf("CPU init (MIDR: 0x%lx)...\n", mrs(MIDR_EL1));
|
||||
const char *type = init_cpu();
|
||||
printf("CPU: %s\n\n", type);
|
||||
printf(" CPU: %s\n\n", type);
|
||||
|
||||
printf("boot_args at %p\n", boot_args);
|
||||
|
||||
|
|
Loading…
Reference in a new issue