Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions Documentation/devicetree/bindings/media/apple,avd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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>;
};
};
7 changes: 4 additions & 3 deletions arch/arm64/boot/dts/apple/t600x-dieX.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions arch/arm64/boot/dts/apple/t6040.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <AIC_IRQ 1442 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 1443 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_avd_sys>;
resets = <&ps_avd_sys>;
iommus = <&avd_dart 0>;
iommus = <&avd_dart 0>, <&avd_dart 1>;
};

avd_dart: iommu@281020000 {
Expand Down
7 changes: 4 additions & 3 deletions arch/arm64/boot/dts/apple/t8112.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions arch/arm64/boot/dts/apple/t8140.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};

Expand Down
15 changes: 15 additions & 0 deletions drivers/media/platform/apple/avd/avd-drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -903,6 +904,20 @@ 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");
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);
Expand Down
10 changes: 10 additions & 0 deletions drivers/media/platform/apple/avd/avd-hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions drivers/media/platform/apple/avd/avd-regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions drivers/media/platform/apple/avd/avd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down