Skip to content

Commit

Permalink
chickens: Initial T6030 Everest/Sawtooth support
Browse files Browse the repository at this point in the history
Signed-off-by: a-ramses <[email protected]>
  • Loading branch information
a-ramses committed Dec 13, 2024
1 parent e25b58a commit a412466
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/chickens.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#define MIDR_PART_T6020_AVALANCHE 0x35
#define MIDR_PART_T6021_BLIZZARD 0x38
#define MIDR_PART_T6021_AVALANCHE 0x39
#define MIDR_PART_T6030_SAWTOOTH 0x44
#define MIDR_PART_T6030_EVEREST 0x45
#define MIDR_PART_T6031_EVEREST 0x49
#define MIDR_PART_T6031_SAWTOOTH 0x48

Expand Down Expand Up @@ -66,6 +68,8 @@ void init_t6020_blizzard(void);
void init_t6020_avalanche(int rev);
void init_t6021_blizzard(void);
void init_t6021_avalanche(int rev);
void init_t6030_sawtooth(void);
void init_t6030_everest(int rev);
void init_t6031_sawtooth(void);
void init_t6031_everest(int rev);

Expand Down Expand Up @@ -204,6 +208,16 @@ const char *init_cpu(void)
init_t6021_blizzard();
break;

case MIDR_PART_T6030_EVEREST:
cpu = "M3 Pro Everest";
init_t6030_everest(rev);
break;

case MIDR_PART_T6030_SAWTOOTH:
cpu = "M3 Pro Sawtooth";
init_t6030_sawtooth();
break;

case MIDR_PART_T6031_EVEREST:
cpu = "M3 Max Everest";
init_t6031_everest(rev);
Expand Down
43 changes: 43 additions & 0 deletions src/chickens_everest.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,49 @@ static void init_common_everest(void)
reg_clr(s3_0_c15_c2_4, BIT(0) | BIT(1) | BIT(16) | BIT(17) | BIT(18) | BIT(22));
}

void init_t6030_everest(int rev)
{
UNUSED(rev);
msr(s3_1_c15_c1_5, 0x1uL);
if (in_el2())
msr(s3_4_c15_c14_6, 0x3uL);

reg_set(SYS_IMP_APL_HID16, BIT(54));
reg_set(SYS_IMP_APL_HID3, HID3_DEV_PCIE_THROTTLE_ENABLE);
reg_mask(SYS_IMP_APL_HID3, HID3_DEV_PCIE_THROTTLE_LIMIT_MASK, HID3_DEV_PCIE_THROTTLE_LIMIT(60));
reg_clr(SYS_IMP_APL_HID3, BIT(4));
reg_set(SYS_IMP_APL_HID9, BIT(17));
reg_mask(SYS_IMP_APL_HID13,
HID13_POST_OFF_CYCLES_MASK | HID13_POST_ON_CYCLES_MASK |
HID13_PRE_CYCLES_MASK | HID13_GROUP0_FF0_DELAY_MASK |
HID13_GROUP0_FF1_DELAY_MASK | HID13_GROUP0_FF2_DELAY_MASK |
HID13_GROUP0_FF3_DELAY_MASK | HID13_GROUP0_FF4_DELAY_MASK |
HID13_GROUP0_FF5_DELAY_MASK | HID13_GROUP0_FF6_DELAY_MASK |
HID13_GROUP0_FF7_DELAY_MASK | HID13_RESET_CYCLES_MASK,
HID13_POST_OFF_CYCLES(4) | HID13_POST_ON_CYCLES(5) | HID13_PRE_CYCLES(1) | HID13_GROUP0_FF0_DELAY(0) |
HID13_GROUP0_FF1_DELAY(4) | HID13_GROUP0_FF2_DELAY(4) | HID13_GROUP0_FF3_DELAY(4) |
HID13_GROUP0_FF4_DELAY(4) | HID13_GROUP0_FF5_DELAY(4) | HID13_GROUP0_FF6_DELAY(4) |
HID13_GROUP0_FF7_DELAY(4) | HID13_RESET_CYCLES(0));

msr(SYS_IMP_APL_HID26,
HID26_GROUP1_OFFSET(0x16 | (0x2 << 8) | (0x2 << 12) | (0x2 << 16) | (0x2 << 20) | (0x2 << 24) | (0x2 << 28) | (0x2uL << 32)) |
HID26_GROUP2_OFFSET(0x23 | (0x1 << 8) | (0x1 << 12) | (0x1 << 16) | (0x1 << 20) | (0x1 << 24)));

reg_mask(SYS_IMP_APL_HID27,
GENMASK(43, 40) | GENMASK(39, 36) | GENMASK(35, 32) | GENMASK(31, 28) |
GENMASK(27, 24) | GENMASK(23, 20) | GENMASK(19, 16) | GENMASK(15, 8) |
GENMASK(7, 4) | GENMASK(3, 0),
BIT(40) | BIT(36) | BIT(32) | BIT(28) | BIT(24) | BIT(20) | BIT(16) | 0x2b00uL |
BIT(4) | BIT(0));

reg_set(SYS_IMP_APL_HID18, BIT(61) | HID18_GENTER_SPECULATION_DISABLE | HID18_GEXIT_EL_SPECULATION_DISABLE);

reg_set(s3_0_c15_c2_3, BIT(3));
reg_clr(s3_0_c15_c2_4, BIT(0) | BIT(1) | BIT(16) | BIT(17) | BIT(18) | BIT(22));

reg_set(SYS_IMP_APL_HID4, HID4_ENABLE_LFSR_STALL_LOAD_PIPE2_ISSUE);
}

