mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-28 17:30:18 +00:00
tunables_static: New module to set up static tunables
This is for things that xnu hard-codes. This first one for AGX is required to make coprocessor TLB coherency work properly... Signed-off-by: Asahi Lina <lina@asahilina.net>
This commit is contained in:
parent
a15eb0919d
commit
fe0d3e8e34
4 changed files with 72 additions and 1 deletions
2
Makefile
2
Makefile
|
@ -116,7 +116,7 @@ OBJECTS := \
|
||||||
start.o \
|
start.o \
|
||||||
startup.o \
|
startup.o \
|
||||||
string.o \
|
string.o \
|
||||||
tunables.o \
|
tunables.o tunables_static.o \
|
||||||
tps6598x.o \
|
tps6598x.o \
|
||||||
uart.o \
|
uart.o \
|
||||||
uartproxy.o \
|
uartproxy.o \
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "pcie.h"
|
#include "pcie.h"
|
||||||
#include "sep.h"
|
#include "sep.h"
|
||||||
#include "smp.h"
|
#include "smp.h"
|
||||||
|
#include "tunables.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
@ -1149,6 +1150,7 @@ int kboot_boot(void *kernel)
|
||||||
usb_init();
|
usb_init();
|
||||||
pcie_init();
|
pcie_init();
|
||||||
dapf_init_all();
|
dapf_init_all();
|
||||||
|
tunables_apply_static();
|
||||||
|
|
||||||
printf("Setting SMP mode to WFE...\n");
|
printf("Setting SMP mode to WFE...\n");
|
||||||
smp_set_wfe_mode(true);
|
smp_set_wfe_mode(true);
|
||||||
|
|
|
@ -37,4 +37,6 @@ int tunables_apply_local(const char *path, const char *prop, u32 reg_idx);
|
||||||
*/
|
*/
|
||||||
int tunables_apply_local_addr(const char *path, const char *prop, uintptr_t base);
|
int tunables_apply_local_addr(const char *path, const char *prop, uintptr_t base);
|
||||||
|
|
||||||
|
int tunables_apply_static(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
67
src/tunables_static.c
Normal file
67
src/tunables_static.c
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
/* SPDX-License-Identifier: MIT */
|
||||||
|
|
||||||
|
#include "tunables.h"
|
||||||
|
#include "adt.h"
|
||||||
|
#include "pmgr.h"
|
||||||
|
#include "soc.h"
|
||||||
|
#include "types.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These magic tunable sequences are hardcoded in various places in XNU, and are required for
|
||||||
|
* proper operation of various fabric features and other miscellanea. Without them, things tend
|
||||||
|
* to subtly break...
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct entry {
|
||||||
|
u32 offset;
|
||||||
|
u32 clear;
|
||||||
|
u32 set;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct entry t8103_agx_tunables[] = {
|
||||||
|
{0x30, 0xffffffff, 0x50014}, {0x34, 0xffffffff, 0xa003c},
|
||||||
|
{0x400, 0x400103ff, 0x40010001}, {0x600, 0x1ffffff, 0x1ffffff},
|
||||||
|
{0x738, 0x1ff01ff, 0x140034}, {0x798, 0x1ff01ff, 0x14003c},
|
||||||
|
{0x800, 0x100, 0x100}, {-1, 0, 0},
|
||||||
|
};
|
||||||
|
|
||||||
|
static void tunables_apply(u64 base, struct entry *entry)
|
||||||
|
{
|
||||||
|
while (entry->offset != UINT32_MAX) {
|
||||||
|
mask32(base + entry->offset, entry->clear, entry->set);
|
||||||
|
entry++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int power_and_apply(const char *path, u64 base, struct entry *entries)
|
||||||
|
{
|
||||||
|
if (pmgr_adt_power_enable(path) < 0) {
|
||||||
|
printf("tunables: Failed to enable power: %s\n", path);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tunables_apply(base, entries);
|
||||||
|
|
||||||
|
if (pmgr_adt_power_disable(path) < 0) {
|
||||||
|
printf("tunables: Failed to disable power: %s\n", path);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tunables_apply_static(void)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
switch (chip_id) {
|
||||||
|
case T8103:
|
||||||
|
ret |= power_and_apply("/arm-io/sgx", 0x205000000, t8103_agx_tunables);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret ? -1 : 0;
|
||||||
|
}
|
Loading…
Reference in a new issue