Skip to content
Draft
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
14 changes: 14 additions & 0 deletions arch/arm64/boot/dts/apple/s5l8960x-j85.dts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,18 @@
/ {
compatible = "apple,j85", "apple,s5l8960x", "apple,arm-platform";
model = "Apple iPad mini 2 (Wi-Fi)";
aliases {
gpu = &gpu;
};

/* m1n1 fills this from the booted board's SGX ADT perf-states. */
gpu_opp: opp-table-gpu {
compatible = "operating-points-v2";
};
};

/* J85's populated live SGX ADT is available to m1n1 at each RAM boot. */
&gpu {
operating-points-v2 = <&gpu_opp>;
status = "okay";
};
59 changes: 57 additions & 2 deletions drivers/gpu/drm/imagination/pvr_apple_s8003.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ struct pvr_apple_s8003 {
void __iomem *bridges; /* the GPU's two bus bridges */
u8 *border; /* BorderColorTable's contents (firmware file) */
u32 chip_info[3]; /* PLATFORM +0x300..+0x308, from the core's ID */
/* Six powered GPU OPP rows filled from this boot's ADT. */
u32 a7_mhz[7], a7_mv[7];
bool a7_live_perf;
struct s8003_mem hwobj[4]; /* the hardware objects at 0x8_00000000 */
struct s8003_mem a7_scratch; /* the A7's: GPU VA 0xff_ffff_f000 */
bool t7000_pio_mapped;
Expand Down Expand Up @@ -3888,8 +3891,10 @@ static void t7000_init_build(struct pvr_apple *apple, u32 q)
put32(platform + 0x30c, 3); /* the highest performance state */
put32(platform + 0x310, soc->perf_count);
for (i = 0; i < ARRAY_SIZE(t7000_mhz); i++) {
put32(platform + 0x314 + 4 * i, soc->mhz[i]);
put32(platform + 0x354 + 4 * i, soc->mv[i]);
put32(platform + 0x314 + 4 * i,
s->a7_live_perf ? s->a7_mhz[i] : soc->mhz[i]);
put32(platform + 0x354 + 4 * i,
s->a7_live_perf ? s->a7_mv[i] : soc->mv[i]);
}
/* The interrupt to the host: its word and bit among the AIC's software sets (P4 0x10, 0x400) */
put32(platform + 0x494, 4 * (s->irq / 32));
Expand Down Expand Up @@ -6267,6 +6272,50 @@ static void __iomem *t7000_ioremap(struct device *dev, const char *name)
return addr;
}

/*
* m1n1 fills an opt-in GPU OPP table from the current boot's ADT. Reject a
* malformed table before mapping PMGR or loading firmware. A GPU node
* without this property keeps its model's measured fallback.
*/
static int t7000_live_pstates(struct pvr_apple_s8003 *s)
{
struct device *dev = apple_dev(s->apple);
struct device_node *table;
u32 seen = 0;
int err = 0;

table = of_parse_phandle(dev->of_node, "operating-points-v2", 0);
if (!table)
return -EINVAL;

s->a7_mhz[0] = 0;
s->a7_mv[0] = s->v->soc->mv[0];
for_each_available_child_of_node_scoped(table, opp) {
u64 hz;
u32 uv, level;

if (of_property_read_u32(opp, "opp-level", &level) ||
of_property_read_u64(opp, "opp-hz", &hz) ||
of_property_read_u32(opp, "opp-microvolt", &uv) ||
level < 1 || level > 6 || (seen & BIT(level)) ||
hz < 100000000 || hz > 600000000 || hz % 1000000 ||
uv < 500000 || uv > 1200000 || uv % 1000) {
err = -EINVAL;
break;
}
s->a7_mhz[level] = hz / 1000000;
s->a7_mv[level] = uv / 1000;
seen |= BIT(level);
}
of_node_put(table);
if (err || seen != GENMASK(6, 1))
return -EINVAL;

s->a7_live_perf = true;
dev_info(dev, "GPU performance rows from this boot's ADT OPP table\n");
return 0;
}

/*
* The power manager's and the bridges' registers, and BorderColorTable's
* contents: 0x800 bytes of the kext's data (0xfffffff0088f1460), shipped
Expand All @@ -6280,6 +6329,12 @@ static int t7000_init(struct pvr_apple *apple)
const struct firmware *border;
int err;

if (of_find_property(dev->of_node, "operating-points-v2", NULL)) {
err = t7000_live_pstates(s);
if (err)
return dev_err_probe(dev, err, "no valid live GPU performance table\n");
}

s->pmgr = t7000_ioremap(dev, "pmgr");
s->bridges = t7000_ioremap(dev, "bridges");
if (!s->pmgr || !s->bridges)
Expand Down
Loading