1 #!/usr/bin/python
2 # Python script to automatically generate the IO pad and delay data
3 # Author:- Nikhil Devshatwar
5 # This script uses regdump of the pad registers to figure out the muxmodes
6 # Based on the pad and muxmode, it find out all possible virtual/manual modes
7 # by referring to the PCT XML model. Using the, selection file, script
8 # decides which modes to be selected. Finally it dumps the required array entries
10 # This script depends on following files:-
11 # * XML data files - Shipped with the DRA7xx PCT tool
12 # * Pad register dump - Generate using omapconf dump 0x4a003400 0x4a00380c
13 # * selection file - List of selected virtual/manual modes to be used
15 import xml.etree.ElementTree as ET
16 import re
17 import argparse
19 # Handle the command line arguments
20 parser = argparse.ArgumentParser(prog='iodelay-autogen.py',
21 description='Python script to generate the IOdelay data.\n' \
22 'This script refers to the XML data and automatically generates\n' \
23 'PAD and DELAY data for the same use case.\n' \
24 'Note that only the PADs which are used in the dump are configured.',
25 epilog='Generate the pad and delay data using pad regdump')
27 parser.add_argument('-d', '--debug', dest='debug',
28 action='store', type=int, choices=[0, 1, 2], default=0,
29 help='set the debug level')
31 parser.add_argument('-i', '--interactive', dest='interactive',
32 action='store', type=int, choices=[0, 1], default=1,
33 help='run interactively with menus for resolving conflicts')
35 parser.add_argument('-f', '--format', dest='format',
36 action='store', type=str, choices=["linux", "uboot", "bios"], default="uboot",
37 help='select the output format to be used')
39 parser.add_argument('-r', '--revision', dest='revision',
40 action='store', type=str, choices=["1.1", "2.0"], default="1.1",
41 help='select the silicon revision')
43 parser.add_argument('-m', '--module', dest='module',
44 action='store', type=str, default="",
45 help='generate only for this module')
47 parser.add_argument('-s', '--strict', dest='strict',
48 action='store_true',
49 help='strict mode - ask for each pad of the group, do not save selection.\n' \
50 'For some peripherals, same delaymode cannot be used for all the pads.\n' \
51 'Use this mode to select different modes for each pad')
53 parser.add_argument('-g', '--gpio', dest='gpio',
54 action='store_true',
55 help='generate script to read pad data from GPIO')
57 parser.add_argument('-c', '--check', dest='check_xml',
58 action='store_true',
59 help='check consistency of the XML files and other data')
61 args = parser.parse_args()
62 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
64 PCT_VERSION = "v1.0.7"
65 pad_data_xml = "XMLFiles/CTRL_MODULE_CORE.xml"
66 iod_data_xml = "XMLFiles/IODELAYCONFIG.xml"
67 model_data_xml = "XMLFiles/model_DRA75x_DRA74x_SR" + args.revision + "_" + PCT_VERSION + ".xml"
69 modehelp_file = "guidelines.txt"
70 pad_file = "ctrl-core.dump"
71 sel_file = "selected-modes.txt"
73 # Read the XML file database for pad and delay registers
74 pad_xml = ET.parse(pad_data_xml).getroot()
75 iod_xml = ET.parse(iod_data_xml).getroot()
76 model_xml = ET.parse(model_data_xml).getroot()
78 # Functions to parse the input files and build data structures
79 def read_guidelines(fname):
80 modehelp = {}
81 pattern = re.compile('(.+\w)\t+(.+)')
82 f = open(fname)
83 for line in f.readlines():
84 list = re.match(pattern, line)
85 if ( list == None):
86 continue
87 mode = list.groups(0)[0]
88 info = list.groups(0)[1]
89 modehelp[mode] = info
90 if (args.debug >= 2):
91 print "Help: Mode '%s' is used for '%s'" % (mode, info)
92 return modehelp
94 def read_selmodes(fname):
95 sel = {}
96 pattern = re.compile('(\w+)\W*,\W*(\w*)')
97 f = open(fname)
98 for line in f.readlines():
99 list = re.match(pattern, line)
100 if ( list == None):
101 continue
102 module = list.groups(0)[0]
103 mode = list.groups(0)[1]
104 sel[module] = mode
105 if (args.debug >= 2):
106 print "INFO: Select '%s' for '%s'" % (mode, module)
107 return sel
109 def read_pad_dump(file):
110 regmap = {}
111 pattern = re.compile('.*(0x[0-9A-F]+).*(0x[0-9A-F]+).*')
112 f = open(file, 'r')
113 for line in f:
114 list = re.match(pattern, line)
115 if ( list == None):
116 continue
117 addr = int(list.groups(0)[0], 16)
118 val = int(list.groups(0)[1], 16)
119 #print "PADXML: Addr = %08x Value = %08x" % (addr, val)
120 regmap[addr] = val
121 return regmap
122 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
124 # Helper functions to parse XML nodes and get the desired data
125 # Hugely dependent on the XML format of the PCT files
126 # Uses XPath to search elements with queries and filters
127 # Parse the nodes to generate data in desired format
129 def xml_pad_get_name(offset):
130 padlist = pad_xml.findall("register[@offset='0x%X']" % offset)
131 if (len(padlist) == 0):
132 return "Unknown"
133 else:
134 return padlist[0].get("id")
136 def xml_pad_get_pin(offset, muxmode):
137 padlist = pad_xml.findall("register[@offset='0x%X']" % offset)
138 if (len(padlist) == 0):
139 return "Unknown"
140 else:
141 mux_field = padlist[0].findall("./bitfield[@end='0']")
142 if (len(mux_field) == 0):
143 return "Unknown"
144 modes = mux_field[0].findall("./bitenum[@value='%d']" % muxmode)
145 if (len(modes) == 0):
146 return "Unknown"
147 return modes[0].get("id")
149 def xml_iodelay_get_reg(name):
150 delaylist = iod_xml.findall("register[@id='%s']" % name)
151 if (len(delaylist) == 0):
152 return 0
153 else:
154 offset = delaylist[0].get("offset")
155 #print "IOD: Name = %s Offset = %s" % (del_reg, offset)
156 return int(offset, 16)
158 def xml_get_virtual(mode):
159 vmodes = {}
160 signal = mode.findtext("signal")
161 for virt in mode.findall("virtualmode/mode"):
162 virt_mode = virt.findtext("value")
163 virt_name = virt.findtext("name")
164 if (virt_name == "NA"):
165 continue
166 virt_mode = int(virt_mode)
167 vmodes[virt_name] = virt_mode
168 if (args.debug >= 1):
169 print (" * VIRTUAL: %s [%s] => delaymode = %d" % (signal, virt_name, virt_mode))
170 return vmodes
172 def xml_get_manual(mode):
173 mmodes = {}
174 signal = mode.findtext("signal")
175 for man in mode.findall("manualmode"):
176 regname = man.findtext("cfgreg/name")
177 for sel in man.findall("cfgreg/mode"):
178 adel = sel.findtext("adelay")
179 gdel = sel.findtext("gdelay")
180 man_name = sel.findtext("name")
181 if (man_name == "NA"):
182 continue
183 adel = int(adel)
184 gdel = int(gdel)
185 if (man_name not in mmodes.keys()):
186 mmodes[man_name] = []
187 mmodes[man_name].append((regname, adel, gdel))
188 if (args.debug >= 1):
189 print (" * MANUAL: %s [%s] => delay[%s] = %d, %d" % (signal, man_name, regname, adel, gdel))
190 return mmodes
192 def xml_find_delaymodes(pad_name, muxmode):
193 padlist = model_xml.findall("padDB/clockNode/type/pad")
194 for pad in padlist:
195 if (pad_name == pad.findtext("confregisters/regbit/register")):
196 muxmodes = pad.findall("muxmode")
197 break
198 if not muxmodes:
199 return None
200 for mode in muxmodes:
201 if ("%d" % muxmode == mode.findtext("mode")):
202 virt = xml_get_virtual(mode)
203 man = xml_get_manual(mode)
204 return (virt, man)
205 return None
207 def xml_check_correctness(modehelp):
208 if(args.check_xml == False):
209 return
211 print "###########################################"
212 print "XML correctness checks:"
213 padcore_list = []
214 padmodel_list = []
215 modes = {}
217 # Fint all the pads in core XML
218 pad_list = pad_xml.findall("register")
219 for i in pad_list:
220 name = i.get("id")
221 if (re.match("CTRL_CORE_PAD_.*", name) == None):
222 continue
223 padcore_list.append(name)
224 print ">> Total pads defined in core XML = %d" % len(padcore_list)
226 # Find all the pads in model XML
227 pad_list = model_xml.findall("padDB/clockNode/type/pad/confregisters/regbit")
228 for i in pad_list:
229 name = i.findtext("register")
230 padmodel_list.append(name)
231 print ">> Total pads defined in model XML = %d" % len(padmodel_list)
233 # Find all the manual modes
234 manmode_list = model_xml.findall("padDB/clockNode/type/pad/muxmode/manualmode/cfgreg/mode")
235 for i in manmode_list:
236 man_name = i.findtext("name")
237 modes[man_name] = "manual"
238 # Find all the virtual modes
239 virtmode_list = model_xml.findall("padDB/clockNode/type/pad/muxmode/virtualmode/mode")
240 for i in virtmode_list:
241 virt_name = i.findtext("name")
242 modes[virt_name] = "virtual"
243 print ">> Total delaymodes defined in model XML = %d" % len(modes)
245 # Print out all the errors found in the tests
246 print "== Pads defined in core XML but not in model XML =="
247 for i in padcore_list:
248 if (i not in padmodel_list):
249 print "\t%s" % i
250 print "== Pads defined in model XML but not in core XML =="
251 for i in padmodel_list:
252 if (i not in padcore_list):
253 print "\t%s" % i
255 # Check if description for each mode is available
256 print "== Delaymodes missing description in the guidelines.txt =="
257 for i in modes:
258 if (i not in modehelp):
259 print "\t%s" % i
261 print "###########################################"
263 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
265 # Decision point of the script
266 # For each pad/pin, decide what delay method is used
267 # Lookup in the selection file or ask user with a menu
268 def select_mode(pad, pin, module, virt, man, modehelp, sel):
269 modelist = []
270 for modename in virt.keys():
271 modelist.append(modename)
273 for modename in man.keys():
274 modelist.append(modename)
276 if (len(modelist) == 0):
277 return "LEGACY"
279 if (module in sel.keys()):
280 mode = sel[module]
281 if (mode == "SKIP" or mode in modelist):
282 return mode
283 else:
284 print("ERR: Invalid delaymode '%s' for module '%s'" % (mode, module))
286 if (args.interactive == 0):
287 print "WARN: No delay modes for %s found, skipping" % module
288 mode = "SKIP"
289 sel[module] = mode
290 return mode
292 # Display the menu and ask user to select the 'right' mode
293 while True:
294 print ""
295 print "MENU: Select delay mode for %s -> %s" % (pad, pin)
296 i = 0
297 print "MENU: %d: %s \t\t\t%s" % (i, "SKIP", "Skips this module for now")
298 for mode in modelist:
299 i += 1
300 if (mode in modehelp):
301 helptext = modehelp[mode]
302 else:
303 helptext = "Unknown"
304 print "MENU: %d: %s \t\t%s" % (i, mode, helptext)
305 try:
306 choice = int(raw_input("Select delay mode #> "))
307 if (choice == 0):
308 mode = "SKIP"
309 break
310 elif (choice >=0 and choice <= len(modelist)):
311 mode = modelist[choice - 1]
312 break
313 print "ERROR: Invalid choice"
314 except ValueError:
315 print "ERROR: Invalid choice"
316 print "MENU: Selected mode is %s" % mode
317 print ""
319 return mode
320 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
322 # Pad read using GPIO - Specific to linux only
323 # As each pad is muxed with a SoC gpio (for most of the pads)
324 # It's possible to read the pad data using gpio datain registers
325 # Dump the linux commands to read the gpio registers and read the pad data
326 def pad_dump_gpio(padconf, per_padconf):
327 if(args.gpio == False):
328 return
330 print "# Read pad signals using GPIO DATA-IN registers"
331 print "# Works only for the input signals"
332 gpio_data_addrs = (0, 0x4ae10138, 0x48055138, 0x48057138, 0x48059138, 0x4805b138, 0x4805d138, 0x48051138, 0x48053138)
333 for i in padconf:
334 (pad_name, pin_name, addr, val, delayinfo) = i
336 offset = addr - 0x4a002000
337 gpio_name = xml_pad_get_pin(offset, 14)
338 matchlist = re.match("GPIO(.)_(.)", gpio_name)
339 if (matchlist == None):
340 print "ERR: No GPIO for pad %s" % pad_name
341 continue
343 inst = int(matchlist.groups(0)[0])
344 bit = int(matchlist.groups(0)[1])
345 gpio_addr = gpio_data_addrs[inst]
347 print "#Read GPIO%d_%d to sample %s" % (inst, bit, pin_name)
348 print " echo %d > /sys/class/gpio/export 2>/dev/null;" % ((inst - 1) * 32)
349 print " val=`omapconf read 0x%x 2>&1 | grep -v \"support\"`;" % gpio_addr
350 print " status=$((0x$val >> %d & 0x1));" % bit
351 print " echo -e \"%s (%s)\t = $status\";" % (pin_name, gpio_name)
352 print ""
353 print ""
354 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
356 # Generate the final pad and delay data in the required format
357 def format_pad_regs(padconf, per_padconf):
358 print "###########################################"
359 print "Pad data output (with the delay modes)"
360 print "###########################################"
361 if (args.format == "uboot"):
362 uboot_format_pad_regs(padconf, per_padconf)
363 elif (args.format == "linux"):
364 linux_format_pad_regs(padconf, per_padconf)
365 elif (args.format == "bios"):
366 bios_format_pad_regs(padconf, per_padconf)
367 else:
368 print "ERR: Format %s not suppported" % args.format
370 def format_delay_regs(delayconf, per_delayconf):
371 print "#########################################"
372 print "Delay data output (for manual modes)"
373 print "#########################################"
374 if (args.format == "uboot"):
375 uboot_format_delay_regs(delayconf, per_delayconf)
376 elif (args.format == "linux"):
377 linux_format_delay_regs(delayconf, per_delayconf)
378 elif (args.format == "bios"):
379 bios_format_delay_regs(delayconf, per_delayconf)
380 else:
381 print "ERR: Format %s not suppported" % args.format
383 def get_pin_info(val):
384 inp_en = (val >> 18) & 0x1
385 pulltype = (val >> 17) & 0x1
386 pull_dis = (val >> 16) & 0x1
387 pin = "PIN"
388 if (inp_en):
389 pin += "_INPUT"
390 else:
391 pin += "_OUTPUT"
392 if (pull_dis == 0):
393 if (pulltype):
394 pin += "_PULLUP"
395 else:
396 pin += "_PULLDOWN"
397 return pin
399 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
401 # Generate output in u-boot format
402 def uboot_format_pad_regs(padconf, per_padconf):
403 print "\nconst struct pad_conf_entry dra74x_core_padconf_array[] = {"
404 for i in padconf:
405 (pad_name, pin_name, addr, val, delayinfo) = i
407 if (re.match("MMC.*", pin_name) != None):
408 print "WARN: Skipping MMC padconf in uboot"
409 continue
411 muxmode = val & 0xf
412 (method, data) = delayinfo
413 if (method == "LEGACY"):
414 extramode = ""
415 elif (method == "VIRTUAL"):
416 delaymode = data
417 extramode = " | VIRTUAL_MODE%d" % delaymode
418 elif (method == "MANUAL"):
419 extramode = " | MANUAL_MODE"
420 else:
421 print "ERR: Invalid method %s" % method
423 pin_info = get_pin_info(val) + extramode
424 pad_short = re.sub("CTRL_CORE_PAD_", "", pad_name)
425 comment = (pad_short + "." + pin_name).lower()
427 print "\t{ %s, (M%d | %s) },\t/* %s */" % (pad_short, muxmode, pin_info, comment)
428 print "};\n"
430 def uboot_format_delay_regs(delayconf, per_delayconf):
431 print "\nconst struct iodelay_cfg_entry dra742_iodelay_cfg_array[] = {"
432 for i in delayconf:
433 (pad_name, pin_name, regname, del_offset, man_name, adel, gdel) = i
435 if (re.match("MMC.*", pin_name) != None):
436 print "WARN: Skipping MMC delayconf in uboot"
437 continue
439 print "\t{ 0x%04X, %5d, %5d },\t/* %s */" % (del_offset, adel, gdel, regname)
440 print "};\n"
442 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
444 # Generate output in linux format
445 def linux_format_pad_regs(padconf, per_padconf):
446 print "&dra7_pmx_core {"
447 for per in per_padconf:
449 if (re.match("MMC.*", per) == None):
450 print "ERR: Only MMC padconf is recommended in kernel"
451 continue
453 dtsnode = ("%s_pins_default" % per).lower()
454 print ""
455 print "\t%s: %s {" % (dtsnode, dtsnode)
456 print "\t\tpinctrl-single,pins = <"
457 for i in per_padconf[per]:
458 (pad_name, pin_name, addr, val, delayinfo) = i
460 muxmode = val & 0xf
461 (method, data) = delayinfo
462 if (method == "LEGACY"):
463 extramode = ""
464 elif (method == "VIRTUAL"):
465 delaymode = data
466 extramode = " | VIRTUAL_MODE%d" % delaymode
467 elif (method == "MANUAL"):
468 extramode = " | MANUAL_MODE"
469 else:
470 print "ERR: Invalid method %s" % method
472 pin_info = get_pin_info(val) + extramode
473 pad_short = re.sub("CTRL_CORE_PAD_", "", pad_name)
474 offset = addr - 0x4a003400
475 comment = (pad_short + "." + pin_name).lower()
477 print "\t\t\t0x%03X\t(%s | MUM_MODE%d)\t/* %s */" % (offset, pin_info, muxmode, comment)
478 print "\t\t>;"
479 print "\t};"
480 print "};\n"
483 def linux_format_delay_regs(delayconf, per_delayconf):
484 print "&dra7_iodelay_core {"
485 for per in per_delayconf.keys():
487 if (re.match("MMC.*", per) == None):
488 print "ERR: Only MMC delayconf is recommended in kernel"
489 continue
491 # Get the mode from the first entry
492 (pad_name, pin_name, regname, del_offset, mode, adel, gdel) = per_delayconf[per][0]
494 dtsnode = ("%s_iodelay_%s_conf" % (per, mode)).lower()
495 print "\t%s: %s {" % (dtsnode, dtsnode)
496 print "\t\tpinctrl-single,pins = <"
497 for i in per_delayconf[per]:
498 (pad_name, pin_name, regname, del_offset, mode, adel, gdel) = i
500 print "\t\t\t0x%03X A_DELAY(%d) | G_DELAY(%d)\t/* %s */" % (del_offset, adel, gdel, regname)
501 print "\t\t>;"
502 print "\t};"
503 print "};\n"
505 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
507 # Generate output in bios format
508 def bios_format_pad_regs(padconf, per_padconf):
509 for i in padconf:
510 (pad_name, pin_name, addr, val, delayinfo) = i
512 delaylist = []
513 (method, data) = delayinfo
514 if (method == "VIRTUAL"):
515 virt_mode = data
516 val = val | ( virt_mode<< 4)
517 val = val | (1 << 8)
518 elif (method == "MANUAL"):
519 delaylist = data
520 val = val | (1 << 8)
522 offset = addr - 0x4a003400
523 out_delreg = out_adel = out_gdel = 0
524 in_delreg = in_adel = in_gdel = 0
525 oen_delreg = oen_adel = oen_gdel = 0
527 for j in delaylist:
528 (regname, adel, gdel) = j
529 if (re.match(".*_IN", regname) != None):
530 in_delreg = xml_iodelay_get_reg(regname)
531 in_adel = adel
532 in_gdel = gdel
533 elif (re.match(".*_OEN", regname) != None):
534 oen_delreg = xml_iodelay_get_reg(regname)
535 oen_adel = adel
536 oen_gdel = gdel
537 elif (re.match(".*_OUT", regname) != None):
538 out_delreg = xml_iodelay_get_reg(regname)
539 out_adel = adel
540 out_gdel = gdel
541 indel = "{ 0x%04X, %4d, %4d }" % (in_delreg, in_adel, in_gdel)
542 oendel = "{ 0x%04X, %4d, %4d }" % (oen_delreg, oen_adel, oen_gdel)
543 outdel = "{ 0x%04X, %4d, %4d }" % (out_delreg, out_adel, out_gdel)
544 pin_info = get_pin_info(val)
545 print "\t/* %s -> %s (%s) %s delaymode */" % (pad_name, pin_name, pin_info, method)
546 print "\t{ 0x%03X, 0x%08X, %s, %s, %s }" % (offset, val, indel, oendel, outdel)
548 def bios_format_delay_regs(delayconf, per_delayconf):
549 print "Manual delays are not configured separately"
550 print "Delays are configured as part of the padconf step only"
552 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
554 # Main execution starts here
555 # * Parse all the XML files - Get the pad data and IOdelay data
556 # * Iterate over the pad register dumps
557 # * For each pad, find out the muxmode being used and the pad direction, etc
558 # * For the muxmode being used, find out available virtual/modes
559 # - Dump the virtual/manual modes available (based on options)
560 # - Build up the gpio script to read the pad data using GPIO module
561 # * Select the correct mode to be used
562 # - Check if the mode is described for the peripheral module, (from selected-modes.txt)
563 # - Otherwise ask the user (with a menu) to decide the delaymode
564 # => Update the selection for the whole of the peripheral module
565 # - Worst case, skip the delaymode for this pad
566 # * Build the pad and delay register information
567 # * Create the dump for pad and delay data in linux/u-boot format
568 # * Dump the delaymode selection for each peripheral
569 # * Dump the GPIO script for each peripheral (all pads grouped together)
570 #
572 # Read all the input files and parse the required info
573 modehelp = read_guidelines(modehelp_file)
574 sel = read_selmodes(sel_file)
575 regmap = read_pad_dump(pad_file)
576 reglist = regmap.keys()
578 # List of all the pads being configured
579 padconf = []
580 # List of all the delay registers being configured (for manual mode)
581 delayconf = []
582 # Dictionary of pads grouped by peripheral/module
583 per_padconf = {}
584 # Dictionary of delay registers grouped by peripheral/module
585 per_delayconf = {}
587 xml_check_correctness(modehelp)
588 # Start iterating over each pad
589 for i in range(0, 260):
590 # Find out the muxmode and pad direction, etc
591 addr = 0x4a003400 + i * 4
592 offset = 0x1400 + i * 4
593 dts_offset = offset - 0x1400
595 if (addr not in reglist):
596 print "WARN: Register dump for pad 0x%X not found" % addr
597 continue
598 val = regmap[addr]
599 muxmode = val & 0xf
601 # Find out the pin based on the muxmode
602 pad_name = xml_pad_get_name(offset)
603 pin_name = xml_pad_get_pin(offset, muxmode)
604 if (pad_name == "Unknown" or pin_name == "Unknown"):
605 print "WARN: Cannot find out Pad/Pin name for PAD address 0x%X (%s[%s] = %s)" \
606 % (addr, pad_name, muxmode, pin_name)
607 continue
608 if (pin_name == "DRIVER OFF"):
609 continue
611 # Find out if the delaymode for this module is already selected
612 module = re.match("([^_]+)_.*", pin_name).groups(0)[0]
614 if (args.module != "" and args.module != module):
615 continue
617 if (args.debug >= 1):
618 print "\nPAD: %s: Addr= 0x%08X Value = 0x%08X \"%s\"" \
619 % (pad_name, addr, val, pin_name)
621 # Find out all the possible virtual, manual modes fot the specific pad -> pin combination
622 (virt, man) = xml_find_delaymodes(pad_name, muxmode)
624 # Need to select one out of allowed modes
625 mode = select_mode(pad_name, pin_name, module, virt, man, modehelp, sel)
627 # Remember the selection for that module, for later reuse
628 if (args.strict == False):
629 sel[module] = mode
631 if (mode == "SKIP"):
632 continue
633 elif (mode == "LEGACY"):
634 delayinfo = ("LEGACY", "")
635 elif (mode in virt):
636 delayinfo = ("VIRTUAL", virt[mode])
637 elif (mode in man):
638 delayinfo = ("MANUAL", man[mode])
639 else:
640 print "ERR: Unknown mode '%s' selected" % mode
641 continue
643 if (args.debug >= 1):
644 print " => Using mode %s" % mode
645 paddata = (pad_name, pin_name, addr, val, delayinfo)
646 if (module not in per_padconf.keys()):
647 per_padconf[module] = []
648 padconf.append(paddata)
649 per_padconf[module].append(paddata)
651 if(mode not in man):
652 continue
654 # Add the delay data if using manual mode
655 for regval in man[mode]:
656 (regname, adel, gdel) = regval
657 del_offset = xml_iodelay_get_reg(regname)
658 if (del_offset == 0):
659 print "WARN: Can't find delay offset of register %s" % regname
660 break
661 if (args.debug >= 1):
662 print " => Manual delay[%s] = (%d, %d)" % (regname, adel, gdel)
663 delaydata = (pad_name, pin_name, regname, del_offset, mode, adel, gdel)
664 if (module not in per_delayconf.keys()):
665 per_delayconf[module] = []
666 delayconf.append(delaydata)
667 per_delayconf[module].append(delaydata)
669 print ""
670 print "Total PAD registers: %d" % len(padconf)
671 print "Total DELAY registers: %d" % len(delayconf)
672 print ""
674 format_pad_regs(padconf, per_padconf)
675 format_delay_regs(delayconf, per_delayconf)
676 pad_dump_gpio(padconf, per_padconf)
678 # Dump the final selection for reuse
679 print "Selected modes for each peripheral module\n"
680 for group in sel:
681 print "%s,\t%s" % (group, sel[group])
682 print ""
683 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #