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
4 changes: 4 additions & 0 deletions Documentation/devicetree/bindings/iommu/apple,dart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ properties:
- const: apple,t8140-ane-dart
- const: apple,t8140-dart
- const: apple,t8110-dart
- items:
- const: apple,t8142-ane-dart
- const: apple,t8142-dart
- const: apple,t8110-dart
- items:
- enum:
- apple,t6000-dart
Expand Down
15 changes: 15 additions & 0 deletions Documentation/devicetree/bindings/npu/apple,ane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ properties:
- apple,t6050-ane
- apple,t8112-ane
- apple,t8140-ane
- apple,t8142-ane
- items:
- const: apple,t6001-ane
- const: apple,ane
Expand Down Expand Up @@ -226,12 +227,23 @@ allOf:
const: 0x200
apple,dapf-ranges:
maxItems: 4
- if:
properties:
compatible:
const: apple,t8142-ane
then:
properties:
apple,ane-type:
const: 0x210
apple,dapf-ranges:
maxItems: 4
- if:
properties:
compatible:
enum:
- apple,t6050-ane
- apple,t8140-ane
- apple,t8142-ane
then:
properties:
interrupts:
Expand Down Expand Up @@ -266,6 +278,7 @@ allOf:
- apple,t6041-ane
- apple,t6050-ane
- apple,t8140-ane
- apple,t8142-ane
required:
- memory-region
then:
Expand Down Expand Up @@ -339,6 +352,7 @@ allOf:
- apple,t8140-ane
- apple,t6041-ane
- apple,t6050-ane
- apple,t8142-ane
then:
properties:
interrupt-names: false
Expand Down Expand Up @@ -440,6 +454,7 @@ allOf:
- apple,t6041-ane
- apple,t6050-ane
- apple,t6001-ane
- apple,t8142-ane
else:
properties:
power-domains:
Expand Down
24 changes: 24 additions & 0 deletions arch/arm64/boot/dts/apple/t8142-j815.dts
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,27 @@
&ave {
status = "okay";
};

/*
* The Neural Engine. It stays off until the first request: the firmware is
* started then, from the preload, and system sleep cycles it cold.
*/
&ps_ane_sys {
status = "okay";
};

&ane_dart0 {
status = "okay";
};

&ane_dart1 {
status = "okay";
};

&ane_dart2 {
status = "okay";
};

&ane {
status = "okay";
};
77 changes: 77 additions & 0 deletions arch/arm64/boot/dts/apple/t8142-peripherals.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,73 @@
status = "disabled";
};

/*
* The Neural Engine's three DARTs (ADT dart-ane, one interrupt for all):
* revision 0x204, 16 streams; SIDs 1-7 are the exclave's and 10/13
* bypass. The cold profile leaves every inherited stream alone and
* gives the kernel only SID0.
*/
ane_dart0: iommu@421800000 {
compatible = "apple,t8142-ane-dart", "apple,t8142-dart",
"apple,t8110-dart";
reg = <0x4 0x21800000 0x0 0xc000>;
#iommu-cells = <1>;
interrupts = <AIC_IRQ 752 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_ane_sys>;
/* The firmware DVAs reach 0x100_xxxx_xxxx. */
apple,dma-range = <0x0 0x0 0x400 0x0>;
status = "disabled";
};

ane_dart1: iommu@421820000 {
compatible = "apple,t8142-ane-dart", "apple,t8142-dart",
"apple,t8110-dart";
reg = <0x4 0x21820000 0x0 0xc000>;
#iommu-cells = <1>;
interrupts = <AIC_IRQ 752 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_ane_sys>;
apple,dma-range = <0x0 0x0 0x400 0x0>;
status = "disabled";
};

ane_dart2: iommu@421840000 {
compatible = "apple,t8142-ane-dart", "apple,t8142-dart",
"apple,t8110-dart";
reg = <0x4 0x21840000 0x0 0xc000>;
#iommu-cells = <1>;
interrupts = <AIC_IRQ 752 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_ane_sys>;
apple,dma-range = <0x0 0x0 0x400 0x0>;
status = "disabled";
};

