]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/iodelay-config.git/commitdiff
script: Refactoring the logic improved interface
authorNikhil Devshatwar <nikhil.nd@ti.com>
Sat, 8 Aug 2015 11:59:21 +0000 (17:29 +0530)
committerNikhil Devshatwar <nikhil.nd@ti.com>
Wed, 12 Aug 2015 09:48:12 +0000 (15:18 +0530)
* Remove the config file and the config parser.
* Add command line option parser and add basic options.
* Introduce debug levels controlled by cmd line option.
* Do not dump the generated values on the fly, save and dump later.
* Hooks to generate the data in the required format - kernel/uboot/QNX.
* Rename functions and variable to improve readability.
* Rearranged functions and added comments for better understanding.
* Fixed bugs for handling unused pads and lagacy mode.

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
config-iodelay-autogen [deleted file]
iodelay-autogen.py
selected-modes.txt

diff --git a/config-iodelay-autogen b/config-iodelay-autogen
deleted file mode 100644 (file)
index 3400d8d..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-[general]
-auto_decide = 0
-dump_all = 0
-dump_gpio = 0
-dump_virtual = 0
-dump_manual = 0
-[gui]
-interactive = 1
index 695ff74864cd1358e13d06f98245b81be4b9218e..221074bc357fb2586f069eb043d465e781c98273 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 #!/usr/bin/python
-#Python script to automatically generate the IO pad and delay data
-#Author:- Nikhil Devshatwar
+# Python script to automatically generate the IO pad and delay data
+# Author:- Nikhil Devshatwar
 
 # This script uses regdump of the pad registers to figure out the muxmodes
 # Based on the pad and muxmode, it find out all possible virtual/manual modes
 
 # This script uses regdump of the pad registers to figure out the muxmodes
 # Based on the pad and muxmode, it find out all possible virtual/manual modes
 # * Pad register dump  - Generate using omapconf dump 0x4a003400 0x4a00380c
 # * selection file     - List of selected virtual/manual modes to be used
 
 # * Pad register dump  - Generate using omapconf dump 0x4a003400 0x4a00380c
 # * selection file     - List of selected virtual/manual modes to be used
 
+import xml.etree.ElementTree as ET
+import re
+import argparse
+
 pad_data_xml = "XMLFiles/CTRL_MODULE_CORE.xml"
 iod_data_xml = "XMLFiles/IODELAYCONFIG.xml"
 model_data_xml = "XMLFiles/model_DRA75x_DRA74x_SR1.1_v1.0.6.xml"
 pad_data_xml = "XMLFiles/CTRL_MODULE_CORE.xml"
 iod_data_xml = "XMLFiles/IODELAYCONFIG.xml"
 model_data_xml = "XMLFiles/model_DRA75x_DRA74x_SR1.1_v1.0.6.xml"
-gdl_file = "guidelines.txt"
+modehelp_file = "guidelines.txt"
 
 pad_file = "ctrl-core.dump"
 sel_file = "selected-modes.txt"
 
 pad_file = "ctrl-core.dump"
 sel_file = "selected-modes.txt"
-config_file = "config-iodelay-autogen"
 
 
-import xml.etree.ElementTree as ET
-import ConfigParser as CP
-import re
+# Handle the command line arguments
+parser = argparse.ArgumentParser(prog='iodelay-autogen.py',
+       description='Python script to generate the IOdelay data',
+       epilog='Generate the pad and delay data using pad regdump')
+
+parser.add_argument('-d', '--debug', dest='debug',
+       action='store', type=int, choices=[0, 1, 2], default=0,
+       help='set the debug level')
+
+parser.add_argument('-i', '--interactive', dest='interactive',
+       action='store', type=int, choices=[0, 1], default=1,
+       help='run interactively with menus for resolving conflicts')
+
+args = parser.parse_args()
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 
 
+# Read the XML file database for pad and delay registers
 pad_xml = ET.parse(pad_data_xml).getroot()
 iod_xml = ET.parse(iod_data_xml).getroot()
 model_xml = ET.parse(model_data_xml).getroot()
 pad_xml = ET.parse(pad_data_xml).getroot()
 iod_xml = ET.parse(iod_data_xml).getroot()
 model_xml = ET.parse(model_data_xml).getroot()
