]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/iodelay-config.git/blobdiff - iodelay-autogen.py
script: Pass selected mode name in pad data
[glsdk/iodelay-config.git] / iodelay-autogen.py
index 3094328599df40884491bc9abc21f8a36e80e080..130a310455a00f4c2ea3c4924ea2aa669a8ad1ef 100755 (executable)
@@ -38,9 +38,13 @@ parser.add_argument('-f', '--format', dest='format',
        help='select the output format to be used')
 
 parser.add_argument('-r', '--revision', dest='revision',
-       action='store', type=str, choices=["1.1", "2.0"], default="1.1",
+       action='store', type=str, choices=["1.0", "1.1", "2.0"], default="1.1",
        help='select the silicon revision')
 
+parser.add_argument('-p', '--part', dest='part',
+       action='store', type=str, choices=["dra74x", "dra75x", "dra72x"], default="dra74x",
+       help='select the device part')
+
 parser.add_argument('-m', '--module', dest='module',
        action='store', type=str, default="",
        help='generate only for this module')
@@ -62,15 +66,30 @@ parser.add_argument('-c', '--check', dest='check_xml',
 args = parser.parse_args()
 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 
-PCT_VERSION = "v1.0.7"
-pad_data_xml = "XMLFiles/CTRL_MODULE_CORE.xml"
-iod_data_xml = "XMLFiles/IODELAYCONFIG.xml"
-model_data_xml = "XMLFiles/model_DRA75x_DRA74x_SR" + args.revision + "_" + PCT_VERSION + ".xml"
+VERSION = "2.4"
+
+if (args.part == "dra74x" or args.part == "dra75x"):
+       XML_PATH = "XMLFiles/DRA75x_DRA74x"
+       PART = "DRA75x_DRA74x"
+       PCT_VERSION = "v1.0.9"
+elif (args.part == "dra72x"):
+       XML_PATH = "XMLFiles/DRA72x"
+       PART = "DRA72x"
+       PCT_VERSION = "v1.0.5"
+
+pad_data_xml   = XML_PATH + "/CTRL_MODULE_CORE.xml"
+iod_data_xml   = XML_PATH + "/IODELAYCONFIG.xml"
+model_data_xml = XML_PATH + "/model_" + PART + "_SR" + args.revision + "_" + PCT_VERSION + ".xml"
+modehelp_file  = XML_PATH + "/guidelines.txt"
 
-modehelp_file = "guidelines.txt"
 pad_file = "ctrl-core.dump"
 sel_file = "selected-modes.txt"
 
+print "iodelay-autogen.py - Python script to generate the IOdelay data."
+print "v" + VERSION + " using PCT version " + PCT_VERSION
+print "Parsing PCT data from " + model_data_xml + "..."
+print ""
+
 # 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()
@@ -79,7 +98,7 @@ model_xml = ET.parse(model_data_xml).getroot()
 # Functions to parse the input files and build data structures
 def read_guidelines(fname):
        modehelp = {}
-       pattern = re.compile('(.+\w)\t+(.+)')
+       pattern = re.compile('([^\t.]+\w)\t+(.+)')
        f = open(fname)
        for line in f.readlines():
                list = re.match(pattern, line)
@@ -279,7 +298,7 @@ def select_mode(pad, pin, module, virt, man, modehelp, sel):
 
        if (module in sel.keys()):
                mode = sel[module]
-               if (mode == "SKIP" or mode in modelist):
+               if (mode == "SKIP" or mode == "LEGACY" or mode in modelist):
                        return mode
                else:
                        print("ERR: Invalid delaymode '%s' for module '%s'" % (mode, module))
@@ -287,7 +306,6 @@ def select_mode(pad, pin, module, virt, man, modehelp, sel):
        if (args.interactive == 0):
                print "WARN: No delay modes for %s found, skipping" % module
                mode = "SKIP"
-               sel[module] = mode
                return mode
 
        # Display the menu and ask user to select the 'right' mode
@@ -296,6 +314,8 @@ def select_mode(pad, pin, module, virt, man, modehelp, sel):
                print "MENU: Select delay mode for %s -> %s" % (pad, pin)
                i = 0
                print "MENU: %d: %s \t\t\t%s" % (i, "SKIP", "Skips this module for now")
+               i = 1
+               print "MENU: %d: %s \t\t%s" % (i, "LEGACY", "No external delay config (No virtual/manual needed)")
                for mode in modelist:
                        i += 1
                        if (mode in modehelp):
@@ -308,8 +328,11 @@ def select_mode(pad, pin, module, virt, man, modehelp, sel):
                        if (choice == 0):
                                mode = "SKIP"
                                break
-                       elif (choice >=0 and choice <= len(modelist)):
-                               mode = modelist[choice - 1]
+                       elif (choice == 1):
+                               mode = "LEGACY"
+                               break
+                       elif (choice >=2 and choice <= len(modelist) + 1):
+                               mode = modelist[choice - 2]
                                break
                        print "ERROR: Invalid choice"
                except ValueError:
@@ -332,11 +355,11 @@ def pad_dump_gpio(padconf, per_padconf):
        print "# Works only for the input signals"
        gpio_data_addrs = (0, 0x4ae10138, 0x48055138, 0x48057138, 0x48059138, 0x4805b138, 0x4805d138, 0x48051138, 0x48053138)
        for i in padconf:
-               (pad_name, pin_name, addr, val, delayinfo) = i
+               (pad_name, pin_name, addr, val, mode, delayinfo) = i
 
                offset = addr - 0x4a002000
                gpio_name = xml_pad_get_pin(offset, 14)
-               matchlist = re.match("GPIO(.)_(.)", gpio_name)
+               matchlist = re.match("GPIO(.)_(.*)", gpio_name)
                if (matchlist == None):
                        print "ERR: No GPIO for pad %s" % pad_name
                        continue
@@ -403,7 +426,7 @@ def get_pin_info(val):
 def uboot_format_pad_regs(padconf, per_padconf):
        print "\nconst struct pad_conf_entry dra74x_core_padconf_array[] = {"
        for i in padconf:
-               (pad_name, pin_name, addr, val, delayinfo) = i
+               (pad_name, pin_name, addr, val, mode, delayinfo) = i
 
                if (re.match("MMC.*", pin_name) != None):
                        print "WARN: Skipping MMC padconf in uboot"
@@ -437,13 +460,13 @@ def uboot_format_delay_regs(delayconf, per_delayconf):
                        print "WARN: Skipping MMC delayconf in uboot"
                        continue
 
-               entry = (del_offset, adel, gdel, regname)
+               entry = (del_offset, adel, gdel, regname, pin_name, man_name)
                manual_del.append(entry)
 
        es_rev = args.revision.replace('.', '_')
        print "\nconst struct iodelay_cfg_entry dra742_es" + es_rev + "_iodelay_cfg_array[] = {"
        for entry in sorted(manual_del):
-               print "\t{ 0x%04X, %5d, %5d },\t/* %s */" % entry
+               print "\t{ 0x%04X, %5d, %5d },\t/* %s : %s - %s */" % entry
        print "};\n"
 
 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@@ -457,12 +480,15 @@ def linux_format_pad_regs(padconf, per_padconf):
                        print "ERR: Only MMC padconf is recommended in kernel"
                        continue
 
-               dtsnode = ("%s_pins_default" % per).lower()
+               # Get the mode from the first entry
+               (pad_name, pin_name, addr, val, mode, delayinfo) = per_padconf[per][0]
+
+               dtsnode = ("%s_pins_%s" % (per, mode)).lower()
                print ""
                print "\t%s: %s {" % (dtsnode, dtsnode)
                print "\t\tpinctrl-single,pins = <"
                for i in per_padconf[per]:
-                       (pad_name, pin_name, addr, val, delayinfo) = i
+                       (pad_name, pin_name, addr, val, mode, delayinfo) = i
 
                        muxmode = val & 0xf
                        (method, data) = delayinfo
@@ -504,7 +530,7 @@ def linux_format_delay_regs(delayconf, per_delayconf):
                for i in per_delayconf[per]:
                        (pad_name, pin_name, regname, del_offset, mode, adel, gdel) = i
 
-                       print "\t\t\t0x%03X A_DELAY(%d) | G_DELAY(%d)\t/* %s */" % (del_offset, adel, gdel, regname)
+                       print "\t\t\t0x%03X (A_DELAY(%d) | G_DELAY(%d))\t/* %s */" % (del_offset, adel, gdel, regname)
                print "\t\t>;"
                print "\t};"
        print "};\n"
@@ -514,7 +540,7 @@ def linux_format_delay_regs(delayconf, per_delayconf):
 # Generate output in bios format
 def bios_format_pad_regs(padconf, per_padconf):
        for i in padconf:
-               (pad_name, pin_name, addr, val, delayinfo) = i
+               (pad_name, pin_name, addr, val, mode, delayinfo) = i
 
                delaylist = []
                (method, data) = delayinfo
@@ -592,6 +618,7 @@ per_padconf = {}
 per_delayconf = {}
 
 xml_check_correctness(modehelp)
+
 # Start iterating over each pad
 for i in range(0, 260):
        # Find out the muxmode and pad direction, etc
@@ -632,7 +659,7 @@ for i in range(0, 260):
        mode = select_mode(pad_name, pin_name, module, virt, man, modehelp, sel)
 
        # Remember the selection for that module, for later reuse
-       if (args.strict == False):
+       if (args.strict == False and module not in sel.keys()):
                sel[module] = mode
 
        if (mode == "SKIP"):
@@ -649,7 +676,7 @@ for i in range(0, 260):
 
        if (args.debug >= 1):
                print "  => Using mode %s" % mode
-       paddata = (pad_name, pin_name, addr, val, delayinfo)
+       paddata = (pad_name, pin_name, addr, val, mode, delayinfo)
        if (module not in per_padconf.keys()):
                per_padconf[module] = []
        padconf.append(paddata)