]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/iodelay-config.git/blobdiff - iodelay-autogen.py
script: Remove unwanted debug prints
[glsdk/iodelay-config.git] / iodelay-autogen.py
index 63fe63be07e1fbbbaf209e5a53c5230afd01e859..2c36b4578f06d2c94f610838ff07ffc3b5ee2693 100755 (executable)
@@ -30,7 +30,7 @@ parser.add_argument('-p', '--part', dest='part',
        help='select the device part')
 
 parser.add_argument('-r', '--revision', dest='revision',
-       action='store', type=str, choices=["1.0", "1.1", "2.0"], default="1.1",
+       action='store', type=str, choices=["1.0", "1.1", "2.0"], default="2.0",
        help='select the silicon revision')
 
 parser.add_argument('-m', '--module', dest='module',
@@ -70,21 +70,21 @@ args.resetslew = True
 
 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 
-VERSION = "2.5"
+VERSION = "2.8"
 
 if (args.part == "dra74x" or args.part == "dra75x"):
-       if (args.revision == "1.0"):
-               args.revision = "1.1"
+       if (args.revision == "1.0" or args.revision == "1.1"):
+               args.revision = "1.x"
        XML_PATH = "XMLFiles/DRA75x_DRA74x"
        PART = "DRA75x_DRA74x"
-       PCT_VERSION = "v1.0.10"
+       PCT_VERSION = "v1.0.16"
 elif (args.part == "dra72x"):
        if (args.revision == "1.1"):
                print "dra72x doesn't have silicon revision 1.1"
                exit()
        XML_PATH = "XMLFiles/DRA72x"
        PART = "DRA72x"
-       PCT_VERSION = "v1.0.7"
+       PCT_VERSION = "v1.0.9"
 
 pad_data_xml   = XML_PATH + "/CTRL_MODULE_CORE.xml"
 iod_data_xml   = XML_PATH + "/IODELAYCONFIG.xml"
@@ -107,6 +107,9 @@ def warn(msg):
        trace(1, "WARN: " + msg)
 def error(msg):
        trace(0, "ERR: " + msg)
+def fatal(msg):
+       trace(0, "FATAL: " + msg)
+       exit()
 
 if (args.interactive):
        print "iodelay-autogen.py - Python script to generate the IOdelay data."
@@ -150,7 +153,7 @@ def read_selmodes(fname):
 
 def read_pad_dump(file):
        regmap = {}
-       pattern = re.compile('.*(0x[0-9A-F]+).*(0x[0-9A-F]+).*')
+       pattern = re.compile('.*(0x[0-9A-Fa-f]+).*(0x[0-9A-Fa-f]+).*')
        f = open(file, 'r')
        for line in f:
                list = re.match(pattern, line)
@@ -161,6 +164,14 @@ def read_pad_dump(file):
                verbose("XML pad-reg: Addr = %08x Value = %08x" % (addr, val))
                regmap[addr] = val
        return regmap
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# 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()
+
 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 
 # Helper functions to parse XML nodes and get the desired data
@@ -175,6 +186,13 @@ def xml_pad_get_name(offset):
        else:
                return padlist[0].get("id")
 
+def xml_pad_get_offset(name):
+       padlist = pad_xml.findall("register[@id='%s']" % name)
+       if (len(padlist) == 0):
+               return None
+       else:
+               return int(padlist[0].get("offset"), 16)
+
 def xml_pad_get_slew(offset):
        padlist = pad_xml.findall("register[@offset='0x%X']" % offset)
        if (len(padlist) == 0):
@@ -190,6 +208,8 @@ def xml_pad_get_slew(offset):
 # CTRL_CORE_ALT_SELECT_MUX register allows to select between one of the signals
 # Its like a board mux has been added inside the SoC, except it uses same muxmode.
 def resolve_group(muxmode_str):
+       if (muxmode_str == "DRIVER OFF"):
+               return muxmode_str
        mmlist = muxmode_str.split(" ")
        mmlen = len(mmlist)
        if (mmlen == 1):
@@ -263,7 +283,55 @@ def xml_get_manual(mode):
                        debug("    * MANUAL: %s [%s] => delay[%s] = %d, %d" % (signal, man_name, regname, adel, gdel))
        return mmodes
 
+def xml_get_additional_mode(orig):
+       additional_mux = orig.findall("additionalMux/confregisters")
+       if (len(additional_mux) == 0):
+               return orig
+       else:
+               additional_mux = additional_mux[0]
+               mux_reg_name = additional_mux.findtext("register")
+               offset = xml_pad_get_offset(mux_reg_name)
+
+               if (offset == None):
+                       error("Could not find register address for register '%s'" % mux_reg_name)
+                       fatal("This pin may have virtual/manual modes, Fix XML file")
+
+               addr = 0x4a002000 + offset
+               if (addr not in reglist):
+                       error("register dump lacks data for additional muxes")
+                       warn("using default values")
+                       muxval = 0x0
+               else:
+                       muxval = regmap[addr]
+
+               values = additional_mux.findall("value")
+               for value in values:
+
+                       option = int(value.findtext("option"))
+                       fieldpos = value.findtext("fieldPos")
+                       signal = value.findtext("signal").upper()
+                       matchlist = re.match("([0-9]+)[:]*([0-9]*)", fieldpos)
+
+                       verbose("++++ Additional mux %s possible" % signal)
+                       end = int(matchlist.groups(0)[0])
+                       if (matchlist.groups(0)[1] == ""):
+                               start = end
+                       else:
+                               start = int(matchlist.groups(0)[1])
+
+                       muxval = muxval & (1 << end)
+                       muxval = muxval >> start
+
+                       if (muxval == option):
+                               debug(">>>> Additional mux %s[%s] = %d" % (mux_reg_name, fieldpos, option))
+                               debug(">>>> Effective signal = %s" % signal)
+                               return value
+               error("None of the additional Mux value matched, using default")
+               return values[0]
+
 def xml_find_delaymodes(pad_name, muxmode):
+       virt = {}
+       man = {}
        padlist = model_xml.findall("padDB/clockNode/type/pad")
        for pad in padlist:
                if (pad_name == pad.findtext("confregisters/regbit/register")):
@@ -273,10 +341,11 @@ def xml_find_delaymodes(pad_name, muxmode):
                return None
        for mode in muxmodes:
                if ("%d" % muxmode == mode.findtext("mode")):
+                       mode = xml_get_additional_mode(mode)
                        virt = xml_get_virtual(mode)
                        man = xml_get_manual(mode)
                        return (virt, man)
-       return None
+       return (virt, man)
 
 def xml_check_correctness(modehelp):
 
@@ -304,11 +373,21 @@ def xml_check_correctness(modehelp):
 
        # Find all the manual modes
        manmode_list = model_xml.findall("padDB/clockNode/type/pad/muxmode/manualmode/cfgreg/mode")
+       for i in manmode_list:
+               man_name = i.findtext("name")
+               modes[man_name] = "manual"
+       # Find all the additional manual modes
+       manmode_list = model_xml.findall("padDB/clockNode/type/pad/muxmode/additionalMux/confregisters/value/manualmode/cfgreg/mode")
        for i in manmode_list:
                man_name = i.findtext("name")
                modes[man_name] = "manual"
        # Find all the virtual modes
        virtmode_list = model_xml.findall("padDB/clockNode/type/pad/muxmode/virtualmode/mode")
+       for i in virtmode_list:
+               virt_name = i.findtext("name")
+               modes[virt_name] = "virtual"
+       # Find all the additional virtual modes
+       virtmode_list = model_xml.findall("padDB/clockNode/type/pad/muxmode/additionalMux/confregisters/value/virtualmode/mode")
        for i in virtmode_list:
                virt_name = i.findtext("name")
                modes[virt_name] = "virtual"
@@ -690,12 +769,6 @@ def bios_format_delay_regs(delayconf, per_delayconf):
 # * 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()
-
 # List of all the pads being configured
 padconf = []
 # List of all the delay registers being configured (for manual mode)
@@ -747,7 +820,7 @@ for i in range(0, 260):
        if (args.resetslew):
                val |= (xml_pad_get_slew(offset) & 0x1) << 19
 
-       debug("\nPAD: %s: Addr= 0x%08X Value = 0x%08X \"%s\"" \
+       debug("PAD: %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