From: Luke Kenneth Casson Leighton Date: Mon, 23 Jul 2018 10:53:09 +0000 (+0100) Subject: pass in Interface factory, to do GPIO differently X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a2417c752d628f72b33727721d29c8787a034a10;p=pinmux.git pass in Interface factory, to do GPIO differently --- diff --git a/src/bsv/interface_decl.py b/src/bsv/interface_decl.py index 1a728fa..3da0fc0 100644 --- a/src/bsv/interface_decl.py +++ b/src/bsv/interface_decl.py @@ -350,13 +350,16 @@ class IOInterface(Interface): def wirefmt(self, *args): return generic_io.format(*args) +class InterfaceGPIO(Interface): + pass class Interfaces(InterfacesBase, PeripheralInterfaces): """ contains a list of interface definitions """ def __init__(self, pth=None): - InterfacesBase.__init__(self, Interface, pth) + InterfacesBase.__init__(self, Interface, pth, + {'gpio': InterfaceGPIO }) PeripheralInterfaces.__init__(self) def ifacedef(self, f, *args): diff --git a/src/ifacebase.py b/src/ifacebase.py index 0d6d250..e5e7e97 100644 --- a/src/ifacebase.py +++ b/src/ifacebase.py @@ -10,9 +10,11 @@ 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.ifacecount = [] + if ifaceklsdict is None: + ifaceklsdict = {} UserDict.__init__(self, {}) if not pth: return @@ -31,16 +33,21 @@ class InterfacesBase(UserDict): {'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):