Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
20 changes: 20 additions & 0 deletions arch/arm64/boot/dts/apple/t8132-j773g.dts
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,23 @@
&avd {
status = "okay";
};

/*
* ProRes: the T8132 PMGR policy has no SCODEC entries, so the domains are
* stated here, or it would leave them disabled.
*/
&ps_scodec {
status = "okay";
};

&ps_scodec_streaming {
status = "okay";
};

&dart_apr0 {
status = "okay";
};

&apr {
status = "okay";
};
8 changes: 7 additions & 1 deletion arch/arm64/boot/dts/apple/t8132-peripherals.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -438,15 +438,21 @@
status = "disabled";
};

/*
* ADT /arm-io/apr. Its windows are where AppleProResHW applies its core,
* AXI-to-fabric and SCODEC system rows; its reset is ARST(0x32), SCODEC.
*/
apr: video-codec@281000000 {
compatible = "apple,t8132-prores", "apple,prores";
reg = <0x2 0x81000000 0x0 0x4000>,
<0x2 0x80000000 0x0 0x1000000>,
<0x2 0x810c0000 0x0 0x4000>;
reg-names = "core", "wrapper", "aux";
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 1147 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 1184 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_scodec>;
power-domains = <&ps_scodec_streaming>;
resets = <&ps_scodec>;
iommus = <&dart_apr0 1>;
status = "disabled";
};
Expand Down
256 changes: 256 additions & 0 deletions drivers/media/platform/apple/prores/apple-prores-drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,237 @@ static_assert(ARRAY_SIZE(apr_t8142_ctrl_tunables) == APRI_CONTROL_COUNT);
static_assert(ARRAY_SIZE(apr_t8142_engine_tunables) == APRI_CORE_COUNT);
static_assert(ARRAY_SIZE(apr_t8142_wrapper_tunables) == APRI_T8142_WRAPPER_COUNT);

