autopep8 whitespace cleanup
[pinmux.git] / src / spec / minitest.py
1 #!/usr/bin/env python
2
3 from spec.interfaces import Pinouts
4
5 from spec.ifaceprint import display, display_fns, check_functions
6 from spec.ifaceprint import display_fixed
7
8
9 def pinspec():
10 pinbanks = {
11 'B': 28,
12 }
13 bankspec = {}
14 pkeys = sorted(pinbanks.keys())
15 offs = 0
16 for kn in pkeys:
17 bankspec[kn] = offs
18 offs += pinbanks[kn]
19
20 pinouts = Pinouts(bankspec)
21
22 # Bank B, 16-47
23 pinouts.gpio("", ('B', 0), "B", 0, 0, 28)
24 pinouts.rgbttl("", ('B', 0), "B", 1, limit=23)
25 pinouts.spi("0", ('B', 10), "B", 2)
26 pinouts.quadspi("", ('B', 4), "B", 2)
27 pinouts.uart("0", ('B', 16), "B", 2)
28 pinouts.i2c("2", ('B', 18), "B", 2)
29 pinouts.pwm("", ('B', 21), "B", 2, 0, 3)
30 pinouts.sdmmc("0", ('B', 22), "B", 3)
31 pinouts.eint("", ('B', 0), "B", 3, 0, 4)
32 pinouts.eint("", ('B', 20), "B", 2, 4, 1)
33 pinouts.eint("", ('B', 23), "B", 1, 5, 1)
34 pinouts.sdmmc("1", ('B', 4), "B", 3)
35 pinouts.jtag("1", ('B', 10), "B", 3)
36 pinouts.uartfull("0", ('B', 14), "B", 3)
37 pinouts.uartfull("1", ('B', 18), "B", 3)
38 pinouts.jtag("0", ('B', 24), "B", 2)
39 pinouts.spi("1", ('B', 24), "B", 1)
40 pinouts.i2c("0", ('B', 0), "B", 2)
41 pinouts.uart("1", ('B', 2), "B", 2)
42 pinouts.uart("2", ('B', 14), "B", 2)
43
44 print ("""# Pinouts (PinMux)
45 auto-generated by [[pinouts.py]]
46
47 [[!toc ]]
48 """)
49 display(pinouts)
50
51 print ("\n# Pinouts (Fixed function)\n")
52
53 fixedpins = {
54 'CTRL_SYS': [
55 'TEST',
56 'JTAG_SEL',
57 'UBOOT_SEL',
58 'NMI#',
59 'RESET#',
60 'CLK24M_IN',
61 'CLK24M_OUT',
62 'PLLTEST',
63 'PLLREGIO',
64 'PLLVP25',
65 'PLLDV',
66 'PLLVREG',
67 'PLLGND',
68 ],
69 'POWER_GPIO': [
70 'VDD_GPIOB',
71 'GND_GPIOB',
72 ]}
73
74 fixedpins = display_fixed(fixedpins, len(pinouts))
75
76 print ("""# Functions (PinMux)
77
78 auto-generated by [[pinouts.py]]
79 """)
80
81 function_names = {'EINT': 'External Interrupt',
82 'FB': 'MC68k FlexBus',
83 'IIS': 'I2S Audio',
84 'JTAG0': 'JTAG (same as JTAG1, JTAG_SEL=LOW)',
85 'JTAG1': 'JTAG (same as JTAG0, JTAG_SEL=HIGH)',
86 'LCD': '24-pin RGB/TTL LCD',
87 'RG': 'RGMII Ethernet',
88 'MMC': 'eMMC 1/2/4/8 pin',
89 'PWM': 'PWM (pulse-width modulation)',
90 'SD0': 'SD/MMC 0',
91 'SD1': 'SD/MMC 1',
92 'SD2': 'SD/MMC 2',
93 'SPI0': 'SPI (Serial Peripheral Interface) 0',
94 'SPI1': 'SPI (Serial Peripheral Interface) 1',
95 'QSPI': 'Quad SPI (Serial Peripheral Interface) 1',
96 'TWI0': 'I2C 0',
97 'TWI1': 'I2C 1',
98 'TWI2': 'I2C 2',
99 'UARTQ0': 'UART (TX/RX/CTS/RTS) 0',
100 'UARTQ1': 'UART (TX/RX/CTS/RTS) 1',
101 'UART0': 'UART (TX/RX) 0',
102 'UART1': 'UART (TX/RX) 1',
103 'UART2': 'UART (TX/RX) 2',
104 'ULPI0': 'ULPI (USB Low Pin-count) 0',
105 'ULPI1': 'ULPI (USB Low Pin-count) 1',
106 'ULPI2': 'ULPI (USB Low Pin-count) 2',
107 }
108
109 fns = display_fns(bankspec, pinouts, function_names)
110 print
111
112 # Scenarios below can be spec'd out as either "find first interface"
113 # by name/number e.g. SPI1, or as "find in bank/mux" which must be
114 # spec'd as "BM:Name" where B is bank (A-F), M is Mux (0-3)
115 # EINT and PWM are grouped together, specially, but may still be spec'd
116 # using "BM:Name". Pins are removed in-order as listed from
117 # lists (interfaces, EINTs, PWMs) from available pins.
118
119 minitest = ['ULPI0/8', 'ULPI1', 'MMC', 'SD0', 'UART0',
120 'TWI0', 'SPI0', 'B3:SD1', ]
121 minitest_eint = ['EINT_0', 'EINT_1', 'EINT_2', 'EINT_3', 'EINT_4']
122 minitest_pwm = ['B2:PWM_0']
123 descriptions = {
124 'MMC': 'internal (on Card)',
125 'SD0': 'user-facing: internal (on Card), multiplexed with JTAG1\n'
126 'and UART2, for debug purposes',
127 'TWI2': 'I2C.\n',
128 'E2:SD1': '',
129 'SPI1': '',
130 'UART0': '',
131 'B1:LCD/22': '18-bit RGB/TTL LCD',
132 'ULPI0/8': 'user-facing: internal (on Card), USB-OTG ULPI PHY',
133 'ULPI1': 'dual USB2 Host ULPI PHY'
134 }
135
136 unused_pins = check_functions("MiniTest", bankspec, fns, pinouts,
137 minitest, minitest_eint, minitest_pwm,
138 descriptions)
139
140 print ("""# Reference Datasheets
141
142 datasheets and pinout links
143 * <http://datasheets.chipdb.org/AMD/8018x/80186/amd-80186.pdf>
144 * <http://hands.com/~lkcl/eoma/shenzen/frida/FRD144A2701.pdf>
145 * <http://pinouts.ru/Memory/sdcard_pinout.shtml>
146 * p8 <http://www.onfi.org/~/media/onfi/specs/onfi_2_0_gold.pdf?la=en>
147 * <https://www.heyrick.co.uk/blog/files/datasheets/dm9000aep.pdf>
148 * <http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4393.pdf>
149 * <https://www.nxp.com/docs/en/data-sheet/MCF54418.pdf>
150 * ULPI OTG PHY, ST <http://www.st.com/en/interfaces-and-transceivers/stulpi01a.html>
151 * ULPI OTG PHY, TI TUSB1210 <http://ti.com/product/TUSB1210/>
152 """)
153
154 return pinouts, bankspec, pinbanks, fixedpins