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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions Documentation/devicetree/bindings/media/apple,t8140-ave.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,24 @@ allOf:
- description: Preloaded firmware text
- description: Preloaded firmware data

aurora,ave-text-crc32:
$ref: /schemas/types.yaml#/definitions/string
pattern: '^[0-9a-fA-F]{1,8}$'
description: |
Hexadecimal CRC32 of this encoder's preloaded firmware text region,
injected by the bootloader at boot. When absent, the driver falls
back to /chosen/aurora,ave-text-crc32 for compatibility with older
bootloaders; if present, it takes precedence and must be valid.

aurora,ave-data-crc32:
$ref: /schemas/types.yaml#/definitions/string
pattern: '^[0-9a-fA-F]{1,8}$'
description: |
Hexadecimal CRC32 of this encoder's clean preloaded firmware data
region, injected by the bootloader at boot. When absent, the driver
falls back to /chosen/aurora,ave-data-crc32 for compatibility with
older bootloaders; if present, it takes precedence and must be valid.

required:
- compatible
- reg
Expand Down Expand Up @@ -167,3 +185,36 @@ allOf:
additionalProperties: false

unevaluatedProperties: false

examples:
- |
#include <dt-bindings/interrupt-controller/apple-aic.h>
#include <dt-bindings/interrupt-controller/irq.h>

soc {
#address-cells = <2>;
#size-cells = <2>;

video-codec@285100000 {
compatible = "apple,t6041-ave";
reg = <0x2 0x85100000 0x0 0x45c000>,
<0x2 0x85050000 0x0 0x4000>,
<0x2 0x85800000 0x0 0x800000>;
reg-names = "codec", "mailbox", "coproc";
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 1476 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 1470 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 1469 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 1472 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 1471 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_venc1_dma>, <&ps_venc1_pipe4>,
<&ps_venc1_pipe5>, <&ps_venc1_me0>,
<&ps_venc1_me1>, <&pmc_soc_max>;
power-domain-names = "dma", "pipe4", "pipe5", "me0", "me1", "perf";
iommus = <&ave1_dart0 0>, <&ave1_dart0 12>,
<&ave1_dart1 0>, <&ave1_dart1 12>;
memory-region = <&ave1_fw_text>, <&ave1_fw_data>;
aurora,ave-text-crc32 = "9a080cad";
aurora,ave-data-crc32 = "6e66c376";
};
};
44 changes: 27 additions & 17 deletions arch/arm64/boot/dts/apple/t6041.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<&ps_venc0_pipe5>, <&ps_venc0_me0>, <&ps_venc0_me1>,
<&pmc_soc_max>;
power-domain-names = "dma", "pipe4", "pipe5", "me0", "me1", "perf";
iommus = <&ave0_dart0 0>, <&ave0_dart0 12>,
<&ave0_dart1 0>, <&ave0_dart1 12>;
};

/* The loader supplies the ANE firmware and reservations. */
Expand Down Expand Up @@ -831,8 +833,10 @@
/*
* The second video encoder (ADT ave1, soc-id t6041), unique to the M4 Max.
* Its six PMGR power states (VENC1_SYS through VENC1_ME1) live in pmgr_aux
* (0x5028002a0..0x5028002c8). All nodes stay disabled until a bootloader
* handoff preloads and qualifies ave1's firmware.
* (0x5028002a0..0x5028002c8), and it shares the VENC1-SOC-VMAX performance
* vote (pmc_soc_max) like ave0. It has no board wiring, so it is enabled on
* every M4 Max board; the boot loader reserves its preloaded firmware, sets
* up dart-ave1's DAPF filter, and disables it if absent from the ADT.
*/
&pmgr_aux {
ps_venc1_sys: power-controller@2a0 {
Expand All @@ -842,7 +846,7 @@
#reset-cells = <0>;
label = "venc1_sys";
power-domains = <&ps_fab0_soc>;
status = "disabled";
status = "okay";
};

ps_venc1_dma: power-controller@2a8 {
Expand All @@ -852,7 +856,7 @@
#reset-cells = <0>;
label = "venc1_dma";
power-domains = <&ps_venc1_sys>;
status = "disabled";
status = "okay";
};

ps_venc1_pipe4: power-controller@2b0 {
Expand All @@ -862,7 +866,7 @@
#reset-cells = <0>;
label = "venc1_pipe4";
power-domains = <&ps_venc1_dma>;
status = "disabled";
status = "okay";
};

ps_venc1_pipe5: power-controller@2b8 {
Expand All @@ -872,7 +876,7 @@
#reset-cells = <0>;
label = "venc1_pipe5";
power-domains = <&ps_venc1_dma>;
status = "disabled";
status = "okay";
};

ps_venc1_me0: power-controller@2c0 {
Expand All @@ -882,7 +886,7 @@
#reset-cells = <0>;
label = "venc1_me0";
power-domains = <&ps_venc1_dma>;
status = "disabled";
status = "okay";
};

ps_venc1_me1: power-controller@2c8 {
Expand All @@ -892,7 +896,7 @@
#reset-cells = <0>;
label = "venc1_me1";
power-domains = <&ps_venc1_me0>;
status = "disabled";
status = "okay";
};
};