-config = CP.RawConfigParser()
-config.read(config_file)
 
 
-def read_pad_file(file):
+# Functions to parse the input files and build data structures
+def read_guidelines(fname):
+       modehelp = {}
+       pattern = re.compile('(.+\w)\t+(.+)')
+       f = open(fname)
+       for line in f.readlines():
+               list = re.match(pattern, line)
+               if ( list == None):
+                       continue
+               mode = list.groups(0)[0]
+               info = list.groups(0)[1]
+               modehelp[mode] = info
+               if (args.debug >= 2):
+                       print "Help: Mode '%s' is used for '%s'" % (mode, info)
+       return modehelp
+
+def read_selmodes(fname):
+       sel = {}
+       pattern = re.compile('(\w+)\W*,\W*(\w*)')
+       f = open(fname)
+       for line in f.readlines():
+               list = re.match(pattern, line)
+               if ( list == None):
+                       continue
+               module = list.groups(0)[0]
+               mode = list.groups(0)[1]
+               sel[module] = mode
+               if (args.debug >= 2):
+                       print "INFO: Select '%s' for '%s'" % (mode, module)
+       return sel
+
+def read_pad_dump(file):
        regmap = {}
        pattern = re.compile('.*(0x[0-9A-F]+).*(0x[0-9A-F]+).*')
        f = open(file, 'r')
        regmap = {}
        pattern = re.compile('.*(0x[0-9A-F]+).*(0x[0-9A-F]+).*')
        f = open(file, 'r')
@@ -41,18 +86,24 @@ def read_pad_file(file):
                        continue
                addr = int(list.groups(0)[0], 16)
                val = int(list.groups(0)[1], 16)
                        continue
                addr = int(list.groups(0)[0], 16)
                val = int(list.groups(0)[1], 16)
-               #print "PADDUMP: Addr = %08x Value = %08x" % (addr, val)
+               #print "PADXML: Addr = %08x Value = %08x" % (addr, val)
                regmap[addr] = val
        return regmap
                regmap[addr] = val
        return regmap
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+# Helper functions to parse XML nodes and get the desired data
+# Hugely dependent on the XML format of the PCT files
+# Uses XPath to search elements with queries and filters
+# Parse the nodes to generate data in desired format
 
 
-def pad_get_name(offset):
+def xml_pad_get_name(offset):
        padlist = pad_xml.findall("register[@offset='0x%X']" % offset)
        if (len(padlist) == 0):
                return "Unknown"
        else:
                return padlist[0].get("id")
 
        padlist = pad_xml.findall("register[@offset='0x%X']" % offset)
        if (len(padlist) == 0):
                return "Unknown"
        else:
                return padlist[0].get("id")
 
-def pad_get_pin(offset, muxmode):
+def xml_pad_get_pin(offset, muxmode):
        padlist = pad_xml.findall("register[@offset='0x%X']" % offset)
        if (len(padlist) == 0):
                return "Unknown"
        padlist = pad_xml.findall("register[@offset='0x%X']" % offset)
        if (len(padlist) == 0):
                return "Unknown"
@@ -65,18 +116,7 @@ def pad_get_pin(offset, muxmode):
                        return "Unknown"
                return modes[0].get("id")
 
                        return "Unknown"
                return modes[0].get("id")
 
-def pad_dump_gpio(addr, offset, pin_name):
-       gpio_data_addrs = (0, 0x4ae10138, 0x48055138, 0x48057138, 0x48059138, 0x4805b138, 0x4805d138, 0x48051138, 0x48053138)
-       gpio_name = pad_get_pin(offset, 14)
-       matchlist = re.match("GPIO(.)_(.)", gpio_name)
-       if (matchlist == None):
-               return
-       inst = int(matchlist.groups(0)[0])
-       bit = int(matchlist.groups(0)[1])
-       gpio_addr = gpio_data_addrs[inst]
-       print "GPIO: echo %d > /sys/class/gpio/export 2>/dev/null; val=`omapconf read 0x%x 2>&1 | grep -v \"support\"`; status=$((0x$val >> %d & 0x1)); echo -e \"%s (%s)\t = $status\";" % ((inst - 1) * 32, gpio_addr, bit, pin_name, gpio_name)
-
-def iodelay_get_reg(name):
+def xml_iodelay_get_reg(name):
        delaylist = iod_xml.findall("register[@id='%s']" % name)
        if (len(delaylist) == 0):
                return 0
        delaylist = iod_xml.findall("register[@id='%s']" % name)
        if (len(delaylist) == 0):
                return 0
