boards/intel_adsp_cavs15: add generic ADSP detection to adsplog.py
As there are a lot of PCI IDs for various devices, identifying the ADSP this way will be hard to maintain. Implement a more generic device look-up using the PCI vendor and class information to detect a compatible ADSP. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
This commit is contained in:
parent
28f0a7a2ac
commit
ed2d104bab
1 changed files with 17 additions and 20 deletions
|
@ -6,7 +6,6 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import subprocess
|
|
||||||
import mmap
|
import mmap
|
||||||
|
|
||||||
# Log reader for the trace output buffer on a ADSP device.
|
# Log reader for the trace output buffer on a ADSP device.
|
||||||
|
@ -40,31 +39,29 @@ WIN_IDX = 3
|
||||||
WIN_SIZE = 0x20000
|
WIN_SIZE = 0x20000
|
||||||
LOG_OFFSET = WIN_OFFSET + WIN_IDX * WIN_SIZE
|
LOG_OFFSET = WIN_OFFSET + WIN_IDX * WIN_SIZE
|
||||||
|
|
||||||
# List of known ADSP devices by their PCI IDs
|
|
||||||
DEVICES = ["8086:5a98"]
|
|
||||||
|
|
||||||
mem = None
|
mem = None
|
||||||
|
sys_devices = "/sys/bus/pci/devices"
|
||||||
|
|
||||||
for dev in DEVICES:
|
for dev_addr in os.listdir(sys_devices):
|
||||||
# Find me a way to do this detection as cleanly in python as shell, I
|
class_file = sys_devices + "/" + dev_addr + "/class"
|
||||||
# dare you.
|
pciclass = open(class_file).read()
|
||||||
barfile = subprocess.Popen(["sh", "-c",
|
|
||||||
"echo -n "
|
vendor_file = sys_devices + "/" + dev_addr + "/vendor"
|
||||||
"$(dirname "
|
pcivendor = open(vendor_file).read()
|
||||||
f" $(fgrep PCI_ID={dev.upper()} "
|
|
||||||
" /sys/bus/pci/devices/*/uevent))"
|
if not "0x8086" in pcivendor:
|
||||||
"/resource4"],
|
|
||||||
stdout=subprocess.PIPE).stdout.read()
|
|
||||||
if not os.path.exists(barfile):
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not os.access(barfile, os.R_OK):
|
# Intel Multimedia audio controller
|
||||||
sys.stderr.write(f"ERROR: Cannot open {barfile} for reading.\n")
|
# 0x040100 -> DSP is present
|
||||||
sys.exit(1)
|
# 0x040380 -> DSP is present but optional
|
||||||
|
if "0x040100" in pciclass or "0x040380" in pciclass:
|
||||||
|
barfile = sys_devices + "/" + dev_addr + "/resource4"
|
||||||
|
|
||||||
fd = open(barfile)
|
fd = open(barfile)
|
||||||
mem = mmap.mmap(fd.fileno(), MAP_SIZE, offset=LOG_OFFSET,
|
mem = mmap.mmap(fd.fileno(), MAP_SIZE, offset=LOG_OFFSET,
|
||||||
prot=mmap.PROT_READ)
|
prot=mmap.PROT_READ)
|
||||||
|
break
|
||||||
|
|
||||||
if mem is None:
|
if mem is None:
|
||||||
sys.stderr.write("ERROR: No ADSP device found.\n")
|
sys.stderr.write("ERROR: No ADSP device found.\n")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue