mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-26 08:20:18 +00:00
a489a646bd
Signed-off-by: Hector Martin <marcan@marcan.st>
24 lines
653 B
Python
24 lines
653 B
Python
import json, sys
|
|
|
|
data = json.load(open(sys.argv[1]))
|
|
for reg in data:
|
|
name = reg['name']
|
|
|
|
print(f"#define SYS_{name} sys_reg({', '.join(str(i) for i in reg['enc'])})")
|
|
|
|
if name[-4:-1] == "_EL":
|
|
name = name[:-4]
|
|
|
|
for fieldset in reg["fieldsets"]:
|
|
if "instance" in fieldset:
|
|
print(f"// {fieldset['instance']}")
|
|
for f in fieldset["fields"]:
|
|
fname = f["name"]
|
|
msb, lsb = f["msb"], f["lsb"]
|
|
|
|
if msb == lsb:
|
|
print(f"#define {name}_{fname} BIT({lsb})")
|
|
else:
|
|
print(f"#define {name}_{fname} GENMASK({msb}, {lsb})")
|
|
|
|
print()
|