/*
* The Neural Engine (ADT /arm-io/ane, "ane,t8132exclave", ane-type 0x210):
* the H17 engine, exclave-assigned, with firmware that iBoot preloads; the
* boot loader hands the preload over as firmware-text and firmware-data.
* PWGATE is the ADT's reg[2] (PMGR +0x24000) + 0x3640, measured under
* macOS 27.2.1.
*/
ane: ane@420000000 {
compatible = "apple,t8142-ane";
reg = <0x4 0x20000000 0x0 0x2000000>,
<0x3 0x80700000 0x0 0x18000>,
<0x3 0x80727640 0x0 0x34>;
reg-names = "engine", "pmgr", "pwgate";
interrupts = <AIC_IRQ 751 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 764 IRQ_TYPE_LEVEL_HIGH>;
iommus = <&ane_dart0 0>, <&ane_dart1 0>, <&ane_dart2 0>;
power-domains = <&ps_ane_sys>;
apple,firmware-preloaded;
apple,firmware-iovas = /bits/ 64 <0x10000000000 0x100000c0000>;
/* Inclusive SID0 identity windows from the ADT's dart-ane dapf-instance-0. */
apple,dapf-ranges = /bits/ 64 <0x4a1668000 0x4a1668003
0x3807002e8 0x3807002eb
0x38070c008 0x38070c00b
0x582668000 0x582668003>;
status = "disabled";
};

scaler0_dart: iommu@305260000 {
compatible = "apple,t8142-dart", "apple,t8110-dart";
reg = <0x3 0x5260000 0x0 0x20000>;
Expand Down Expand Up @@ -462,6 +529,16 @@
};