@@ -85,22 +125,22 @@ def iodelay_get_reg(name):
                #print "IOD: Name = %s Offset = %s" % (del_reg, offset)
                return int(offset, 16)
 
                #print "IOD: Name = %s Offset = %s" % (del_reg, offset)
                return int(offset, 16)
 
-def virtual_get_modes(mode):
-       list = []
+def xml_get_virtual(mode):
+       vmodes = {}
        signal = mode.findtext("signal")
        for virt in mode.findall("virtualmode/mode"):
                virt_mode = virt.findtext("value")
                virt_name = virt.findtext("name")
                if (virt_name == "NA"):
                        continue
        signal = mode.findtext("signal")
        for virt in mode.findall("virtualmode/mode"):
                virt_mode = virt.findtext("value")
                virt_name = virt.findtext("name")
                if (virt_name == "NA"):
                        continue
-               found = (virt_mode, virt_name)
-               list.append(found)
-               if (config.get("general", "dump_virtual") == "1"):
-                       print ("VIRTUAL: %s %s" % found) + " %s" % signal
-       return list
-
-def manual_get_modes(mode):
-       list = []
+               virt_mode = int(virt_mode)
+               vmodes[virt_name] = virt_mode
+               if (args.debug >= 1):
+                       print ("    * VIRTUAL: %s [%s] => delaymode = %d" % (signal, virt_name, virt_mode))
+       return vmodes
+
+def xml_get_manual(mode):
+       mmodes = {}
        signal = mode.findtext("signal")
        for man in mode.findall("manualmode"):
                regname = man.findtext("cfgreg/name")
        signal = mode.findtext("signal")
        for man in mode.findall("manualmode"):
                regname = man.findtext("cfgreg/name")
@@ -110,14 +150,17 @@ def manual_get_modes(mode):
                        man_name = sel.findtext("name")
                        if (man_name == "NA"):
                                continue
                        man_name = sel.findtext("name")
                        if (man_name == "NA"):
                                continue
-                       found = (regname, adel, gdel, man_name)
-                       list.append(found)
-                       if (config.get("general", "dump_manual") == "1"):
-                               print ("MANUAL: %s %s %s %s" % found) + " %s" % signal
-       return list
+                       adel = int(adel)
+                       gdel = int(gdel)
+                       if (man_name not in mmodes.keys()):
+                               mmodes[man_name] = []
+                       mmodes[man_name].append((regname, adel, gdel))
+                       if (args.debug >= 1):
+                               print ("    * MANUAL: %s [%s] => delay[%s] = %d, %d" % (signal, man_name, regname, adel, gdel))
+       return mmodes
                
 
                
 
-def model_find_delaymodes(pad_name, muxmode):
+def xml_find_delaymodes(pad_name, muxmode):
        padlist = model_xml.findall("padDB/clockNode/type/pad")
        for pad in padlist:
                if (pad_name == pad.findtext("confregisters/regbit/register")):
        padlist = model_xml.findall("padDB/clockNode/type/pad")
        for pad in padlist:
                if (pad_name == pad.findtext("confregisters/regbit/register")):
@@ -127,107 +170,176 @@ def model_find_delaymodes(pad_name, muxmode):
                return None
        for mode in muxmodes:
                if ("%d" % muxmode == mode.findtext("mode")):
                return None
        for mode in muxmodes:
                if ("%d" % muxmode == mode.findtext("mode")):
-                       virt = virtual_get_modes(mode)
-                       man = manual_get_modes(mode)
+                       virt = xml_get_virtual(mode)
+                       man = xml_get_manual(mode)
                        return (virt, man)
        return None
                        return (virt, man)
        return None
