Skip to content
Merged
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
49 changes: 41 additions & 8 deletions Documentation/devicetree/bindings/npu/apple,ane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ description:
yet established. T8132 has a single H16 engine, two interrupts, six
register windows (no second-engine aux-3), and five DAPF records. Its
virtual ANE-SYS-V gate resolves to the ANE system domain; ANE-SYS-V-PMP
is a firmware notification gate with no physical PMGR power state.
is a firmware notification gate with no physical PMGR power state. T8122
has a single H15 engine, one interrupt, three register windows (engine,
pmgr, aux-0), five ANE power domains, five DAPF records, and preloaded
firmware.

properties:
compatible:
Expand All @@ -37,6 +40,7 @@ properties:
- apple,t6041-ane
- apple,t6050-ane
- apple,t8112-ane
- apple,t8122-ane
- apple,t8132-ane
- apple,t8140-ane
- apple,t8142-ane
Expand Down Expand Up @@ -139,12 +143,13 @@ properties:
$ref: /schemas/types.yaml#/definitions/uint64-array
items:
- const: 0x10000000000
- const: 0x100000c0000
- enum: [0x100000bc000, 0x100000c0000, 0x100000c8000]
description:
Device addresses of the preloaded TEXT and DATA segments. Their sizes
are 0xc0000 and 0x2ac000 bytes respectively. The bootloader supplies
the physical reservations. The device addresses are fixed by the
firmware layout and may be described statically.
Device addresses of the preloaded TEXT and DATA segments. The bootloader
supplies the physical reservations. The device addresses are fixed by the
firmware layout (TEXT at 0x10000000000; DATA at 0x100000bc000 on T8132
27.2, 0x100000c0000 on H16/H17 26.x, or 0x100000c8000 on T8122 27.2) and
may be described statically.

apple,dapf-ranges:
$ref: /schemas/types.yaml#/definitions/uint64-matrix
Expand All @@ -155,7 +160,7 @@ properties:
- description: Physical start address, inclusive
- description: Physical end address, inclusive
description:
Four (five on T6050 and T8132) DART address protection filter (DAPF)
Four (five on T6050, T8122 and T8132) DART address protection filter (DAPF)
ranges, in hardware record order. Each pair contains inclusive 64-bit physical
bounds, not a base and length. The same records apply to all three ANE DARTs.
Firmware accesses these registers through identity mappings of the
Expand All @@ -175,7 +180,7 @@ properties:

apple,ane-type:
$ref: /schemas/types.yaml#/definitions/uint32
enum: [0x100, 0x110, 0x200]
enum: [0xb0, 0x100, 0x110, 0x200]
description: Firmware generation identifier supplied by the bootloader

apple,firmware-preloaded:
Expand Down Expand Up @@ -366,6 +371,33 @@ allOf:
- apple,ane-type
- apple,firmware-preloaded
- apple,dapf-ranges
- if:
properties:
compatible:
const: apple,t8122-ane
then:
properties:
interrupts:
maxItems: 1
reg:
minItems: 3
maxItems: 3
reg-names:
items:
- const: engine
- const: pmgr
- const: aux-0
power-domains:
minItems: 5
maxItems: 5
apple,ane-type:
const: 0xb0
apple,dapf-ranges:
minItems: 5
required:
- apple,ane-type
- apple,firmware-preloaded
- apple,dapf-ranges
- if:
properties:
compatible:
Expand All @@ -388,6 +420,7 @@ allOf:
- apple,t8140-ane
- apple,t6041-ane
- apple,t6050-ane
- apple,t8122-ane
- apple,t8142-ane
- apple,t8132-ane
then:
Expand Down
16 changes: 16 additions & 0 deletions arch/arm64/boot/dts/apple/t8122-j615.dts
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,19 @@
&nvram_qspi {
read-only;
};

&ane_dart0 {
status = "okay";
};

&ane_dart1 {
status = "okay";
};

&ane_dart2 {
status = "okay";
};

&ane {
status = "okay";
};
57 changes: 57 additions & 0 deletions arch/arm64/boot/dts/apple/t8122-peripherals.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,69 @@
status = "disabled";
};

