update m_class to emmc naming
[pinmux.git] / src / spec / ifaceprint.py
index 3dc60f7bb9163813d2337ac2311feb3587d42559..55b820d2bf376c5d9d908204177845b4d7f3e3ef 100644 (file)
@@ -3,7 +3,7 @@
 from copy import deepcopy
 
 
-def display(of, pins, banksel=None):
+def display(of, pins, banksel=None, muxwidth=4):
     of.write("""\
 | Pin | Mux0        | Mux1        | Mux2        | Mux3        |
 | --- | ----------- | ----------- | ----------- | ----------- |
@@ -13,7 +13,7 @@ def display(of, pins, banksel=None):
         pdata = pins.get(pin)
         if banksel:
             skip = False
-            for mux in range(4):
+            for mux in range(muxwidth):
                 if mux not in pdata:
                     continue
                 name, bank = pdata[mux]
@@ -22,7 +22,7 @@ def display(of, pins, banksel=None):
             if skip:
                 continue
         res = '| %3d |' % pin
-        for mux in range(4):
+        for mux in range(muxwidth):
             if mux not in pdata:
                 res += "             |"
                 continue
@@ -80,6 +80,8 @@ def display_fns(of, bankspec, pins, function_names):
     current_fn = None
     for fname in fnidx:
         fnbase = find_fn(fname, fn_names)
+        assert fnbase in function_names, "fn %s not in descriptions %s" % \
+                    (fname, str(function_names.keys()))
         #print "name", fname, fnbase
         if fnbase != current_fn:
             if current_fn is not None:
@@ -100,6 +102,10 @@ def check_functions(of, title, bankspec, fns, pins, required, eint, pwm,
     pins = deepcopy(pins)
     if descriptions is None:
         descriptions = {}
+    fnidx = fns.keys()
+
+    #print dir(fns)
+    #print dir(pins)
 
     of.write("# Pinmap for %s\n\n" % title)
 
@@ -123,13 +129,21 @@ def check_functions(of, title, bankspec, fns, pins, required, eint, pwm,
         else:
             count = 100000
         name = name[0]
+        #print name
         found = set()
-        fnidx = fns.keys()
-        # fnidx.sort(fnsort)
         pinfound = {}
+        located = set()
         for fname in fnidx:
             if not fname.startswith(name):
                 continue
+            for k in pins.fnspec.keys():
+                if fname.startswith(k):
+                    fk = list(pins.fnspec[k].keys())
+                    fn = pins.fnspec[k]
+                    fn = fn[fk[0]]
+                    #print fname, fn, dir(fn)
+                    if count == 100000:
+                        count = len(fn.pingroup)
             for pin, mux, bank in fns[fname]:
                 if findbank is not None:
                     if findbank != bank:
@@ -142,6 +156,7 @@ def check_functions(of, title, bankspec, fns, pins, required, eint, pwm,
 
         pinidx = sorted(pinfound.keys())
 
+        removedcount = 0
         for pin_ in pinidx:
             fname, pin_, bank, pin, mux = pinfound[pin_]
             if fname in found:
@@ -150,8 +165,15 @@ def check_functions(of, title, bankspec, fns, pins, required, eint, pwm,
             if len(found) > count:
                 continue
             del pins[pin_]
+            removedcount += 1
             of.write("* %s %d %s%d/%d\n" % (fname, pin_, bank, pin, mux))
 
+        if removedcount != count:
+            print ("not all found", name, removedcount, count, title, found,
+                   fns[fname])
+            print ("pins found", pinfound)
+
+        # fnidx.sort(fnsort)
         of.write('\n')
 
     # gpios