Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ static u32 pstate_reg_to_pstate(u64 val)
case T8122:
case T8142:
case T8140:
case T6050:
return FIELD_GET(CLUSTER_PSTATE_DESIRED1, val);
default:
printf("cpufreq: Chip 0x%x is unsupported\n", chip_id);
Expand All @@ -80,8 +81,10 @@ static u32 pstate_reg_to_pstate(u64 val)

static int set_pstate(const struct cluster_t *cluster, uint32_t pstate)
{
if (chip_id == T8142 && poll64(cluster->base + CLUSTER_PSTATE, CLUSTER_PSTATE_BUSY, 0,
CLUSTER_SWITCH_TIMEOUT) < 0) {
bool t8142_model = chip_id == T8142 || chip_id == T6050;

if (t8142_model && poll64(cluster->base + CLUSTER_PSTATE, CLUSTER_PSTATE_BUSY, 0,
CLUSTER_SWITCH_TIMEOUT) < 0) {
printf("cpufreq: Cluster %s is busy before P-State request\n", cluster->name);
return -1;
}
Expand Down Expand Up @@ -118,6 +121,7 @@ static int set_pstate(const struct cluster_t *cluster, uint32_t pstate)
case T8122:
case T8142:
case T8140:
case T6050:
val &= ~CLUSTER_PSTATE_DESIRED1;
val |= CLUSTER_PSTATE_SET | FIELD_PREP(CLUSTER_PSTATE_DESIRED1, pstate);
break;
Expand All @@ -133,8 +137,7 @@ static int set_pstate(const struct cluster_t *cluster, uint32_t pstate)
}
}

if (chip_id == T8142 &&
pstate_reg_to_pstate(read64(cluster->base + CLUSTER_PSTATE)) != pstate) {
if (t8142_model && pstate_reg_to_pstate(read64(cluster->base + CLUSTER_PSTATE)) != pstate) {
printf("cpufreq: Cluster %s did not accept P-State %u\n", cluster->name, pstate);
return -1;
}
Expand Down Expand Up @@ -179,6 +182,7 @@ int cpufreq_init_cluster(const struct cluster_t *cluster, const struct feat_t *f
case S8000 ... S8003:
case T8010 ... T8015: /* This covers a gap but T8013 and T8014 will not randomly appear. */
case T8142: /* Keep firmware voltage, PLL and throttling configuration. */
case T6050:
/* Do nothing */
break;
case T8103:
Expand Down Expand Up @@ -378,6 +382,16 @@ static const struct cluster_t t8142_clusters[] = {
{},
};

/*
* T6050 (M5 Pro/Max): two M clusters (ADT voltage-states22/23, 15 P-states,
* 1.344 to 4.38 GHz) and one P cluster (voltage-states5, 20 P-states). m1n1
* sets the boot P-state of cluster 0 only; Linux drives all three.
*/
static const struct cluster_t t6050_clusters[] = {
{"MCPU0", 0x210e00000, false, 1, 4},
{},
};

const struct cluster_t *cpufreq_get_clusters(void)
{
switch (chip_id) {
Expand Down Expand Up @@ -417,6 +431,8 @@ const struct cluster_t *cpufreq_get_clusters(void)
return t6030_clusters;
case T8142:
return t8142_clusters;
case T6050:
return t6050_clusters;
case T6031:
case T6034:
return t6031_clusters;
Expand Down Expand Up @@ -535,6 +551,7 @@ const struct feat_t *cpufreq_get_features(void)
case T8122:
return t8122_features;
case T8142:
case T6050:
return t8142_features;
case T6020:
case T6021:
Expand Down
18 changes: 15 additions & 3 deletions src/kboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -6466,7 +6466,8 @@ int kboot_prepare_dt(void *fdt)
image_end < (u64)_base || image_end > ram_end)
bail("FDT: invalid T8103 inherited memory extent\n");
}
if (chip_id == T8140) {
/* T6050 hands its live NVMe session to Linux the same way: keep the heap. */
if (chip_id == T8140 || chip_id == T6050) {
u64 ram_end, inherited = cur_boot_args.top_of_kernel_data;
u64 high_water = heapblock_high_water();

Expand Down Expand Up @@ -6585,7 +6586,7 @@ int kboot_prepare_dt(void *fdt)
return -1;
if (dt_disable_missing_devs("acio", "cio@", 8, 2))
return -1;
if (dt_disable_missing_devs("i2c", "i2c@", 8, 0))
if (dt_disable_missing_devs("i2c", "i2c@", 16, 0)) /* T6050 (J714c) has nine i2c nodes */
return -1;
if (dt_disable_missing_j700_touch_id())
return -1;
Expand Down Expand Up @@ -6699,7 +6700,18 @@ int kboot_boot(void *kernel)
if (dt_remain < SZ_16K)
printf("FDT: free dt buffer space low, %u bytes left\n", dt_remain);
}
ret = chip_id == T8142 ? dapf_init_fdt(dt) : dapf_init_all();
if (chip_id == T8142) {
ret = dapf_init_fdt(dt);
} else if (chip_id == T6050) {
/*
* Only the MTP filter, reg 1 of dart-mtp: the AOP entry of the
* table points at the block shared by every DART and faults.
*/
ret = dapf_init("/arm-io/dart-mtp", 1);
printf("kboot: MTP DAPF %s on T6050\n", ret < 0 ? "failed" : "programmed");
} else {
ret = dapf_init_all();
}
if (ret < 0 && chip_id == T8140) {
printf("kboot: refusing T8140 handoff after DAPF failure\n");
pcie_shutdown();
Expand Down
4 changes: 4 additions & 0 deletions src/nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ bool nvme_init(void)
if (chip_id == T8140 && nvmmu_base == 0x38dcc0000 &&
nvme_base == 0x3cdcc0000 && nvme_size == 0x10000)
nvme_size = 0x30000;
/* The J714c (T6050) ADT has the same 64 KiB alias; same registers above it. */
if (chip_id == T6050 && nvmmu_base == 0x41dcc0000 && nvme_base == 0x45dcc0000 &&
nvme_size == 0x10000)
nvme_size = 0x30000;
if (nvmmu_size < NVMMU_TCB_STAT + sizeof(u32) ||
nvme_size < NVME_DB_LINEAR_IOSQ + sizeof(u32) || nvmmu_base > UINT64_MAX - nvmmu_size ||
nvme_base > UINT64_MAX - nvme_size ||
Expand Down
5 changes: 3 additions & 2 deletions src/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,9 @@ void smp_secondary_prep_el3(void)

static u32 cpu_start_bit(int index, const struct cpu_info *cpu)
{
/* T8142 has six E cores followed by four P cores, not four-core banks. */
if (chip_id == T8142)
/* T8142 has six E cores followed by four P cores, not four-core banks.
* T6050 (J714c) measures the same: one bit per CPU index, write-1-to-clear. */
if (chip_id == T8142 || chip_id == T6050)
return BIT(index);

return BIT(4 * cpu->cluster + cpu->core);
Expand Down