-
-def get_pin_info(val):
-       inp_en = (val >> 18) & 0x1
-       pulltype = (val >> 17) & 0x1
-       pull_dis = (val >> 16) & 0x1
-       pin = "PIN"
-       if (inp_en):
-               pin += "_INPUT"
-       else:
-               pin += "_OUTPUT"
-       if (pull_dis == 0):
-               if (pulltype):
-                       pin += "_PULLUP"
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+# Decision point of the script
+# For each pad/pin, decide what delay method is used
+# Lookup in the selection file or ask user with a menu
+def select_mode(pad, pin, virt, man, modehelp, sel):
+       modelist = []
+       for modename in virt.keys():
+               modelist.append(modename)
+
+       for modename in man.keys():
+               modelist.append(modename)
+
+       if (len(modelist) == 0):
+               return "LEGACY"
+
+       # Find out if the delaymode for this module is already selected
+       module = re.match("([^_]+)_.*", pin).groups(0)[0]
+       if (module in sel.keys()):
+               mode = sel[module]
+               if (mode == "SKIP" or mode in modelist):
+                       return mode
                else:
                else:
-                       pin += "_PULLDOWN"
-       return pin
+                       print("ERR: Invalid delaymode '%s' for module '%s'" & (mode, module))
 
 
-def read_guidelines(fname):
-       gdl = {}
-       pattern = re.compile('(.+\w)\t+(.+)')
-       f = open(fname)
-       for line in f.readlines():
-               list = re.match(pattern, line)
-               if ( list == None):
-                       continue
-               mode = list.groups(0)[0]
-               info = list.groups(0)[1]
-               gdl[mode] = info
-               #print "GDL: Parsed info<%s> <%s>" % ( mode, info)
-       return gdl
-
-def read_selection(fname):
-       sel = {}
-       pattern = re.compile('(\w+)\W*,\W*(\w*)')
-       f = open(fname)
-       for line in f.readlines():
-               list = re.match(pattern, line)
-               if ( list == None):
-                       continue
-               group = list.groups(0)[0]
-               mode = list.groups(0)[1]
-               sel[group] = mode
-               #print "SEL: Parsed info<%s> <%s>" % (mode, group)
-       return sel
+       if (args.interactive == 0):
+               print "WARN: No delay modes for %s:%s found, skipping" % (pad, pin)
+               mode = "SKIP"
+               sel[module] = mode
+               return mode
 
 
-def find_selection(pad, pin, modes, gdl, sel):
-       group = re.match("([^_]+)_.*", pin).groups(0)[0]
-       if (group in sel.keys()):
-               if (sel[group] == "SKIP"):
-                       return sel[group]
-               for mode in modes:
-                       if (sel[group] == mode):
-                               #print "DBG: Found %s mode in selection for %s" % (mode, group)
-                               return mode
-
-       if (config.get("gui", "interactive") == "0"):
-               return "SKIP"
-
-       #print "\nDBG: Selected modes"
-       #print sel
+       # Display the menu and ask user to select the 'right' mode
        while True:
                print ""
                print "MENU: Select delay mode for %s -> %s" % (pad, pin)
                i = 0
        while True:
                print ""
                print "MENU: Select delay mode for %s -> %s" % (pad, pin)
                i = 0
-               print "MENU: %d: %s \t\t\t%s" % (i, "SKIP", "Skips this group for now")
-               for mode in modes:
+               print "MENU: %d: %s \t\t\t%s" % (i, "SKIP", "Skips this module for now")
+               for mode in modelist:
                        i += 1
                        i += 1
-                       print "MENU: %d: %s \t\t%s" % (i, mode, gdl[mode])
+                       print "MENU: %d: %s \t\t%s" % (i, mode, modehelp[mode])
                try:
                        choice = int(raw_input("Select delay mode #> "))
                        if (choice == 0):
                                mode = "SKIP"
                                break
                try:
                        choice = int(raw_input("Select delay mode #> "))
                        if (choice == 0):
                                mode = "SKIP"
                                break