void init_t6031_everest(int rev)
{
UNUSED(rev);
Expand Down
13 changes: 13 additions & 0 deletions src/chickens_sawtooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ static void init_common_sawtooth(void)
reg_set(SYS_IMP_APL_EHID0, EHID0_BLI_UNK32);
}

void init_t6030_sawtooth(void)
{
// disable CNTFREQ scaling 1GHz
msr(s3_1_c15_c1_5, 0x3uL);
init_common_sawtooth();
reg_mask(SYS_IMP_APL_EHID9, EHID9_DEV_2_THROTTLE_LIMIT_MASK, EHID9_DEV_2_THROTTLE_LIMIT(62));
reg_set(SYS_IMP_APL_EHID9, EHID9_DEV_2_THROTTLE_ENABLE);

reg_set(SYS_IMP_APL_EHID18, EHID18_BLZ_UNK34);

reg_mask(SYS_IMP_APL_HID5, HID5_BLZ_UNK_19_18_MASK, HID5_BLZ_UNK19);
}

void init_t6031_sawtooth(void)
{
init_common_sawtooth();
Expand Down
2 changes: 2 additions & 0 deletions src/cpu_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@
#define HID13_POST_ON_CYCLES_MASK GENMASK(13, 7)
#define HID13_PRE_CYCLES(x) ((ULONG(x)) << 14)
#define HID13_PRE_CYCLES_MASK GENMASK(17, 14)
#define HID13_GROUP0_FF0_DELAY(x) ((ULONG(x)) << 18)
#define HID13_GROUP0_FF0_DELAY_MASK GENMASK(25, 18)
#define HID13_GROUP0_FF1_DELAY(x) ((ULONG(x)) << 26)
#define HID13_GROUP0_FF1_DELAY_MASK GENMASK(29, 26)
#define HID13_GROUP0_FF2_DELAY(x) ((ULONG(x)) << 30)
Expand Down
3 changes: 3 additions & 0 deletions src/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define T6020 0x6020
#define T6021 0x6021
#define T6022 0x6022
#define T6030 0x6030
#define T6031 0x6031
#define T6034 0x6034

Expand All @@ -41,6 +42,8 @@
#define EARLY_UART_BASE 0x391200000
#elif TARGET == T8015
#define EARLY_UART_BASE 0x22e600000
#elif TARGET == T6030
#define EARLY_UART_BASE 0x289200000
#elif TARGET == T7000 || TARGET == T7001 || TARGET == S8000 || TARGET == S8001 || \
TARGET == S8003 || TARGET == T8010 || TARGET == T8011
#if TARGET == T7000 && defined(TARGET_BOARD) && TARGET_BOARD == 0x34 // Apple TV HD
Expand Down

0 comments on commit a412466

Please sign in to comment.