/*
* T8132 (M4) rows, as AppleProResHW 27.2 applies them in activateDevice():
* SCODEC system (82), ProRes core (80) and SCODEC AXI-to-fabric wrapper (48)
* read-modify-writes, from its generated tunable tables for chip 0x8132
* (soc_subsystem0 scodec_sys, scodec_prores0 and scodec_af_scodecaxi2af).
* The core table is the one the kext also gives T6041. The same tables of
* T6041, T6050, T8140 and T8142 agree, under their masks, with the rows
* traced from macOS on those chips.
*/
static const struct apr_tunable apr_t8132_aux_tunables[] = {
{ 0x008, 0x00000001, 0x00000001 },
{ 0x00c, 0x000001ff, 0x00000001 },
{ 0x014, 0x01110111, 0x01100110 },
{ 0x018, 0x7f7f7f7f, 0x7f007f00 },
{ 0x01c, 0xffff007f, 0xa000004c },
{ 0x020, 0x0fff0fff, 0x001c0090 },
{ 0x024, 0xffff007f, 0xa000004c },
{ 0x028, 0x0fff0fff, 0x08000002 },
{ 0x1000, 0x00007f11, 0x00007f00 },
{ 0x1004, 0x03ff03ff, 0x00000000 },
{ 0x1008, 0x7fffff7f, 0x00000000 },
{ 0x100c, 0x7fffff7f, 0x00000000 },
{ 0x1010, 0x7fffff7f, 0x00000000 },
{ 0x1014, 0x7fffff7f, 0x00000000 },
{ 0x1018, 0x7fffff7f, 0x00000000 },
{ 0x101c, 0x7fffff7f, 0x00000000 },
{ 0x1020, 0x7fffff7f, 0x00000000 },
{ 0x1024, 0x01ff01ff, 0x00000000 },
{ 0x1028, 0x01ff01ff, 0x00000000 },
{ 0x102c, 0x01ff01ff, 0x00000000 },
{ 0x1030, 0x01ff01ff, 0x00000000 },
{ 0x1034, 0x01ff01ff, 0x00000000 },
{ 0x1038, 0x01ff01ff, 0x00000000 },
{ 0x103c, 0x01ff01ff, 0x00000000 },
{ 0x1040, 0x1ff7fdff, 0x00000000 },
{ 0x1044, 0x1ff7fdff, 0x00000000 },
{ 0x1048, 0x1ff7fdff, 0x00000000 },
{ 0x104c, 0x1ff7fdff, 0x00000000 },
{ 0x1050, 0x1ff7fdff, 0x00000000 },
{ 0x1054, 0x1ff7fdff, 0x00000000 },
{ 0x1058, 0x1ff7fdff, 0x00000000 },
{ 0x105c, 0x0fff0fff, 0x00000000 },
{ 0x1060, 0x0fff0fff, 0x00000000 },
{ 0x1064, 0x0fff0fff, 0x00000000 },
{ 0x1068, 0x0fff0fff, 0x00000000 },
{ 0x106c, 0x0fff0fff, 0x00000000 },
{ 0x1070, 0x0fff0fff, 0x00000000 },
{ 0x1074, 0x0fff0fff, 0x00000000 },
{ 0x1078, 0x00007f11, 0x00007f00 },
{ 0x107c, 0x03ff03ff, 0x00000000 },
{ 0x1080, 0x7fffff7f, 0x00000000 },
{ 0x1084, 0x7fffff7f, 0x00000000 },
{ 0x1088, 0x7fffff7f, 0x00000000 },
{ 0x108c, 0x7fffff7f, 0x00000000 },
{ 0x1090, 0x7fffff7f, 0x00000000 },
{ 0x1094, 0x7fffff7f, 0x00000000 },
{ 0x1098, 0x7fffff7f, 0x00000000 },
{ 0x109c, 0x01ff01ff, 0x00000000 },
{ 0x10a0, 0x01ff01ff, 0x00000000 },
{ 0x10a4, 0x01ff01ff, 0x00000000 },
{ 0x10a8, 0x01ff01ff, 0x00000000 },
{ 0x10ac, 0x01ff01ff, 0x00000000 },
{ 0x10b0, 0x01ff01ff, 0x00000000 },
{ 0x10b4, 0x01ff01ff, 0x00000000 },
{ 0x10b8, 0x1ff7fdff, 0x00000000 },
{ 0x10bc, 0x1ff7fdff, 0x00000000 },
{ 0x10c0, 0x1ff7fdff, 0x00000000 },
{ 0x10c4, 0x1ff7fdff, 0x00000000 },
{ 0x10c8, 0x1ff7fdff, 0x00000000 },
{ 0x10cc, 0x1ff7fdff, 0x00000000 },
{ 0x10d0, 0x1ff7fdff, 0x00000000 },
{ 0x10d4, 0x0fff0fff, 0x00000000 },
{ 0x10d8, 0x0fff0fff, 0x00000000 },
{ 0x10dc, 0x0fff0fff, 0x00000000 },
{ 0x10e0, 0x0fff0fff, 0x00000000 },
{ 0x10e4, 0x0fff0fff, 0x00000000 },
{ 0x10e8, 0x0fff0fff, 0x00000000 },
{ 0x10ec, 0x0fff0fff, 0x00000000 },
{ 0x10fc, 0x7fffff7f, 0x00000000 },
{ 0x1100, 0x7fffff7f, 0x00000000 },
{ 0x1104, 0x7fffff7f, 0x00000000 },
{ 0x1108, 0x7fffff7f, 0x00000000 },
{ 0x110c, 0x7fffff7f, 0x00000000 },
{ 0x1110, 0x7fffff7f, 0x00000000 },
{ 0x1114, 0x7fffff7f, 0x00000000 },
{ 0x1118, 0x7fffff7f, 0x00000000 },
{ 0x111c, 0x7fffff7f, 0x00000000 },
{ 0x1120, 0x7fffff7f, 0x00000000 },
{ 0x1124, 0x7fffff7f, 0x00000000 },
{ 0x1128, 0x7fffff7f, 0x00000000 },
{ 0x112c, 0x7fffff7f, 0x00000000 },
{ 0x1130, 0x7fffff7f, 0x00000000 },
};