-                       elif (choice >=0 and choice <= len(modes)):
-                               mode = modes.keys()[choice - 1]
+                       elif (choice >=0 and choice <= len(modelist)):
+                               mode = modelist[choice - 1]
                                break
                        print "ERROR: Invalid choice"
                except ValueError:
                        print "ERROR: Invalid choice"
        print "MENU: Selected mode is %s" % mode
        print ""
                                break
                        print "ERROR: Invalid choice"
                except ValueError:
                        print "ERROR: Invalid choice"
        print "MENU: Selected mode is %s" % mode
        print ""
+
+       # Remember the selection for that module, for later reuse
+       sel[module] = mode
        return mode
        return mode
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 
 
-#Main execution starts here
-print "IOdelay autogen - Python script to generate the IOdelay data"
-print "Generate the MUX mode data based on the register dumps"
-print ""
+# Pad read using GPIO - Specific to linux only
+# As each pad is muxed with a SoC gpio (for most of the pads)
+# It's possible to read the pad data using gpio datain registers
+# Dump the linux commands to read the gpio registers and read the pad data
+def pad_dump_gpio(addr, offset, pin_name):
+       # Dump the script to read this pad using the gpio data register
+       gpio_data_addrs = (0, 0x4ae10138, 0x48055138, 0x48057138, 0x48059138, 0x4805b138, 0x4805d138, 0x48051138, 0x48053138)
+       gpio_name = xml_pad_get_pin(offset, 14)
+       matchlist = re.match("GPIO(.)_(.)", gpio_name)
+       if (matchlist == None):
+               return
+       inst = int(matchlist.groups(0)[0])
+       bit = int(matchlist.groups(0)[1])
+       gpio_addr = gpio_data_addrs[inst]
+       print "echo %d > /sys/class/gpio/export 2>/dev/null;" % (inst - 1) * 32
+       print "val=`omapconf read 0x%x 2>&1 | grep -v \"support\"`;" % gpio_addr
+       print "status=$((0x$val >> %d & 0x1));" % bit
+       print "echo -e \"%s (%s)\t = $status\";" % (pin_name, gpio_name)
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+# Generate the final pad and delay data in the required format
+# This can be changed to work for linux / u-boot / QNX / other format
+def format_pin_info(val):
+       inp_en = (val >> 18) & 0x1
+       pulltype = (val >> 17) & 0x1
+       pull_dis = (val >> 16) & 0x1
+       pin = "PIN"
+       if (inp_en):
+               pin += "_INPUT"
+       else:
+               pin += "_OUTPUT"
+       if (pull_dis == 0):
+               if (pulltype):
+                       pin += "_PULLUP"
+               else:
+                       pin += "_PULLDOWN"
+       return pin
 
 
-gdl = read_guidelines(gdl_file)
-sel = read_selection(sel_file)
-regmap = read_pad_file(pad_file)
+def format_pad_regs(padconf):
+       # Generate the padmux data in kernel format
+       print "###########################################"
+       print "Pad data for u-boot (with the delay modes):"
+       print "###########################################"
+       print "\nconst struct pad_conf_entry dra74x_core_padconf_array[] = {"
+       for i in padconf:
+               (pad_name, pin_name, addr, val, delaydata) = i
+               muxmode = val & 0xf
+               (method, data) = delaydata
+               if (method == "LEGACY"):
+                       extramode = ""
+               elif (method == "VIRTUAL"):
+                       delaymode = data
+                       extramode = " | VIRTUAL_MODE%d" % delaymode
+               elif (method == "MANUAL"):
+                       extramode = " | MANUAL_MODE"
+               else:
+                       print "ERR: Invalid method %s" % method
+
+               pin_info = format_pin_info(val) + extramode
+               pad_short = re.sub("CTRL_CORE_PAD_", "", pad_name)
+               comment = (pad_short + "." + pin_name).lower()
+               print "\t{ %s, (M%d | %s) },\t/* %s */" % (pad_short, muxmode, pin_info, comment)
+       print "};\n"
+
+def format_delay_regs(delayconf):
+       # Generate the delay data in kernel format
+       print "#########################################"
+       print "Delay data for u-boot (for manual modes):"
+       print "#########################################"
+       print "\nconst struct iodelay_cfg_entry dra742_iodelay_cfg_array[] = {"
+       for i in delayconf:
+               (pad_name, pin_name, regname, del_offset, adel, gdel) = i
+               print "\t{ 0x%04X, %5d, %5d },\t/* %s */" % (del_offset, adel, gdel, regname)
+       print "};\n"
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+
+# Main execution starts here
+# * Parse all the XML files - Get the pad data and IOdelay data
+# * Iterate over the pad register dumps
+# * For each pad, find out the muxmode being used and the pad direction, etc
+# * For the muxmode being used, find out available virtual/modes
+#   - Dump the virtual/manual modes available (based on options)
+#   - Build up the gpio script to read the pad data using GPIO module
+# * Select the correct mode to be used
+#   - Check if the mode is described for the peripheral module, (from selected-modes.txt)
+#   - Otherwise ask the user (with a menu) to decide the delaymode
+#     => Update the selection for the whole of the peripheral module
+#   - Worst case, skip the delaymode for this pad
+# * Build the pad and delay register information
+# * Create the dump for pad and delay data in kernel/u-boot format
+# * Dump the delaymode selection for each peripheral
+# * Dump the GPIO script for each peripheral (all pads grouped together)
+#
+
+# Read all the input files and parse the required info
+modehelp = read_guidelines(modehelp_file)
+sel = read_selmodes(sel_file)
+regmap = read_pad_dump(pad_file)
 reglist = regmap.keys()
 
 reglist = regmap.keys()
 
