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
74 changes: 62 additions & 12 deletions Documentation/devicetree/bindings/npu/apple,ane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ description:
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.
firmware. On T8112 the boot loader may also hand over the firmware iBoot
preloaded (macOS 27.2 and later stubs). It then adds the TEXT and DATA
reservations, their device addresses and apple,firmware-preloaded, and
the driver cold-starts that firmware instead of staging a disk image.

properties:
compatible:
Expand Down Expand Up @@ -137,7 +140,8 @@ properties:
maxItems: 2
description:
On T602x, the IOVA-only reservation of the firmware entry alias.
On T6041, T6050, T8132 and T8140, bootloader-provided physical TEXT
On T6041, T6050, T8132 and T8140, and on T8112 when the bootloader
hands the preload over, bootloader-provided physical TEXT
and DATA preload reservations in that order. Each reservation must have no-map, must
not be reusable, and must remain reserved until reboot. Physical
addresses vary per boot and must not be hard-coded in a board DTS.
Expand All @@ -150,14 +154,15 @@ properties:
apple,firmware-iovas:
$ref: /schemas/types.yaml#/definitions/uint64-array
items:
- const: 0x10000000000
- enum: [0x100000bc000, 0x100000c0000, 0x100000c8000]
- enum: [0x800000000, 0x10000000000]
- enum: [0x8000d8000, 0x100000bc000, 0x100000c0000, 0x100000c8000]
description:
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.
27.2, 0x100000c0000 on H16/H17 26.x, or 0x100000c8000 on T8122 27.2;
on T8112 27.2 TEXT at 0x800000000 and DATA at 0x8000d8000) and may be
described statically.

apple,dapf-ranges:
$ref: /schemas/types.yaml#/definitions/uint64-matrix
Expand All @@ -168,7 +173,7 @@ properties:
- description: Physical start address, inclusive
- description: Physical end address, inclusive
description:
Four (five on T6050, T8122 and T8132) DART address protection filter (DAPF)
Four (five on T6050, T8122 and T8132; four on T8112) 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 @@ -188,9 +193,15 @@ properties:

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

dma-coherent:
description:
The engine's memory accesses are cache coherent. Required for the
shared backend's private firmware surfaces; on T8112 it is described
only for macOS 27.2 stubs, whose preload hand-off uses that backend.

apple,firmware-preloaded:
type: boolean
description:
Expand Down Expand Up @@ -497,16 +508,32 @@ allOf:
- const: pmgr
- const: set
- const: fuse
apple,exclave-assigned: false
required:
- interrupt-names

- if:
properties:
compatible:
not:
contains:
enum:
- apple,t8112-ane
- apple,t8140-ane
- apple,t6041-ane
- apple,t6050-ane
- apple,t8122-ane
- apple,t8142-ane
- apple,t8132-ane
then:
properties:
memory-region:
maxItems: 1
memory-region-names: false
apple,firmware-iovas: false
apple,ane-type: false
apple,firmware-preloaded: false
apple,exclave-assigned: false
apple,dapf-ranges: false
required:
- interrupt-names

- if:
properties:
Expand Down Expand Up @@ -565,9 +592,32 @@ allOf:
minItems: 7
maxItems: 7
resets: false
memory-region: false
memory-region:
minItems: 2
apple,ane-type:
const: 0x80
apple,dapf-ranges:
maxItems: 4
required:
- mboxes
if:
anyOf:
- required:
- memory-region
- required:
- memory-region-names
- required:
- apple,firmware-iovas
- required:
- apple,firmware-preloaded
then:
required:
- apple,firmware-preloaded
- memory-region
- memory-region-names
- apple,firmware-iovas
- apple,ane-type
- apple,dapf-ranges

- if:
properties:
Expand Down
11 changes: 11 additions & 0 deletions arch/arm64/boot/dts/apple/t8112-ane-fw27.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: GPL-2.0+ OR MIT
/*
* T8112 with macOS 27 system firmware (27.2 stub): the boot loader may hand
* the ANE firmware iBoot preloaded over, and the driver then starts it cold
* on the shared AP-direct backend, whose private firmware surfaces need a
* cache-coherent client. The 13.5 legacy path keeps its own description.
*/

