3 """ define functions here, with their pin names and the pin type.
5 each function returns a pair of lists
6 (or objects with a __getitem__ function)
8 the first list (or object) contains pin name plus type specifications.
12 * "-" for an input pin,
13 * "+" for an output pin,
14 * "*" for an in/out pin
16 each function is then added to the pinspec tuple, below, as a ("NAME",
19 different functions may be added multiple times under the same NAME,
20 so that complex (or large) functions can be split into one or more
21 groups (and placed on different pinbanks).
23 eint, pwm and gpio are slightly odd in that instead of a fixed list
24 an object is returned with a __getitem__ function that accepts a
25 slice object. in this way the actual generation of the pin name
26 is delayed until it is known precisely how many pins are to be
27 generated, and that's not known immediately (or it would be if
28 every single one of the functions below had a start and end parameter
29 added). see spec.interfaces.PinGen class slice on pingroup
31 the second list is the names of pins that are part of an inout bus.
32 this list of pins (a ganged group) will need to be changed under
33 the control of the function, as a group. for example: sdmmc's
34 D0-D3 pins are in-out, they all change from input to output at
35 the same time under the control of the function, therefore there's
36 no point having multiple in-out switch/control wires, as the
37 sdmmc is never going to do anything other than switch this entire
38 bank all at once. so in this particular example, sdmmc returns:
40 (['CMD+', 'CLK+', 'D0*', 'D1*', 'D2*', 'D3*'] # pin names
41 ['D0*', 'D1*', 'D2*', 'D3*']) # ganged bus names
45 def i2s(suffix
, bank
):
46 return (['MCK+', 'BCK+', 'LRCK+', 'DI-', 'DO+'],
50 # XXX TODO: correct these. this is a stub for now
51 def lpc(suffix
, bank
, pincount
=8):
52 emmcpins
= ['CMD+', 'CLK+']
54 for i
in range(pincount
):
56 emmcpins
.append(pname
)
58 return (emmcpins
, inout
)
61 def emmc(suffix
, bank
, pincount
=8):
62 emmcpins
= ['CMD+', 'CLK+']
64 for i
in range(pincount
):
66 emmcpins
.append(pname
)
68 return (emmcpins
, inout
)
71 def sdmmc(suffix
, bank
):
72 return emmc(suffix
, bank
, pincount
=4)
75 def nspi(suffix
, bank
, iosize
, masteronly
=True):
77 qpins
= ['CK+', 'NSS+']
79 qpins
= ['CK*', 'NSS*']
81 for i
in range(iosize
):
88 def mspi(suffix
, bank
):
89 return nspi(suffix
, bank
, 2, masteronly
=True)
92 def mquadspi(suffix
, bank
):
93 return nspi(suffix
, bank
, 4, masteronly
=True)
96 def spi(suffix
, bank
):
97 return nspi(suffix
, bank
, 2)
100 def quadspi(suffix
, bank
):
101 return nspi(suffix
, bank
, 4)
104 def i2c(suffix
, bank
):
105 return (['SDA*', 'SCL*'], [])
108 def jtag(suffix
, bank
):
109 return (['TMS-', 'TDI-', 'TDO+', 'TCK+'], [])
112 def uart(suffix
, bank
):
113 return (['TX+', 'RX-'], [])
116 def ulpi(suffix
, bank
):
117 ulpipins
= ['CK+', 'DIR+', 'STP+', 'NXT+']
119 ulpipins
.append('D%d*' % i
)
120 return (ulpipins
, [])
123 def uartfull(suffix
, bank
):
124 return (['TX+', 'RX-', 'CTS-', 'RTS+'],
128 def rgbttl(suffix
, bank
):
129 ttlpins
= ['CK+', 'DE+', 'HS+', 'VS+']
131 ttlpins
.append("OUT%d+" % i
)
135 def rgmii(suffix
, bank
):
138 buspins
.append("ERXD%d-" % i
)
140 buspins
.append("ETXD%d+" % i
)
141 buspins
+= ['ERXCK-', 'ERXERR-', 'ERXDV-',
143 'ETXEN+', 'ETXCK+', 'ECRS-',
148 def flexbus1(suffix
, bank
):
153 buspins
.append(pname
)
156 buspins
.append("CS%d+" % i
)
157 buspins
+= ['ALE+', 'OE+', 'RW+', 'TA-',
158 # 'TS+', commented out for now, mirrors ALE, for mux'd mode
162 buspins
.append("BWE%d+" % i
)
163 for i
in range(2, 6):
164 buspins
.append("CS%d+" % i
)
165 return (buspins
, inout
)
168 def flexbus2(suffix
, bank
):
170 for i
in range(8, 32):
171 buspins
.append("AD%d*" % i
)
172 return (buspins
, buspins
)
175 def sdram1(suffix
, bank
):
179 pname
= "SDRDQM%d+" % i
180 buspins
.append(pname
)
182 pname
= "SDRD%d*" % i
183 buspins
.append(pname
)
186 buspins
.append("SDRAD%d+" % i
)
188 buspins
.append("SDRBA%d+" % i
)
189 buspins
+= ['SDRCLK+', 'SDRCKE+', 'SDRRASn+', 'SDRCASn+', 'SDRWEn+',
191 return (buspins
, inout
)
194 def sdram2(suffix
, bank
):
197 for i
in range(1, 6):
198 buspins
.append("SDRCSn%d+" % i
)
199 for i
in range(8, 16):
200 pname
= "SDRDQM%d*" % i
201 buspins
.append(pname
)
202 for i
in range(8, 16):
203 pname
= "SDRD%d*" % i
204 buspins
.append(pname
)
206 return (buspins
, inout
)
209 def sdram3(suffix
, bank
):
212 for i
in range(12, 13):
213 buspins
.append("SDRAD%d+" % i
)
214 for i
in range(8, 64):
215 pname
= "SDRD%d*" % i
216 buspins
.append(pname
)
218 return (buspins
, inout
)
221 def mcu8080(suffix
, bank
):
225 pname
= "MCUD%d*" % i
226 buspins
.append(pname
)
229 buspins
.append("MCUAD%d+" % (i
+ 8))
231 buspins
.append("MCUCS%d+" % i
)
233 buspins
.append("MCUNRB%d+" % i
)
234 buspins
+= ['MCUCD+', 'MCURD+', 'MCUWR+', 'MCUCLE+', 'MCUALE+',
236 return (buspins
, inout
)
239 class RangePin(object):
240 def __init__(self
, suffix
, prefix
=None):
242 self
.prefix
= prefix
or ''
244 def __getitem__(self
, s
):
246 for idx
in range(s
.start
or 0, s
.stop
or -1, s
.step
or 1):
247 res
.append("%s%d%s" % (self
.prefix
, idx
, self
.suffix
))
251 def eint(suffix
, bank
):
252 return (RangePin("-"), [])
255 def pwm(suffix
, bank
):
256 return (RangePin("+"), [])
259 def gpio(suffix
, bank
):
260 return (("GPIO%s" % bank
, RangePin(prefix
=bank
, suffix
="*")), [])
263 # list functions by name here
265 pinspec
= (('IIS', i2s
),