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