Skip to content

Commit cda5917

Browse files
Reworked pin group generation to use induvidual mux fields
1 parent bc21124 commit cda5917

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

tools/rt_cfg_utils.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -549,16 +549,20 @@ def write_pinctrl_header(self, outfile):
549549
" */\n\n")
550550
for pin in sorted(self._signal_map.values()):
551551
for iomux_opt in sorted(pin.get_mux_options()):
552+
header_block = ""
552553
# Get iomuxc constant values
553554
iomuxc_name = iomux_opt.get_name()
554555
register = iomux_opt.get_mux_reg()
556+
header_block += f"#define {iomuxc_name}_MUX 0x{register:x}\n"
555557
mode = iomux_opt.get_mux_val()
558+
header_block += f"#define {iomuxc_name}_MODE {mode:d}\n"
556559
input_reg = iomux_opt.get_daisy_reg()
560+
header_block += f"#define {iomuxc_name}_INPUT 0x{input_reg:x}\n"
557561
input_daisy = iomux_opt.get_daisy_val()
562+
header_block += f"#define {iomuxc_name}_DAISY {input_daisy:d}\n"
558563
config_reg = iomux_opt.get_cfg_reg()
559-
header_line = (f"#define {iomuxc_name} 0x{register:x} {mode:d}"
560-
f" 0x{input_reg:x} {input_daisy:d} 0x{config_reg:x}\n")
561-
soc_header.write(header_line)
564+
header_block += f"#define {iomuxc_name}_CFG 0x{config_reg:x}\n"
565+
soc_header.write(header_block)
562566
soc_header.write("\n")
563567
soc_header.close()
564568

@@ -652,14 +656,25 @@ def write_pinctrl_groups(self, mexfile, outputfile):
652656
# as well as their shared configuration into a group
653657
for idx in range(len(cfg_dict.keys())):
654658
pinmuxes = cfg_dict[sorted_keys[idx]]
655-
pinmux_str = ""
659+
# MUX REG, MUX MODE, DAISY REG, DAISY, CFG_REG
660+
mux_props = ["", "" ,"", "", ""]
661+
# Generate each named pinmux property
656662
for mux in pinmuxes:
657-
pinmux_str += f"<{mux}>,\n\t\t\t\t"
658-
pinmux_str = pinmux_str.strip(',\n\t\t\t\t')
663+
mux_props[0] += f"<{mux + '_MUX'}>,\n\t\t\t\t"
664+
mux_props[1] += f"<{mux + '_MODE'}>,\n\t\t\t\t"
665+
mux_props[2] += f"<{mux + '_INPUT'}>,\n\t\t\t\t"
666+
mux_props[3] += f"<{mux + '_DAISY'}>,\n\t\t\t\t"
667+
mux_props[4] += f"<{mux + '_CFG'}>,\n\t\t\t\t"
668+
for i in range(len(mux_props)):
669+
mux_props[i] = re.sub(r',\n\t\t\t\t$','', mux_props[i])
659670
# Name of group
660671
dts_entry = f"\t\tgroup{idx} {{\n"
661672
# Pinmuxes for group
662-
dts_entry += f"\t\t\tpins = {pinmux_str};\n"
673+
dts_entry += f"\t\t\tmux = {mux_props[0]};\n"
674+
dts_entry += f"\t\t\tmode = {mux_props[1]};\n"
675+
dts_entry += f"\t\t\tinput = {mux_props[2]};\n"
676+
dts_entry += f"\t\t\tdaisy = {mux_props[3]};\n"
677+
dts_entry += f"\t\t\tcfg = {mux_props[4]};\n"
663678
# Properties of group
664679
for prop in sorted_keys[idx]:
665680
dts_entry += f"\t\t\t{prop};\n"

0 commit comments

Comments
 (0)