]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/iodelay-config.git/blobdiff - iodelay-autogen.py
script: Exit after generating GPIO script
[glsdk/iodelay-config.git] / iodelay-autogen.py
index 393a2d948635358a21e01f892bfc31da6c70fd84..d7720716f74df70560d76f57ccd830c90b010576 100755 (executable)
@@ -47,7 +47,7 @@ parser.add_argument('-p', '--part', dest='part',
 
 parser.add_argument('-m', '--module', dest='module',
        action='store', type=str, default="",
-       help='generate only for this module')
+       help='generate only for modules matching the provided RE')
 
 parser.add_argument('-s', '--strict', dest='strict',
        action='store_true',
@@ -64,6 +64,10 @@ parser.add_argument('-c', '--check', dest='check_xml',
        help='check consistency of the XML files and other data')
 
 args = parser.parse_args()
+
+# Some more knobs for developers, Don't want to expose them to cmd line
+args.resetslew = True
+
 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 
 VERSION = "2.4"
@@ -71,11 +75,11 @@ VERSION = "2.4"
 if (args.part == "dra74x" or args.part == "dra75x"):
        XML_PATH = "XMLFiles/DRA75x_DRA74x"
        PART = "DRA75x_DRA74x"
-       PCT_VERSION = "v1.0.9"
+       PCT_VERSION = "v1.0.10"
 elif (args.part == "dra72x"):
        XML_PATH = "XMLFiles/DRA72x"
        PART = "DRA72x"
-       PCT_VERSION = "v1.0.5"
+       PCT_VERSION = "v1.0.6"
 
 pad_data_xml   = XML_PATH + "/CTRL_MODULE_CORE.xml"
 iod_data_xml   = XML_PATH + "/IODELAYCONFIG.xml"
@@ -153,7 +157,40 @@ def xml_pad_get_name(offset):
        else:
                return padlist[0].get("id")
 
-def xml_pad_get_pin(offset, muxmode):
+def xml_pad_get_slew(offset):
+       padlist = pad_xml.findall("register[@offset='0x%X']" % offset)
+       if (len(padlist) == 0):
+               return 0x0
+       else:
+               bitlist = padlist[0].findall("bitfield[@begin='19']")
+               if (len(bitlist) == 0):
+                       return 0x0
+               else:
+                       return int(bitlist[0].get("resetval"), 16)
+
+# For DRA72x SoC, for "ball compatibility" purpose, some signals have same muxmode.
+# 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):
+       mmlist = muxmode_str.split(" ")
+       mmlen = len(mmlist)
+       if (mmlen == 1):
+               def_mode = mmlist[0]
+               return mmlist[0]
+       elif (mmlen == 2):
+               def_mode = mmlist[0]
+               grp1_mode = mmlist[1]
+       elif (mmlen == 3):
+               def_mode = mmlist[0]
+               grp1_mode = mmlist[1]
+               grp2_mode = mmlist[2]
+       else:
+               print "ERR: Cannot resolve muxmode group for '%s'" % muxmode_str
+
+       #HACK for now
+       return def_mode
+
+def xml_model_get_signal(offset, muxmode):
        padlist = pad_xml.findall("register[@offset='0x%X']" % offset)
        if (len(padlist) == 0):
                return "Unknown"
@@ -164,7 +201,7 @@ def xml_pad_get_pin(offset, muxmode):
                modes = mux_field[0].findall("./bitenum[@value='%d']" % muxmode)
                if (len(modes) == 0):
                        return "Unknown"
-               return modes[0].get("id")
+               return resolve_group(modes[0].get("id"))
 
 def xml_iodelay_get_reg(name):
        delaylist = iod_xml.findall("register[@id='%s']" % name)
@@ -348,17 +385,16 @@ def select_mode(pad, pin, module, virt, man, modehelp, sel):
 # 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(padconf, per_padconf):
-       if(args.gpio == False):
-               return
-
-       print "# Read pad signals using GPIO DATA-IN registers"
+       print "###########################################"
+       print "# Read %s signals using GPIO DATA-IN registers" % args.module
        print "# Works only for the input signals"
+       print "###########################################"
        gpio_data_addrs = (0, 0x4ae10138, 0x48055138, 0x48057138, 0x48059138, 0x4805b138, 0x4805d138, 0x48051138, 0x48053138)
        for i in padconf:
                (pad_name, pin_name, addr, val, mode, delayinfo) = i
 
                offset = addr - 0x4a002000
-               gpio_name = xml_pad_get_pin(offset, 14)
+               gpio_name = xml_model_get_signal(offset, 14)
                matchlist = re.match("GPIO(.)_(.*)", gpio_name)
                if (matchlist == None):
                        print "ERR: No GPIO for pad %s" % pad_name
@@ -405,6 +441,7 @@ def format_delay_regs(delayconf, per_delayconf):
                print "ERR: Format %s not suppported" % args.format
 
 def get_pin_info(val):
+       slew_fast = (val >> 19) & 0x1
        inp_en = (val >> 18) & 0x1
        pulltype = (val >> 17) & 0x1
        pull_dis = (val >> 16) & 0x1
@@ -418,6 +455,8 @@ def get_pin_info(val):
                        pin += "_PULLUP"
                else:
                        pin += "_PULLDOWN"
+       if (slew_fast):
+               pin += " | SLEWCONTROL"
        return pin
 
 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@@ -428,9 +467,6 @@ def uboot_format_pad_regs(padconf, per_padconf):
        for i in padconf:
                (pad_name, pin_name, addr, val, mode, delayinfo) = i
 
-               if (re.match("MMC.*", pin_name) != None):
-                       print "WARN: Skipping MMC padconf in uboot"
-
                muxmode = val & 0xf
                (method, data) = delayinfo
                if (method == "LEGACY"):
@@ -455,10 +491,6 @@ def uboot_format_delay_regs(delayconf, per_delayconf):
        for i in delayconf:
                (pad_name, pin_name, regname, del_offset, man_name, adel, gdel) = i
 
-               if (re.match("MMC.*", pin_name) != None):
-                       print "WARN: Skipping MMC delayconf in uboot"
-                       continue
-
                entry = (del_offset, adel, gdel, regname, pin_name, man_name)
                manual_del.append(entry)
 
@@ -476,8 +508,7 @@ def linux_format_pad_regs(padconf, per_padconf):
        for per in per_padconf:
 
                if (re.match("MMC.*", per) == None):
-                       print "ERR: Only MMC padconf is recommended in kernel"
-                       continue
+                       print "WARN: Only MMC padconf is recommended in kernel"
 
                # Get the mode from the first entry
                (pad_name, pin_name, addr, val, mode, delayinfo) = per_padconf[per][0]
@@ -517,8 +548,7 @@ def linux_format_delay_regs(delayconf, per_delayconf):
        for per in per_delayconf.keys():
 
                if (re.match("MMC.*", per) == None):
-                       print "ERR: Only MMC delayconf is recommended in kernel"
-                       continue
+                       print "WARN: Only MMC delayconf is recommended in kernel"
 
                # Get the mode from the first entry
                (pad_name, pin_name, regname, del_offset, mode, adel, gdel) = per_delayconf[per][0]
@@ -633,20 +663,25 @@ for i in range(0, 260):
 
        # Find out the pin based on the muxmode
        pad_name = xml_pad_get_name(offset)
-       pin_name = xml_pad_get_pin(offset, muxmode)
+       pin_name = xml_model_get_signal(offset, muxmode)
        if (pad_name == "Unknown" or pin_name == "Unknown"):
                print "WARN: Cannot find out Pad/Pin name for PAD address 0x%X (%s[%s] = %s)" \
                % (addr, pad_name, muxmode, pin_name)
                continue
-       if (pin_name == "DRIVER OFF"):
+       if (pin_name == "DRIVER"):
                continue
 
        # Find out if the delaymode for this module is already selected
        module = re.match("([^_]+)_.*", pin_name).groups(0)[0]
 
-       if (args.module != "" and args.module != module):
+       if (args.module != "" and re.match("%s" % args.module, module) == None):
                continue
 
+       # It is recommended to keep the reset value of the slewcontrol bit
+       # Find out the reset value from XML and update if required
+       if (args.resetslew):
+               val |= (xml_pad_get_slew(offset) & 0x1) << 19
+
        if (args.debug >= 1):
                print "\nPAD: %s: Addr= 0x%08X Value = 0x%08X \"%s\"" \
                % (pad_name, addr, val, pin_name)
@@ -654,8 +689,11 @@ for i in range(0, 260):
        # Find out all the possible virtual, manual modes fot the specific pad -> pin combination
        (virt, man) = xml_find_delaymodes(pad_name, muxmode)
 
-       # Need to select one out of allowed modes
-       mode = select_mode(pad_name, pin_name, module, virt, man, modehelp, sel)
+       if (args.gpio == True):
+               mode = "LEGACY"
+       else:
+               # Need to select one out of allowed modes
+               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 and module not in sel.keys()):
@@ -704,9 +742,12 @@ print "Total PAD registers: %d" % len(padconf)
 print "Total DELAY registers: %d" % len(delayconf)
 print ""
 
+if(args.gpio == True):
+       pad_dump_gpio(padconf, per_padconf)
+       exit()
+
 format_pad_regs(padconf, per_padconf)
 format_delay_regs(delayconf, per_delayconf)
-pad_dump_gpio(padconf, per_padconf)
 
 # Dump the final selection for reuse
 print "Selected modes for each peripheral module\n"