&pmgr {
/* ADT pmgr device ANE_SYS (id 73), parent AFISOCNI3 (no power state). */
ps_ane_sys: power-controller@2e8 {
compatible = "apple,t8142-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate";
reg = <0x2e8 4>;
#power-domain-cells = <0>;
#reset-cells = <0>;
label = "ane_sys";
status = "disabled";
};

ps_msr: power-controller@2a8 {
compatible = "apple,t8142-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate";
reg = <0x2a8 4>;
Expand Down
17 changes: 14 additions & 3 deletions drivers/accel/ane/ane_fw_cold.c
Original file line number Diff line number Diff line change
Expand Up @@ -2142,13 +2142,18 @@ static bool ane_fw_handoff_present(struct platform_device *pdev,
!strcmp(name, i ? "firmware-data" : "firmware-text") &&
!ane_fw_preload_range(np, i, &h.phys[i], &h.size[i]);
}
if (h.regions_ok && ane_fw_preload_ranges_valid(soc, h.phys, h.size, h.dva)) {
/*
* Hash what the loader handed over even when its layout is not this
* SoC's, so that one boot of a new firmware or SoC reports both.
*/
if (h.regions_ok) {
void *text = memremap(h.phys[0], h.size[0], MEMREMAP_WB);

if (text) {
sha256(text, h.size[0], digest);
memunmap(text);
h.text_ok = !memcmp(digest, soc->text_pin, sizeof(digest));
h.text_ok = ane_fw_preload_ranges_valid(soc, h.phys, h.size, h.dva) &&
!memcmp(digest, soc->text_pin, sizeof(digest));
}
}
*hp = h;
Expand All @@ -2158,9 +2163,15 @@ static bool ane_fw_handoff_present(struct platform_device *pdev,
!h.marker || strcmp(h.marker, ANE_FW_COLD_BOOT_EVIDENCE) ? "raw-boot marker" :
!h.preloaded || !h.regions_ok ? "preload reservations" :
!h.text_ok ? "firmware TEXT pin" : "preload layout");
if (h.regions_ok && !h.text_ok)
if (h.regions_ok && !h.text_ok) {
dev_info(&pdev->dev, "H17 ANE: preloaded TEXT sha256 %*phN\n",
(int)sizeof(digest), digest);
dev_info(&pdev->dev,
"H17 ANE: preload TEXT %#llx+%#llx @%#llx, DATA %#llx+%#llx @%#llx (%s)\n",
h.phys[0], h.size[0], h.dva[0], h.phys[1], h.size[1], h.dva[1],
ane_fw_preload_ranges_valid(soc, h.phys, h.size, h.dva) ?
"layout as expected" : "layout differs");
}
return false;
}

Expand Down
60 changes: 60 additions & 0 deletions drivers/accel/ane/ane_fw_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/platform_device.h>
#include <crypto/sha2.h>

#include "ane_fw_cold.h"
#include "ane_fw_platform.h"
Expand Down Expand Up @@ -177,6 +178,65 @@ const struct ane_fw_platform ane_t6050_platform = {
.text_pin = ane_t6050_text_pin_27_0,
};

/*
* The M5 (T8142, J813/J815) ANE: "ane,t8132exclave", ane-type 0x210,
* exclave-assigned and preloaded by iBoot. From the T8142 ADT: ANE_SYS at
* PMGR +0x2e8 (pmgr device 73, parent AFISOCNI3), ANE_CPU +0xc000 and
* ANE_TDBASE +0xc008 as on T8140; four DAPF records. The macOS 27.0 (26A428)
* stub's iBoot preloads TEXT 0xc0000 and DATA 0x2ac000 at T8140's IOVAs,
* measured on a J815 under aura with TEXT sha256 1212c260...b6d4e3 (the 27.2
* host's preload is 0xbc000/0x2b0000 at 0x100_000b_c000).
*
* Measured under aura's hypervisor on a J815 running macOS 27.2.1 (cold
* model load, power-up and power-down traced): the PWGATE window at PMGR
* +0x27640 (request +0xc, acknowledge +0x30, as on T8140), the scratch
* cells from +0x1880028 (as on T6050), DART revision 0x204 (PARAMS_8
* 0x2a2a0204) and the four DAPF records. macOS powers the engine down in
* T8140's order: sub-block, PWGATE request 3, acknowledge 0, CPU, then
* ANE_SYS. So sleep and the parked start follow T8140.
*/
static const u8 ane_t8142_text_26a428[] = {
0x12, 0x12, 0xc2, 0x60, 0x6e, 0xf8, 0xca, 0xce,
0x51, 0xfd, 0x95, 0x1e, 0x60, 0xbc, 0xce, 0x75,
0xbe, 0x8e, 0x65, 0xd5, 0xf0, 0xfe, 0x19, 0x37,
0xac, 0x3b, 0x58, 0x07, 0x49, 0xd6, 0xb4, 0xe3,
};

const struct ane_fw_platform ane_t8142_platform = {
.soc = 0x8142,
.chip_family = 17,
.ane_type = 0x210,
.hwx_subtype = 9,
.task_generation = 19,
.interrupt_count = 2,
.owner = ANE_FW_OWNER_EXCLAVE,
.reg_names = ane_h17_reg_names,
.reg_sizes = ane_h17_reg_sizes,
.reg_count = ARRAY_SIZE(ane_h17_reg_names),
.wrapper = 0x1600000,
.mailbox = 0x1608000,
.scratch = 0x1880028,
.doorbell = 0x1884000,
.irq_status = 0x188c000,
.irq_ack = 0x1890000,
.preload_dva = { 0x10000000000, 0x100000c0000 },
.preload_size = { 0xc0000, 0x2ac000 },
.stream_mask = BIT(0),
.firmware_preloaded = true,
.safe_reset = false,
/* Exclave mode at boot, cold sleep cycle and parked start, as on T8140. */
.exclave_mode_stop = true,
.macos_sleep = true,
.sleep_warm = false,
.pmgr_sys = 0x2e8,
.pmgr_cpu = 0xc000,
.pmgr_subblock = 0xc008,
.dart_compatible = "apple,t8142-ane-dart",
.dart_revision = 0x204,
.dapf_count = 4,
.text_pin = ane_t8142_text_26a428,
};

/*
* The iBoot preload is firmware memory. Accept it only as a no-map child of
* /reserved-memory that Linux does not manage as System RAM, whether the
Expand Down
3 changes: 2 additions & 1 deletion drivers/accel/ane/ane_fw_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ ane_fw_sleep_path(const struct ane_fw_platform *platform)
return platform ? ANE_SLEEP_FW_BACKEND : ANE_SLEEP_RTCLIENT;
}

extern const struct ane_fw_platform ane_h16_platform, ane_h17_platform, ane_t6050_platform;
extern const struct ane_fw_platform ane_h16_platform, ane_h17_platform, ane_t6050_platform,
ane_t8142_platform;
int ane_fw_platform_preflight(struct platform_device *pdev,
const struct ane_fw_platform *soc);

Expand Down
5 changes: 5 additions & 0 deletions drivers/accel/ane/ane_t6021_rtclient_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4422,6 +4422,10 @@ static const struct ane_t602x_soc ane_t6050_soc = {
.platform = &ane_t6050_platform,
};

static const struct ane_t602x_soc ane_t8142_soc = {
.platform = &ane_t8142_platform,
};

static const struct of_device_id ane_rtclient_of_match[] = {
{ .compatible = "apple,t6020-ane", .data = &ane_t6020_soc },
{ .compatible = "apple,t6021-ane", .data = &ane_t6021_soc },
Expand All @@ -4430,6 +4434,7 @@ static const struct of_device_id ane_rtclient_of_match[] = {
{ .compatible = "apple,t6041-ane", .data = &ane_h16_soc },
{ .compatible = "apple,t8140-ane", .data = &ane_h17_soc },
{ .compatible = "apple,t6050-ane", .data = &ane_t6050_soc },
{ .compatible = "apple,t8142-ane", .data = &ane_t8142_soc },
{ }
};
MODULE_DEVICE_TABLE(of, ane_rtclient_of_match);
Expand Down
9 changes: 7 additions & 2 deletions drivers/iommu/apple-dart.c
Original file line number Diff line number Diff line change
Expand Up @@ -5172,7 +5172,8 @@ static int apple_dart_probe(struct platform_device *pdev)
dart->dev = dev;
dart->hw = of_device_get_match_data(dev);
dart->tunneled = tunneled;
dart->cold_ane = of_device_is_compatible(dev->of_node, "apple,t8140-ane-dart");
dart->cold_ane = of_device_is_compatible(dev->of_node, "apple,t8140-ane-dart") ||
of_device_is_compatible(dev->of_node, "apple,t8142-ane-dart");
if (dart->cold_ane && !IS_BUILTIN(CONFIG_APPLE_DART))
return -EOPNOTSUPP;
dart->isp_host = of_device_is_compatible(dev->of_node, "apple,t6050-isp-dart");
Expand Down Expand Up @@ -5643,8 +5644,12 @@ static int apple_dart_probe(struct platform_device *pdev)
/* No reset, TCR/TTBR clear, global enable, remap or IRQ ACK.
* Cold acquisition is checked by the staged ANE backend before
* it attaches a private SID0 domain. Even bypass SIDs stay intact.
* T8140's ANE DARTs are revision 0x203, T8142's 0x204.
*/
if (dart->locked || dart->version != 0x203 || dart->num_streams != 16 ||
u32 cold_version = of_device_is_compatible(dev->of_node, "apple,t8142-ane-dart") ?
0x204 : 0x203;

if (dart->locked || dart->version != cold_version || dart->num_streams != 16 ||
!bitmap_empty(dart->remapped, DART_MAX_STREAMS)) {
ret = -EPERM;
goto err_clk_disable;
Expand Down
Loading