-pad_count = 0
-delay_count = 0
+padconf = []
+delayconf = []
+padinfo = []
 
 
-for i in range(0, 281):
+# Start iterating over each pad
+for i in range(0, 260):
+       # Find out the muxmode and pad direction, etc
        addr = 0x4a003400 + i * 4
        offset = 0x1400 + i * 4
        dts_offset = offset - 0x1400
        addr = 0x4a003400 + i * 4
        offset = 0x1400 + i * 4
        dts_offset = offset - 0x1400
@@ -237,85 +349,69 @@ for i in range(0, 281):
                continue
        val = regmap[addr]
        muxmode = val & 0xf
                continue
        val = regmap[addr]
        muxmode = val & 0xf
-       pad_name = pad_get_name(offset)
-       pin_name = pad_get_pin(offset, muxmode)
+
+       # Find out the pin based on the muxmode
+       pad_name = xml_pad_get_name(offset)
+       pin_name = xml_pad_get_pin(offset, muxmode)
        if (pad_name == "Unknown" or pin_name == "Unknown"):
        if (pad_name == "Unknown" or pin_name == "Unknown"):
-               print "ERROR: Cannot find out Pad/Pin name for PAD address 0x%X (%s[%s] = %s)" \
+               print "WARN: Cannot find out Pad/Pin name for PAD address 0x%X (%s[%s] = %s)" \
                % (addr, pad_name, muxmode, pin_name)
                continue
                % (addr, pad_name, muxmode, pin_name)
                continue
