pass in muxwidth as argument
[pinmux.git] / src / spec / base.py
1 from spec.interfaces import Pinouts
2
3 from spec.ifaceprint import display, display_fns, check_functions
4 from spec.ifaceprint import display_fixed
5
6
7 class PinSpec(Pinouts):
8 def __init__(self, pinbanks, fixedpins, function_names, fast=None):
9 self.fastbus = fast or []
10 self.pinbanks = {}
11 self.muxwidths = {}
12 for bank, (sz, muxwidth) in pinbanks.items():
13 self.pinbanks[bank] = sz
14 self.muxwidths[bank] = muxwidth
15 self.fixedpins = fixedpins
16 self.function_names = function_names
17 bankspec = {}
18 self.offs = 0
19 pkeys = sorted(self.pinbanks.keys())
20 print self.pinbanks
21 for kn in pkeys:
22 bankspec[kn] = self.offs
23 self.offs += self.pinbanks[kn]
24
25 self.scenarios = []
26
27 Pinouts.__init__(self, bankspec)
28
29 def add_scenario(self, name, needed, eint, pwm, descriptions):
30 # Scenarios below can be spec'd out as either "find first interface"
31 # by name/number e.g. SPI0, or as "find in bank/mux" which must be
32 # spec'd as "BM:Name" where B is bank (A-F), M is Mux (0-3)
33 # EINT and PWM are grouped together, specially, but may still be spec'd
34 # using "BM:Name". Pins are removed in-order as listed from
35 # lists (interfaces, EINTs, PWMs) from available pins.
36
37 self.scenarios.append((name, needed, eint, pwm, descriptions))
38
39 def write(self, of):
40 of.write("""# Pinouts (PinMux)
41 auto-generated by [[pinouts.py]]
42
43 [[!toc ]]
44
45 """)
46 bk = sorted(self.pinbanks.keys())
47 for bank in bk:
48 of.write(
49 "\n## Bank %s (%d pins, width %d)\n\n" %
50 (bank, self.pinbanks[bank], self.muxwidths[bank]))
51 display(of, self, bank, muxwidth=self.muxwidths[bank])
52
53 of.write("\n# Pinouts (Fixed function)\n\n")
54 fixedpins = display_fixed(of, self.fixedpins, len(self))
55
56 of.write("""# Functions (PinMux)
57
58 auto-generated by [[pinouts.py]]
59
60 """)
61 fns = display_fns(of, self.bankspec, self, self.function_names)
62 of.write('\n')
63
64 for scenario in self.scenarios:
65 name, needed, eint, pwm, descriptions = scenario
66 unused_pins = check_functions(of, name, self.bankspec, fns,
67 self,
68 needed, eint, pwm,
69 descriptions)
70
71 of.write("""# Reference Datasheets
72
73 datasheets and pinout links
74 * <http://datasheets.chipdb.org/AMD/8018x/80186/amd-80186.pdf>
75 * <http://hands.com/~lkcl/eoma/shenzen/frida/FRD144A2701.pdf>
76 * <http://pinouts.ru/Memory/sdcard_pinout.shtml>
77 * p8 <http://www.onfi.org/~/media/onfi/specs/onfi_2_0_gold.pdf?la=en>
78 * <https://www.heyrick.co.uk/blog/files/datasheets/dm9000aep.pdf>
79 * <http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4393.pdf>
80 * <https://www.nxp.com/docs/en/data-sheet/MCF54418.pdf>
81 * ULPI OTG PHY, ST <http://www.st.com/en/interfaces-and-transceivers/stulpi01a.html>
82 * ULPI OTG PHY, TI TUSB1210 <http://ti.com/product/TUSB1210/>
83
84 """)
85
86 return self, self.bankspec, self.pinbanks, fixedpins