From cd6ca692864a0691518b9efa9f81f3aa74457a21 Mon Sep 17 00:00:00 2001 From: ricktav <82380971+ricktav@users.noreply.github.com> Date: Thu, 19 Nov 2026 13:08:06 +0100 Subject: [PATCH 1/4] kernel: ANS1 storage driver for A7-A8X Add Nick Chan's ANS1 (asp) block driver from Hoolock, the mailbox match it needs and a small opt-in RTKit hook, as a module in both configs: - CONFIG_APPLE_ASP=m: the iPad Air 2 (J81, A8X) keeps its internal storage behind ANS1; the platform initrd loads it to find the root. apple-16k builds it too, as both configs carry the same options. - RTKit gains an epmap_done callback (only drivers that set it see a change) and decodes armv7 crash logs. Hoolock's RTKit 10.0 support is left out: the J81's ANS speaks RTKit 12.0 and does not need it, and it would change behaviour for other RTKit firmware. Each patch names its Hoolock origin and what changed on the way (hardening from mattonik/ipad-nixos and micro23/ipadair2-omarchy; no read-only default or LBA write window). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01SFMaVe993UGYsK61nbtYhR --- kernel/configs/apple-16k/config | 1 + kernel/configs/apple-4k/config | 1 + ...k-Add-the-Apple-ANS1-storage-control.patch | 84 + ...er-for-the-Apple-ANS1-storage-contro.patch | 1394 +++++++++++++++++ ...box-apple-mailbox-Add-the-A7-A8X-ANS.patch | 53 + ...mailbox-Match-the-A7-A8X-ANS-mailbox.patch | 31 + ...Let-a-driver-start-app-endpoints-at-.patch | 297 ++++ 7 files changed, 1861 insertions(+) create mode 100644 kernel/patches/drivers/block/0001-dt-bindings-block-Add-the-Apple-ANS1-storage-control.patch create mode 100644 kernel/patches/drivers/block/0002-block-Add-a-driver-for-the-Apple-ANS1-storage-contro.patch create mode 100644 kernel/patches/drivers/soc-apple/0025-dt-bindings-mailbox-apple-mailbox-Add-the-A7-A8X-ANS.patch create mode 100644 kernel/patches/drivers/soc-apple/0026-soc-apple-mailbox-Match-the-A7-A8X-ANS-mailbox.patch create mode 100644 kernel/patches/drivers/soc-apple/0027-soc-apple-rtkit-Let-a-driver-start-app-endpoints-at-.patch diff --git a/kernel/configs/apple-16k/config b/kernel/configs/apple-16k/config index da25c45f..7c9011d1 100644 --- a/kernel/configs/apple-16k/config +++ b/kernel/configs/apple-16k/config @@ -1790,6 +1790,7 @@ CONFIG_OF_OVERLAY=y # CONFIG_PARPORT is not set CONFIG_BLK_DEV=y # CONFIG_BLK_DEV_NULL_BLK is not set +CONFIG_APPLE_ASP=m # CONFIG_BLK_DEV_PCIESSD_MTIP32XX is not set CONFIG_ZRAM=y # CONFIG_ZRAM_BACKEND_LZ4 is not set diff --git a/kernel/configs/apple-4k/config b/kernel/configs/apple-4k/config index 08fa8524..e738fed1 100644 --- a/kernel/configs/apple-4k/config +++ b/kernel/configs/apple-4k/config @@ -1791,6 +1791,7 @@ CONFIG_OF_OVERLAY=y # CONFIG_PARPORT is not set CONFIG_BLK_DEV=y # CONFIG_BLK_DEV_NULL_BLK is not set +CONFIG_APPLE_ASP=m # CONFIG_BLK_DEV_PCIESSD_MTIP32XX is not set CONFIG_ZRAM=y # CONFIG_ZRAM_BACKEND_LZ4 is not set diff --git a/kernel/patches/drivers/block/0001-dt-bindings-block-Add-the-Apple-ANS1-storage-control.patch b/kernel/patches/drivers/block/0001-dt-bindings-block-Add-the-Apple-ANS1-storage-control.patch new file mode 100644 index 00000000..3f0e36db --- /dev/null +++ b/kernel/patches/drivers/block/0001-dt-bindings-block-Add-the-Apple-ANS1-storage-control.patch @@ -0,0 +1,84 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Nick Chan +Date: Thu, 19 Nov 2026 13:15:01 +0100 +Subject: [PATCH] dt-bindings: block: Add the Apple ANS1 storage controller + +[Orchard: from HoolockLinux/linux ans1 ed8528f f9eb00ee2a47.] +Signed-off-by: Nick Chan +Signed-off-by: ricktav <82380971+ricktav@users.noreply.github.com> +Co-Authored-By: Claude Opus 5.5 +--- + .../bindings/block/apple,s5l8960x-ans.yaml | 64 +++++++++++++++++++ + 1 file changed, 64 insertions(+) + create mode 100644 Documentation/devicetree/bindings/block/apple,s5l8960x-ans.yaml + +diff --git a/Documentation/devicetree/bindings/block/apple,s5l8960x-ans.yaml b/Documentation/devicetree/bindings/block/apple,s5l8960x-ans.yaml +new file mode 100644 +index 000000000..4fb0acf40 +--- /dev/null ++++ b/Documentation/devicetree/bindings/block/apple,s5l8960x-ans.yaml +@@ -0,0 +1,64 @@ ++# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause ++%YAML 1.2 ++--- ++$id: http://devicetree.org/schemas/block/apple,s5l8960x-ans.yaml# ++$schema: http://devicetree.org/meta-schemas/core.yaml# ++ ++title: Apple ANS1 storage controller ++ ++maintainers: ++ - Nick Chan ++ ++properties: ++ compatible: ++ oneOf: ++ - const: apple,s5l8960x-ans ++ - items: ++ - enum: ++ - apple,t7000-ans ++ - apple,t7001-ans ++ - const: apple,s5l8960x-ans ++ ++ reg: ++ maxItems: 1 ++ description: AKF co-processor control registers ++ ++ power-domains: ++ maxItems: 1 ++ description: ANS1 CPU and mailbox power domain ++ ++ mboxes: ++ maxItems: 1 ++ description: Mailbox of the ANS1 co-processor ++ ++ resets: ++ maxItems: 1 ++ ++ memory-region: ++ maxItems: 1 ++ description: Region containing ANS1 firmware ++ ++ memory-region-names: ++ const: firmware ++ ++required: ++ - compatible ++ - reg ++ - power-domains ++ - mboxes ++ - resets ++ ++additionalProperties: false ++ ++examples: ++ - | ++ #include ++ #include ++ ++ block@8040000 { ++ compatible = "apple,t7000-ans", "apple,s5l8960x-ans"; ++ reg = <0x8040000 0x40000>; ++ mboxes = <&ans_mbox>; ++ power-domains = <&ps_ans>; ++ resets = <&ps_ans>; ++ }; diff --git a/kernel/patches/drivers/block/0002-block-Add-a-driver-for-the-Apple-ANS1-storage-contro.patch b/kernel/patches/drivers/block/0002-block-Add-a-driver-for-the-Apple-ANS1-storage-contro.patch new file mode 100644 index 00000000..e1b3eb0f --- /dev/null +++ b/kernel/patches/drivers/block/0002-block-Add-a-driver-for-the-Apple-ANS1-storage-contro.patch @@ -0,0 +1,1394 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Nick Chan +Date: Thu, 19 Nov 2026 13:15:01 +0100 +Subject: [PATCH] block: Add a driver for the Apple ANS1 storage controller + +The A7, A8 and A8X keep their internal flash behind ANS1, an RTKit +coprocessor with its own command protocol (not NVMe). The driver exposes +the user area as aspn1 and the controller's auxiliary namespaces +(firmware, NVRAM, ...) as read-only disks. + +[Orchard: from HoolockLinux/linux ans1 ed8528f (3b237c39df79, 7d02ab33cbdf, 4b2287d6c792, +f0530ce5636c, ed8528f482a5), with the hardening from mattonik/ipad-nixos +b94d42f and micro23/ipadair2-omarchy 7ea2b2b: BUG() on internal +inconsistencies became WARN() plus an I/O error, the scatter list bound +is checked before each entry is written, flush commands are cleared and +tagged, admin output is refused and writes or flushes to the auxiliary +namespaces are refused; the unused enable_reformat parameter is gone. +Their read-only default and LBA write window are not carried: the user +area is writable, as on the NVMe iPads. +The storage endpoint is fixed at 0x20 (RTKit 11 and later) instead of +derived from the RTKit 10 protocol version.] +Signed-off-by: Nick Chan +Signed-off-by: ricktav <82380971+ricktav@users.noreply.github.com> +Co-Authored-By: Claude Opus 5.5 +--- + drivers/block/Kconfig | 11 + + drivers/block/Makefile | 1 + + drivers/block/asp.c | 1323 ++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 1335 insertions(+) + create mode 100644 drivers/block/asp.c + +diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig +index 858320b6e..27abb78c1 100644 +--- a/drivers/block/Kconfig ++++ b/drivers/block/Kconfig +@@ -58,6 +58,17 @@ config ATARI_FLOPPY + tristate "Atari floppy support" + depends on ATARI + ++config APPLE_ASP ++ tristate "Support for Apple ANS1 Storage Processor" ++ depends on APPLE_RTKIT && (ARCH_APPLE || COMPILE_TEST) ++ help ++ The ASP controller is found on devices with Apple A7, A8, A8X ++ SoCs. Say Y here to enable support for internal storage on ++ Apple devices with these SoCs. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called asp. ++ + config MAC_FLOPPY + tristate "Support for PowerMac floppy" + depends on PPC_PMAC && !PPC_PMAC64 +diff --git a/drivers/block/Makefile b/drivers/block/Makefile +index 2d8096eb8..1fb9a2168 100644 +--- a/drivers/block/Makefile ++++ b/drivers/block/Makefile +@@ -15,6 +15,7 @@ obj-$(CONFIG_BLK_DEV_FD) += floppy.o + obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o + obj-$(CONFIG_PS3_DISK) += ps3disk.o + obj-$(CONFIG_PS3_VRAM) += ps3vram.o ++obj-$(CONFIG_APPLE_ASP) += asp.o + obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o + obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o + obj-$(CONFIG_N64CART) += n64cart.o +diff --git a/drivers/block/asp.c b/drivers/block/asp.c +new file mode 100644 +index 000000000..ae1cc80ec +--- /dev/null ++++ b/drivers/block/asp.c +@@ -0,0 +1,1323 @@ ++/* SPDX-License-Identifier: GPL-2.0 OR MIT */ ++/* ++ * Apple ANS1 Storage Processor Driver ++ * ++ * Copyright (c) 2026 Nick Chan ++ */ ++ ++#define DEBUG 1 ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define DEVICE_NAME "asp" ++#define ASP_RTKIT_ENDPOINT 0x20 ++#define DISK_NAME "asp%dn%d" ++ ++#define AKF_V1_REMAP_AP_LO 0x8 ++#define AKF_V1_REMAP_AP_HI 0xc ++#define AKF_V1_REMAP_IOP_LO 0x10 ++#define AKF_V1_REMAP_IOP_HI 0x14 ++#define AKF_V1_REMAP_SZ_LO 0x18 ++#define AKF_V1_REMAP_SZ_HI 0x1c ++#define AKF_V1_ENDIANNESS 0x20 ++ ++#define AKF_V1_LITTLE_ENDIAN BIT(0) ++ ++#define AKF_V1_CPU_CONTROL 0x28 ++#define AKF_V1_CPU_CONTROL_START BIT(4) ++ ++/* ++ * The command buffer must be less than 262144 bytes, and must be alinged ++ * to cacheline. Dividing equally yields 16320 bytes per tag. ++ */ ++#define ASP_TAG_SIZE 16320 ++#define ASP_NUM_TAGS 16 ++#define ASP_QUEUE_SIZE (ASP_TAG_SIZE * ASP_NUM_TAGS) ++ ++#define ASP_TIMEOUT_MS 30000 ++#define ASP_CMD_HDR_SIZE 0x30 ++ ++#define ASP_CMD_MAX_SECTORS (ASP_TAG_SIZE - ASP_CMD_HDR_SIZE) \ ++ / sizeof(uint32_t) ++ ++/* ++ * All ASP instances seen uses 4096 bytes sector size. Since this hardware is ++ * already replaced by NVMe, it is unlikely any other sector sizes will be ++ * used in practice. ++ */ ++#define ASP_LBA_SHIFT 12 ++#define ASP_LBA_SIZE BIT(ASP_LBA_SHIFT) ++ ++/* ASP Commands */ ++#define ASP_CMD_IDENTIFY 0x0 ++#define ASP_CMD_READ_USERAREA 0x10 ++#define ASP_CMD_WRITE_USERAREA 0x11 ++#define ASP_CMD_FLUSH 0x13 ++ ++#define ASP_CMD_FORMAT_ALL 0x15 ++#define ASP_CMD_FORMAT_USERAREA 0x16 ++#define ASP_CMD_FORMAT_CLEAR 0x18 ++ ++#define ASP_CMD_WRITE_UNLOCK 0x19 ++ ++#define ASP_CMD_OP_READ_LLB 0x30 ++#define ASP_CMD_OP_READ_FW 0x31 ++#define ASP_CMD_OP_READ_UTILDM 0x32 ++#define ASP_CMD_OP_READ_DM 0x33 ++#define ASP_CMD_OP_READ_CTRLBITS 0x34 ++#define ASP_CMD_OP_READ_EFFACE 0x35 ++#define ASP_CMD_OP_READ_NVRAM 0x36 ++#define ASP_CMD_OP_READ_SYSCFG 0x37 ++#define ASP_CMD_OP_READ_PANICLOG 0x38 ++ ++#define ASP_CMD_OP_WRITE_LLB 0x40 ++#define ASP_CMD_OP_WRITE_FW 0x41 ++#define ASP_CMD_OP_WRITE_UTILDM 0x42 ++#define ASP_CMD_OP_WRITE_DM 0x43 ++#define ASP_CMD_OP_WRITE_CTRLBITS 0x44 ++#define ASP_CMD_OP_WRITE_EFFACE 0x45 ++#define ASP_CMD_OP_WRITE_NVRAM 0x46 ++#define ASP_CMD_OP_WRITE_SYSCFG 0x47 ++#define ASP_CMD_OP_WRITE_PANICLOG 0x48 ++ ++#define ASP_CMD_OP_GET_PPN_FW_VERSION 0x79 ++#define ASP_CMD_OP_POWER_CONFIG 0x80 ++ ++/* ++ * Auxiliary Storage Sizes ++ * ++ * Hardcode the sizes as there are no way to get the size of auxiliary ++ * storage sizes from the firmware. ++ */ ++#define ASP_FW_NUM_SECTORS 1024 ++#define ASP_LLB_NUM_SECTORS 254 ++#define ASP_UTILDM_NUM_SECTORS 2 ++#define ASP_DM_NUM_SECTORS 32 ++#define ASP_CTRLBITS_NUM_SECTORS 32 ++#define ASP_EFFACE_NUM_SECTORS 32 ++#define ASP_NVRAM_NUM_SECTORS 32 ++#define ASP_SYSCFG_NUM_SECTORS 256 ++#define ASP_PANICLOG_NUM_SECTORS 256 ++ ++/* Mailbox messages */ ++#define ASP_MSG_TYPE GENMASK(3, 0) ++#define ASP_MSG_TYPE_SET_CMDBUF 0 ++#define ASP_MSG_TYPE_SET_TAG_OFF 1 ++#define ASP_MSG_TYPE_COMPLETE 2 ++#define ASP_MSG_TYPE_SUBMIT 3 ++#define ASP_MSG_TYPE_UNK4 4 ++ ++#define ASP_SET_CMDBUF_BASE GENMASK_ULL(55, 16) ++#define ASP_SET_CMDBUF_SIZE_17_6 GENMASK(15, 4) ++ ++#define ASP_SET_TAG_CMDBUF_SIZE_17_6 GENMASK_ULL(35, 24) ++#define ASP_SET_TAG_CMDBUF_OFF_17_6 GENMASK(23, 12) ++#define ASP_SET_TAG_CMDBUF_TAG GENMASK(7, 4) ++ ++#define ASP_SUBMIT_OP GENMASK(19, 12) ++#define ASP_SUBMIT_OP_RING 0xff ++#define ASP_SUBMIT_TAG GENMASK(7, 4) ++ ++/* ++ * This is wider than the submission tag, since ANS1 will send ++ * two special tags during startup: ++ * ++ * 254 - sent automatically soon after ANS endpoint is enabled, ++ * possibly ready signal ++ * ++ * 253 - reply of ASP_MSG_TYPE_SET_CMDBUF ++ */ ++#define ASP_COMPLETION_TAG GENMASK(11, 4) ++#define ASP_COMPLETION_TAG_READY 254 ++#define ASP_COMPLETION_TAG_CMDBUF_OK 253 ++ ++#define ASP_COMPLETION_STATUS GENMASK(15, 12) ++#define ASP_COMPLETION_STATUS_OK 0 ++#define ASP_COMPLETION_STATUS_IGNORED 1 /* not exist command */ ++#define ASP_COMPLETION_STATUS_ABORT 2 ++#define ASP_COMPLETION_STATUS_INIT 0xa /* Seen with the special tags */ ++ ++/* ++ * Without this flag the operation would still take place but instead of ++ * the intended data garbage corresponding to the input data in 128-bit ++ * block sizes would be used, so likely encryption. ++ */ ++#define ASP_CMD_IO_FLAG_NO_ENCRYPTION BIT(3) ++ ++/* ++ * this enum is used to generate hardware operations, so do not change the order ++ * of items. ++ */ ++enum asp_queue_type { ++ ASP_QUEUE_TYPE_ADMIN = 0, ++ ASP_QUEUE_TYPE_USERAREA, ++ ASP_QUEUE_TYPE_LLB, ++ ASP_QUEUE_TYPE_FW, ++ ASP_QUEUE_TYPE_UTILDM, ++ ASP_QUEUE_TYPE_DM, ++ ASP_QUEUE_TYPE_CTRLBITS, ++ ASP_QUEUE_TYPE_EFFACE, ++ ASP_QUEUE_TYPE_NVRAM, ++ ASP_QUEUE_TYPE_SYSCFG, ++ ASP_QUEUE_TYPE_PANICLOG, ++ ASP_QUEUE_TYPE_COUNT ++}; ++ ++struct asp_identify { ++ u32 num_lba_formatted; ++ u32 lba_size; ++ u8 unk1[8]; ++ bool util_formatted; ++ u8 unk2[7]; ++ u32 num_lba_raw; ++ u8 unk3[20]; ++ u8 chip_id_bus0[6]; ++ u8 chip_id_bus1[6]; ++ u8 manufacturer_id_bus0[6]; ++ u8 manufacturer_id_bus1[6]; ++}__attribute__((packed)); ++ ++struct asp_ppn_fw { ++ u32 fw_ver_len; ++ char fw_ver[0x10][2]; ++}__attribute__((packed)); ++ ++struct asp_rw { ++ u32 sglist[ASP_CMD_MAX_SECTORS]; ++}; ++ ++struct asp_cmd_hdr { ++ u8 op; ++ u8 tag; ++ u16 flags; ++ u32 slba; ++ u32 length; ++ u8 pad[0x24]; ++}__attribute__((packed)); ++ ++struct asp_queue { ++ enum asp_queue_type type; ++ struct gendisk *disk; ++}; ++ ++struct apple_asp { ++ void *__iomem akf_base; ++ sector_t capacity; ++ struct device *dev; ++ struct apple_rtkit *rtk; ++ struct completion init_done; ++ int init_ret; ++ int instance; ++ void *q; ++ struct request_queue *admin_rq; ++ struct blk_mq_tag_set tagset; ++ union { ++ struct asp_queue qd_head; /* for container_of() */ ++ struct asp_queue q_data[ASP_QUEUE_TYPE_COUNT]; ++ }; ++ dma_addr_t q_iova; ++ mempool_t *iod_mempool; ++ u32 lba_size; ++ u8 ep; ++}; ++ ++struct asp_iod { ++ struct asp_cmd_hdr cmd; ++ int nr_mapped; ++ struct scatterlist *sg; ++ int nents; ++ void *buffer; ++ size_t buf_len; ++ u8 status; ++}; ++ ++//static int asp_major; ++static DEFINE_IDA(asp_instance_ida); ++ ++/* ++ * The information about unknown commands in this function is derived by ++ * attempting command execution when the write lock is still armed. ++ */ ++static bool asp_is_write(struct asp_cmd_hdr *cmd) ++{ ++ switch (cmd->op) { ++ case ASP_CMD_IDENTIFY: ++ case ASP_CMD_READ_USERAREA: ++ case ASP_CMD_FLUSH: ++ return false; ++ case ASP_CMD_WRITE_USERAREA: ++ case ASP_CMD_FORMAT_ALL: ++ case ASP_CMD_FORMAT_USERAREA: ++ case ASP_CMD_FORMAT_CLEAR: ++ return true; ++ case ASP_CMD_WRITE_UNLOCK: ++ return false; ++ case ASP_CMD_OP_READ_LLB: ++ case ASP_CMD_OP_READ_FW: ++ case ASP_CMD_OP_READ_UTILDM: ++ case ASP_CMD_OP_READ_DM: ++ case ASP_CMD_OP_READ_CTRLBITS: ++ case ASP_CMD_OP_READ_EFFACE: ++ case ASP_CMD_OP_READ_NVRAM: ++ case ASP_CMD_OP_READ_SYSCFG: ++ case ASP_CMD_OP_READ_PANICLOG: ++ return false; ++ case ASP_CMD_OP_WRITE_LLB: ++ case ASP_CMD_OP_WRITE_FW: ++ case ASP_CMD_OP_WRITE_UTILDM: ++ case ASP_CMD_OP_WRITE_DM: ++ case ASP_CMD_OP_WRITE_CTRLBITS: ++ case ASP_CMD_OP_WRITE_EFFACE: ++ case ASP_CMD_OP_WRITE_NVRAM: ++ case ASP_CMD_OP_WRITE_SYSCFG: ++ case ASP_CMD_OP_WRITE_PANICLOG: ++ return true; ++ case 0x50: ++ case 0x51: ++ case 0x52: ++ return true; ++ case 0x72: ++ case 0x73: ++ case 0x74: ++ case 0x75: ++ case 0x76: ++ case 0x77: ++ case 0x78: ++ case ASP_CMD_OP_GET_PPN_FW_VERSION: ++ return false; ++ case 0x7a: ++ return true; ++ case 0x7b: ++ case 0x7c: ++ case 0x7d: ++ case 0x7e: ++ case 0x7f: ++ case 0x80: ++ case 0x81: ++ case 0x82: ++ case 0x90: ++ return false; ++ case 0x91: ++ return true; ++ case 0xa0: ++ case 0xa1: ++ return false; ++ default: ++ /* ++ * an unrecognized admin ++ * opcode reaching here is an internal-consistency bug ++ * (this driver only ever constructs opcodes from its ++ * own known set), not something a crash improves. ++ * Conservatively classify it as a write -- callers ++ * only use this to decide REQ_OP_DRV_OUT vs _IN, and ++ * asp_setup_cmd() rejects REQ_OP_DRV_OUT, so the safe ++ * direction to guess wrong in is "write." ++ */ ++ WARN_ON(1); ++ return true; ++ }; ++} ++ ++static enum req_op asp_req_op(struct asp_cmd_hdr *cmd) ++{ ++ return asp_is_write(cmd) ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN; ++} ++ ++static int apple_asp_init_hctx(struct blk_mq_hw_ctx *hctx, void *data, ++ unsigned int hctx_idx) ++{ ++ hctx->driver_data = data; ++ ++ return 0; ++} ++ ++static struct apple_asp *queue_to_apple_asp(struct asp_queue *aq) ++{ ++ return container_of(aq - aq->type, struct apple_asp, qd_head); ++} ++ ++static void *asp_q_cmd_hdr(struct apple_asp *asp, struct asp_cmd_hdr *cmd) ++{ ++ return asp->q + (cmd->tag * ASP_TAG_SIZE); ++} ++ ++static void *asp_q_cmd_data(struct apple_asp *asp, struct asp_cmd_hdr *cmd) ++{ ++ return asp->q + (cmd->tag * ASP_TAG_SIZE) + ASP_CMD_HDR_SIZE; ++} ++ ++static blk_status_t asp_setup_rw(struct asp_queue *qd, struct request *req, ++ bool write) ++{ ++ struct asp_iod *iod = blk_mq_rq_to_pdu(req); ++ struct asp_cmd_hdr *cmd = &iod->cmd; ++ struct apple_asp *asp = queue_to_apple_asp(qd); ++ struct req_iterator iter; ++ struct bio_vec bvec; ++ ++ switch (qd->type) { ++ case ASP_QUEUE_TYPE_ADMIN: ++ /* ++ * admin requests never ++ * reach the rw setup path in normal operation ++ * (asp_setup_cmd() only calls this for REQ_OP_READ/ ++ * WRITE), so this is an internal-consistency bug, ++ * not a crash-worthy one. ++ */ ++ WARN_ON(1); ++ return BLK_STS_IOERR; ++ case ASP_QUEUE_TYPE_USERAREA: ++ cmd->op = 0x10 | write; ++ break; ++ case ASP_QUEUE_TYPE_LLB: ++ case ASP_QUEUE_TYPE_FW: ++ case ASP_QUEUE_TYPE_UTILDM: ++ case ASP_QUEUE_TYPE_DM: ++ case ASP_QUEUE_TYPE_CTRLBITS: ++ case ASP_QUEUE_TYPE_EFFACE: ++ case ASP_QUEUE_TYPE_NVRAM: ++ case ASP_QUEUE_TYPE_SYSCFG: ++ case ASP_QUEUE_TYPE_PANICLOG: ++ cmd->op = (write ? 0x40 : 0x30) | (qd->type - 2); ++ break; ++ default: ++ /* Same reasoning: unreachable in practice, but a ++ * clean I/O error beats taking the kernel down. ++ */ ++ WARN_ON(1); ++ return BLK_STS_IOERR; ++ } ++ ++ cmd->flags = ASP_CMD_IO_FLAG_NO_ENCRYPTION; ++ cmd->slba = blk_rq_pos(req) >> 3; ++ cmd->length = blk_rq_bytes(req) >> ASP_LBA_SHIFT; ++ ++ iod->sg = mempool_alloc(asp->iod_mempool, GFP_ATOMIC); ++ if (!iod->sg) ++ return BLK_STS_RESOURCE; ++ ++ sg_init_table(iod->sg, blk_rq_nr_phys_segments(req)); ++ iod->nents = blk_rq_map_sg(req, iod->sg); ++ ++ if (!iod->nents) ++ goto out_free_sg; ++ ++ iod->nr_mapped = dma_map_sg_attrs(asp->dev, iod->sg, iod->nents, ++ rq_dma_dir(req), DMA_ATTR_NO_WARN); ++ ++ if (!iod->nr_mapped) ++ goto out_free_sg; ++ ++ //dev_dbg(asp->dev, "queue type: %d nr_mapped: %d", qd->type, iod->nr_mapped); ++ ++ if (qd->type > ASP_QUEUE_TYPE_USERAREA ++ && rq_dma_dir(req) == DMA_FROM_DEVICE) { ++ /* ++ * If reading auxiliary storage, then zero the dma memory ++ * beforehand, as the request gets truncated when trying to ++ * read "unwritten" sectors. ++ * ++ * This matches iOS' behavior except in the case where the ++ * first sector is unwritten due to an iOS bug. ++ */ ++ rq_for_each_segment(bvec, req, iter) ++ memzero_bvec(&bvec); ++ } ++ ++ return BLK_STS_OK; ++ ++out_free_sg: ++ mempool_free(iod->sg, asp->iod_mempool); ++ return BLK_STS_RESOURCE; ++} ++ ++/* ++ * The controller requires writes to auxiliary storage to start at sector 0, ++ * so do not bother with their write support for now. ++ */ ++ ++/* ++ * UTILDM, DM, CTRLBITS seems to be controller internal data and putting the ++ * wrong things in them could cause persistent firmware crashes so do not ++ * allow writes to them. ++ * ++ * The controller does not allow writing to UTILDM (maximum allowed size ++ * for writing is 0), and DM has a minimum write size requirement of ++ * 12 sectors, though this does not matter since we set it to read-only ++ * anyways. ++ */ ++ ++static blk_status_t asp_setup_cmd(struct asp_queue *qd, struct request *req) ++{ ++ blk_status_t ret; ++ struct asp_iod *iod = blk_mq_rq_to_pdu(req); ++ struct asp_cmd_hdr *cmd = &iod->cmd; ++ ++ cmd->tag = req->tag; ++ ++ /* ++ * Only the user area takes writes: the auxiliary namespaces are ++ * read-only (see apple_asp_start_disk()), and no admin output is ++ * passed through. ++ */ ++ if (req_op(req) == REQ_OP_DRV_OUT) ++ return BLK_STS_NOTSUPP; ++ if ((req_op(req) == REQ_OP_WRITE || req_op(req) == REQ_OP_FLUSH) && ++ qd->type != ASP_QUEUE_TYPE_USERAREA) ++ return BLK_STS_NOTSUPP; ++ ++ switch (req_op(req)) { ++ /* already setup */ ++ case REQ_OP_DRV_IN: ++ ret = BLK_STS_OK; ++ break; ++ ++ case REQ_OP_READ: ++ case REQ_OP_WRITE: ++ ret = asp_setup_rw(qd, req, req_op(req) == REQ_OP_WRITE); ++ break; ++ case REQ_OP_FLUSH: ++ memset(cmd, 0, sizeof(*cmd)); ++ cmd->tag = req->tag; ++ cmd->op = ASP_CMD_FLUSH; ++ ret = BLK_STS_OK; ++ break; ++ ++ default: ++ ret = BLK_STS_NOTSUPP; ++ break; ++ } ++ ++ return ret; ++} ++ ++static blk_status_t apple_asp_submit_cmd(struct apple_asp *asp, ++ struct asp_cmd_hdr *cmd) ++{ ++ int ret; ++ ++ memcpy(asp_q_cmd_hdr(asp, cmd), cmd, ASP_CMD_HDR_SIZE); ++ ++ dma_wmb(); ++ //dev_info(asp->dev, "tag: %d", cmd->tag); ++ /* ++ * the tag set is sized to ASP_NUM_TAGS ++ * (16) by this same driver, so an out-of-range tag here is an ++ * internal-consistency bug. Fail that one request rather than the ++ * whole kernel. ++ */ ++ if (WARN_ON(cmd->tag >= 16)) ++ return BLK_STS_IOERR; ++ ++ u64 rtk_msg = FIELD_PREP(ASP_MSG_TYPE, ASP_MSG_TYPE_SUBMIT) ++ | FIELD_PREP(ASP_SUBMIT_TAG, cmd->tag) ++ | FIELD_PREP(ASP_SUBMIT_OP, ASP_SUBMIT_OP_RING); ++ ++ ret = apple_rtkit_send_message(asp->rtk, asp->ep, rtk_msg, NULL, false); ++ if (ret == -ETIMEDOUT) ++ return BLK_STS_TIMEOUT; ++ else if (ret < 0) ++ return BLK_STS_IOERR; ++ ++ return BLK_STS_OK; ++} ++ ++static void asp_setup_hw_sgl(struct apple_asp *asp, struct asp_iod *iod) ++{ ++ int i, hw_idx = 0; ++ struct scatterlist *sg; ++ u32 *hw_sgl = asp_q_cmd_data(asp, &iod->cmd); ++ ++ for_each_sg(iod->sg, sg, iod->nr_mapped, i) { ++ unsigned int len = sg_dma_len(sg); ++ dma_addr_t addr = sg_dma_address(sg); ++ ++ while (len) { ++ //dev_dbg(asp->dev, "HW SGL IDX: %d addr 0x%llx len 0x%x", hw_idx, addr, len); ++ ++ /* ++ * check *before* writing, ++ * not after. The original BUG_ON(hw_idx > ++ * ASP_CMD_MAX_SECTORS) ran only once, after the loop ++ * had already finished -- by the time it fired, the ++ * out-of-bounds write into hw_sgl[] had already ++ * happened. blk-mq's own queue_limits (max_hw_sectors/ ++ * max_segments, set in apple_asp_start_disk()) should ++ * make this unreachable in practice; this is defense ++ * in depth, not a expected path. ++ */ ++ if (WARN_ON(hw_idx >= ASP_CMD_MAX_SECTORS)) ++ return; ++ ++ hw_sgl[hw_idx++] = addr >> ASP_LBA_SHIFT; ++ ++ addr += ASP_LBA_SIZE; ++ len -= ASP_LBA_SIZE; ++ } ++ ++ } ++} ++ ++static bool apple_asp_is_aux_read(struct asp_cmd_hdr *cmd) ++{ ++ switch (cmd->op) { ++ case ASP_CMD_OP_READ_LLB: ++ case ASP_CMD_OP_READ_FW: ++ case ASP_CMD_OP_READ_UTILDM: ++ case ASP_CMD_OP_READ_DM: ++ case ASP_CMD_OP_READ_CTRLBITS: ++ case ASP_CMD_OP_READ_EFFACE: ++ case ASP_CMD_OP_READ_NVRAM: ++ case ASP_CMD_OP_READ_SYSCFG: ++ case ASP_CMD_OP_READ_PANICLOG: ++ return true; ++ } ++ ++ return false; ++} ++ ++static blk_status_t apple_asp_queue_rq(struct blk_mq_hw_ctx *hctx, ++ const struct blk_mq_queue_data *bd) ++{ ++ struct asp_queue *qd = hctx->queue->queuedata; ++ struct apple_asp *asp = queue_to_apple_asp(qd); ++ struct request *req = bd->rq; ++ struct asp_iod *iod = blk_mq_rq_to_pdu(req); ++ blk_status_t ret; ++ ++ ret = asp_setup_cmd(qd, req); ++ if (ret) ++ return ret; ++ ++ if (iod->sg) ++ asp_setup_hw_sgl(asp, iod); ++ ++ blk_mq_start_request(req); ++ ++ ret = apple_asp_submit_cmd(asp, &iod->cmd); ++ if (ret) ++ return ret; ++ ++ return BLK_STS_OK; ++} ++ ++/* don't need this i think */ ++#if 0 ++static int apple_asp_init_request(struct blk_mq_tag_set *set ++ struct request *req, unsigned int hctx_idx, ++ int numa_node) ++{ ++ struct apple_asp *asp = set->driver_data; ++ struct asp_queue *qd = req->q->queuedata; ++ struct asp_iod *iod = blk_mq_rq_to_pdu(req); ++ ++ return 0; ++} ++#endif ++ ++static blk_status_t asp_submit_sync_admin_cmd(struct request_queue *q, ++ struct asp_cmd_hdr *cmd, ++ void *buffer, size_t buf_len) ++{ ++ struct request *req; ++ struct asp_iod *iod; ++ blk_status_t ret; ++ blk_mq_req_flags_t blk_flags = 0; ++ ++ if (cmd->length) ++ return -EOPNOTSUPP; ++ ++ req = blk_mq_alloc_request(q, asp_req_op(cmd), blk_flags); ++ ++ if (IS_ERR(req)) ++ return PTR_ERR(req); ++ ++ iod = blk_mq_rq_to_pdu(req); ++ ++ memcpy(&iod->cmd, cmd, ASP_CMD_HDR_SIZE); ++ iod->buffer = buffer; ++ iod->buf_len = buf_len; ++ ++ ret = blk_execute_rq(req, false); ++ blk_mq_free_request(req); ++ ++ return ret; ++} ++ ++#if 0 ++static enum blk_eh_timer_return apple_asp_timeout(struct request *req) ++{ ++ struct asp_queue *qd = req->q->queuedata; ++ struct asp_iod *iod = blk_mq_rq_to_pdu(req); ++ struct apple_asp *asp = queue_to_apple_asp(qd); ++ ++ /* soft-reset the controller since commands cannot be aborted */ ++ dev_warn(asp-dev, "I/O %d:%d timeout: resetting controller", ++ qd->type, req->tag); ++ ++ /* freeze all queues while it is resetting */ ++ blk_mq_freeze_queue(asp->admin_rq); ++ for (int i = ASP_QUEUE_TYPE_USERAREA; i < ASP_QUEUE_TYPE_COUNT; i++) ++ blk_mq_freeze_queue(asp->q_data[i].disk->queue); ++ ++ ++ if (!apple_rtkit_is_running(asp->rtk)) { ++ /* ++ * the storage firmware is loaded by previous stages, so ++ * recovery cannot be implemented. ++ */ ++ dev_err(asp->dev, "RTKit has crashed; cannot recover.") ++ return BLK_EH_DONE; ++ } ++ ++ ret = apple_rtkit_shutdown(asp->rtk) ++ if (ret < 0) { ++ dev_err(asp->dev, "Failed to shutdown RTKit: %d", ret); ++ return BLK_EH_DONE; ++ } ++ ++ /* Turn it back on */ ++ ++ blk_mq_unfreeze_queue(asp->admin_rq); ++ for (int i = ASP_QUEUE_TYPE_USERAREA; i < ASP_QUEUE_TYPE_COUNT; i++) ++ blk_mq_unfreeze_queue(asp->q_data[i].disk->queue); ++ ++ return BLK_EH_DONE; ++} ++#endif ++ ++static void apple_asp_complete_rq(struct request *rq) ++{ ++ struct asp_queue *qd = rq->q->queuedata; ++ struct asp_iod *iod = blk_mq_rq_to_pdu(rq); ++ struct apple_asp *asp = queue_to_apple_asp(qd); ++ ++ if (iod->sg) { ++ dma_unmap_sg(asp->dev, iod->sg, iod->nents, rq_dma_dir(rq)); ++ mempool_free(iod->sg, asp->iod_mempool); ++ } ++ ++ switch (iod->status) { ++ case ASP_COMPLETION_STATUS_OK: ++ blk_mq_end_request(rq, BLK_STS_OK); ++ break; ++ case ASP_COMPLETION_STATUS_IGNORED: ++ blk_mq_end_request(rq, BLK_STS_NOTSUPP); ++ break; ++ case ASP_COMPLETION_STATUS_ABORT: ++ /* ++ * When reading auxiliary storage, if the starting ++ * sector is unwritten, then the request will fail with ++ * ASP_COMPLETION_STATUS_ABORT. Consider this case a ++ * success (the zeroing is already done in ++ * asp_setup_rw()) ++ */ ++ if (apple_asp_is_aux_read(&iod->cmd)) { ++ blk_mq_end_request(rq, BLK_STS_OK); ++ break; ++ } ++ fallthrough; ++ default: ++ blk_mq_end_request(rq, BLK_STS_IOERR); ++ break; ++ } ++} ++ ++static const struct blk_mq_ops apple_asp_queue_ops = { ++ .queue_rq = apple_asp_queue_rq, ++ .complete = apple_asp_complete_rq, ++ //.init_request = apple_asp_init_request, ++ .init_hctx = apple_asp_init_hctx, ++ //.timeout = apple_asp_timeout, ++}; ++ ++/* ++ * Compute reserve memory size needed for the driver to complete a ++ * a request, even when under memory pressure, so things like swap ++ * can work ++ */ ++static inline size_t apple_asp_iod_alloc_size(void) ++{ ++ return (ASP_CMD_MAX_SECTORS * sizeof(struct scatterlist)); ++} ++ ++static const struct block_device_operations asp_fops = { ++ .owner = THIS_MODULE, ++}; ++ ++/* called when ASP is ready to receive commands */ ++static int apple_asp_start_disk(struct apple_asp *asp) ++{ ++ int ret; ++ int disk_added; ++ blk_status_t status; ++ struct asp_cmd_hdr *cmd; ++ struct asp_identify *identify; ++ ++ ret = ida_alloc(&asp_instance_ida, GFP_KERNEL); ++ if (ret < 0) ++ return ret; ++ ++ asp->instance = ret; ++ asp->iod_mempool = mempool_create_kmalloc_pool(1, ++ apple_asp_iod_alloc_size()); ++ ++ if (!asp->iod_mempool) { ++ ret = -ENOMEM; ++ goto out_free_ida; ++ } ++ ++ asp->tagset.ops = &apple_asp_queue_ops; ++ asp->tagset.nr_hw_queues = 1; ++ asp->tagset.queue_depth = ASP_NUM_TAGS; ++ asp->tagset.timeout = ASP_TIMEOUT_MS; ++ asp->tagset.numa_node = NUMA_NO_NODE; ++ asp->tagset.cmd_size = sizeof(struct asp_iod); ++ asp->tagset.driver_data = asp; ++ ++ dev_dbg(asp->dev, "allocating tag set"); ++ ret = blk_mq_alloc_tag_set(&asp->tagset); ++ ++ if (ret < 0) { ++ dev_err(asp->dev, "unable to allocate tag set"); ++ goto out_destroy_mempool; ++ } ++ ++ for (int i = 0; i < ASP_QUEUE_TYPE_COUNT; i++) ++ asp->q_data[i].type = i; ++ ++ dev_dbg(asp->dev, "allocating request queues"); ++ ++ asp->admin_rq = blk_mq_alloc_queue(&asp->tagset, NULL, &asp->q_data[0]); ++ if (IS_ERR(asp->admin_rq)) { ++ ret = dev_err_probe(asp->dev, PTR_ERR(asp->admin_rq), ++ "unable to allocate admin request queue"); ++ goto out_free_tag_set; ++ } ++ ++ // identify ++ // one queue for each namespace ++ cmd = kmalloc_obj(struct asp_cmd_hdr); ++ if (IS_ERR(cmd)) { ++ ret = -ENOMEM; ++ goto out_free_admin_rq; ++ } ++ ++ identify = kmalloc_obj(struct asp_identify); ++ if (IS_ERR(identify)) { ++ ret = -ENOMEM; ++ goto out_free_cmd; ++ } ++ ++ cmd->op = ASP_CMD_IDENTIFY; ++ cmd->flags = 0; ++ cmd->slba = 0; ++ cmd->length = 0; ++ ++ status = asp_submit_sync_admin_cmd(asp->admin_rq, cmd, identify, ++ sizeof(struct asp_identify)); ++ if (status) { ++ dev_dbg(asp->dev, "identify controller failure status: %d", ++ status); ++ ret = -EIO; ++ goto out_free_id_data; ++ } ++ ++ // TODO support auto reformat (with module arg?) ++ if (!identify->util_formatted) { ++ dev_err(asp->dev, "media not formatted"); ++ ret = -ENXIO; ++ goto out_free_id_data; ++ } ++ ++ if (identify->lba_size != ASP_LBA_SIZE) { ++ dev_err(asp->dev, "unsupported LBA size %d", ++ identify->lba_size); ++ ret = -EOPNOTSUPP; ++ goto out_free_id_data; ++ } ++ ++ dev_dbg(asp->dev, "ASP block device %llu bytes", ++ (u64)identify->num_lba_formatted * identify->lba_size); ++ ++ asp->capacity = identify->num_lba_formatted; ++ ++ kfree(identify); ++ ++ memset(cmd, 0, sizeof(*cmd)); ++ cmd->op = ASP_CMD_WRITE_UNLOCK; ++ status = asp_submit_sync_admin_cmd(asp->admin_rq, cmd, NULL, 0); ++ if (status) { ++ dev_err(asp->dev, "could not enable writes: %d", status); ++ ret = -EIO; ++ goto out_free_cmd; ++ } ++ ++ struct queue_limits lim = { ++ .logical_block_size = ASP_LBA_SIZE, ++ .max_hw_sectors = ASP_CMD_MAX_SECTORS, ++ /* only constrianted by max_hw_sectors */ ++ .max_segments = USHRT_MAX, ++ .max_segment_size = UINT_MAX, ++ .features = BLK_FEAT_WRITE_CACHE, ++ }; ++ ++ for (int i = ASP_QUEUE_TYPE_USERAREA; i < ASP_QUEUE_TYPE_COUNT; i++) { ++ struct gendisk *disk; ++ ++ asp->q_data[i].disk = blk_mq_alloc_disk(&asp->tagset, &lim, ++ &asp->q_data[i]); ++ disk = asp->q_data[i].disk; ++ ++ if (!disk) { ++ ret = -ENOMEM; ++ goto out_free_disk; ++ } ++ snprintf(disk->disk_name, sizeof(disk->disk_name), "asp%dn%d", ++ asp->instance, i); ++ ++ disk->fops = &asp_fops; ++ disk->private_data = asp; ++ } ++ ++ /* ++ * Auxiliary storage can only be written if starting LBA is zero, ++ * and certain ones has additional constriants, so don't bother ++ * with write support for them for now. ++ * ++ * Enabling writes to certain namespaces is also unsafe as putting ++ * the wrong things in some of them could cause persistent controller ++ * crashes. ++ * ++ * Eventually though it would be nie to support things like writing ++ * NVRAM, so set it to RO outside of the loop such that the statement ++ * can be removed on per-namespace basis. ++ */ ++ set_disk_ro(asp->q_data[ASP_QUEUE_TYPE_LLB].disk, true); ++ set_disk_ro(asp->q_data[ASP_QUEUE_TYPE_FW].disk, true); ++ /* write disallowed at controller level */ ++ set_disk_ro(asp->q_data[ASP_QUEUE_TYPE_UTILDM].disk, true); ++ /* unsafe to write */ ++ set_disk_ro(asp->q_data[ASP_QUEUE_TYPE_DM].disk, true); ++ /* unsafe to write */ ++ set_disk_ro(asp->q_data[ASP_QUEUE_TYPE_CTRLBITS].disk, true); ++ set_disk_ro(asp->q_data[ASP_QUEUE_TYPE_EFFACE].disk, true); ++ set_disk_ro(asp->q_data[ASP_QUEUE_TYPE_NVRAM].disk, true); ++ /* ++ * unrecoverable even with DFU, but some applications may want to ++ * write it anyways ++ */ ++ set_disk_ro(asp->q_data[ASP_QUEUE_TYPE_SYSCFG].disk, true); ++ set_disk_ro(asp->q_data[ASP_QUEUE_TYPE_PANICLOG].disk, true); ++ ++ /* no partitions on auxiliary storage */ ++ asp->q_data[ASP_QUEUE_TYPE_LLB].disk->flags = GENHD_FL_NO_PART; ++ asp->q_data[ASP_QUEUE_TYPE_FW].disk->flags = GENHD_FL_NO_PART; ++ asp->q_data[ASP_QUEUE_TYPE_UTILDM].disk->flags = GENHD_FL_NO_PART; ++ asp->q_data[ASP_QUEUE_TYPE_DM].disk->flags = GENHD_FL_NO_PART; ++ asp->q_data[ASP_QUEUE_TYPE_CTRLBITS].disk->flags = GENHD_FL_NO_PART; ++ asp->q_data[ASP_QUEUE_TYPE_EFFACE].disk->flags = GENHD_FL_NO_PART; ++ asp->q_data[ASP_QUEUE_TYPE_NVRAM].disk->flags = GENHD_FL_NO_PART; ++ asp->q_data[ASP_QUEUE_TYPE_SYSCFG].disk->flags = GENHD_FL_NO_PART; ++ asp->q_data[ASP_QUEUE_TYPE_PANICLOG].disk->flags = GENHD_FL_NO_PART; ++ ++ /* convert 4096-byte sectors to 512-byte sectors */ ++ set_capacity(asp->q_data[ASP_QUEUE_TYPE_USERAREA].disk, ++ asp->capacity << 3); ++ set_capacity(asp->q_data[ASP_QUEUE_TYPE_LLB].disk, ++ ASP_LLB_NUM_SECTORS << 3); ++ set_capacity(asp->q_data[ASP_QUEUE_TYPE_FW].disk, ++ ASP_FW_NUM_SECTORS << 3); ++ set_capacity(asp->q_data[ASP_QUEUE_TYPE_UTILDM].disk, ++ ASP_UTILDM_NUM_SECTORS << 3); ++ set_capacity(asp->q_data[ASP_QUEUE_TYPE_DM].disk, ++ ASP_DM_NUM_SECTORS << 3); ++ set_capacity(asp->q_data[ASP_QUEUE_TYPE_CTRLBITS].disk, ++ ASP_CTRLBITS_NUM_SECTORS << 3); ++ set_capacity(asp->q_data[ASP_QUEUE_TYPE_EFFACE].disk, ++ ASP_EFFACE_NUM_SECTORS << 3); ++ set_capacity(asp->q_data[ASP_QUEUE_TYPE_NVRAM].disk, ++ ASP_NVRAM_NUM_SECTORS << 3); ++ set_capacity(asp->q_data[ASP_QUEUE_TYPE_SYSCFG].disk, ++ ASP_SYSCFG_NUM_SECTORS << 3); ++ set_capacity(asp->q_data[ASP_QUEUE_TYPE_PANICLOG].disk, ++ ASP_PANICLOG_NUM_SECTORS << 3); ++ ++ for (int i = ASP_QUEUE_TYPE_USERAREA; i < ASP_QUEUE_TYPE_COUNT; i++) { ++ /* TODO: sysfs attributes for serial number etc? */ ++ ret = device_add_disk(asp->dev, asp->q_data[i].disk, NULL); ++ if (ret < 0) ++ goto out_cleanup_disk; ++ ++ disk_added = i; ++ } ++ ++ kfree(cmd); ++ return 0; ++out_cleanup_disk: ++ /* make sure only disks that were added are removed */ ++ for (int i = ASP_QUEUE_TYPE_USERAREA; i <= disk_added; i++) ++ del_gendisk(asp->q_data[i].disk); ++out_free_disk: ++ for (int i = ASP_QUEUE_TYPE_USERAREA; i < ASP_QUEUE_TYPE_COUNT; i++) { ++ if (asp->q_data[i].disk) ++ put_disk(asp->q_data[i].disk); ++ } ++out_free_id_data: ++ kfree(identify); ++out_free_cmd: ++ kfree(cmd); ++out_free_admin_rq: ++ blk_mq_destroy_queue(asp->admin_rq); ++ blk_put_queue(asp->admin_rq); ++out_free_tag_set: ++ blk_mq_free_tag_set(&asp->tagset); ++out_destroy_mempool: ++ mempool_destroy(asp->iod_mempool); ++out_free_ida: ++ ida_free(&asp_instance_ida, asp->instance); ++ return ret; ++} ++ ++static int apple_asp_setup_firmware(struct apple_asp *asp) ++{ ++ struct device_node *mem_node; ++ u64 fw_base; ++ u64 fw_size; ++ int idx; ++ ++ idx = of_property_match_string(asp->dev->of_node, ++ "memory-region-names", "firmware"); ++ ++ mem_node = of_parse_phandle(asp->dev->of_node, "memory-region", idx); ++ if (!mem_node) ++ return dev_err_probe(asp->dev, -ENODEV, ++ "No memory-region found for firmware\n"); ++ ++ if (of_property_read_reg(mem_node, 0, &fw_base, &fw_size)) ++ return dev_err_probe(asp->dev, -ENODEV, ++ "Could not read memory-region reg\n"); ++ ++ dev_dbg(asp->dev, "fw_base: 0x%llx, fw_size: 0x%llx\n", fw_base, fw_size); ++ ++ /* make firmware available to ASP */ ++ writel(fw_base & 0xffffffff, ++ asp->akf_base + AKF_V1_REMAP_AP_LO); ++ writel(fw_base >> 32, asp->akf_base + AKF_V1_REMAP_AP_HI); ++ writel(0, asp->akf_base + AKF_V1_REMAP_IOP_LO); ++ writel(0, asp->akf_base + AKF_V1_REMAP_IOP_HI); ++ writel(fw_size & 0xffffffff, ++ asp->akf_base + AKF_V1_REMAP_SZ_LO); ++ writel(fw_size >> 32, asp->akf_base + AKF_V1_REMAP_SZ_HI); ++ writel(AKF_V1_LITTLE_ENDIAN, ++ asp->akf_base + AKF_V1_ENDIANNESS); ++ ++ /* start ASP */ ++ writel(AKF_V1_CPU_CONTROL_START, ++ asp->akf_base + AKF_V1_CPU_CONTROL); ++ ++ return 0; ++} ++ ++static void apple_asp_rtkit_crashed(void *cookie, const void *crashlog, ++ size_t crashlog_size) ++{ ++ struct apple_asp *asp = cookie; ++ ++ dev_err(asp->dev, "RTKit crashed; unable to recover without a reboot"); ++ // TODO cleanup and remove disk ++} ++ ++// TODO NAND information exposed via sysfs ++ ++static void apple_asp_setup_queue(struct apple_asp *asp) ++{ ++ u64 rtk_msg; ++ ++ dev_dbg(asp->dev, "Initializing command buffer"); ++ ++ asp->q = dma_alloc_coherent(asp->dev, ASP_QUEUE_SIZE, &asp->q_iova, ++ GFP_KERNEL); ++ ++ if (!asp->q) { ++ asp->init_ret = -ENOMEM; ++ complete(&asp->init_done); ++ return; ++ } ++ ++ rtk_msg = FIELD_PREP(ASP_SET_CMDBUF_BASE, asp->q_iova) ++ | FIELD_PREP(ASP_SET_CMDBUF_SIZE_17_6, ASP_QUEUE_SIZE >> 6) ++ | FIELD_PREP(ASP_MSG_TYPE, ASP_MSG_TYPE_SET_CMDBUF); ++ ++ asp->init_ret = apple_rtkit_send_message(asp->rtk, asp->ep, rtk_msg, ++ NULL, false); ++ return; ++} ++ ++static void apple_asp_setup_tags(struct apple_asp *asp) ++{ ++ u64 rtk_msg; ++ ++ for (u8 i = 0; i < ASP_NUM_TAGS; i++) { ++ rtk_msg = FIELD_PREP(ASP_SET_TAG_CMDBUF_TAG, i) ++ | FIELD_PREP(ASP_SET_TAG_CMDBUF_SIZE_17_6, ++ ASP_TAG_SIZE >> 6) ++ | FIELD_PREP(ASP_SET_TAG_CMDBUF_OFF_17_6, ++ (ASP_TAG_SIZE * i) >> 6) ++ | FIELD_PREP(ASP_MSG_TYPE, ASP_MSG_TYPE_SET_TAG_OFF); ++ ++ asp->init_ret = apple_rtkit_send_message(asp->rtk, asp->ep, ++ rtk_msg, NULL, false); ++ if (asp->init_ret < 0) { ++ complete(&asp->init_done); ++ return; ++ } ++ } ++ complete(&asp->init_done); ++} ++ ++static void apple_asp_handle_cq(struct apple_asp *asp, u8 tag, u8 status) ++{ ++ struct request *rq; ++ struct asp_iod *iod; ++ ++ rq = blk_mq_tag_to_rq(asp->tagset.tags[0], tag); ++ if (unlikely(!rq)) { ++ dev_warn(asp->dev, "invalid tag %d completed with status %d", ++ tag, status); ++ return; ++ } ++ ++ dma_rmb(); ++ ++ iod = blk_mq_rq_to_pdu(rq); ++ iod->status = status; ++ ++ if (iod->buffer) { ++ void *cmdd = asp_q_cmd_data(asp, &iod->cmd); ++ memcpy(iod->buffer, cmdd, iod->buf_len); ++ } ++ ++ blk_mq_complete_request(rq); ++} ++ ++static void apple_asp_rtkit_recv(void *cookie, u8 endpoint, u64 message) ++{ ++ struct apple_asp *asp = cookie; ++ ++ if (endpoint != asp->ep) { ++ dev_warn(asp->dev, "Message to unknown endpoint %d", endpoint); ++ return; ++ } ++ ++ if (asp->init_ret < 0) ++ return; ++ ++ u8 type = FIELD_GET(ASP_MSG_TYPE, message); ++ ++ /* noise */ ++ if (type == ASP_MSG_TYPE_UNK4) ++ return; ++ ++ if (type != ASP_MSG_TYPE_COMPLETE) { ++ dev_warn(asp->dev, "Unhandled ASP message type %d", type); ++ return; ++ } ++ ++ u8 tag = FIELD_GET(ASP_COMPLETION_TAG, message); ++ u8 status = FIELD_GET(ASP_COMPLETION_STATUS, message); ++ ++ if (tag == ASP_COMPLETION_TAG_READY ++ || tag == ASP_COMPLETION_TAG_CMDBUF_OK) { ++ ++ if (status != ASP_COMPLETION_STATUS_INIT) { ++ dev_err(asp->dev, ++ "Unexpected init message status: %d", status); ++ asp->init_ret = -EIO; ++ return; ++ } ++ ++ if (tag == ASP_COMPLETION_TAG_READY) ++ return apple_asp_setup_queue(asp); ++ else if (tag == ASP_COMPLETION_TAG_CMDBUF_OK) ++ return apple_asp_setup_tags(asp); ++ } ++ ++ ++ if (tag >= ASP_NUM_TAGS) { ++ dev_warn(asp->dev, "ASP tag %d out of bounds\n", tag); ++ return; ++ } ++ ++ apple_asp_handle_cq(asp, tag, status); ++} ++ ++static void apple_asp_rtkit_epmap_done(void *cookie) ++{ ++ struct apple_asp *asp = cookie; ++ int ret; ++ ++ /* ++ * The storage endpoint is the first app endpoint: 0x20 on RTKit 11 and ++ * later (the iPad Air 2's ANS speaks 12.0). Older ANS firmware with ++ * RTKit 10 is not supported; starting the endpoint fails there. ++ */ ++ asp->ep = ASP_RTKIT_ENDPOINT; ++ ++ dev_dbg(asp->dev, "ASP endpoint is %d", asp->ep); ++ ++ ret = apple_rtkit_start_ep(asp->rtk, asp->ep); ++ if (ret < 0) { ++ dev_err(asp->dev, "Could not start ASP endpoint: %d", ret); ++ return; ++ } ++} ++ ++static const struct apple_rtkit_ops apple_asp_rtkit_ops = { ++ .crashed = apple_asp_rtkit_crashed, ++ .recv_message = apple_asp_rtkit_recv, ++ .epmap_done = apple_asp_rtkit_epmap_done, ++}; ++ ++static int apple_asp_probe(struct platform_device *pdev) ++{ ++ struct apple_asp *asp; ++ struct device *dev = &pdev->dev; ++ struct resource *res; ++ int ret; ++ ++ asp = devm_kzalloc(dev, sizeof(*asp), GFP_KERNEL); ++ if (!asp) ++ return -ENOMEM; ++ ++ asp->akf_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); ++ if (IS_ERR(asp->akf_base)) ++ return PTR_ERR(asp->akf_base); ++ ++ asp->dev = dev; ++ ++ /* limit of ARMv7 long descriptor format */ ++ if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40))) ++ return -ENXIO; ++ ++ ret = apple_asp_setup_firmware(asp); ++ if (ret < 0) ++ return ret; ++ ++ asp->rtk = devm_apple_rtkit_init(dev, asp, NULL, 0, &apple_asp_rtkit_ops); ++ if (IS_ERR(asp->rtk)) { ++ ret = dev_err_probe(dev, PTR_ERR(asp->rtk), ++ "Failed to initialize RTKit"); ++ goto out_stop_iop; ++ } ++ ++ init_completion(&asp->init_done); ++ ++ ret = apple_rtkit_wake(asp->rtk); ++ if (ret) { ++ ret = dev_err_probe(dev, ret, "Failed to wake ASP"); ++ goto out_stop_iop; ++ } ++ ++ /* error already printed in apple_asp_rtkit_epmap_done() */ ++ if (!asp->ep) { ++ ret = -ENXIO; ++ goto out_rtkit; ++ } ++ ++ if (!wait_for_completion_timeout(&asp->init_done, ++ msecs_to_jiffies(ASP_TIMEOUT_MS))) { ++ ret = dev_err_probe(dev, -ETIMEDOUT, "ASP Init timeout"); ++ goto out_rtkit; ++ } ++ ++ if (asp->init_ret < 0) { ++ ret = dev_err_probe(dev, asp->init_ret, "ASP Init Error"); ++ goto out_rtkit; ++ } ++ ++ platform_set_drvdata(pdev, asp); ++ ++ dev_dbg(dev, "ASP is alive!"); ++ ++ ret = apple_asp_start_disk(asp); ++ if (ret < 0) ++ goto out_rtkit; ++ ++ return 0; ++ ++out_rtkit: ++ apple_rtkit_shutdown(asp->rtk); ++out_stop_iop: ++ writel(0, asp->akf_base + AKF_V1_CPU_CONTROL_START); ++ ++ return ret; ++} ++ ++static void apple_asp_remove(struct platform_device *pdev) ++{ ++ dev_notice(&pdev->dev, "Removing ASP"); ++ ++ struct apple_asp *asp = platform_get_drvdata(pdev); ++ ++ for (int i = ASP_QUEUE_TYPE_USERAREA; i < ASP_QUEUE_TYPE_COUNT; i++) { ++ del_gendisk(asp->q_data[i].disk); ++ put_disk(asp->q_data[i].disk); ++ } ++ ++ blk_mq_destroy_queue(asp->admin_rq); ++ blk_put_queue(asp->admin_rq); ++ blk_mq_free_tag_set(&asp->tagset); ++ ++ if (apple_rtkit_is_running(asp->rtk)) ++ apple_rtkit_shutdown(asp->rtk); ++ ++ mempool_destroy(asp->iod_mempool); ++ ida_free(&asp_instance_ida, asp->instance); ++ ++ dma_free_coherent(asp->dev, ASP_QUEUE_SIZE, asp->q, asp->q_iova); ++ ++ writel(0, asp->akf_base + AKF_V1_CPU_CONTROL_START); ++} ++ ++ ++static const struct of_device_id apple_asp_of_match[] = { ++ { .compatible = "apple,s5l8960x-ans" }, ++ {} ++}; ++MODULE_DEVICE_TABLE(of, apple_asp_of_match); ++ ++static struct platform_driver apple_asp_driver = { ++ .driver = { ++ .name = "apple-asp", ++ .of_match_table = apple_asp_of_match, ++ }, ++ .probe = apple_asp_probe, ++ .remove = apple_asp_remove, ++ .shutdown = apple_asp_remove, ++}; ++ ++module_platform_driver(apple_asp_driver); ++ ++MODULE_LICENSE("Dual MIT/GPL"); ++MODULE_DESCRIPTION("Apple ANS1 Storage Processor Driver"); ++MODULE_AUTHOR("Nick Chan "); diff --git a/kernel/patches/drivers/soc-apple/0025-dt-bindings-mailbox-apple-mailbox-Add-the-A7-A8X-ANS.patch b/kernel/patches/drivers/soc-apple/0025-dt-bindings-mailbox-apple-mailbox-Add-the-A7-A8X-ANS.patch new file mode 100644 index 00000000..e1346694 --- /dev/null +++ b/kernel/patches/drivers/soc-apple/0025-dt-bindings-mailbox-apple-mailbox-Add-the-A7-A8X-ANS.patch @@ -0,0 +1,53 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Nick Chan +Date: Thu, 19 Nov 2026 13:15:00 +0100 +Subject: [PATCH] dt-bindings: mailbox: apple,mailbox: Add the A7-A8X ANS + mailbox + +The storage coprocessor (ANS) of the A7, A8 and A8X talks through an AKF +mailbox with the A7 IOP register layout and 64-bit message packing. + +[Orchard: from HoolockLinux/linux ans1 ed8528f (38048006727d, 69243a528954), reconciled in +mattonik/ipad-nixos b94d42f and micro23/ipadair2-omarchy 7ea2b2b; one +description for both compatibles, the T8015 description as in Hoolock.] +Signed-off-by: Nick Chan +Signed-off-by: ricktav <82380971+ricktav@users.noreply.github.com> +Co-Authored-By: Claude Opus 5.5 +--- + .../bindings/mailbox/apple,mailbox.yaml | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +diff --git a/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml b/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml +index ea414a8f4..4529d58e8 100644 +--- a/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml ++++ b/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml +@@ -35,9 +35,10 @@ properties: + - const: apple,asc-mailbox-v4 + + - description: +- An older ASC mailbox interface found on T2 and A11 that is also +- used for the NVMe coprocessor and the system management +- controller. ++ The oldest ASC mailbox interface as well as a 96-bit variant ++ of the AKF mailbox with similar behaviours are found on T2 and ++ A11 and is used for the NVMe coprocessor and system management ++ coprocessor. + items: + - const: apple,t8015-asc-mailbox + +@@ -65,6 +66,15 @@ properties: + - const: apple,s8000-a7iop-mailbox + - const: apple,t8010-a7iop-mailbox + ++ - description: ++ The AKF mailbox of the A7 to A8X storage (ANS) coprocessor. It has ++ the A7 IOP register layout and 64-bit message packing. ++ items: ++ - enum: ++ - apple,t7000-akf-mailbox-v1 ++ - apple,s5l8960x-akf-mailbox-v1 ++ - const: apple,akf-mailbox-v1 ++ + reg: + maxItems: 1 + diff --git a/kernel/patches/drivers/soc-apple/0026-soc-apple-mailbox-Match-the-A7-A8X-ANS-mailbox.patch b/kernel/patches/drivers/soc-apple/0026-soc-apple-mailbox-Match-the-A7-A8X-ANS-mailbox.patch new file mode 100644 index 00000000..5a12fc28 --- /dev/null +++ b/kernel/patches/drivers/soc-apple/0026-soc-apple-mailbox-Match-the-A7-A8X-ANS-mailbox.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: ricktav <82380971+ricktav@users.noreply.github.com> +Date: Thu, 19 Nov 2026 13:15:00 +0100 +Subject: [PATCH] soc: apple: mailbox: Match the A7-A8X ANS mailbox + +The A7-A8X ANS mailbox has the same FIFO, mask and message packing as +the A7 IOP mailbox that is already supported, so match its generic +compatible to that variant instead of carrying a separate 64-bit AKF +implementation. + +[Orchard: replaces Hoolock's AKF mailbox series (HoolockLinux/linux ans1 ed8528f a9683d122ab2, +b055d938b01a, 26f606f7aa9f, 4cfff10fc213) by Nick Chan on this stack.] +Signed-off-by: ricktav <82380971+ricktav@users.noreply.github.com> +Co-Authored-By: Claude Opus 5.5 +--- + drivers/soc/apple/mailbox.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/soc/apple/mailbox.c b/drivers/soc/apple/mailbox.c +index cd27fb666..75aa1b2d0 100644 +--- a/drivers/soc/apple/mailbox.c ++++ b/drivers/soc/apple/mailbox.c +@@ -553,6 +553,8 @@ static const struct of_device_id apple_mbox_of_match[] = { + { .compatible = "apple,asc-mailbox-v4", .data = &apple_mbox_asc_hw }, + { .compatible = "apple,t8015-asc-mailbox", .data = &apple_mbox_t8015_hw }, + { .compatible = "apple,t8010-a7iop-mailbox", .data = &apple_mbox_a7iop_hw }, ++ /* A7-A8X ANS/AKF coprocessors: same FIFO, mask and packing layout as A7IOP */ ++ { .compatible = "apple,akf-mailbox-v1", .data = &apple_mbox_a7iop_hw }, + { .compatible = "apple,m3-mailbox-v2", .data = &apple_mbox_m3_hw }, + {} + }; diff --git a/kernel/patches/drivers/soc-apple/0027-soc-apple-rtkit-Let-a-driver-start-app-endpoints-at-.patch b/kernel/patches/drivers/soc-apple/0027-soc-apple-rtkit-Let-a-driver-start-app-endpoints-at-.patch new file mode 100644 index 00000000..72035891 --- /dev/null +++ b/kernel/patches/drivers/soc-apple/0027-soc-apple-rtkit-Let-a-driver-start-app-endpoints-at-.patch @@ -0,0 +1,297 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Nick Chan +Date: Thu, 19 Nov 2026 13:15:01 +0100 +Subject: [PATCH] soc: apple: rtkit: Let a driver start app endpoints at epmap + +The A8X storage coprocessor (ANS) only reaches the power-on state once +its app endpoint is started, which RTKit allows only after boot. Add an +epmap_done callback that runs when the endpoint map is complete; a driver +that sets it may start and use its app endpoints from there. Drivers +without the callback behave as before. + +Also decode the armv7 register section ('CrgA') of crash logs, which the +ANS firmware writes; the armv8 section ('Crg8') is decoded as before. + +[Orchard: from HoolockLinux/linux ans1 ed8528f (c71b8d3d1b10, 143ee29f3f46, 6444b900c760), reduced +to what the iPad Air 2's ANS (RTKit 12.0) needs. Hoolock's RTKit 10.0 +support (protocol version split, 4-bit message types, HELLO reply and +power-state changes) is left out: it changes behaviour for other RTKit +10.x firmware and was not needed here.] +Signed-off-by: Nick Chan +Signed-off-by: ricktav <82380971+ricktav@users.noreply.github.com> +Co-Authored-By: Claude Opus 5.5 +--- + drivers/soc/apple/rtkit-crashlog.c | 136 ++++++++++++++++++++++++----- + drivers/soc/apple/rtkit.c | 8 +- + include/linux/soc/apple/rtkit.h | 6 ++ + 3 files changed, 128 insertions(+), 22 deletions(-) + +diff --git a/drivers/soc/apple/rtkit-crashlog.c b/drivers/soc/apple/rtkit-crashlog.c +index 8319e3651..20b9d596f 100644 +--- a/drivers/soc/apple/rtkit-crashlog.c ++++ b/drivers/soc/apple/rtkit-crashlog.c +@@ -13,7 +13,8 @@ + #define APPLE_RTKIT_CRASHLOG_VERSION FOURCC('C', 'v', 'e', 'r') + #define APPLE_RTKIT_CRASHLOG_MBOX FOURCC('C', 'm', 'b', 'x') + #define APPLE_RTKIT_CRASHLOG_TIME FOURCC('C', 't', 'i', 'm') +-#define APPLE_RTKIT_CRASHLOG_REGS FOURCC('C', 'r', 'g', '8') ++#define APPLE_RTKIT_CRASHLOG_ARMV7 FOURCC('C', 'r', 'g', 'A') ++#define APPLE_RTKIT_CRASHLOG_ARMV8 FOURCC('C', 'r', 'g', '8') + + /* For COMPILE_TEST on non-ARM64 architectures */ + #ifndef PSR_MODE_EL0t +@@ -25,6 +26,21 @@ + #define PSR_MODE_MASK 0x0000000f + #endif + ++/* ++ * ARMv7 mode definitions: APPLE_RTKIT depends on APPLE_MAILBOX, which ++ * depends on 64BIT, so there is no need to care about COMPILE_TEST on ARM. ++ */ ++#define USR_MODE 0x00000010 ++#define FIQ_MODE 0x00000011 ++#define IRQ_MODE 0x00000012 ++#define SVC_MODE 0x00000013 ++#define MON_MODE 0x00000016 ++#define ABT_MODE 0x00000017 ++#define HYP_MODE 0x0000001a ++#define UND_MODE 0x0000001b ++#define SYSTEM_MODE 0x0000001f ++#define MODE_MASK 0x0000001f ++ + struct apple_rtkit_crashlog_header { + u32 fourcc; + u32 version; +@@ -42,7 +58,7 @@ struct apple_rtkit_crashlog_mbox_entry { + }; + static_assert(sizeof(struct apple_rtkit_crashlog_mbox_entry) == 0x18); + +-struct apple_rtkit_crashlog_regs { ++struct apple_rtkit_crashlog_armv8 { + u32 unk_0; + u32 unk_4; + u64 regs[31]; +@@ -58,7 +74,21 @@ struct apple_rtkit_crashlog_regs { + u64 esr; + u64 unk_Z; + } __packed; +-static_assert(sizeof(struct apple_rtkit_crashlog_regs) == 0x350); ++static_assert(sizeof(struct apple_rtkit_crashlog_armv8) == 0x350); ++ ++struct apple_rtkit_crashlog_armv7 { ++ u32 unk_0; ++ u32 unk_4; ++ u32 regs[16]; ++ u32 psr; ++ u32 unk_x1; ++ u8 stack[0x100]; ++ u32 unk_x2; ++ u32 unk_x3; ++ u32 unk_x4; ++ u32 unk_x5; ++} __packed; ++static_assert(sizeof(struct apple_rtkit_crashlog_armv7) == 0x160); + + static void apple_rtkit_crashlog_dump_str(struct apple_rtkit *rtk, u8 *bfr, + size_t size) +@@ -123,21 +153,21 @@ static void apple_rtkit_crashlog_dump_mailbox(struct apple_rtkit *rtk, u8 *bfr, + } + } + +-static void apple_rtkit_crashlog_dump_regs(struct apple_rtkit *rtk, u8 *bfr, +- size_t size) ++static void apple_rtkit_crashlog_dump_armv8(struct apple_rtkit *rtk, u8 *bfr, ++ size_t size) + { +- struct apple_rtkit_crashlog_regs *regs; ++ struct apple_rtkit_crashlog_armv8 *state; + const char *el; + int i; + +- if (size < sizeof(*regs)) { +- dev_warn(rtk->dev, "RTKit: Regs section too small: 0x%zx", size); ++ if (size < sizeof(*state)) { ++ dev_warn(rtk->dev, "RTKit: ARMv8 section too small: 0x%zx", size); + return; + } + +- regs = (struct apple_rtkit_crashlog_regs *)bfr; ++ state = (struct apple_rtkit_crashlog_armv8 *)bfr; + +- switch (regs->psr & PSR_MODE_MASK) { ++ switch (state->psr & PSR_MODE_MASK) { + case PSR_MODE_EL0t: + el = "EL0t"; + break; +@@ -160,11 +190,11 @@ static void apple_rtkit_crashlog_dump_regs(struct apple_rtkit *rtk, u8 *bfr, + + dev_warn(rtk->dev, "RTKit: Exception dump:"); + dev_warn(rtk->dev, " == Exception taken from %s ==", el); +- dev_warn(rtk->dev, " PSR = 0x%llx", regs->psr); +- dev_warn(rtk->dev, " PC = 0x%llx\n", regs->pc); +- dev_warn(rtk->dev, " ESR = 0x%llx\n", regs->esr); +- dev_warn(rtk->dev, " FAR = 0x%llx\n", regs->far); +- dev_warn(rtk->dev, " SP = 0x%llx\n", regs->sp); ++ dev_warn(rtk->dev, " PSR = 0x%llx", state->psr); ++ dev_warn(rtk->dev, " PC = 0x%llx\n", state->pc); ++ dev_warn(rtk->dev, " ESR = 0x%llx\n", state->esr); ++ dev_warn(rtk->dev, " FAR = 0x%llx\n", state->far); ++ dev_warn(rtk->dev, " SP = 0x%llx\n", state->sp); + dev_warn(rtk->dev, "\n"); + + for (i = 0; i < 31; i += 4) { +@@ -172,17 +202,79 @@ static void apple_rtkit_crashlog_dump_regs(struct apple_rtkit *rtk, u8 *bfr, + dev_warn(rtk->dev, + " x%02d-x%02d = %016llx %016llx %016llx %016llx\n", + i, i + 3, +- regs->regs[i], regs->regs[i + 1], +- regs->regs[i + 2], regs->regs[i + 3]); ++ state->regs[i], state->regs[i + 1], ++ state->regs[i + 2], state->regs[i + 3]); + else + dev_warn(rtk->dev, + " x%02d-x%02d = %016llx %016llx %016llx\n", i, i + 3, +- regs->regs[i], regs->regs[i + 1], regs->regs[i + 2]); ++ state->regs[i], state->regs[i + 1], state->regs[i + 2]); + } + + dev_warn(rtk->dev, "\n"); + } + ++static void apple_rtkit_crashlog_dump_armv7(struct apple_rtkit *rtk, u8 *bfr, ++ size_t size) ++{ ++ struct apple_rtkit_crashlog_armv7 *state; ++ const char *mode; ++ int i; ++ ++ if (size < sizeof(*state)) { ++ dev_warn(rtk->dev, "RTKit: ARMv7 section too small: 0x%zx", size); ++ return; ++ } ++ ++ state = (struct apple_rtkit_crashlog_armv7 *)bfr; ++ ++ switch (state->psr & MODE_MASK) { ++ case USR_MODE: ++ mode = "User"; ++ break; ++ case FIQ_MODE: ++ mode = "FIQ"; ++ break; ++ case IRQ_MODE: ++ mode = "IRQ"; ++ break; ++ case SVC_MODE: ++ mode = "Supervisor"; ++ break; ++ case MON_MODE: ++ mode = "Monitor"; ++ break; ++ case ABT_MODE: ++ mode = "Abort"; ++ break; ++ case HYP_MODE: ++ mode = "Hypervisor"; ++ break; ++ case UND_MODE: ++ mode = "Undefined"; ++ break; ++ case SYSTEM_MODE: ++ mode = "System"; ++ break; ++ default: ++ mode = "Unknown"; ++ break; ++ } ++ ++ dev_warn(rtk->dev, "RTKit: Exception dump:"); ++ dev_warn(rtk->dev, " == Exception taken from %s mode ==", mode); ++ dev_warn(rtk->dev, " PSR = 0x%x", state->psr); ++ dev_warn(rtk->dev, "\n"); ++ ++ for (i = 0; i < 16; i += 4) ++ dev_warn(rtk->dev, ++ " r%02d-r%02d = %08x %08x %08x %08x\n", ++ i, i + 3, ++ state->regs[i], state->regs[i + 1], ++ state->regs[i + 2], state->regs[i + 3]); ++ ++ dev_warn(rtk->dev, "\n"); ++} ++ + void apple_rtkit_crashlog_dump(struct apple_rtkit *rtk, u8 *bfr, size_t size) + { + size_t offset; +@@ -229,8 +321,12 @@ void apple_rtkit_crashlog_dump(struct apple_rtkit *rtk, u8 *bfr, size_t size) + apple_rtkit_crashlog_dump_time(rtk, bfr + offset + 16, + section_size); + break; +- case APPLE_RTKIT_CRASHLOG_REGS: +- apple_rtkit_crashlog_dump_regs(rtk, bfr + offset + 16, ++ case APPLE_RTKIT_CRASHLOG_ARMV7: ++ apple_rtkit_crashlog_dump_armv7(rtk, bfr + offset + 16, ++ section_size); ++ break; ++ case APPLE_RTKIT_CRASHLOG_ARMV8: ++ apple_rtkit_crashlog_dump_armv8(rtk, bfr + offset + 16, + section_size); + break; + default: +diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c +index 387e6933e..569206c76 100644 +--- a/drivers/soc/apple/rtkit.c ++++ b/drivers/soc/apple/rtkit.c +@@ -212,6 +212,9 @@ static void apple_rtkit_management_rx_epmap(struct apple_rtkit *rtk, u64 msg) + + rtk->boot_result = 0; + complete_all(&rtk->epmap_completion); ++ ++ if (rtk->ops->epmap_done) ++ rtk->ops->epmap_done(rtk->cookie); + } + + static void apple_rtkit_management_rx_iop_pwr_ack(struct apple_rtkit *rtk, +@@ -623,7 +626,8 @@ int apple_rtkit_send_message(struct apple_rtkit *rtk, u8 ep, u64 message, + return -EINVAL; + } + +- if (ep >= rtk->app_ep_start && !apple_rtkit_is_running(rtk)) { ++ if (ep >= rtk->app_ep_start && !rtk->ops->epmap_done && ++ !apple_rtkit_is_running(rtk)) { + dev_warn(rtk->dev, + "RTKit: Endpoint 0x%02x is not running, cannot send message\n", ep); + return -EINVAL; +@@ -652,7 +656,7 @@ int apple_rtkit_start_ep(struct apple_rtkit *rtk, u8 endpoint) + + if (!test_bit(endpoint, rtk->endpoints)) + return -EINVAL; +- if (endpoint >= rtk->app_ep_start && ++ if (endpoint >= rtk->app_ep_start && !rtk->ops->epmap_done && + !apple_rtkit_is_running(rtk)) + return -EINVAL; + +diff --git a/include/linux/soc/apple/rtkit.h b/include/linux/soc/apple/rtkit.h +index 743e89cc8..ef33268f3 100644 +--- a/include/linux/soc/apple/rtkit.h ++++ b/include/linux/soc/apple/rtkit.h +@@ -39,6 +39,11 @@ struct apple_rtkit_shmem { + * + * @crashed: Called when the co-processor has crashed. Runs in process + * context. ++ * @epmap_done: Called when epmap is completed. Useful if the IOP requires ++ * app endpoints to be started in order to reach power-on state. ++ * If it is specified, it is assumed that messages may be ++ * received on app endpoints during boot and shutdown. Runs in ++ * process context. + * @recv_message: Function called when a message from RTKit is received + * on a non-system endpoint. Called from a worker thread. + * @recv_message_early: +@@ -57,6 +62,7 @@ struct apple_rtkit_shmem { + */ + struct apple_rtkit_ops { + void (*crashed)(void *cookie, const void *crashlog, size_t crashlog_size); ++ void (*epmap_done)(void *cookie); + void (*recv_message)(void *cookie, u8 endpoint, u64 message); + bool (*recv_message_early)(void *cookie, u8 endpoint, u64 message); + int (*shmem_setup)(void *cookie, struct apple_rtkit_shmem *bfr); From 6aaf882176d087c5d813d7ddc0e610ca1036d549 Mon Sep 17 00:00:00 2001 From: ricktav <82380971+ricktav@users.noreply.github.com> Date: Thu, 19 Nov 2026 13:08:06 +0100 Subject: [PATCH 2/4] j81: enable ANS1 internal storage in the device tree Describe the A8X ANS coprocessor and its mailbox (disabled in t7001.dtsi) and enable them on the iPad Air 2 with the firmware region m1n1 fills in through the asp alias. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01SFMaVe993UGYsK61nbtYhR --- ...64-dts-apple-t7001-Add-the-ANS-nodes.patch | 59 +++++++++++++++++++ ...e-t7001-air2-Enable-internal-storage.patch | 43 ++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 kernel/patches/devices/t7001/0010-arm64-dts-apple-t7001-Add-the-ANS-nodes.patch create mode 100644 kernel/patches/devices/t7001/0011-arm64-dts-apple-t7001-air2-Enable-internal-storage.patch diff --git a/kernel/patches/devices/t7001/0010-arm64-dts-apple-t7001-Add-the-ANS-nodes.patch b/kernel/patches/devices/t7001/0010-arm64-dts-apple-t7001-Add-the-ANS-nodes.patch new file mode 100644 index 00000000..a712c274 --- /dev/null +++ b/kernel/patches/devices/t7001/0010-arm64-dts-apple-t7001-Add-the-ANS-nodes.patch @@ -0,0 +1,59 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Nick Chan +Date: Thu, 19 Nov 2026 13:15:01 +0100 +Subject: [PATCH] arm64: dts: apple: t7001: Add the ANS nodes + +Describe the A8X storage coprocessor and its mailbox, disabled until a +board enables them. m1n1 fills the coprocessor's firmware region through +the asp alias. + +[Orchard: from HoolockLinux/linux ans1 ed8528f 32c5dac3841f.] +Signed-off-by: Nick Chan +Signed-off-by: ricktav <82380971+ricktav@users.noreply.github.com> +Co-Authored-By: Claude Opus 5.5 +--- + arch/arm64/boot/dts/apple/t7001.dtsi | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +diff --git a/arch/arm64/boot/dts/apple/t7001.dtsi b/arch/arm64/boot/dts/apple/t7001.dtsi +index 1a666e7be..892ff78bd 100644 +--- a/arch/arm64/boot/dts/apple/t7001.dtsi ++++ b/arch/arm64/boot/dts/apple/t7001.dtsi +@@ -20,6 +20,7 @@ / { + aliases { + ausbphy0 = &ausbphy0; /* Used by loader */ + serial0 = &serial0; ++ asp = &ans; + }; + + clkref: clock-ref { +@@ -141,6 +142,29 @@ cpufreq: performance-controller@202220000 { + #performance-domain-cells = <0>; + }; + ++ ans: block@208040000 { ++ compatible = "apple,t7001-ans", "apple,s5l8960x-ans"; ++ reg = <0x2 0x08040000 0x0 0x1000>; ++ mboxes = <&ans_mbox>; ++ power-domains = <&ps_ans>; ++ resets = <&ps_ans>; ++ status = "disabled"; ++ }; ++ ++ ans_mbox: mbox@208041000 { ++ compatible = "apple,t7000-akf-mailbox-v1", "apple,akf-mailbox-v1"; ++ reg = <0x2 0x08041000 0x0 0x1000>; ++ interrupt-parent = <&aic>; ++ interrupts = , ++ , ++ , ++ ; ++ interrupt-names = "send-empty", "send-not-empty", ++ "recv-empty", "recv-not-empty"; ++ #mbox-cells = <0>; ++ power-domains = <&ps_ans>; ++ }; ++ + serial0: serial@20a0c0000 { + compatible = "apple,s5l-uart"; + reg = <0x2 0x0a0c0000 0x0 0x4000>; diff --git a/kernel/patches/devices/t7001/0011-arm64-dts-apple-t7001-air2-Enable-internal-storage.patch b/kernel/patches/devices/t7001/0011-arm64-dts-apple-t7001-air2-Enable-internal-storage.patch new file mode 100644 index 00000000..f101c5ce --- /dev/null +++ b/kernel/patches/devices/t7001/0011-arm64-dts-apple-t7001-air2-Enable-internal-storage.patch @@ -0,0 +1,43 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: ricktav <82380971+ricktav@users.noreply.github.com> +Date: Thu, 19 Nov 2026 13:15:02 +0100 +Subject: [PATCH] arm64: dts: apple: t7001-air2: Enable internal storage + +Enable ANS with the firmware region m1n1 fills in. + +Signed-off-by: ricktav <82380971+ricktav@users.noreply.github.com> +Co-Authored-By: Claude Opus 5.5 +--- + arch/arm64/boot/dts/apple/t7001-air2.dtsi | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +diff --git a/arch/arm64/boot/dts/apple/t7001-air2.dtsi b/arch/arm64/boot/dts/apple/t7001-air2.dtsi +index d4b114f73..246790a7f 100644 +--- a/arch/arm64/boot/dts/apple/t7001-air2.dtsi ++++ b/arch/arm64/boot/dts/apple/t7001-air2.dtsi +@@ -95,7 +95,11 @@ reserved-memory { + #size-cells = <2>; + ranges; + +- /* To be filled by loader */ ++ ans_firmware: ans-firmware { ++ /* Filled in by the loader. */ ++ reg = <0 0 0 0>; ++ no-map; ++ }; + }; + + battery_info: battery { +@@ -113,6 +117,12 @@ wlan_vdd: regulator-wlan-vdd { + }; + }; + ++&ans { ++ memory-region = <&ans_firmware>; ++ memory-region-names = "firmware"; ++ status = "okay"; ++}; ++ + &serial0 { + status = "okay"; + }; From eda5f94f8f346873a1374dcb2337a32bb386d987 Mon Sep 17 00:00:00 2001 From: ricktav <82380971+ricktav@users.noreply.github.com> Date: Thu, 19 Nov 2026 13:08:06 +0100 Subject: [PATCH 3/4] install: ANS1 disks as the root and install target - apple-4k's initrd loads asp instead of nvme: A7-A8X have no NVMe. - The installer takes aspn1, the ANS1 user area, as the internal disk. - udev names asp partitions under /dev/disk/by-partuuid and by-uuid: systemd's 60-persistent-storage.rules skips asp*, so the installer's /boot fstab entry by PARTUUID timed out into emergency mode. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01SFMaVe993UGYsK61nbtYhR --- platforms/apple-4k.toml | 5 +++++ src/orchard/install_direct.py | 9 +++++---- .../usr/lib/udev/rules.d/59-orchard-asp-storage.rules | 7 +++++++ tests/test_armv7_install.py | 5 +++++ tests/test_platform_layer.py | 1 + 5 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 system/defaults/usr/lib/udev/rules.d/59-orchard-asp-storage.rules diff --git a/platforms/apple-4k.toml b/platforms/apple-4k.toml index 2486ab87..9302ed18 100644 --- a/platforms/apple-4k.toml +++ b/platforms/apple-4k.toml @@ -15,3 +15,8 @@ config = "kernel/configs/apple-4k/config" defconfig = "orchard_apple4k_defconfig" # the same config in OrchardLinux/linux branch = "main" # its branch in OrchardLinux/linux loader = "m1n1" # the payload format that boots this kernel + +[root] +# A7, A8 and A8X keep their internal storage behind ANS1 (drivers/block/asp.c), +# not NVMe: the initrd loads asp to find the installed root. +storage_modules = ["asp"] diff --git a/src/orchard/install_direct.py b/src/orchard/install_direct.py index efaa1110..ae22b254 100644 --- a/src/orchard/install_direct.py +++ b/src/orchard/install_direct.py @@ -34,10 +34,11 @@ ADD_ON = ROOT / 'boot/initramfs/install' HOST = '172.16.42.1' -# The one internal disk: NVMe on 64-bit boards, the iOS flash translation layer on 32-bit ones. -# Apple's NVMe has several namespaces; the storage iOS and Linux live on is the first, -# the others hold the controller's own data (nvme0n2 and up on an iPad 6). -INTERNAL_DISK = re.compile(r'nvme[0-9]+n1|applesftl[0-9]+') +# The one internal disk: NVMe on A9 and later, ANS1 (asp) on A7-A8X, the iOS flash +# translation layer on 32-bit boards. Apple's NVMe and ANS1 have several namespaces; the +# storage iOS and Linux live on is the first, the others hold the controller's own data +# (nvme0n2 and up on an iPad 6, asp0n2 and up on an iPad Air 2). +INTERNAL_DISK = re.compile(r'nvme[0-9]+n1|applesftl[0-9]+|asp[0-9]+n1') BOOT_ARGS = 'fbcon=map:9 vt.global_cursor_default=0' INITRAMFS_MAGIC = b'm1n1_initramfs' XBOOTLDR, ROOT_ARM64 = D.XBOOTLDR, D.ROOT_ARM64 diff --git a/system/defaults/usr/lib/udev/rules.d/59-orchard-asp-storage.rules b/system/defaults/usr/lib/udev/rules.d/59-orchard-asp-storage.rules new file mode 100644 index 00000000..6ae8bb83 --- /dev/null +++ b/system/defaults/usr/lib/udev/rules.d/59-orchard-asp-storage.rules @@ -0,0 +1,7 @@ +# The asp driver's disks (ANS1 storage, e.g. J81) are named asp*, which +# systemd's 60-persistent-storage.rules does not cover: without these rules +# there is no /dev/disk/by-partuuid or by-uuid for them, so an fstab entry by +# PARTUUID (the installer's /boot) times out and the boot ends in emergency mode. +SUBSYSTEM=="block", KERNEL=="asp*", IMPORT{builtin}="blkid" +SUBSYSTEM=="block", KERNEL=="asp*", ENV{DEVTYPE}=="partition", ENV{PARTUUID}=="?*", SYMLINK+="disk/by-partuuid/$env{PARTUUID}" +SUBSYSTEM=="block", KERNEL=="asp*", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" diff --git a/tests/test_armv7_install.py b/tests/test_armv7_install.py index a0471f3a..2b57875c 100644 --- a/tests/test_armv7_install.py +++ b/tests/test_armv7_install.py @@ -124,6 +124,11 @@ def test_the_disk_is_the_first_nvme_namespace(self): with FakeDevice(disks=[f'nvme0n{n}' for n in range(1, 8)]): self.assertEqual(direct.find_disk(None), '/dev/nvme0n1') + def test_the_disk_is_the_first_ans1_namespace(self): + # An iPad Air 2 lists ten ANS1 namespaces; only the first is the storage. + with FakeDevice(disks=[f'asp0n{n}' for n in range(1, 11)]): + self.assertEqual(direct.find_disk(None), '/dev/asp0n1') + def test_two_internal_disks_stop_the_install(self): with FakeDevice(disks=['nvme0n1', 'applesftl0']), self.assertRaisesRegex(D.InstallError, 'More than one'): direct.find_disk(None) diff --git a/tests/test_platform_layer.py b/tests/test_platform_layer.py index 1aa0f90f..c7ed43c9 100644 --- a/tests/test_platform_layer.py +++ b/tests/test_platform_layer.py @@ -57,6 +57,7 @@ def test_every_board_of_the_platform_and_nothing_outside_usr(self): 'usr/lib/firmware/regulatory.db.p7s', 'usr/lib/NetworkManager/conf.d/30-orchard-usb.conf', 'usr/lib/udev/rules.d/70-orchard-wifi-address.rules', + 'usr/lib/udev/rules.d/59-orchard-asp-storage.rules', 'usr/lib/orchard/wifi-address', 'usr/lib/orchard/boot-entries', 'usr/lib/orchard/platform.SHA256SUMS'}, names) From 8546fe564a05a230562a08c621f1a9826fadc45e Mon Sep 17 00:00:00 2001 From: ricktav <82380971+ricktav@users.noreply.github.com> Date: Thu, 19 Nov 2026 13:08:06 +0100 Subject: [PATCH 4/4] j81: internal storage works; installable Seen on an iPad Air 2 Wi-Fi: orchard install wrote Omarchy A next to iPadOS and orchard launch starts it from internal storage, root and /boot read-write, desktop, touch and Wi-Fi working. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01SFMaVe993UGYsK61nbtYhR --- CHANGELOG.md | 6 ++++++ devices/j81/device.toml | 4 ++-- docs/compatibility.md | 6 ++++-- tests/test_catalog.py | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6562a1f0..469132ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,12 @@ is missing or empty. ## Unreleased +### Devices + +- iPad Air 2 (Wi-Fi): internal storage works, so Omarchy installs with + `orchard install` and starts from the iPad with `orchard launch`, next to + iPadOS. The A8X storage controller (ANS1) has a kernel driver now. + ### Install & launch - On Linux, `orchard run` and `orchard launch` use the released Pongo again diff --git a/devices/j81/device.toml b/devices/j81/device.toml index da7029a6..a2c90ee6 100644 --- a/devices/j81/device.toml +++ b/devices/j81/device.toml @@ -39,8 +39,8 @@ accelerometer = "missing" gyroscope = "missing" light_sensor = "missing" touch_id = "missing" -storage_read = "missing" -storage_write = "missing" +storage_read = "working" +storage_write = "working" wifi = "working" bluetooth_input = "untested" bluetooth_audio = "untested" diff --git a/docs/compatibility.md b/docs/compatibility.md index 67570fe3..8671c226 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -67,7 +67,7 @@ Generated by `tools/catalog/generate matrix` from `devices/`, `chips/` and `meth | A8 | `j97` | iPad mini 4 (Cellular) | iPad5,2 | experimental | – | checkm8-pongo | yes | yes | 19H422 | | A8 | `n56` | iPhone 6+ | iPhone7,1 | experimental | – | checkm8-pongo | yes | yes | 16H88 | | A8 | `n61` | iPhone 6 | iPhone7,2 | experimental | – | checkm8-pongo | yes | yes | 16H22 | -| A8X | `j81` | iPad Air 2 (Wi-Fi) | iPad5,3 | experimental | – | checkm8-pongo | yes | yes | 19H422 | +| A8X | `j81` | iPad Air 2 (Wi-Fi) | iPad5,3 | experimental | yes | checkm8-pongo | yes | yes | 19H422 | | A8X | `j82` | iPad Air 2 (Cellular) | iPad5,4 | experimental | – | checkm8-pongo | yes | yes | 19H422 | | A9 | `j71s` | iPad 5 (Wi-Fi, Samsung) | iPad6,11 | experimental | – | checkm8-pongo | yes | yes | 20H350 | | A9 | `j72s` | iPad 5 (Cellular, Samsung) | iPad6,12 | experimental | – | checkm8-pongo | yes | yes | 20H350 | @@ -154,7 +154,7 @@ Boards Orchard builds for. States: working, untested, missing, none (no such har | `j97` | untested | missing | untested | untested | untested | missing | missing | missing | missing | missing | missing | untested | missing | missing | missing | untested | missing | missing | untested | untested | untested | untested | missing | missing | missing | missing | missing | | `n56` | untested | missing | untested | missing | untested | missing | missing | missing | missing | missing | missing | missing | missing | missing | missing | untested | missing | missing | untested | untested | untested | untested | missing | missing | missing | missing | missing | | `n61` | working | untested | untested | working | untested | missing | missing | missing | missing | missing | missing | missing | missing | missing | missing | untested | missing | missing | untested | untested | working | untested | missing | missing | missing | missing | missing | -| `j81` | working | untested | working | working | working | missing | missing | missing | missing | missing | missing | working | untested | untested | none | working | missing | missing | untested | untested | working | working | missing | missing | missing | missing | missing | +| `j81` | working | untested | working | working | working | missing | missing | missing | missing | working | working | working | untested | untested | none | working | missing | missing | untested | untested | working | working | missing | missing | missing | missing | missing | | `j82` | untested | untested | untested | untested | untested | missing | missing | missing | missing | missing | missing | untested | untested | untested | missing | untested | missing | missing | untested | untested | untested | untested | missing | missing | missing | missing | missing | | `j71s` | untested | untested | untested | untested | untested | untested | untested | untested | missing | missing | missing | missing | untested | untested | none | untested | untested | untested | untested | untested | untested | untested | untested | untested | untested | missing | untested | | `j72s` | untested | untested | untested | untested | untested | untested | untested | untested | missing | missing | missing | missing | untested | untested | missing | untested | untested | untested | untested | untested | untested | untested | untested | untested | untested | missing | untested | @@ -248,6 +248,8 @@ A yes means an enabled device tree node binds a driver in `7.3.0-rc1-orchard-app | Board | Feature | | | --- | --- | --- | +| `j81` | Internal storage read | working, but no driver binds | +| `j81` | Internal storage write | working, but no driver binds | | `j71s` | Microphone | untested, but no driver binds | | `j72s` | Microphone | untested, but no driver binds | | `j71t` | Microphone | untested, but no driver binds | diff --git a/tests/test_catalog.py b/tests/test_catalog.py index 62ac0c52..0150773e 100644 --- a/tests/test_catalog.py +++ b/tests/test_catalog.py @@ -246,7 +246,7 @@ def test_the_boards_with_every_requirement_can_install(self): from orchard import hardware boards = {path.parent.name for path in DESCRIPTORS if not hardware.install_blockers(path.parent.name)} self.assertEqual(boards, {'d10', 'd101', 'd11', 'd111', 'd20', 'd201', 'd21', 'd211', 'd22', 'd221', - 'j171', 'j172', 'j71b', 'j71t', 'j72b', 'j72t'}) + 'j171', 'j172', 'j71b', 'j71t', 'j72b', 'j72t', 'j81'}) def test_data_can_name_a_method_this_code_does_not_implement(self): from orchard import hardware