|
24 | 24 | # Zephyr doesn't use tristate symbols. They're supported here just to make the
|
25 | 25 | # script a bit more generic.
|
26 | 26 | from kconfiglib import Kconfig, split_expr, expr_value, expr_str, BOOL, \
|
27 |
| - TRISTATE, TRI_TO_STR, AND, OR |
| 27 | + TRISTATE, TRI_TO_STR, AND, OR, STRING, TYPE_TO_STR, Symbol |
28 | 28 |
|
29 | 29 |
|
30 | 30 | def main():
|
@@ -112,6 +112,63 @@ def main():
|
112 | 112 | else:
|
113 | 113 | edt = None
|
114 | 114 |
|
| 115 | + SYM_TO_TYPE = { |
| 116 | + "FLASH_HAS_DRIVER_ENABLED": "api", |
| 117 | + "SERIAL_HAS_DRIVER": "api", |
| 118 | + "ENTROPY_HAS_DRIVER": "api", |
| 119 | + "SERIAL_SUPPORT_INTERRUPT": "feature", |
| 120 | + "SERIAL_SUPPORT_ASYNC": "feature", |
| 121 | + } |
| 122 | + |
| 123 | + if edt: |
| 124 | + for compat in edt.compat2okay.keys(): |
| 125 | + device_sym = compat2symbol(kconf, compat) |
| 126 | + |
| 127 | + if device_sym: |
| 128 | +# print("C: %s" % compat) |
| 129 | +# print("N: %s" % device_sym.name) |
| 130 | +# print(device_sym) |
| 131 | +# for r in device_sym.referenced: |
| 132 | +# if isinstance(r, Symbol) and r != kconf.y: |
| 133 | +# print("R: %s" % r.name) |
| 134 | + for (sym, cond) in device_sym.selects: |
| 135 | +# print("S: %s" % sym.name) |
| 136 | + if sym.name in SYM_TO_TYPE: |
| 137 | + print('dts compatible: "%s" Kconfig Symbol: %s' % (compat, device_sym.name)) |
| 138 | + print("%s - %s" % (SYM_TO_TYPE[sym.name], sym.name)) |
| 139 | + print("") |
| 140 | + |
| 141 | +def compat2symbol(kconf, compat): |
| 142 | + dt_sym = None |
| 143 | + for sym in kconf.syms.values(): |
| 144 | + if sym.type == STRING and sym.str_value == compat: |
| 145 | + dt_sym = sym |
| 146 | + |
| 147 | + if dt_sym == None: |
| 148 | +# print("error found no symbol matching %s" % compat) |
| 149 | + return None |
| 150 | + |
| 151 | + dt_has_sym = None |
| 152 | + for r in dt_sym.referenced: |
| 153 | + if isinstance(r, Symbol): |
| 154 | + if "DT_HAS_" in r.name: |
| 155 | + dt_has_sym = r |
| 156 | + |
| 157 | + if dt_has_sym == None: |
| 158 | + print("error found no symbol matching %s" % compat) |
| 159 | + |
| 160 | + device_sym = None |
| 161 | + for sym in kconf.syms.values(): |
| 162 | + if sym == dt_sym: |
| 163 | + continue |
| 164 | + for r in sym.referenced: |
| 165 | + if isinstance(r, Symbol) and r == dt_has_sym: |
| 166 | + if device_sym: |
| 167 | + print("ERROR - only expect one device symbol to match") |
| 168 | + device_sym = sym |
| 169 | + |
| 170 | + return device_sym |
| 171 | + |
115 | 172 |
|
116 | 173 | def check_no_promptless_assign(kconf):
|
117 | 174 | # Checks that no promptless symbols are assigned
|
|
0 commit comments