&ane {
dma-coherent;
};
1 change: 1 addition & 0 deletions arch/arm64/boot/dts/apple/t8112-j413-fw27.dts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/* J413 with macOS 27 system firmware (27.2 stub). */
#include "t8112-j413.dts"
#include "t8112-mtp-fw27.dtsi"
#include "t8112-ane-fw27.dtsi"
1 change: 1 addition & 0 deletions arch/arm64/boot/dts/apple/t8112-j415-fw27.dts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/* J415 with macOS 27 system firmware (27.2 stub). */
#include "t8112-j415.dts"
#include "t8112-mtp-fw27.dtsi"
#include "t8112-ane-fw27.dtsi"
1 change: 1 addition & 0 deletions arch/arm64/boot/dts/apple/t8112-j473.dts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@


#include "t8112-j473-peripherals.dtsi"
#include "t8112-ane-fw27.dtsi"

/*
* The 27.2 GPU firmware keeps running through suspend-to-idle. Gating the GFX
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/boot/dts/apple/t8112-j493-fw27.dts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/* J493 with macOS 27 system firmware (27.2 stub). */
#include "t8112-j493.dts"
#include "t8112-mtp-fw27.dtsi"
#include "t8112-ane-fw27.dtsi"
11 changes: 11 additions & 0 deletions arch/arm64/boot/dts/apple/t8112.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -2016,6 +2016,17 @@
<&ps_ane_base>, <&ps_ane_set1>, <&ps_ane_set2>,
<&ps_ane_set3>, <&ps_ane_set4>;
mboxes = <&ane_mbox>;
/*
* For a boot loader preload hand-off (macOS 27.2 stubs),
* from the J473 27.2 ADT: ane-type and dart-ane
* dapf-instance-0, inclusive CPU addresses, in record
* order. The legacy disk loader ignores them.
*/
apple,ane-type = <0x80>;
apple,dapf-ranges = /bits/ 64 <0x22b45c000 0x22b45c003>,
/bits/ 64 <0x23b70c000 0x23b70c03b>,
/bits/ 64 <0x23b7004a8 0x23b7004ab>,
/bits/ 64 <0x206468000 0x206468003>;
};

dispext0_dart: iommu@271304000 {
Expand Down
2 changes: 1 addition & 1 deletion drivers/accel/ane/ane_fw_cold.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ static int ane_fw_quarantine(struct ane_fw_backend *b, int error)
return error;
}

