From 1885d483a872f95172b26073182b32f933e86b61 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 31 Oct 2026 12:53:56 +0000 Subject: [PATCH 1/4] dt-bindings: media: apple,avd: describe the PIODMA resources Describe an optional appended PIODMA register range, the seven interrupt sources, and the decode, DMA controller and optional ADS buffer streams. Require at least two streams with PIODMA while retaining legacy four-range nodes without that aperture. Assisted-by: LLM Signed-off-by: Ryan Murray --- .../devicetree/bindings/media/apple,avd.yaml | 49 +++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/media/apple,avd.yaml b/Documentation/devicetree/bindings/media/apple,avd.yaml index 59ccb50461181..d767d168f4579 100644 --- a/Documentation/devicetree/bindings/media/apple,avd.yaml +++ b/Documentation/devicetree/bindings/media/apple,avd.yaml @@ -33,22 +33,33 @@ properties: - apple,t8140-avd reg: + minItems: 4 items: - description: cm3 code - description: cm3 sram - description: mbox registers - description: decode ctrl registers + - description: PIODMA registers reg-names: + minItems: 4 items: - const: code - const: sram - const: mbox - const: ctrl + - const: piodma iommus: + description: + Decode, PIODMA DMA controller, and optional ADS buffer streams, in that + order. Legacy nodes without a PIODMA register range may describe only + the decode stream. minItems: 1 - maxItems: 3 + items: + - description: Decode stream + - description: PIODMA DMA controller stream + - description: ADS buffer stream power-domains: maxItems: 1 @@ -65,6 +76,35 @@ properties: - description: mailbox 3 - description: flag 0 - description: flag 1 + - description: PIODMA + + interrupt-names: + minItems: 2 + items: + - const: mbox0 + - const: mbox1 + - const: mbox2 + - const: mbox3 + - const: flag0 + - const: flag1 + - const: piodma + +allOf: + - if: + properties: + reg-names: + contains: + const: piodma + then: + properties: + reg: + minItems: 5 + iommus: + minItems: 2 + else: + properties: + reg: + maxItems: 4 required: - compatible @@ -96,8 +136,9 @@ examples: reg = <0x2 0x89080000 0x0 0x12000>, <0x2 0x89092000 0x0 0x12000>, <0x2 0x890a4000 0x0 0x4000>, - <0x2 0x89100000 0x0 0x10000>; - reg-names = "code", "sram", "mbox", "ctrl"; - iommus = <&avd_dart 0>; + <0x2 0x89100000 0x0 0x10000>, + <0x2 0x89070000 0x0 0x4000>; + reg-names = "code", "sram", "mbox", "ctrl", "piodma"; + iommus = <&avd_dart 0>, <&avd_dart 1>; }; }; From 24cff9883af036e06309713893d3898e9b2b3539 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 31 Oct 2026 12:54:05 +0000 Subject: [PATCH 2/4] arm64: dts: apple: describe AVD PIODMA on T6040, T8140, T6000 and T8112 Append the PIODMA range without changing the existing resource indices. Route the DMA controller through DART stream 1 and preserve T8140 stream 2. The retained ADT mapper topology identifies stream 1 as the PIODMA mapper; the register subrange follows the publicly documented AVD layout. Assisted-by: LLM Signed-off-by: Ryan Murray --- arch/arm64/boot/dts/apple/t600x-dieX.dtsi | 7 ++++--- arch/arm64/boot/dts/apple/t6040.dtsi | 7 ++++--- arch/arm64/boot/dts/apple/t8112.dtsi | 7 ++++--- arch/arm64/boot/dts/apple/t8140.dtsi | 5 +++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t600x-dieX.dtsi b/arch/arm64/boot/dts/apple/t600x-dieX.dtsi index 0b0da1a4b066b..f42b162745f6b 100644 --- a/arch/arm64/boot/dts/apple/t600x-dieX.dtsi +++ b/arch/arm64/boot/dts/apple/t600x-dieX.dtsi @@ -39,9 +39,10 @@ reg = <0x2 0x87080000 0x0 0x10000>, <0x2 0x87090000 0x0 0x10000>, <0x2 0x870a0000 0x0 0x4000>, - <0x2 0x87100000 0x0 0x10000>; - reg-names = "code", "sram", "mbox", "ctrl"; - iommus = <&DIE_NODE(avd_dart) 0>; + <0x2 0x87100000 0x0 0x10000>, + <0x2 0x87070000 0x0 0x4000>; + reg-names = "code", "sram", "mbox", "ctrl", "piodma"; + iommus = <&DIE_NODE(avd_dart) 0>, <&DIE_NODE(avd_dart) 1>; }; DIE_NODE(avd_dart): iommu@287010000 { diff --git a/arch/arm64/boot/dts/apple/t6040.dtsi b/arch/arm64/boot/dts/apple/t6040.dtsi index f2c603b3f01e6..de89fae00d398 100644 --- a/arch/arm64/boot/dts/apple/t6040.dtsi +++ b/arch/arm64/boot/dts/apple/t6040.dtsi @@ -590,14 +590,15 @@ reg = <0x2 0x81080000 0x0 0x14000>, <0x2 0x81094000 0x0 0x14000>, <0x2 0x810a8000 0x0 0x4000>, - <0x2 0x81100000 0x0 0x10000>; - reg-names = "code", "sram", "mbox", "ctrl"; + <0x2 0x81100000 0x0 0x10000>, + <0x2 0x81070000 0x0 0x4000>; + reg-names = "code", "sram", "mbox", "ctrl", "piodma"; interrupt-parent = <&aic>; interrupts = , ; power-domains = <&ps_avd_sys>; resets = <&ps_avd_sys>; - iommus = <&avd_dart 0>; + iommus = <&avd_dart 0>, <&avd_dart 1>; }; avd_dart: iommu@281020000 { diff --git a/arch/arm64/boot/dts/apple/t8112.dtsi b/arch/arm64/boot/dts/apple/t8112.dtsi index e19ef0b98292a..26aa59dc8c1c0 100644 --- a/arch/arm64/boot/dts/apple/t8112.dtsi +++ b/arch/arm64/boot/dts/apple/t8112.dtsi @@ -1767,9 +1767,10 @@ reg = <0x2 0x69080000 0x0 0x10000>, <0x2 0x69090000 0x0 0x10000>, <0x2 0x690a0000 0x0 0x4000>, - <0x2 0x69100000 0x0 0x10000>; - reg-names = "code", "sram", "mbox", "ctrl"; - iommus = <&avd_dart 0>; + <0x2 0x69100000 0x0 0x10000>, + <0x2 0x69070000 0x0 0x4000>; + reg-names = "code", "sram", "mbox", "ctrl", "piodma"; + iommus = <&avd_dart 0>, <&avd_dart 1>; }; avd_dart: iommu@269010000 { diff --git a/arch/arm64/boot/dts/apple/t8140.dtsi b/arch/arm64/boot/dts/apple/t8140.dtsi index 450470726c3e6..e123ffb371d28 100644 --- a/arch/arm64/boot/dts/apple/t8140.dtsi +++ b/arch/arm64/boot/dts/apple/t8140.dtsi @@ -1345,8 +1345,9 @@ reg = <0x3 0x81080000 0x0 0x10000>, <0x3 0x81090000 0x0 0x10000>, <0x3 0x810a0000 0x0 0x4000>, - <0x3 0x81100000 0x0 0x10000>; - reg-names = "code", "sram", "mbox", "ctrl"; + <0x3 0x81100000 0x0 0x10000>, + <0x3 0x81070000 0x0 0x4000>; + reg-names = "code", "sram", "mbox", "ctrl", "piodma"; iommus = <&avd_dart 0>, <&avd_dart 1>, <&avd_dart 2>; }; From 9bcde8aa80bd77d62c2d398f57429c80f99de96e Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 31 Oct 2026 12:54:17 +0000 Subject: [PATCH 3/4] media: apple: avd: initialize PIODMA before starting the CM3 Map the optional named PIODMA resource and retain the physical SRAM base. Program that base in 16-byte units on every CM3 boot so resume and reset restore it, and log the PIODMA version once per device while powered. Keep probing legacy device trees that omit the PIODMA aperture. Assisted-by: LLM Signed-off-by: Ryan Murray --- drivers/media/platform/apple/avd/avd-drv.c | 18 ++++++++++++++++++ drivers/media/platform/apple/avd/avd-hw.c | 10 ++++++++++ drivers/media/platform/apple/avd/avd-regs.h | 3 +++ drivers/media/platform/apple/avd/avd.h | 3 +++ 4 files changed, 34 insertions(+) diff --git a/drivers/media/platform/apple/avd/avd-drv.c b/drivers/media/platform/apple/avd/avd-drv.c index bf5bf96f4c62a..4baa5a9aa265b 100644 --- a/drivers/media/platform/apple/avd/avd-drv.c +++ b/drivers/media/platform/apple/avd/avd-drv.c @@ -873,6 +873,7 @@ MODULE_DEVICE_TABLE(of, avd_of_match); static int avd_probe(struct platform_device *pdev) { struct avd_dev *avd; + struct resource *res; const struct of_device_id *match; const char *codec_info = NULL; int ret, irq; @@ -903,6 +904,23 @@ static int avd_probe(struct platform_device *pdev) if (IS_ERR(avd->ctrl)) return PTR_ERR(avd->ctrl); + /* Older device trees do not describe the PIODMA aperture. */ + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "piodma"); + if (res) { + avd->piodma = devm_ioremap_resource(avd->dev, res); + if (IS_ERR(avd->piodma)) + return PTR_ERR(avd->piodma); + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sram"); + if (!res) + return dev_err_probe(avd->dev, -EINVAL, + "missing SRAM resource for PIODMA\n"); + if (!IS_ALIGNED(res->start, 16) || (res->start >> 4) > U32_MAX) + return dev_err_probe(avd->dev, -EINVAL, + "SRAM address cannot be encoded for PIODMA\n"); + avd->sram_phys = res->start; + } + avd->domain = iommu_get_domain_for_dev(avd->dev); if (avd->domain) { avd->empty_domain = iommu_paging_domain_alloc(avd->dev); diff --git a/drivers/media/platform/apple/avd/avd-hw.c b/drivers/media/platform/apple/avd/avd-hw.c index a3987ac4510de..1d55d3b90082a 100644 --- a/drivers/media/platform/apple/avd/avd-hw.c +++ b/drivers/media/platform/apple/avd/avd-hw.c @@ -51,6 +51,16 @@ int avd_boot(struct avd_dev *avd) memcpy_toio(avd->code, avd->fw->data, avd->fw->size); + if (avd->piodma) { + /* Program the AP SRAM address before releasing the CM3. */ + writel(avd->sram_phys >> 4, avd->piodma + AVD_PIODMA_SRAM_BASE); + if (!avd->piodma_version_logged) { + dev_info(avd->dev, "PIODMA version: %08x\n", + readl(avd->piodma + AVD_PIODMA_VERSION)); + avd->piodma_version_logged = true; + } + } + writel_relaxed(AVD_MBOX_ENABLE, avd->mbox + AVD_REG_MBOX1_STATUS); writel_relaxed(AVD_MBOX1_NOT_EMPTY, avd->mbox + AVD_REG_MBOX_IRQ_ENABLE); writel_relaxed(AVD_RUN_CTRL_UNK_RUN, avd->mbox + AVD_REG_RUN_CTRL); diff --git a/drivers/media/platform/apple/avd/avd-regs.h b/drivers/media/platform/apple/avd/avd-regs.h index 388f3e64895f5..d8c849a3d3b92 100644 --- a/drivers/media/platform/apple/avd/avd-regs.h +++ b/drivers/media/platform/apple/avd/avd-regs.h @@ -3,6 +3,9 @@ #ifndef AVD_REGS_H_ #define AVD_REGS_H_ +#define AVD_PIODMA_SRAM_BASE 0x24 +#define AVD_PIODMA_VERSION 0xb4 + #define AVD_REG_RUN_CTRL 0x08 #define AVD_RUN_CTRL_UNK_RUN BIT(0) #define AVD_RUN_CTRL_UNK_STOP BIT(1) | BIT(2) | BIT(3) diff --git a/drivers/media/platform/apple/avd/avd.h b/drivers/media/platform/apple/avd/avd.h index ad7accb6e9615..ad4d02681517f 100644 --- a/drivers/media/platform/apple/avd/avd.h +++ b/drivers/media/platform/apple/avd/avd.h @@ -217,6 +217,9 @@ struct avd_dev { void __iomem *code; void __iomem *mbox; void __iomem *ctrl; + void __iomem *piodma; + phys_addr_t sram_phys; + bool piodma_version_logged; struct iommu_domain *domain; struct iommu_domain *empty_domain; From b9d5643dcd00784e19a1b14e52e486c6ffb61fd3 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 31 Oct 2026 13:00:24 +0000 Subject: [PATCH 4/4] media: apple: avd: use the documented SRAM base encoding Keep SRAM base programming in the documented register format. The binding and retained ADT contract do not impose an extra 36-bit platform resource restriction on probe. Assisted-by: LLM Signed-off-by: Ryan Murray --- drivers/media/platform/apple/avd/avd-drv.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/media/platform/apple/avd/avd-drv.c b/drivers/media/platform/apple/avd/avd-drv.c index 4baa5a9aa265b..4b7e13b00f22d 100644 --- a/drivers/media/platform/apple/avd/avd-drv.c +++ b/drivers/media/platform/apple/avd/avd-drv.c @@ -915,9 +915,6 @@ static int avd_probe(struct platform_device *pdev) if (!res) return dev_err_probe(avd->dev, -EINVAL, "missing SRAM resource for PIODMA\n"); - if (!IS_ALIGNED(res->start, 16) || (res->start >> 4) > U32_MAX) - return dev_err_probe(avd->dev, -EINVAL, - "SRAM address cannot be encoded for PIODMA\n"); avd->sram_phys = res->start; }