Skip to content
Closed
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
15 changes: 10 additions & 5 deletions proxyclient/m1n1/hw/pmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, u, adt_path=None):

self.node = u.adt[adt_path]
self.bus_type = bus_type
if bus_type == "spmi":
if bus_type.startswith("spmi"):
self.spmi = SPMI(u, adt_path.rpartition('/')[0])
self.primary = u.adt[adt_path].is_primary == 1
elif bus_type == "i2c":
Expand All @@ -26,9 +26,13 @@ def __init__(self, u, adt_path=None):
self.reg = u.adt[adt_path].reg[0]

def reset_panic_counter(self):
if self.primary and self.bus_type == "spmi":
leg_scrpad = self.node.info_leg__scrpad[0]
self.spmi.write8(self.reg, leg_scrpad + 2, 0) # error counts
if self.primary and self.bus_type.startswith("spmi"):
if self.bus_type == "spmi3":
leg_scrpad = self.node.info_leg__scrpad[0]
self.spmi.write8(self.reg, leg_scrpad + 2, 0) # error counts
else:
print("Reset panic unsupported")
return
elif self.primary and self.bus_type == "i2c":
if self.node.compatible[0] in ["pmu,d2255", "pmu,d2257", "pmu,d2333", "pmu,d2365", "pmu,d2400"]:
counter = 0x5002
Expand All @@ -45,11 +49,12 @@ def reset_panic_counter(self):
def find_primary_pmu(adt):
for child in adt["/arm-io"]:
if child.name.startswith("nub-spmi") or child.name.startswith("spmi"):
gen = getattr(child, "gen")
for pmu in child:
compat = getattr(pmu, "compatible")[0] if hasattr(pmu, "compatible") else "unset"
primary = (getattr(pmu, "is-primary") == 1) if hasattr(pmu, "is-primary") else False
if compat in ("pmu,spmi", "pmu,d2422", "pmu,d2449") and primary:
return (pmu._path.removeprefix('/device-tree'), "spmi")
return (pmu._path.removeprefix('/device-tree'), f"spmi{gen}")
elif child.name.startswith("i2c"):
for dev in child:
if dev.name == "pmu":
Expand Down
Loading