AddingPeripherals.mdwn
[pinmux.git] / src / ifacebase.py
index 3a3bf1d245d41dc8ed311e3dd9dd7bda20e76b5c..81e4e9d2fcaa8da932a5bd04206744effcbd5052 100644 (file)
@@ -10,9 +10,12 @@ class InterfacesBase(UserDict):
     """ contains a list of interface definitions
     """
 
-    def __init__(self, ifacekls, pth=None):
+    def __init__(self, ifacekls, pth=None, ifaceklsdict=None):
         self.pth = pth
+        self.fastbus = []
         self.ifacecount = []
+        if ifaceklsdict is None:
+            ifaceklsdict = {}
         UserDict.__init__(self, {})
         if not pth:
             return
@@ -25,29 +28,35 @@ class InterfacesBase(UserDict):
                 ln = ln.split("\t")
                 name = ln[0]  # will have uart
                 count = int(ln[1])  # will have count of uart
+                self.fastbus += ln[2:]
                 # spec looks like this:
                 """
                 [{'name': 'sda', 'outen': True},
                  {'name': 'scl', 'outen': True},
                 ]
                 """
+                ikls = ifacekls
+                for k, v in ifaceklsdict.items():
+                    if name.startswith(k):
+                        ikls = v
+                        break
                 spec, ganged = self.read_spec(pth, name)
                 # XXX HORRIBLE hack!!!
                 if name == 'pwm' and count == 1 and len(spec) != 1:
                     #print "read", name, count, spec, ganged
                     #print "multi pwm", spec[:1], len(spec)
                     spec[0]['name'] = 'out'
-                    iface = ifacekls(name, spec[:1], ganged, False)
+                    iface = ikls(name, spec[:1], ganged, False)
                     self.ifaceadd(name, len(spec), iface)
                 else:
-                    iface = ifacekls(name, spec, ganged, count == 1)
+                    iface = ikls(name, spec, ganged, count == 1)
                     self.ifaceadd(name, count, iface)
 
     def getifacetype(self, fname):
         # finds the interface type, e.g sd_d0 returns "inout"
         for iface in self.values():
             typ = iface.getifacetype(fname)
-            #if fname.startswith('pwm'):
+            # if fname.startswith('pwm'):
             #   print fname, iface.ifacename, typ
             if typ:
                 return typ