ane_dart0: iommu@311800000 {
compatible = "apple,t8122-dart", "apple,t8110-dart";
reg = <0x3 0x11800000 0x0 0x4000>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 525 IRQ_TYPE_LEVEL_HIGH>;
#iommu-cells = <1>;
power-domains = <&ps_ane_sys>;
apple,dma-range = <0x0 0x0 0x400 0x0>;
status = "disabled";
};

dart_ane_companion3: filter@311804000 {
compatible = "apple,t8122-dapf", "apple,dapf";
reg = <0x3 0x11804000 0x0 0x4000>;
status = "disabled";
};

ane_dart1: iommu@311810000 {
compatible = "apple,t8122-dart", "apple,t8110-dart";
reg = <0x3 0x11810000 0x0 0x4000>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 525 IRQ_TYPE_LEVEL_HIGH>;
#iommu-cells = <1>;
power-domains = <&ps_ane_sys>;
apple,dma-range = <0x0 0x0 0x400 0x0>;
status = "disabled";
};

ane_dart2: iommu@311820000 {
compatible = "apple,t8122-dart", "apple,t8110-dart";
reg = <0x3 0x11820000 0x0 0x4000>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 525 IRQ_TYPE_LEVEL_HIGH>;
#iommu-cells = <1>;
power-domains = <&ps_ane_sys>;
apple,dma-range = <0x0 0x0 0x400 0x0>;
status = "disabled";
};

ane: ane@310000000 {
compatible = "apple,t8122-ane";
reg = <0x3 0x10000000 0x0 0x2000000>,
<0x2 0xd0700000 0x0 0x18000>,
<0x2 0xd0724000 0x0 0x4000>;
reg-names = "engine", "pmgr", "aux-0";
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 524 IRQ_TYPE_LEVEL_HIGH>;
iommus = <&ane_dart0 0>, <&ane_dart1 0>, <&ane_dart2 0>;
power-domains = <&ps_ane_sys>, <&ps_ane_cpu>, <&ps_ane_mpm>,
<&ps_ane_td>, <&ps_ane_base>;
apple,ane-type = <0xb0>;
apple,firmware-preloaded;
/* ADT dapf-instance-0: inclusive CPU addresses, in record order. */
apple,dapf-ranges = /bits/ 64 <0x2a5468000 0x2a5468003>,
/bits/ 64 <0x2d0700438 0x2d070043b>,
/bits/ 64 <0x2d070c000 0x2d070c01b>,
/bits/ 64 <0x2d072682c 0x2d072682f>,
/bits/ 64 <0x292468000 0x292468003>;
/* Default layout; the loader supplies per-boot physical reservations. */
apple,firmware-iovas = /bits/ 64 <0x10000000000 0x100000c8000>;
status = "disabled";
};

apcie1_piodma: dma-controller@595010000 {
compatible = "apple,t8122-pcie-piodma", "apple,pcie-piodma";
reg = <0x5 0x95010000 0x0 0x4000>,
Expand Down
38 changes: 38 additions & 0 deletions arch/arm64/boot/dts/apple/t8122-pmgr.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@
#power-domain-cells = <0>;
#reset-cells = <0>;
label = "ane_sys";
apple,no-auto-pm;
};

ps_apcie_gp: power-controller@440 {
Expand Down Expand Up @@ -1119,6 +1120,43 @@
power-domains = <&ps_venc_me0>;
};

ps_ane_mpm: power-controller@c000 {
compatible = "apple,t8122-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate";
reg = <0xc000 4>;
#power-domain-cells = <0>;
#reset-cells = <0>;
label = "ane_mpm";
power-domains = <&ps_ane_sys>;
};

ps_ane_cpu: power-controller@c008 {
compatible = "apple,t8122-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate";
reg = <0xc008 4>;
#power-domain-cells = <0>;
#reset-cells = <0>;
label = "ane_cpu";
apple,no-auto-pm;
power-domains = <&ps_ane_sys>;
};

ps_ane_td: power-controller@c010 {
compatible = "apple,t8122-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate";
reg = <0xc010 4>;
#power-domain-cells = <0>;
#reset-cells = <0>;
label = "ane_td";
power-domains = <&ps_ane_sys>;
};