Expand All @@ -905,7 +909,7 @@
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 1473 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_venc1_sys>;
status = "disabled";
status = "okay";
};

ave1_dart0: iommu@2850a0000 {
Expand All @@ -916,7 +920,7 @@
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 1473 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_venc1_sys>;
status = "disabled";
status = "okay";
};

ave1: video-codec@285100000 {
Expand All @@ -932,10 +936,12 @@
<AIC_IRQ 1472 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 1471 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_venc1_dma>, <&ps_venc1_pipe4>,
<&ps_venc1_pipe5>, <&ps_venc1_me0>, <&ps_venc1_me1>;
power-domain-names = "dma", "pipe4", "pipe5", "me0", "me1";
iommus = <&ave1_dart0 0>, <&ave1_dart1 0>;
status = "disabled";
<&ps_venc1_pipe5>, <&ps_venc1_me0>, <&ps_venc1_me1>,
<&pmc_soc_max>;
power-domain-names = "dma", "pipe4", "pipe5", "me0", "me1", "perf";
iommus = <&ave1_dart0 0>, <&ave1_dart0 12>,
<&ave1_dart1 0>, <&ave1_dart1 12>;
status = "okay";
};
};

Expand Down Expand Up @@ -998,8 +1004,7 @@
* The first video encoder (ADT ave0, soc-id t6040), its DARTs and its power
* domains. It has no board wiring, so it is enabled on every M4 Max board.
* iBoot preloads its firmware; the driver refuses a firmware layout it does
* not know at probe. The second encoder (ave1, soc-id t6041) is not
* described.
* not know at probe.
*/
&ps_venc0_sys {
status = "okay";
Expand Down Expand Up @@ -1040,10 +1045,15 @@
#include "t6041-pmgr.dtsi"
#include "t6041-sleep-pmgr.dtsi"

/* The loader uses this alias to enable SIO after placing its firmware. */
/*
* The loader uses these aliases to enable SIO after placing its firmware
* and to program the encoder DAPF filters (dart-ave0, dart-ave1).
*/
/ {
aliases {
sio = &sio;
ave = &ave;
ave1 = &ave1;
};
};

Expand Down
15 changes: 11 additions & 4 deletions drivers/media/platform/apple/ave/ave-fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,19 @@ static const u32 ave_known_text_crc[] = {
0x25bfd039, /* encoder firmware 6070.11.1 / T8112 */
};

static int ave_fw_chosen_crc(struct ave_dev *ave, const char *name, u32 *crc)
static int ave_fw_dt_crc(struct ave_dev *ave, const char *name, u32 *crc)
{
struct device_node *chosen = of_find_node_by_path("/chosen");
struct device_node *chosen;
const char *str;
int ret;

ret = of_property_read_string(ave->dev->of_node, name, &str);
if (!ret)
return kstrtou32(str, 16, crc);
if (ret != -EINVAL)
return ret;

chosen = of_find_node_by_path("/chosen");
if (!chosen)
return -ENOENT;
ret = of_property_read_string(chosen, name, &str);
Expand Down Expand Up @@ -331,7 +338,7 @@ int ave_fw_probe(struct ave_dev *ave)
ret = ave_fw_crc(&ave->text, &text_crc, NULL);
if (ret)
return ret;
ret = ave_fw_chosen_crc(ave, "aurora,ave-text-crc32", &want);
ret = ave_fw_dt_crc(ave, "aurora,ave-text-crc32", &want);
if (ret || text_crc != want)
return dev_err_probe(dev, -ENODEV,
"firmware text differs from loader CRC\n");
Expand Down Expand Up @@ -371,7 +378,7 @@ int ave_fw_probe(struct ave_dev *ave)
* The loader records the DATA checksum before anything runs. If it
* differs, the firmware already ran and there is no clean copy left.
*/
ret = ave_fw_chosen_crc(ave, "aurora,ave-data-crc32", &want);
ret = ave_fw_dt_crc(ave, "aurora,ave-data-crc32", &want);
if (ret || data_crc != want) {
ret = dev_err_probe(dev, -ENODEV,
"firmware data is not in its boot state\n");
Expand Down
Loading