diff --git a/Documentation/devicetree/bindings/media/apple,t8140-ave.yaml b/Documentation/devicetree/bindings/media/apple,t8140-ave.yaml index 50d2f123cb2aa..c214d96768d69 100644 --- a/Documentation/devicetree/bindings/media/apple,t8140-ave.yaml +++ b/Documentation/devicetree/bindings/media/apple,t8140-ave.yaml @@ -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 @@ -167,3 +185,36 @@ allOf: additionalProperties: false unevaluatedProperties: false + +examples: + - | + #include + #include + + 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 = , + , + , + , + ; + 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"; + }; + }; diff --git a/arch/arm64/boot/dts/apple/t6041.dtsi b/arch/arm64/boot/dts/apple/t6041.dtsi index 837aeb8177e04..50a0da521adb3 100644 --- a/arch/arm64/boot/dts/apple/t6041.dtsi +++ b/arch/arm64/boot/dts/apple/t6041.dtsi @@ -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. */ @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -892,7 +896,7 @@ #reset-cells = <0>; label = "venc1_me1"; power-domains = <&ps_venc1_me0>; - status = "disabled"; + status = "okay"; }; }; @@ -905,7 +909,7 @@ interrupt-parent = <&aic>; interrupts = ; power-domains = <&ps_venc1_sys>; - status = "disabled"; + status = "okay"; }; ave1_dart0: iommu@2850a0000 { @@ -916,7 +920,7 @@ interrupt-parent = <&aic>; interrupts = ; power-domains = <&ps_venc1_sys>; - status = "disabled"; + status = "okay"; }; ave1: video-codec@285100000 { @@ -932,10 +936,12 @@ , ; 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"; }; }; @@ -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"; @@ -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; }; }; diff --git a/drivers/media/platform/apple/ave/ave-fw.c b/drivers/media/platform/apple/ave/ave-fw.c index 9522672040711..45a1fa3175753 100644 --- a/drivers/media/platform/apple/ave/ave-fw.c +++ b/drivers/media/platform/apple/ave/ave-fw.c @@ -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); @@ -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"); @@ -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");