From eca7cc7a4a4cb741d8688301a354bf991503d757 Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Fri, 25 Jun 2021 12:12:44 -0700 Subject: [PATCH] boards/intel_adsp: Update cavs-fw.py, robustify vs. Linux PM Add support for the extended manifest blocks that recent versions of rimage are including as a prefix on the firmware blob. Also include some PCI runtime PM tricks to reliably enable the DSP device on kernels that have turned off the DSP device automatically (e.g. systems that have PM enabled by default but where the SOF driver is not loaded -- chromebooks work this way, potentially other distros). Signed-off-by: Andy Ross --- boards/xtensa/intel_adsp_cavs15/tools/cavs-fw.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/boards/xtensa/intel_adsp_cavs15/tools/cavs-fw.py b/boards/xtensa/intel_adsp_cavs15/tools/cavs-fw.py index f36deb755fc..cdc0478ee2b 100755 --- a/boards/xtensa/intel_adsp_cavs15/tools/cavs-fw.py +++ b/boards/xtensa/intel_adsp_cavs15/tools/cavs-fw.py @@ -30,6 +30,10 @@ def main(): with open(FW_FILE, "rb") as f: fw_bytes = f.read() + (magic, sz) = struct.unpack("4sI", fw_bytes[0:8]) + if magic == b'XMan': + fw_bytes = fw_bytes[sz:len(fw_bytes)] + (hda, sd, dsp) = map_regs() # Device register mappings # Turn on HDA "global processing enable" first, which actually @@ -121,6 +125,16 @@ def map_regs(): pcidir = os.path.dirname(p) break + # Disengage runtime power management so the kernel doesn't put it to sleep + with open(pcidir + b"/power/control", "w") as ctrl: + ctrl.write("on") + + # Make sure PCI memory space access and busmastering are enabled. + # Also disable interrupts so as not to confuse the kernel. + with open(pcidir + b"/config", "wb+") as cfg: + cfg.seek(4) + cfg.write(b'\x06\x04') + hdamem = bar_map(pcidir, 0) # Standard HD Audio Registers