static bool ane_fw_raw_boot(void)
bool ane_fw_raw_boot(void)
{
struct device_node *chosen __free(device_node) = of_find_node_by_path("/chosen");
const char *evidence;
Expand Down
3 changes: 3 additions & 0 deletions drivers/accel/ane/ane_fw_cold.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ static inline int ane_fw_heap_tail(const u64 dva[2], const u64 size[2], u64 limi
/* The exact /chosen/apple,ane-cold-boot value a raw loader boot publishes. */
#define ANE_FW_COLD_BOOT_EVIDENCE "raw-no-xnu-ane-untouched-v1"

/* /chosen/apple,ane-cold-boot names a raw loader boot (ANE_FW_COLD_BOOT_EVIDENCE). */
bool ane_fw_raw_boot(void);

/*
* What the loader handed off, as read from the DT and the TEXT segment, and
* the live state of the engine. marker is /chosen/apple,ane-cold-boot or
Expand Down
101 changes: 101 additions & 0 deletions drivers/accel/ane/ane_fw_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ static const u32 ane_t8122_power_words[] = {
0x438, 0xc008, 0xc000, 0xc010, 0xc018,
};

/* T8112 (M2): the legacy H14 windows: engine, PMGR, power gate set, fuse. */
static const char * const ane_t8112_reg_names[] = {
"engine", "pmgr", "set", "fuse",
};

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

/* ANE_SYS (+0x4a8), then the seven ANE domains in power-domains order. */
static const u32 ane_t8112_power_words[] = {
0x4a8, 0xc008, 0xc010, 0xc018, 0xc020, 0xc028, 0xc030, 0xc038,
};

/* 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 @@ -123,6 +137,62 @@ const struct ane_fw_platform ane_t8122_platform = {
.safe_reset = false,
};

/*
* M2 (T8112): H14 engine running the macOS 27.2 (26B123) firmware iBoot
* preloaded, on the shared H16 AP-direct backend. Selected only when the boot
* loader hands the preload over (ane_fw_preload_handoff()); otherwise the
* legacy H14 path stages the disk image as before. The ASC wrapper, mailbox,
* doorbell and IRQ words are those of the legacy H14 path (SCRATCH0 at
* +0x1840048, IPI at +0x1844000); the four DAPF records sit at DART0 +
* 0x4000. Seven power domains, the first the CPU domain under ANE_SYS, with
* the "set" power gate in front of it. The interrupt line is the ASC
* mailbox's, which its own node owns. Cold restart + program replay across
* sleep.
*/
const struct ane_fw_platform ane_t8112_platform = {
.h16_profiles = ane_t8112_profiles_26b123,
.h16_profile_count = ARRAY_SIZE(ane_t8112_profiles_26b123),
.h16_mmio = ane_h14_mmio_t8112,
.h16_mmio_count = ARRAY_SIZE(ane_h14_mmio_t8112),
.dart_params = 0x8,
.dapf_dart = 0,
.dapf_offset = 0x4000,
.dapf_size = SZ_16K,
.dapf_count = 4,
.soc = 0x8112,
.chip_family = 14,
.ane_type = 0x80,
.hwx_subtype = 5,
.task_generation = 14,
.interrupt_count = 1,
.irq_role = ANE_FW_IRQ_MAILBOX,
.owner = ANE_FW_OWNER_AP,
.reg_names = ane_t8112_reg_names,
.reg_sizes = ane_t8112_reg_sizes,
.reg_count = ARRAY_SIZE(ane_t8112_reg_names),
.wrapper = 0x1400000,
.mailbox = 0x1408000,
.scratch = 0x1840048,
.doorbell = 0x1844000,
.irq_status = 0x184c000,
.irq_ack = 0x1850000,
.power_words = ane_t8112_power_words,
.power_count = ARRAY_SIZE(ane_t8112_power_words),
.domain_count = 7,
.sys_parent = true,
.pwgate_window = "set",
.pwgate_offset = 0x8b8,
.dart_reattach = true,
.build_name = "27.2 26B123",
.preload_dva = { 0x800000000, 0x8000d8000 },
.preload_size = { 0xd8000, 0x614000 },
.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 Expand Up @@ -583,6 +653,37 @@ const struct ane_fw_platform *ane_fw_platform_build(struct device_node *np,
}
EXPORT_SYMBOL_GPL(ane_fw_platform_build);

/*
* Whether the boot loader handed this ANE's preloaded firmware over for the
* driver to cold-start: two available firmware-text/firmware-data reserved
* regions, their device addresses, the preload marker and the raw-boot
* evidence in /chosen. Only the DT is read. A SoC whose ANE also has a legacy
* path (T8112) takes the shared backend only with all of them.
*/
bool ane_fw_preload_handoff(struct device_node *np)
{
unsigned int i;

if (!np || !of_property_read_bool(np, "apple,firmware-preloaded") ||
of_property_count_u32_elems(np, "memory-region") != 2 ||
of_property_count_strings(np, "memory-region-names") != 2 ||
of_property_count_u64_elems(np, "apple,firmware-iovas") != 2 ||
!ane_fw_raw_boot())
return false;
for (i = 0; i < 2; i++) {
struct device_node *mem __free(device_node) =
of_parse_phandle(np, "memory-region", i);
const char *name;

if (!mem || !of_device_is_available(mem) ||
of_property_read_string_index(np, "memory-region-names", i, &name) ||
strcmp(name, i ? "firmware-data" : "firmware-text"))
return false;
}
return true;
}
EXPORT_SYMBOL_GPL(ane_fw_preload_handoff);

static int ane_fw_preload_check(struct device *dev,
const struct ane_fw_platform *soc)
{
Expand Down
Loading
Loading