ps_ane_base: power-controller@c018 {
compatible = "apple,t8122-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate";
reg = <0xc018 4>;
#power-domain-cells = <0>;
#reset-cells = <0>;
label = "ane_base";
power-domains = <&ps_ane_td>, <&ps_ane_cpu>;
};

ps_disp_cpu: power-controller@10000 {
compatible = "apple,t8122-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate";
reg = <0x10000 4>;
Expand Down
59 changes: 59 additions & 0 deletions drivers/accel/ane/ane_fw_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ static const u32 ane_t8132_reg_sizes[] = {
0x2000000, 0x18000, 0x4000, 0x30000, 0xff4000, 0x4000,
};

/* T8122 (M3) H15: engine, PMGR and PMGR aux-0 windows from the ADT. */
static const char * const ane_t8122_reg_names[] = {
"engine", "pmgr", "aux-0",
};

static const u32 ane_t8122_reg_sizes[] = {
0x2000000, 0x18000, 0x4000,
};

/* The same five domains; ANE_SYS sits at +0x438 in the T8122 PMGR. */
static const u32 ane_t8122_power_words[] = {
0x438, 0xc008, 0xc000, 0xc010, 0xc018,
};

/* Offsets in reg[1]; genpd, never the ANE driver, owns transitions. */
static const u32 ane_h16_power_words[] = {
0x3c0, 0xc008, 0xc000, 0xc010, 0xc018,
Expand Down Expand Up @@ -64,6 +78,51 @@ static const u8 ane_t6050_text_pin_27_0[] = {
0xd1, 0xa2, 0x20, 0xd0, 0xee, 0x43, 0x8b, 0x8f,
};

/*
* M3 (T8122): H15 engine running the macOS 27.2 (26B123) firmware on the
* shared H16 AP-direct backend: ASC wrapper at +0x1400000, scratch at
* +0x1840050, doorbell/IPI at +0x1844000, ANE_SYS at PMGR +0x438, and five
* DAPF records at DART0 + 0x4000. Cold restart + program replay across sleep.
*/
const struct ane_fw_platform ane_t8122_platform = {
.h16_profiles = ane_t8122_profiles_26b123,
.h16_profile_count = ARRAY_SIZE(ane_t8122_profiles_26b123),
.h16_mmio = ane_h15_mmio_t8122,
.h16_mmio_count = ARRAY_SIZE(ane_h15_mmio_t8122),
.dart_params = 0x8,
.dapf_dart = 0,
.dapf_offset = 0x4000,
.dapf_size = SZ_16K,
.dapf_count = 5,
.soc = 0x8122,
.chip_family = 15,
.ane_type = 0xb0,
.hwx_subtype = 6,
.task_generation = 15,
.interrupt_count = 1,
.irq_role = ANE_FW_IRQ_UNKNOWN,
.owner = ANE_FW_OWNER_AP,
.reg_names = ane_t8122_reg_names,
.reg_sizes = ane_t8122_reg_sizes,
.reg_count = ARRAY_SIZE(ane_t8122_reg_names),
.wrapper = 0x1400000,
.mailbox = 0x1408000,
.scratch = 0x1840050,
.doorbell = 0x1844000,
.irq_status = 0x184c000,
.irq_ack = 0x1850000,
.power_words = ane_t8122_power_words,
.power_count = ARRAY_SIZE(ane_t8122_power_words),
.build_name = "27.2 26B123",
.preload_dva = { 0x10000000000, 0x100000c8000 },
.preload_size = { 0xc8000, 0x2a4000 },
.stream_mask = BIT(0),
.sleep_cold = true,
.boot_qualified = true,
.firmware_preloaded = true,
.safe_reset = false,
};

const struct ane_fw_platform ane_h16_platform = {
.h16_profiles = ane_h16_profiles,
.h16_profile_count = ARRAY_SIZE(ane_h16_profiles),
Expand Down
1 change: 1 addition & 0 deletions drivers/accel/ane/ane_fw_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ ane_fw_sleep_path(const struct ane_fw_platform *platform)

extern const struct ane_fw_platform ane_h16_platform, ane_h17_platform, ane_t6050_platform,
ane_t8142_platform;
extern const struct ane_fw_platform ane_t8122_platform;
extern const struct ane_fw_platform ane_t8132_platform;
int ane_fw_platform_preflight(struct platform_device *pdev,
const struct ane_fw_platform *soc);
Expand Down
27 changes: 27 additions & 0 deletions drivers/accel/ane/ane_fw_platform_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,32 @@ static void ane_platform_staged_bind_test(struct kunit *test)
}

#if IS_BUILTIN(CONFIG_DRM_ACCEL_ANE) && IS_BUILTIN(CONFIG_DRM_ACCEL_ANE_FW_KUNIT_TEST)
/* M3 (T8122) H15: three reg windows, five DAPF records at DART0 + 0x4000, cold sleep. */
static void ane_t8122_platform_test(struct kunit *test)
{
struct platform_device *pdev = platform_device_alloc("ane-t8122", -1);
u64 phys[] = { 0x100000000, 0x200000000 };

KUNIT_ASSERT_NOT_NULL(test, pdev);
KUNIT_EXPECT_EQ(test, ane_t8122_platform.soc, 0x8122U);
KUNIT_EXPECT_EQ(test, ane_t8122_platform.chip_family, 15U);
KUNIT_EXPECT_EQ(test, ane_t8122_platform.ane_type, 0xb0U);
KUNIT_EXPECT_EQ(test, ane_t8122_platform.hwx_subtype, 6U);
KUNIT_EXPECT_EQ(test, ane_t8122_platform.reg_count, 3U);
KUNIT_EXPECT_STREQ(test, ane_t8122_platform.reg_names[2], "aux-0");
KUNIT_EXPECT_FALSE(test, ane_t8122_platform.has_xl);
KUNIT_EXPECT_EQ(test, ane_t8122_platform.dapf_dart, 0U);
KUNIT_EXPECT_EQ(test, ane_t8122_platform.dapf_offset, 0x4000U);
KUNIT_EXPECT_EQ(test, ane_t8122_platform.dapf_count, 5);
KUNIT_EXPECT_EQ(test, ane_t8122_platform.power_words[0], 0x438U);
KUNIT_EXPECT_TRUE(test, ane_t8122_platform.sleep_cold);
KUNIT_EXPECT_TRUE(test, ane_fw_preload_ranges_valid(&ane_t8122_platform, phys,
ane_t8122_platform.preload_size,
ane_t8122_platform.preload_dva));
KUNIT_EXPECT_EQ(test, ane_fw_platform_preflight(pdev, &ane_t8122_platform), -EINVAL);
platform_device_put(pdev);
}

/* One engine: no aux-3, five DAPF records; a node without DT is refused. */
static void ane_t8132_platform_test(struct kunit *test)
{
Expand Down Expand Up @@ -221,6 +247,7 @@ static void ane_t8142_bridge_ops_test(struct kunit *test)

static struct kunit_case ane_fw_platform_cases[] = {
#if IS_BUILTIN(CONFIG_DRM_ACCEL_ANE) && IS_BUILTIN(CONFIG_DRM_ACCEL_ANE_FW_KUNIT_TEST)
KUNIT_CASE(ane_t8122_platform_test),
KUNIT_CASE(ane_t8132_platform_test),
KUNIT_CASE(ane_t8132_builds_test),
KUNIT_CASE(ane_t6050_builds_test),
Expand Down
2 changes: 1 addition & 1 deletion drivers/accel/ane/ane_fw_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ ane_fw_transport_bar_context(struct ane_fw_transport *t, u8 *copy, size_t size)
*/
static inline bool ane_fw_transport_switch_safe(const struct ane_fw_transport *t)
{
return t->soc->chip_family == 16 || t->soc->chip_family == 17;
return t->soc->chip_family >= 15;
}

/* ane_fw_transport_publish_at() offset that copies to the end of the arena. */
Expand Down
9 changes: 6 additions & 3 deletions drivers/accel/ane/ane_h16_boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,13 @@ static inline int ane_h16_prepare(struct ane_h16_boot *b)
{
const struct ane_h16_build *f = b->build;
unsigned int i, j;
int ret = ane_h16_ce(b);
int ret;

if (ret)
return ret;
if (f->ce) {
ret = ane_h16_ce(b);
if (ret)
return ret;
}
for (i = 0; i < f->tunable_count; i++) {
const struct ane_h16_tunables *group = &f->tunables[i];

Expand Down
Loading
Loading