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