static const struct apr_tunable apr_t8132_engine_tunables[] = {
{ 0x008, 0x00000008, 0x00000008 },
{ 0x118, 0x0fff0fff, 0x00000600 },
{ 0x11c, 0x0fff0fff, 0x00000600 },
{ 0x148, 0x00000001, 0x00000001 },
{ 0x180, 0x8fff3fff, 0x800a0600 },
{ 0x184, 0x000000ff, 0x00000001 },
{ 0x188, 0x0fff0fff, 0x09b80038 },
{ 0x1c0, 0x8fff3fff, 0x80040600 },
{ 0x1c4, 0x000000ff, 0x00000003 },
{ 0x1c8, 0x0fff0fff, 0x080000c0 },
{ 0x200, 0x8fff3fff, 0x80050600 },
{ 0x204, 0x000000ff, 0x00000002 },
{ 0x208, 0x0fff0fff, 0x08c000c0 },
{ 0x240, 0x8fff3fff, 0x800007ff },
{ 0x244, 0x000000ff, 0x00000007 },
{ 0x248, 0x000000ff, 0x00000040 },
{ 0x280, 0x8fff3fff, 0x80010600 },
{ 0x284, 0x000000ff, 0x00000006 },
{ 0x288, 0x000000ff, 0x00000080 },
{ 0x2c0, 0x8fff3fff, 0x80020600 },
{ 0x2c4, 0x000000ff, 0x00000005 },
{ 0x2c8, 0x000000ff, 0x00000040 },
{ 0x300, 0x8fff3fff, 0x80030600 },
{ 0x304, 0x000000ff, 0x00000004 },
{ 0x308, 0x000000ff, 0x00000040 },
{ 0x340, 0xbfffff86, 0x81000006 },
{ 0x344, 0xffffffff, 0x0b0a0908 },
{ 0x348, 0x0000ffff, 0x00000720 },
{ 0x34c, 0x000003ff, 0x00000140 },
{ 0x350, 0x00ffffff, 0x00928170 },
{ 0x380, 0x8fff3fff, 0x800b0a00 },
{ 0x384, 0x000000ff, 0x0000000c },
{ 0x388, 0x0fff0fff, 0x09800038 },
{ 0x394, 0xffffffc0, 0x00200000 },
{ 0x3c0, 0x8fff3fff, 0x800b0a00 },
{ 0x3c4, 0x000000ff, 0x00000019 },
{ 0x3c8, 0x0fff0fff, 0x09f00010 },
{ 0x4c0, 0x800f3fff, 0x800b09ff },
{ 0x4c4, 0x000000ff, 0x0000001b },
{ 0x4c8, 0x0fff0fff, 0x09300010 },
{ 0x500, 0x800f3fff, 0x800605ff },
{ 0x504, 0x000000ff, 0x0000000d },
{ 0x508, 0x0fff0fff, 0x080000a0 },
{ 0x540, 0x800f3fff, 0x800005ff },
{ 0x544, 0x000000ff, 0x00000011 },
{ 0x548, 0x000000ff, 0x00000080 },
{ 0x580, 0x800f3fff, 0x800105ff },
{ 0x584, 0x000000ff, 0x00000010 },
{ 0x588, 0x000000ff, 0x00000080 },
{ 0x5c0, 0x800f3fff, 0x800205ff },
{ 0x5c4, 0x000000ff, 0x0000000f },
{ 0x5c8, 0x000000ff, 0x00000040 },
{ 0x600, 0x800f3fff, 0x800305ff },
{ 0x604, 0x000000ff, 0x0000000e },
{ 0x608, 0x000000ff, 0x00000040 },
{ 0x640, 0x802ff040, 0x80070040 },
{ 0x644, 0x00ffffff, 0x00071716 },
{ 0x648, 0xffff0003, 0x07ff0003 },
{ 0x650, 0x0fff0fff, 0x06000040 },
{ 0x680, 0x802ff040, 0x80081040 },
{ 0x684, 0x00ffffff, 0x00071514 },
{ 0x688, 0xffff0003, 0x07ff0003 },
{ 0x690, 0x0fff0fff, 0x06400040 },
{ 0x6c0, 0x802ff040, 0x80092040 },
{ 0x6c4, 0x00ffffff, 0x00071312 },
{ 0x6c8, 0xffff0003, 0x07ff0003 },
{ 0x6d0, 0x0fff0fff, 0x06800040 },
{ 0x700, 0x800f3fff, 0x800b09ff },
{ 0x704, 0x000000ff, 0x00000018 },
{ 0x708, 0x0fff0fff, 0x08a00060 },
{ 0x714, 0xffffffc0, 0x00200000 },
{ 0x740, 0x800f3fff, 0x800b09ff },
{ 0x744, 0x000000ff, 0x0000001a },
{ 0x748, 0x0fff0fff, 0x09000010 },
{ 0x780, 0x800f3fff, 0x800b09ff },
{ 0x784, 0x000000ff, 0x0000001c },
{ 0x788, 0x0fff0fff, 0x09100010 },
{ 0x7c0, 0x800f3fff, 0x800b09ff },
{ 0x7c4, 0x000000ff, 0x0000001d },
{ 0x7c8, 0x0fff0fff, 0x09200010 },
};