-       if (config.get("general", "dump_all") == "1"):
-               print "DUMP: %30s: Address = 0x%X \tOffset = 0x%X Value = 0x%08X \"%s\"" \
-               % (pad_name, addr, offset, val, pin_name)
-
-       if (config.get("general", "dump_gpio") == "1"):
-               pad_dump_gpio(addr, offset, pin_name)
-#Find out all the possible virtual, manual modes fot the specific pad -> pin combination
-       (virt, man) = model_find_delaymodes(pad_name, muxmode)
-       modes = {}
-       for option in virt:
-               (virt_mode, virt_name) = option
-               extramode = "VIRTUAL_MODE%s" % virt_mode
-               modes[virt_name] = extramode
-
-       for option in man:
-               (regname, a_del, g_del, man_name) = option
-               extramode = "MANUAL_MODE"
-               modes[man_name] = extramode
-
-#Decide the mode to be used:-
-       if (len(modes) == 0):
-               if (config.get("general", "auto_decide") == "0"):
-                       continue
-               #Use Legacy mode
-               extramode = ""
-       else:
-               #Need to select one out of allowed modes
-               mode = find_selection(pad_name, pin_name, modes, gdl, sel)
-               if (mode == "unknown"):
-                       print "ERROR: Unresolved delay modes for %s -> %s" % (pad_name, pin_name)
-                       print modes
-                       break
+       if (pin_name == "DRIVER OFF"):
+               continue
 
 
-               #Update the selection for that module
-               group = re.match("([^_]+)_.*", pin_name).groups(0)[0]
-               #print "DBG: Adding %s mode for group %s" % (mode, group)
-               if (mode != "SKIP" or  group not in sel.keys()):
-                       sel[group] = mode
-               if (mode == "SKIP"):
-                       continue
-               extramode = modes[mode]
+       padinfo.append((pad_name, pin_name, addr, offset, val))
+       if (args.debug >= 1):
+               print "\nPAD: %s: Addr= 0x%08X Value = 0x%08X \"%s\"" \
+               % (pad_name, addr, val, pin_name)
+
+       # Find out all the possible virtual, manual modes fot the specific pad -> pin combination
+       (virt, man) = xml_find_delaymodes(pad_name, muxmode)
 
 
-#Generate the u-boot header for PAD mux array
-       if (extramode == ""):
-               delaymode = ""
+       # Need to select one out of allowed modes
+       mode = select_mode(pad_name, pin_name, virt, man, modehelp, sel)
+       if (mode == "SKIP"):
+               continue
+
+       if (mode == "LEGACY"):
+               delaydata = ("LEGACY", "")
+       elif (mode in virt):
+               delaydata = ("VIRTUAL", virt[mode])
+       elif (mode in man):
+               delaydata = ("MANUAL", man[mode])
        else:
        else:
-               delaymode = " | %s" % extramode
-       pin_info = get_pin_info(val) + delaymode
-       pad_short = re.sub("CTRL_CORE_PAD_", "", pad_name)
-       comment = (pad_short + "." + pin_name).lower()
-       print "PAD:\t{ %s, (M%d | %s) },\t/* %s */" % (pad_short, muxmode, pin_info, comment)
-       pad_count += 1
-
-#Generate the u-boot header for IO delay array
-       if (extramode != "MANUAL_MODE"):
+               print "ERR: Unknown mode '%s' selected" % mode
                continue
                continue
-       for option in man:
-               (regname, a_del, g_del, man_name) = option
-               if (man_name != mode):
-                       continue
-               del_offset = iodelay_get_reg(regname)
+
+       if (args.debug >= 1):
+               print "  => Using mode %s" % mode
+       padconf.append((pad_name, pin_name, addr, val, delaydata))
+
+       if(mode not in man):
+               continue
+
+       # Add the delay data if using manual mode
+       for regval in man[mode]:
+               (regname, adel, gdel) = regval
+               del_offset = xml_iodelay_get_reg(regname)
                if (del_offset == 0):
                if (del_offset == 0):
-                       print "ERROR: Can't find delay offset of register %s" % regname
+                       print "WARN: Can't find delay offset of register %s" % regname
                        break
                        break
-               a_del = int(a_del)
-               g_del = int(g_del)
-               print "DELAY:\t{0x%04X, %d, %d},\t/* %s */" \
-                       % (del_offset, a_del, g_del, regname)
+               if (args.debug >= 1):
+                       print "  => Manual delay[%s] = (%d, %d)" % (regname, adel, gdel)
+               delayconf.append((pad_name, pin_name, regname, del_offset, adel, gdel))
 
 
-       delay_count += 1
 print ""
 print ""
-print "Total PAD registers: %d, Total DELAY registers: %d" % (pad_count, delay_count)
-#Dump the final selection for reuse
+print "Total PAD registers: %d" % len(padconf)
+print "Total DELAY registers: %d" % len(delayconf)
+print ""
+
+format_pad_regs(padconf)
+format_delay_regs(delayconf)
+
+# Dump the final selection for reuse
+print "Selected modes for each peripheral module\n"
 for group in sel:
        print "%s,\t%s" % (group, sel[group])
 print ""
 for group in sel:
        print "%s,\t%s" % (group, sel[group])
 print ""
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..4cf7eaad12a52afb213523df1138edf218047676 100644 (file)
@@ -0,0 +1 @@
+VIN1A,  VIP1_MANUAL1