Lines Matching refs:f
40 with open(args.edt_pickle, 'rb') as f:
41 edt = pickle.load(f)
64 sys.exit(f"ERROR: Duplicate 'zephyr,memory-region' ({region}) properties "
65 f"between {regions[region].path} and {node.path}")
72 out_dt_define(f"{node.z_path_id}_PATH", f'"{escape(node.path)}"')
75 out_dt_define(f"{node.z_path_id}_FULL_NAME",
76 f'"{escape(node.name)}"')
77 out_dt_define(f"{node.z_path_id}_FULL_NAME_UNQUOTED",
78 f'{escape(node.name)}')
79 out_dt_define(f"{node.z_path_id}_FULL_NAME_TOKEN",
80 f'{edtlib.str_as_token(escape(node.name))}')
81 out_dt_define(f"{node.z_path_id}_FULL_NAME_UPPER_TOKEN",
82 f'{edtlib.str_as_token(escape(node.name)).upper()}')
85 out_comment(f"Node parent ({node.parent.path}) identifier:")
86 out_dt_define(f"{node.z_path_id}_PARENT",
87 f"DT_{node.parent.z_path_id}")
89 out_comment(f"Node's index in its parent's list of children:")
90 out_dt_define(f"{node.z_path_id}_CHILD_IDX",
94 out_dt_define(f"{node.z_path_id}_NODELABEL_NUM", len(node.labels))
95 out_dt_define(f"{node.z_path_id}_FOREACH_NODELABEL(fn)",
96 " ".join(f"fn({nodelabel})" for nodelabel in node.labels))
97 out_dt_define(f"{node.z_path_id}_FOREACH_NODELABEL_VARGS(fn, ...)",
98 " ".join(f"fn({nodelabel}, __VA_ARGS__)" for nodelabel in node.labels))
125 components.extend(f"S_{str2ident(component)}" for component in
147 s = f"""\
163 s += f" {scc[0].dep_ordinal:<3} {scc[0].path}\n"
183 s = f"""\
191 s += f"""
196 s += f"""
240 idents = [f"N_ALIAS_{str2ident(alias)}" for alias in node.aliases]
244 idents.append(f"N_INST_{instance_no}_{str2ident(compat)}")
246 idents.extend(f"N_NODELABEL_{str2ident(label)}" for label in node.labels)
249 out_dt_define(f"{node.z_path_id}_EXISTS", 1)
253 maxlen = max(len(f"DT_{ident}") for ident in idents)
255 out_dt_define(ident, f"DT_{node.z_path_id}", width=maxlen)
265 out_comment(f"Bus info (controller: '{bus.path}', type: '{node.on_buses}')")
268 out_dt_define(f"{node.z_path_id}_BUS_{str2ident(one_bus)}", 1)
270 out_dt_define(f"{node.z_path_id}_BUS", f"DT_{bus.z_path_id}")
302 idx_vals.append((f"{path_id}_RANGES_NUM", len(node.ranges)))
305 idx_vals.append((f"{path_id}_RANGES_IDX_{i}_EXISTS", 1))
308 idx_vals.append((f"{path_id}_RANGES_IDX_{i}_VAL_CHILD_BUS_FLAGS_EXISTS", 1))
309 idx_macro = f"{path_id}_RANGES_IDX_{i}_VAL_CHILD_BUS_FLAGS"
312 f"{idx_value} /* {hex(idx_value)} */"))
314 idx_macro = f"{path_id}_RANGES_IDX_{i}_VAL_CHILD_BUS_ADDRESS"
320 f"{idx_value} /* {hex(idx_value)} */"))
322 idx_macro = f"{path_id}_RANGES_IDX_{i}_VAL_PARENT_BUS_ADDRESS"
324 f"{range.parent_bus_addr} /* {hex(range.parent_bus_addr)} */"))
326 idx_macro = f"{path_id}_RANGES_IDX_{i}_VAL_LENGTH"
328 f"{range.length} /* {hex(range.length)} */"))
333 out_dt_define(f"{path_id}_FOREACH_RANGE(fn)",
334 " ".join(f"fn(DT_{path_id}, {i})" for i,range in enumerate(node.ranges)))
347 idx_vals.append((f"{path_id}_REG_NUM", len(node.regs)))
350 idx_vals.append((f"{path_id}_REG_IDX_{i}_EXISTS", 1))
352 idx_macro = f"{path_id}_REG_IDX_{i}_VAL_ADDRESS"
354 f"{reg.addr} /* {hex(reg.addr)} */"))
356 name_vals.append((f"{path_id}_REG_NAME_{reg.name}_EXISTS", 1))
357 name_macro = f"{path_id}_REG_NAME_{reg.name}_VAL_ADDRESS"
358 name_vals.append((name_macro, f"DT_{idx_macro}"))
361 idx_macro = f"{path_id}_REG_IDX_{i}_VAL_SIZE"
363 f"{reg.size} /* {hex(reg.size)} */"))
365 name_macro = f"{path_id}_REG_NAME_{reg.name}_VAL_SIZE"
366 name_vals.append((name_macro, f"DT_{idx_macro}"))
384 err(f"Expected binding for {irq.controller!r} to have 'type' in "
392 err(f"Invalid interrupt type specified for {irq!r}")
399 idx_vals.append((f"{path_id}_IRQ_NUM", len(node.interrupts)))
409 idx_vals.append((f"{path_id}_IRQ_IDX_{i}_EXISTS", 1))
410 idx_macro = f"{path_id}_IRQ_IDX_{i}_VAL_{name}"
415 f"{path_id}_IRQ_NAME_{str2ident(irq.name)}_VAL_{name}")
416 name_vals.append((name_macro, f"DT_{idx_macro}"))
419 idx_controller_macro = f"{path_id}_IRQ_IDX_{i}_CONTROLLER"
420 idx_controller_path = f"DT_{irq.controller.z_path_id}"
423 name_controller_macro = f"{path_id}_IRQ_NAME_{str2ident(irq.name)}_CONTROLLER"
424 name_vals.append((name_controller_macro, f"DT_{idx_controller_macro}"))
434 idx_vals.append((f"{path_id}_IRQ_LEVEL", len(irqs)))
449 f"{node.z_path_id}_COMPAT_MATCHES_{str2ident(compat)}", 1)
452 out_dt_define(f"{node.z_path_id}_COMPAT_VENDOR_IDX_{i}_EXISTS", 1)
453 out_dt_define(f"{node.z_path_id}_COMPAT_VENDOR_IDX_{i}",
457 out_dt_define(f"{node.z_path_id}_COMPAT_MODEL_IDX_{i}_EXISTS", 1)
458 out_dt_define(f"{node.z_path_id}_COMPAT_MODEL_IDX_{i}",
469 out_dt_define(f"{node.z_path_id}_FOREACH_ANCESTOR(fn)",
470 " ".join(f"fn(DT_{parent.z_path_id})" for parent in
478 out_dt_define(f"{node.z_path_id}_CHILD_NUM", len(node.children))
485 out_dt_define(f"{node.z_path_id}_CHILD_NUM_STATUS_OKAY", ok_nodes_num)
487 out_dt_define(f"{node.z_path_id}_FOREACH_CHILD(fn)",
488 " ".join(f"fn(DT_{child.z_path_id})" for child in
491 out_dt_define(f"{node.z_path_id}_FOREACH_CHILD_SEP(fn, sep)",
492 " DT_DEBRACKET_INTERNAL sep ".join(f"fn(DT_{child.z_path_id})"
495 out_dt_define(f"{node.z_path_id}_FOREACH_CHILD_VARGS(fn, ...)",
496 " ".join(f"fn(DT_{child.z_path_id}, __VA_ARGS__)"
499 out_dt_define(f"{node.z_path_id}_FOREACH_CHILD_SEP_VARGS(fn, sep, ...)",
500 " DT_DEBRACKET_INTERNAL sep ".join(f"fn(DT_{child.z_path_id}, __VA_ARGS__)"
503 out_dt_define(f"{node.z_path_id}_FOREACH_CHILD_STATUS_OKAY(fn)",
504 " ".join(f"fn(DT_{child.z_path_id})"
507 out_dt_define(f"{node.z_path_id}_FOREACH_CHILD_STATUS_OKAY_SEP(fn, sep)",
508 " DT_DEBRACKET_INTERNAL sep ".join(f"fn(DT_{child.z_path_id})"
511 out_dt_define(f"{node.z_path_id}_FOREACH_CHILD_STATUS_OKAY_VARGS(fn, ...)",
512 " ".join(f"fn(DT_{child.z_path_id}, __VA_ARGS__)"
515 out_dt_define(f"{node.z_path_id}_FOREACH_CHILD_STATUS_OKAY_SEP_VARGS(fn, sep, ...)",
516 " DT_DEBRACKET_INTERNAL sep ".join(f"fn(DT_{child.z_path_id}, __VA_ARGS__)"
521 out_dt_define(f"{node.z_path_id}_STATUS_{str2ident(node.status)}", 1)
529 out_dt_define(f"{node.z_path_id}_PINCTRL_NUM", len(node.pinctrls))
535 out_dt_define(f"{node.z_path_id}_PINCTRL_IDX_{pc_idx}_EXISTS", 1)
545 out_dt_define(f"{node.z_path_id}_PINCTRL_IDX_{pc_idx}_TOKEN", name)
546 out_dt_define(f"{node.z_path_id}_PINCTRL_IDX_{pc_idx}_UPPER_TOKEN", name.upper())
547 out_dt_define(f"{node.z_path_id}_PINCTRL_NAME_{name}_EXISTS", 1)
548 out_dt_define(f"{node.z_path_id}_PINCTRL_NAME_{name}_IDX", pc_idx)
550 out_dt_define(f"{node.z_path_id}_PINCTRL_NAME_{name}_IDX_{idx}_PH",
551 f"DT_{ph.z_path_id}")
562 out_dt_define(f"{node.z_path_id}_PARTITION_ID", flash_area_num)
569 macro = f"{node.z_path_id}_GPIO_HOGS"
576 out_dt_define(f"{macro}_EXISTS", 1)
577 out_dt_define(f"{macro}_NUM", len(node.gpio_hogs))
596 macro = f"{node.z_path_id}_P_{prop_id}"
608 macro2val[f"{macro}_IDX_0"] = quote_str(prop.val)
609 macro2val[f"{macro}_IDX_0_EXISTS"] = 1
622 macro2val[f"{macro}_FOREACH_PROP_ELEM(fn)"] = (
623 ' \\\n\t'.join(f'fn(DT_{node.z_path_id}, {prop_id}, {i})'
627 macro2val[f"{macro}_FOREACH_PROP_ELEM_SEP(fn, sep)"] = (
629 f'fn(DT_{node.z_path_id}, {prop_id}, {i})'
633 macro2val[f"{macro}_FOREACH_PROP_ELEM_VARGS(fn, ...)"] = (
635 f'fn(DT_{node.z_path_id}, {prop_id}, {i}, __VA_ARGS__)'
639 macro2val[f"{macro}_FOREACH_PROP_ELEM_SEP_VARGS(fn, sep, ...)"] = (
641 f'fn(DT_{node.z_path_id}, {prop_id}, {i}, __VA_ARGS__)'
645 macro2val[f"{macro}_LEN"] = plen
648 macro2val[f"{macro}_EXISTS"] = 1
665 f"{macro}_STRING_UNQUOTED": escape_unquoted(val),
667 f"{macro}_STRING_TOKEN": as_token,
669 f"{macro}_STRING_UPPER_TOKEN": as_token.upper()}
678 ret = {f"{macro}_IDX_{i}_ENUM_IDX": index for i, index in enumerate(prop.enum_indices)}
683 ret[f"{macro}_IDX_{i}_EXISTS"] = 1
685 ret[f"{macro}_IDX_{i}_ENUM_VAL_{subval}_EXISTS"] = 1
697 ret[f"{macro}_IDX_{i}_EXISTS"] = 1
701 ret[f"{macro}_IDX_{i}"] = quote_str(subval)
703 ret.update(string_macros(f"{macro}_IDX_{i}", subval))
705 ret[f"{macro}_IDX_{i}"] = subval
718 .join(f"{n.dep_ordinal}, /* {n.path} */"
724 out_dt_define(f"{node.z_path_id}_ORD", node.dep_ordinal)
725 out_dt_define(f"{node.z_path_id}_ORD_STR_SORTABLE", f"{node.dep_ordinal:0>5}")
728 out_dt_define(f"{node.z_path_id}_REQUIRES_ORDS",
732 out_dt_define(f"{node.z_path_id}_SUPPORTS_ORDS",
751 return list2init(f"{val} /* {hex(val)} */" for val in prop.val)
812 ret[f"{macro}"] = f"DT_{prop.val.z_path_id}"
813 ret[f"{macro}_IDX_0"] = f"DT_{prop.val.z_path_id}"
814 ret[f"{macro}_IDX_0_PH"] = f"DT_{prop.val.z_path_id}"
815 ret[f"{macro}_IDX_0_EXISTS"] = 1
818 ret[f"{macro}_IDX_{i}"] = f"DT_{node.z_path_id}"
819 ret[f"{macro}_IDX_{i}_PH"] = f"DT_{node.z_path_id}"
820 ret[f"{macro}_IDX_{i}_EXISTS"] = 1
827 ret[f"{macro}_IDX_{i}_EXISTS"] = 0
846 ret[f"{macro}_IDX_{i}_EXISTS"] = 1
848 ret[f"{macro}_IDX_{i}_PH"] = f"DT_{entry.controller.z_path_id}"
851 ret[f"{macro}_IDX_{i}_VAL_{str2ident(cell)}"] = val
852 ret[f"{macro}_IDX_{i}_VAL_{str2ident(cell)}_EXISTS"] = 1
859 ret[f"{macro}_IDX_{i}_EXISTS"] = 1
861 ret[f"{macro}_IDX_{i}_NAME"] = quote_str(entry.name)
863 ret[f"{macro}_NAME_{name}_PH"] = f"DT_{entry.controller.z_path_id}"
865 ret[f"{macro}_NAME_{name}_EXISTS"] = 1
869 ret[f"{macro}_NAME_{name}_VAL_{cell_ident}"] = (
870 f"DT_{macro}_IDX_{i}_VAL_{cell_ident}")
871 ret[f"{macro}_NAME_{name}_VAL_{cell_ident}_EXISTS"] = 1
882 chosen[f"DT_CHOSEN_{str2ident(name)}"] = f"DT_{node.z_path_id}"
883 chosen[f"DT_CHOSEN_{str2ident(name)}_EXISTS"] = 1
896 " ".join(f"fn(DT_{node.z_path_id})" for node in edt.nodes))
898 " ".join(f"fn(DT_{node.z_path_id})" for node in edt.nodes
901 " ".join(f"fn(DT_{node.z_path_id}, __VA_ARGS__)" for node in edt.nodes))
903 " ".join(f"fn(DT_{node.z_path_id}, __VA_ARGS__)" for node in edt.nodes
917 n_okay_macros[f"DT_N_INST_{ident}_NUM_OKAY"] = len(okay_nodes)
921 for_each_macros[f"DT_FOREACH_OKAY_{ident}(fn)"] = (
922 " ".join(f"fn(DT_{node.z_path_id})"
924 for_each_macros[f"DT_FOREACH_OKAY_VARGS_{ident}(fn, ...)"] = (
925 " ".join(f"fn(DT_{node.z_path_id}, __VA_ARGS__)"
933 for_each_macros[f"DT_FOREACH_OKAY_INST_{ident}(fn)"] = (
934 " ".join(f"fn({edt.compat2nodes[compat].index(node)})"
936 for_each_macros[f"DT_FOREACH_OKAY_INST_VARGS_{ident}(fn, ...)"] = (
937 " ".join(f"fn({edt.compat2nodes[compat].index(node)}, __VA_ARGS__)"
946 macro = f"COMPAT_{str2ident(compat)}_LABEL_{str2ident(label)}"
947 val = f"DT_{child.z_path_id}"
955 out_define(f"DT_COMPAT_HAS_OKAY_{str2ident(compat)}", 1)
967 f"DT_COMPAT_{str2ident(compat)}_BUS_{str2ident(bus)}", 1)
999 ret = f"DT_{macro}"
1017 s = f"#define {macro.ljust(width)}{warn} {val}"
1019 s = f"#define {macro}{warn} {val}"
1045 res.append(f" * {line}".rstrip())
1052 print(f"/* {s} */", file=header_file)
1074 return f'"{escape(s)}"'