static const struct apr_tunable apr_t8132_wrapper_tunables[] = {
{ 0x000000, 0x800001ff, 0x80000019 },
{ 0x000004, 0x81ff01ff, 0x800b000b },
{ 0x000008, 0x81ff01ff, 0x800b000b },
{ 0x00000c, 0x81ff01ff, 0x800b000b },
{ 0x000010, 0x81ff01ff, 0x80060016 },
{ 0x000014, 0x81ff01ff, 0x80060016 },
{ 0x000018, 0x81ff01ff, 0x80010003 },
{ 0x00001c, 0x81ff01ff, 0x80010003 },
{ 0x000020, 0x800000ff, 0x80000010 },
{ 0x000024, 0x800000ff, 0x8000001a },
{ 0x000028, 0x80ff00ff, 0x800e000c },
{ 0x00002c, 0x80ff00ff, 0x80140006 },
{ 0x000030, 0x80ff00ff, 0x8006001a },
{ 0x000034, 0x80ff00ff, 0x80060003 },
{ 0x000038, 0x80ff00ff, 0x80060003 },
{ 0x00003c, 0x800000ff, 0x80000012 },
{ 0x000040, 0x800000ff, 0x8000000e },
{ 0x000044, 0x800000ff, 0x8000000e },
{ 0x000100, 0x000000ff, 0x000000ff },
{ 0x000104, 0x00ff0000, 0x00010000 },
{ 0x000108, 0xffff0006, 0x00040000 },
{ 0x000304, 0x3f3f0000, 0x02020000 },
{ 0x000314, 0x80000000, 0x80000000 },
{ 0x00031c, 0x80000000, 0x80000000 },
{ 0x000324, 0x80000000, 0x80000000 },
{ 0x00032c, 0x80000000, 0x80000000 },
{ 0x00034c, 0xffffffff, 0x00050020 },
{ 0x000350, 0xffffffff, 0x000a0030 },
{ 0x000408, 0xffff0020, 0x000f0020 },
{ 0x000748, 0x07ff07ff, 0x00200000 },
{ 0x000848, 0x07ff07ff, 0x00100030 },
{ 0x000948, 0x07ff07ff, 0x01400100 },
{ 0x000a50, 0x07ff07ff, 0x00800080 },
{ 0x000c00, 0xffffffff, 0x7fffffff },
{ 0x000c04, 0x00000100, 0x00000100 },
{ 0x004008, 0x00000001, 0x00000000 },
{ 0x00400c, 0x00000001, 0x00000000 },
{ 0x004014, 0x00000001, 0x00000000 },
{ 0x004018, 0x00000001, 0x00000000 },
{ 0x00401c, 0x00000001, 0x00000001 },
{ 0x004020, 0xffff0000, 0x00000000 },
{ 0x004024, 0xffff0000, 0x00000000 },
{ 0x004028, 0xffff0000, 0x00000000 },
{ 0x00402c, 0xffff0000, 0x00000000 },
{ 0x004030, 0xffff0000, 0x00000000 },
{ 0x004034, 0xffff0000, 0x00000000 },
{ 0x004038, 0xffff0000, 0x00000000 },
{ 0x00403c, 0xffff0000, 0x00000000 },
};

static_assert(ARRAY_SIZE(apr_t8132_aux_tunables) == APRI_SYSTEM_COUNT);
static_assert(ARRAY_SIZE(apr_t8132_engine_tunables) == APRI_CORE_COUNT);

/* Selected only by the DT compatible, before mapping any resources. */
struct apr_variant {
int (*build_desc)(const struct apr_frame *f, u8 *desc);
Expand Down Expand Up @@ -1045,6 +1276,30 @@ static const struct apr_variant apr_t6041 = {
.apri = &apri_t6041,
};

/*
* T6041's engine, windows and interrupt with the M4's own SCODEC rows. The
* second interrupt (DT index 1) is the DMA error source, which macOS takes
* only on some chips; the engine's is index 0.
*/
static const struct apr_variant apr_t8132 = {
.build_desc = apr_build_desc,
.stats = {
{ APR_REG_STATS0_LO, APR_REG_STATS0_HI, APR_REG_STATS0_SIZE },
{ APR_REG_STATS1_LO, APR_REG_STATS1_HI, APR_REG_STATS1_SIZE },
},
.engine_tunables = apr_t8132_engine_tunables,
.num_engine_tunables = ARRAY_SIZE(apr_t8132_engine_tunables),
.wrapper_tunables = apr_t8132_wrapper_tunables,
.num_wrapper_tunables = ARRAY_SIZE(apr_t8132_wrapper_tunables),
.aux_tunables = apr_t8132_aux_tunables,
.num_aux_tunables = ARRAY_SIZE(apr_t8132_aux_tunables),
.reg_names = { "core", "wrapper", "aux" },
.num_regs = 3,
.num_irqs = 1,
.ring_bytes = APR_RING_BYTES,
.desc_bytes = APR_DESC_BYTES,
};

/* T6041's engine plus the SCODEC control window. */
static const struct apr_variant apr_t6050 = {
.build_desc = apr_build_desc,
Expand Down Expand Up @@ -2161,6 +2416,7 @@ static void apr_remove(struct platform_device *pdev)
static const struct of_device_id apr_of_match[] = {
{ .compatible = "apple,t6000-prores", .data = &apr_t6000 },
{ .compatible = "apple,t6041-prores", .data = &apr_t6041 },
{ .compatible = "apple,t8132-prores", .data = &apr_t8132 },
{ .compatible = "apple,t6050-prores", .data = &apr_t6050 },
{ .compatible = "apple,t8140-prores", .data = &apr_t8140 },
{ .compatible = "apple,t8142-prores", .data = &apr_t8142 },
Expand Down
Loading