big autopep8 whitespace cleanup, not run before on pinmux spec code
[pinmux.git] / src / spec / m_class.py
1 #!/usr/bin/env python
2
3 from interfaces import jtag, uart, ulpi, uartfull, rgbttl, rgmii
4 from interfaces import flexbus1, flexbus2, sdram1, sdram2, mcu8080
5 from interfaces import eint, pwm, gpio, spi, i2c, emmc, sdmmc
6 from interfaces import quadspi, i2s
7 from interfaces import pinmerge, Pinouts
8
9 from ifaceprint import display, display_fns, check_functions
10 from ifaceprint import display_fixed
11
12
13 def pinspec():
14 pinouts = Pinouts()
15
16 pinbanks = {'A': 16,
17 'B': 28,
18 'C': 24,
19 'D': 24,
20 'E': 24,
21 'F': 10,
22 'G': 32,
23 }
24 bankspec = {}
25 pkeys = pinbanks.keys()
26 pkeys.sort()
27 offs = 0
28 for kn in pkeys:
29 bankspec[kn] = offs
30 offs += pinbanks[kn]
31
32 # Bank A, 0-15
33 pinmerge(pinouts, gpio(bankspec, "", ('A', 0), "A", 0, 16, 0))
34 pinmerge(pinouts, spi(bankspec, "1", ('A', 0), "A", 3))
35 pinmerge(pinouts, uartfull(bankspec, "1", ('A', 0), "A", 2))
36 pinmerge(pinouts, i2c(bankspec, "1", ('A', 4), "A", 2))
37 pinmerge(pinouts, emmc(bankspec, "", ('A', 0), "A", 1))
38 #pinmerge(pinouts, uart(bankspec, "2", ('A', 14), "A", 1))
39 pinmerge(pinouts, spi(bankspec, "2", ('A', 6), "A", 2))
40 pinmerge(pinouts, eint(bankspec, "", ('A', 10), "A", 0, 6))
41 pinmerge(pinouts, eint(bankspec, "", ('A', 4), "A", 0, 6, mux=3))
42 pinmerge(pinouts, sdmmc(bankspec, "1", ('A', 10), "A", 2))
43 pinmerge(pinouts, jtag(bankspec, "1", ('A', 10), "A", 3))
44 pinmerge(pinouts, uart(bankspec, "2", ('A', 14), "A", 3))
45
46 # Bank B, 16-47
47 pinmerge(pinouts, gpio(bankspec, "", ('B', 0), "B", 0, 28, 0))
48 pinmerge(pinouts, rgbttl(bankspec, "0", ('B', 0), "B", 1))
49 pinmerge(pinouts, spi(bankspec, "1", ('B', 12), "B", 2))
50 pinmerge(pinouts, quadspi(bankspec, "0", ('B', 4), "B", 2, limit=4))
51 pinmerge(pinouts, uart(bankspec, "3", ('B', 16), "B", 2))
52 pinmerge(pinouts, i2c(bankspec, "3", ('B', 18), "B", 2))
53 pinmerge(pinouts, pwm(bankspec, "0", ('B', 9), "B", mux=2))
54 pinmerge(pinouts, pwm(bankspec, "1", ('B', 20), "B", mux=2))
55 pinmerge(pinouts, pwm(bankspec, "2", ('B', 21), "B", mux=2))
56 pinmerge(pinouts, sdmmc(bankspec, "1", ('B', 22), "B", 2))
57 pinmerge(pinouts, eint(bankspec, "", ('B', 0), "B", 6, 4, mux=3))
58 pinmerge(pinouts, flexbus2(bankspec, "0", ('B', 4), "B", 3))
59 pinmerge(pinouts, i2c(bankspec, "1", ('B', 0), "B", 2))
60 pinmerge(pinouts, uart(bankspec, "2", ('B', 2), "B", 2))
61 pinmerge(pinouts, uart(bankspec, "4", ('B', 10), "B", 2))
62
63 # Bank C, 48-71
64 pinmerge(pinouts, gpio(bankspec, "", ("C", 0), "C", 0, 24, 0))
65 pinmerge(pinouts, ulpi(bankspec, "1", ('C', 0), "C", 1))
66 pinmerge(pinouts, ulpi(bankspec, "2", ('C', 12), "C", 1))
67 pinmerge(pinouts, spi(bankspec, "2", ('C', 8), "C", 2))
68 #pinmerge(pinouts, spi(bankspec, "2", ('C', 28), "C", 2))
69 pinmerge(pinouts, uartfull(bankspec, "0", ('C', 20), "C", 3))
70 pinmerge(pinouts, eint(bankspec, "", ('C', 0), "C", 10, 8, mux=3))
71 pinmerge(pinouts, jtag(bankspec, "2", ('C', 8), "C", 3))
72 pinmerge(pinouts, eint(bankspec, "", ('C', 12), "C", 22, 8, mux=3))
73 pinmerge(pinouts, uart(bankspec, "2", ('C', 22), "C", 2))
74 pinmerge(pinouts, i2s(bankspec, "", ('C', 13), "C", 2))
75 pinmerge(pinouts, pwm(bankspec, "2", ('C', 21), "C", mux=2))
76
77 # Bank D, 72-96
78 flexspec = {
79 'FB0_TS': ('FB0_ALE', 2, "D"),
80 'FB0_CS2': ('FB0_BWE2', 2, "D"),
81 'FB0_A0': ('FB0_BWE2', 3, "D"),
82 'FB0_CS3': ('FB0_BWE3', 2, "D"),
83 'FB0_A1': ('FB0_BWE3', 3, "D"),
84 'FB0_TBST': ('FB0_OE', 2, "D"),
85 'FB0_TSIZ0': ('FB0_BWE0', 2, "D"),
86 'FB0_TSIZ1': ('FB0_BWE1', 2, "D"),
87 }
88 #pinmerge(pinouts, mcu8080("", 72, "D", 1))
89 pinmerge(pinouts, gpio(bankspec, "", ('D', 0), "D", 0, 24, 0))
90 pinmerge(pinouts, flexbus1(bankspec, "0", ('D', 0), "D", 1, spec=flexspec))
91 pinmerge(pinouts, i2c(bankspec, "2", ('D', 17), "D", 2))
92 pinmerge(pinouts, pwm(bankspec, "0", ('D', 21), "D", mux=1))
93 pinmerge(pinouts, pwm(bankspec, "1", ('D', 22), "D", mux=1))
94 pinmerge(pinouts, pwm(bankspec, "2", ('D', 23), "D", mux=1))
95 pinmerge(pinouts, i2c(bankspec, "1", ('D', 10), "D", 3))
96 pinmerge(pinouts, i2c(bankspec, "3", ('D', 19), "D", 2))
97 pinmerge(pinouts, uartfull(bankspec, "0", ('D', 0), "D", 2))
98 pinmerge(pinouts, uart(bankspec, "3", ('D', 21), "D", 2))
99 pinmerge(pinouts, uart(bankspec, "4", ('D', 13), "D", 2))
100 pinmerge(pinouts, eint(bankspec, "", ('D', 19), "D", 18, 4, mux=3))
101 pinmerge(pinouts, eint(bankspec, "", ('D', 23), "D", 9, 1, mux=3))
102 pinmerge(pinouts, eint(bankspec, "", ('D', 13), "D", 5, 4, mux=3))
103 pinmerge(pinouts, eint(bankspec, "", ('D', 0), "D", 30, 2, mux=3))
104 pinmerge(pinouts, i2c(bankspec, "2", ('D', 2), "D", 3))
105 pinmerge(pinouts, sdmmc(bankspec, "2", ('D', 4), "D", 2))
106
107 # Bank E
108 pinmerge(pinouts, gpio(bankspec, "", ('E', 0), "E", 0, 24, 0))
109 pinmerge(pinouts, flexbus2(bankspec, "0", ('E', 0), "E", 1))
110 pinmerge(pinouts, sdmmc(bankspec, "2", ('E', 0), "E", 2))
111 pinmerge(pinouts, sdmmc(bankspec, "3", ('E', 8), "E", 2))
112 pinmerge(pinouts, quadspi(bankspec, "0", ('E', 18), "E", 2))
113 pinmerge(pinouts, uartfull(bankspec, "1", ('E', 14), "E", 2))
114 pinmerge(pinouts, i2c(bankspec, "2", ('E', 6), "E", 2))
115 pinmerge(pinouts, eint(bankspec, "", ('E', 0), "E", 10, 8, mux=3))
116 pinmerge(pinouts, eint(bankspec, "", ('E', 8), "E", 22, 6, mux=3))
117 pinmerge(pinouts, emmc(bankspec, "", ('E', 14), "E", 3))
118
119 # Bank F
120 pinmerge(pinouts, gpio(bankspec, "", ('F', 0), "F", 0, 10, 0))
121 pinmerge(pinouts, i2s(bankspec, "", ('F', 0), "F", 1))
122 pinmerge(pinouts, i2c(bankspec, "1", ('F', 6), "F", 2))
123 pinmerge(pinouts, pwm(bankspec, "0", ('F', 8), "F", mux=2))
124 pinmerge(pinouts, pwm(bankspec, "1", ('F', 9), "F", mux=2))
125 pinmerge(pinouts, uart(bankspec, "4", ('F', 8), "F", 1))
126 pinmerge(pinouts, sdmmc(bankspec, "3", ('F', 0), "F", 2))
127 pinmerge(pinouts, eint(bankspec, "", ('F', 0), "F", 18, 4, mux=3))
128 pinmerge(pinouts, pwm(bankspec, "2", ('F', 4), "F", mux=3))
129 pinmerge(pinouts, eint(bankspec, "", ('F', 5), "F", 7, 1, mux=3))
130 pinmerge(pinouts, eint(bankspec, "", ('F', 6), "F", 28, 4, mux=3))
131
132 # Bank G
133 pinmerge(pinouts, gpio(bankspec, "", ('G', 0), "G", 0, 32, 0))
134 pinmerge(pinouts, rgmii(bankspec, "", ('G', 0), "G", 1))
135 pinmerge(pinouts, ulpi(bankspec, "3", ('G', 20), "G", 1))
136 pinmerge(pinouts, rgbttl(bankspec, "1", ('G', 0), "G", 2))
137 pinmerge(pinouts, quadspi(bankspec, "0", ('G', 26), "G", 3))
138 pinmerge(pinouts, flexbus2(bankspec, "0", ('G', 0), "G", 3))
139 mmc2 = sdmmc(bankspec, "2", ('G', 24), "G", 3, limit=2)
140 pinmerge(pinouts, mmc2)
141 mmc2 = sdmmc(bankspec, "2", ('G', 28), "G", 2, start=2)
142 pinmerge(pinouts, mmc2)
143
144 print "# Pinouts (PinMux)"
145 print
146 print "auto-generated by [[pinouts.py]]"
147 print
148 print "[[!toc ]]"
149 print
150 print pinouts.keys()
151 display(pinouts)
152 print
153
154 print "# Pinouts (Fixed function)"
155 print
156
157 fixedpins = {
158 'DDR3':
159 ['SDQ0', 'SDQ1', 'SDQ2', 'SDQ3', 'SDQ4', 'SDQ5', 'SDQ6', 'SDQ7',
160 'SDQ8', 'SDQ9', 'SDQ10', 'SDQ11', 'SDQ12', 'SDQ13', 'SDQ14', 'SDQ15',
161 'SDQ16', 'SDQ17', 'SDQ18', 'SDQ19', 'SDQ20', 'SDQ21', 'SDQ22', 'SDQ23',
162 'SDQ24', 'SDQ25', 'SDQ26', 'SDQ27', 'SDQ28', 'SDQ29', 'SDQ30', 'SDQ31',
163 'SVREF0', 'SVREF1', 'SVREF2', 'SVREF3',
164 'SDQS0', 'SDQS0#', 'SDQS1', 'SDQS1#',
165 'SDQS2', 'SDQS2#', 'SDQS3', 'SDQS3#',
166 'SDQM0', 'SDQM1', 'SDQM2', 'SDQM3',
167 'SCK#', 'SCK', 'SCKE0', 'SCKE1',
168 'SA0', 'SA1', 'SA2', 'SA3', 'SA4', 'SA5', 'SA6', 'SA7',
169 'SA8', 'SA9', 'SA10', 'SA11', 'SA12', 'SA13', 'SA14',
170 'SBA0', 'SBA1', 'SBA2',
171 'SWE', 'SCAS', 'SRAS',
172 'SCS0', 'SCS1',
173 'SZQ', 'SRST',
174 'SDBG0', 'SDBG1', 'ADBG',
175 'ODT0', 'ODT1'
176 ],
177
178 'CTRL_SYS':
179 [
180 'TEST', 'JTAG_SEL', 'UBOOT_SEL',
181 'NMI#', 'RESET#',
182 'CLK24M_IN', 'CLK24M_OUT',
183 'PLLTEST', 'PLLREGIO', 'PLLVP25',
184 'PLLDV', 'PLLVREG', 'PLLGND',
185 ],
186
187 'POWER_DRAM':
188 ['VCC0_DRAM', 'VCC1_DRAM', 'VCC2_DRAM', 'VCC3_DRAM', 'VCC4_DRAM',
189 'VCC5_DRAM', 'VCC6_DRAM', 'VCC7_DRAM', 'VCC8_DRAM', 'VCC9_DRAM',
190 'GND0_DRAM', 'GND1_DRAM', 'GND2_DRAM', 'GND3_DRAM', 'GND4_DRAM',
191 'GND5_DRAM', 'GND6_DRAM', 'GND7_DRAM', 'GND8_DRAM', 'GND9_DRAM',
192 ],
193
194 'POWER_CPU':
195 ['VDD0_CPU', 'VDD1_CPU', 'VDD2_CPU', 'VDD3_CPU', 'VDD4_CPU', 'VDD5_CPU',
196 'GND0_CPU', 'GND1_CPU', 'GND2_CPU', 'GND3_CPU', 'GND4_CPU', 'GND5_CPU',
197 ],
198
199 'POWER_DLL':
200 ['VDD0_DLL', 'VDD1_DLL', 'VDD2_DLL',
201 'GND0_DLL', 'GND1_DLL', 'GND2_DLL',
202 ],
203
204 'POWER_INT':
205 ['VDD0_INT', 'VDD1_INT', 'VDD2_INT', 'VDD3_INT', 'VDD4_INT',
206 'VDD5_INT', 'VDD6_INT', 'VDD7_INT', 'VDD8_INT', 'VDD9_INT',
207 'GND0_INT', 'GND1_INT', 'GND2_INT', 'GND3_INT', 'GND4_INT',
208 'GND5_INT', 'GND6_INT', 'GND7_INT', 'GND8_INT', 'GND9_INT',
209 ],
210
211 'POWER_GPIO':
212 ['VDD_GPIOA', 'VDD_GPIOB', 'VDD_GPIOC',
213 'VDD_GPIOD', 'VDD_GPIOE', 'VDD_GPIOF',
214 'VDD_GPIOG',
215 'GND_GPIOA', 'GND_GPIOB', 'GND_GPIOC',
216 'GND_GPIOD', 'GND_GPIOE', 'GND_GPIOF',
217 'GND_GPIOG',
218 ]
219
220 }
221
222 display_fixed(fixedpins, len(pinouts))
223
224 print "# Functions (PinMux)"
225 print
226 print "auto-generated by [[pinouts.py]]"
227 print
228
229 function_names = {'EINT': 'External Interrupt',
230 'FB': 'MC68k FlexBus',
231 'IIS': 'I2S Audio',
232 'JTAG1': 'JTAG (same as JTAG2, JTAG_SEL=LOW)',
233 'JTAG2': 'JTAG (same as JTAG1, JTAG_SEL=HIGH)',
234 'LCD': '24-pin RGB/TTL LCD',
235 'RG': 'RGMII Ethernet',
236 'MMC': 'eMMC 1/2/4/8 pin',
237 'PWM': 'PWM (pulse-width modulation)',
238 'SD1': 'SD/MMC 1',
239 'SD2': 'SD/MMC 2',
240 'SD3': 'SD/MMC 3',
241 'SPI1': 'SPI (Serial Peripheral Interface) 1',
242 'SPI2': 'SPI (Serial Peripheral Interface) 2',
243 'QSPI': 'Quad SPI (Serial Peripheral Interface) 1',
244 'TWI1': 'I2C 1',
245 'TWI2': 'I2C 2',
246 'TWI3': 'I2C 3',
247 'UARTQ0': 'UART (TX/RX/CTS/RTS) 0',
248 'UARTQ1': 'UART (TX/RX/CTS/RTS) 1',
249 'UART2': 'UART (TX/RX) 2',
250 'UART3': 'UART (TX/RX) 3',
251 'UART4': 'UART (TX/RX) 4',
252 'ULPI1': 'ULPI (USB Low Pin-count) 1',
253 'ULPI2': 'ULPI (USB Low Pin-count) 2',
254 'ULPI3': 'ULPI (USB Low Pin-count) 3',
255 }
256
257 fns = display_fns(bankspec, pinouts, function_names)
258 print
259
260 # Scenarios below can be spec'd out as either "find first interface"
261 # by name/number e.g. SPI1, or as "find in bank/mux" which must be
262 # spec'd as "BM:Name" where B is bank (A-F), M is Mux (0-3)
263 # EINT and PWM are grouped together, specially, but may still be spec'd
264 # using "BM:Name". Pins are removed in-order as listed from
265 # lists (interfaces, EINTs, PWMs) from available pins.
266
267 # EOMA68 scenario. not totally complete (some GPIO needed for PMIC)
268 # One interface to be connected to the MCU to give RTC and boot/dbg
269 # VBUS_EN, OTG_ID etc. are all not included below, there is plenty
270 # of spare GPIO.
271
272 eoma68 = ['B1:LCD/22', 'ULPI1/8', 'ULPI2', 'MMC', 'SD1', 'UART3',
273 'TWI3', 'SPI2', 'E2:SD2', ]
274 eoma68_eint = ['EINT_16', 'EINT_17', 'EINT_18', 'EINT_19']
275 eoma68_pwm = ['D1:PWM_2']
276 descriptions = {
277 'MMC': 'internal (on Card)',
278 'SD1': 'user-facing: internal (on Card), multiplexed with JTAG1\n'
279 'and UART2, for debug purposes',
280 'TWI3': 'EOMA68-compliance: must be entirely free of devices.\n'
281 'Address 0x51 used (externally) for EOMA68 EEPROM Id',
282 'E2:SD2': 'EOMA68-compliance',
283 'SPI2': 'EOMA68-compliance',
284 'UART3': 'EOMA68-compliance',
285 'B1:LCD/22': 'EOMA68-compliance, 18-bit RGB/TTL LCD',
286 'ULPI1/8': 'user-facing: internal (on Card), USB-OTG ULPI PHY',
287 'ULPI2': 'EOMA68-compliance: dual USB2 Host ULPI PHY'
288 }
289
290 unused_pins = check_functions("EOMA68", bankspec, fns, pinouts,
291 eoma68, eoma68_eint, eoma68_pwm,
292 descriptions)
293
294 # Industrial scenario. not totally complete (some GPIO needed for PMIC)
295 # One interface to be connected to the MCU to give RTC, boot/dbg,
296 # option of CAN Bus, ADC, DAC, OWB, more GPIO, more PWM etc. etc.
297 # Focus is on getting as many UARTs, SPIs and TWIs as possible.
298 # OTG_ID (if to be used) would require dropping some functions in order
299 # to free up GPIO. LCD could be reduced to 15-bit (freeing 3).
300 # MMC could be reduced to 4-bit-wide, used as SD/MMC (freeing 4).
301 # QSPI could be used in 1-bit (MOSI/MISO) mode (freeing up 2 more).
302
303 industrial = ['D1:FB/17', 'E1:FB/8', 'B1:LCD/22', 'ULPI1/8', 'ULPI2/8',
304 'MMC', 'B2:SD1',
305 'JTAG1', 'A3:UART2', 'E2:UART1', 'C3:UART0',
306 'F2:TWI1', 'D2:TWI2', 'D2:TWI3', 'SPI2', 'QSPI', 'F2:SD3']
307 industrial_pwm = ['F2:PWM_0', 'F2:PWM_1', 'D1:PWM_2']
308 industrial_eint = ['EINT_24', 'EINT_25', 'EINT_26', 'EINT_27',
309 'EINT_20', 'EINT_21', 'EINT_22', 'EINT_23']
310
311 unused_pins = check_functions("Industrial", bankspec, fns, pinouts,
312 industrial, industrial_eint, industrial_pwm)
313
314 # Industrial scenario, using an SPI-based LCD instead of RGB/TTL
315 # not totally complete (some GPIO needed for PMIC)
316 # One interface to be connected to the MCU to give RTC, boot/dbg,
317 # option of CAN Bus, ADC, DAC, OWB, more GPIO, more PWM etc. etc.
318 # Focus is on getting as many UARTs, SPIs and TWIs as possible,
319 # leaving some GPIO spare from the RGB/TTL bank (SPI CS#)
320 # also possibility of freeing up FlexBus CS# with a little reorg.
321
322 industrial = ['D1:FB/17', 'E1:FB/8', 'B2:SPI1', 'ULPI1/8', 'ULPI2/8',
323 'MMC', 'B2:SD1',
324 'JTAG1',
325 'A3:UART2', 'E2:UART1', 'C3:UART0', 'B2:UART4', 'B2:UART3',
326 'F2:TWI1', 'D2:TWI2', 'D2:TWI3', 'SPI2', 'QSPI', 'F2:SD3']
327 industrial_pwm = ['F2:PWM_0', 'F2:PWM_1', 'D1:PWM_2']
328 industrial_eint = ['EINT_24', 'EINT_25', 'EINT_26', 'EINT_27',
329 'EINT_20', 'EINT_21', 'EINT_22', 'EINT_23']
330 ind_descriptions = {
331 'B2:SPI1': 'Used for 320x240 or 640x480 etc. SPI-based LCD.\n'
332 'Frees up large numbers of GPIO from RGB/TTL bank'
333 }
334 unused_pins = check_functions("Industrial with SPI-LCD",
335 bankspec, fns, pinouts,
336 industrial, industrial_eint, industrial_pwm,
337 ind_descriptions)
338
339 # Smartphone / Tablet - basically the same thing
340
341 tablet = ['B1:LCD/22', 'ULPI1/8', 'ULPI2/8',
342 'MMC', 'SD1',
343 'F1:IIS', # I2C Audio
344 'TWI2', # I2C Audio
345 'E2:UART1', # WIFI/BT
346 'E2:SD2', # WIFI
347 'C3:UART0', # GPS
348 'D2:UART3',
349 'D2:UART4',
350 'D3:TWI1', 'D2:TWI3', 'SPI2', 'QSPI']
351 tablet_pwm = ['F2:PWM_0', # LCD_BACKLIGHT
352 'F2:PWM_1', 'D1:PWM_2']
353 tablet_eint = ['EINT_24', # BT_HOST_WAKE
354 'EINT_25', # WIFI_HOST_WAKE
355 'EINT_26', # CTP_INT
356 'EINT_27', # GSENSOR_INT
357 'EINT_8', # GPS_INT
358 'EINT_7', # TILT_SENSOR_INT
359 'EINT_22', # COMPASS_INT
360 'EINT_23', # MCU_INT
361 'EINT_16', # PMIC_INT
362 'EINT_17', # PWR_BUTTON_INT
363 'EINT_30', # OTG_ID
364 'EINT_31',
365 ]
366 descriptions = {
367 'B1:LCD/22':
368 'RGB/TTL LCD, 800x480 or use SN75LVDS83b for up to 1440x900',
369 'MMC': 'eMMC: main internal storage',
370 'ULPI1/8': 'USB-OTG, connect to ULPI OTG PHY (for charging)\n'
371 'as well as USB Host or USB Device',
372 'ULPI2/8': 'USB2 Host, connect to ULPI PHY w/and 4-port USB2 Hub\n'
373 'for example GL850G or FE1.1. '
374 'Connects to 2/3/4G/LTE Modem, 2x USB-Camera (VC0345)',
375 'SD1': 'internal, multiplexed with JTAG1\n'
376 'and UART2, for debug purposes',
377 'F1:IIS': 'I2C Audio, connect to AC97 Audio IC',
378 'TWI2': 'Connect to AC97 Audio IC',
379 'E2:UART1': 'Connect to BT on AP6234/AP6335',
380 'E2:SD2': 'Connect to WIFI on AP6234/AP6335',
381 'QSPI': 'Boot Storage (connection to companion / debug / boot MCU)\n'
382 'Only actually needs MISO/MOSI, bootstrap loader v. small\n'
383 'Bootstrap loader checks eMMC, USB-OTG, SD/MMC, SPI, etc.',
384 'SPI2': 'Spare? SPI, connect to higher-speed sensor?',
385 'D2:UART3': 'Spare? UART (or 2 extra GPIO / EINT)',
386 'D2:UART4': 'Spare? UART (or 2 extra GPIO)',
387 'D3:TWI1': 'Connect to PMIC',
388 'D2:TWI3': 'Connect to sensors (Trackpad? CTP GSENSOR TILT COMPASS)',
389 'GPIO': '9 spare GPIO pins for miscellaneous functions:\n'
390 'wake-up of BT, WIFI, LCD power, sensor power etc.\n'
391 '4 GPIO may be needed for PWM Audio from Modem.\n'
392 'LED lights for camera will be needed.\n'
393 'Some phones may have clam-shell or lid switch.\n'
394 'Some Modems have spare GPIO (over AT commandset).\n'
395 'AXP209 PMIC has 4x GPIO, accessible over I2C.\n'
396 'SPI2, UART3-4, PWM1-2 may also be spare (10 extra GPIO).\n'
397 'If more needed, companion MCU may be used (48+ pin variant)\n'
398 'which also includes ADC, DAC, more PWM etc.',
399 'F2:PWM_0': 'LCD Backlight',
400 'F2:PWM_1': 'Spare? PWM (or extra GPIO / EINT)',
401 'D1:PWM_2': 'Spare? PWM (or extra GPIO / EINT)',
402 'EINT_24': 'BT_HOST_WAKE',
403 'EINT_25': 'WIFI_HOST_WAKE',
404 'EINT_26': 'CTP_INT',
405 'EINT_27': 'GSENSOR_INT',
406 'EINT_8': 'GPS_INT',
407 'EINT_7': 'TILT_SENSOR_INT',
408 'EINT_22': 'COMPASS_INT',
409 'EINT_23': 'MCU_INT',
410 'EINT_16': 'PMIC_INT',
411 'EINT_17': 'PWR_BUTTON_INT',
412 'EINT_30': 'OTG_ID',
413 'EINT_31': 'Spare?',
414 }
415 unused_pins = check_functions("Smartphone / Tablet",
416 bankspec, fns, pinouts,
417 tablet, tablet_eint, tablet_pwm,
418 descriptions)
419
420 # Laptop
421
422 laptop = ['D1:FB/17', 'E1:FB/8', 'B1:LCD/22', 'ULPI1/8', 'ULPI2/8',
423 'MMC', 'SD1',
424 'F1:IIS', # I2C Audio
425 'TWI2', # I2C Audio
426 'E2:UART1', # WIFI/BT
427 'E2:SD3', # WIFI
428 'D2:TWI3', 'QSPI']
429 laptop_pwm = ['F2:PWM_0', # LCD_BACKLIGHT
430 ]
431 laptop_eint = ['EINT_20', # BT_HOST_WAKE
432 'EINT_21', # WIFI_HOST_WAKE
433 'EINT_9', # MCU_INT
434 'EINT_31', # PMIC_INT
435 ]
436 descriptions = {
437 'D1:FB/17': 'FlexBus. Connect to DM9000 or AX99896A MCU-style Bus\n'
438 '10/100 Ethernet PHY.',
439 'E1:FB/8': 'FlexBus bus bits 8-15, needed to make a 16-bit bus width',
440 'B1:LCD/22':
441 'RGB/TTL LCD, use SN75LVDS83b for LVDS or SSD2828 for MIPI,\n'
442 'or a Chrontel CH7039, CH7038, CH7034 or CH7018 for dual\n'
443 'display output (eDP/LVDS and HDMI/VGA) '
444 'conversion.',
445 'MMC': 'eMMC: main internal storage',
446 'ULPI1/8': 'USB-OTG, connect to ULPI OTG PHY (for charging)\n'
447 'as well as USB Host or USB Device',
448 'ULPI2/8': 'USB2 Host, connect to ULPI PHY w/and 4-port USB2 Hub\n'
449 'for example GL850G or FE1.1. '
450 'Connects to USB-Camera (VC0345 and 3x external USB Ports)',
451 'SD1': 'internal, multiplexed with JTAG1\n'
452 'and UART2, for debug purposes',
453 'F1:IIS': 'I2C Audio, connect to AC97 Audio IC',
454 'TWI2': 'Connect to AC97 Audio IC',
455 'E2:UART1': 'Connect to BT on AP6234/AP6335',
456 'E2:SD3': 'Connect to WIFI on AP6234/AP6335',
457 'QSPI': 'Boot Storage (connection to companion / debug / boot MCU)\n'
458 'Only actually needs MISO/MOSI, bootstrap loader v. small\n'
459 'Bootstrap loader checks eMMC, USB-OTG, SD/MMC, SPI, etc.\n'
460 'MCU implements keyboard-matrix for keyboard (also trackpad?)',
461 'D2:TWI3': 'Connect to PMIC',
462 'GPIO': 'Plenty of spare GPIO pins for miscellaneous functions\n'
463 'MCU EINT-capable GPIO may be used to generate extra EINTs\n'
464 'on the single MCU_INT line, if really needed',
465 'F2:PWM_0': 'LCD Backlight',
466 'EINT_20': 'BT_HOST_WAKE',
467 'EINT_21': 'WIFI_HOST_WAKE',
468 'EINT_9': 'MCU_INT',
469 'EINT_31': 'PMIC_INT',
470 }
471 unused_pins = check_functions("Laptop / Netbook",
472 bankspec, fns, pinouts,
473 laptop, laptop_eint, laptop_pwm,
474 descriptions)
475
476 # IoT
477
478 iot = ['B1:LCD', 'ULPI2/8', 'ULPI1/8',
479 'MMC', 'SD1',
480 'F1:IIS', # I2C Audio
481 #'TWI2', # I2C Audio
482 'C3:UART0', # HSPA UART
483 'E2:UART1', # BT UART
484 'C2:SPI2', # HSPI SPI
485 'E2:SD3', # WIFI
486 'D3:TWI1', # sensors CTP,
487 'D2:TWI3', 'QSPI']
488 iot_pwm = ['F2:PWM_0', # LCD_BACKLIGHT
489 ]
490 iot_eint = ['EINT_5', # 'HSPA_MST_RDY',
491 'EINT_6', # 'HSPA_SL_RDY',
492 'EINT_7', # 'HSPA_RING',
493 'EINT_8', # 'WL_PMU_EN',
494 'EINT_9', # HSPA_GPIO1
495 'EINT_10', # IR_DT
496 'EINT_11', # 'BT_PCM_CLK',
497 'EINT_12', # 'BT_PCM_DIN',
498 'EINT_13', # 'BT_PCM_SYNC',
499 'EINT_14', # 'BT_PCM_DOUT',
500 'EINT_16', # 'USB_DRVVBUS',
501 'EINT_17', # 'USB_VBUSDET',
502 'EINT_21', # 'USB_ID',
503 'EINT_30', # 'CTP_INT',
504 'EINT_31', # 'SD_DET#',
505 ]
506 descriptions = {
507 'B1:LCD':
508 'RGB/TTL LCD, use SN75LVDS83b for LVDS or SSD2828 for MIPI,\n'
509 'or a Chrontel CH7039, CH7038, CH7034 or CH7018 for dual\n'
510 'display output (eDP/LVDS and HDMI/VGA) '
511 'conversion.',
512 'MMC': 'eMMC: main internal storage',
513 'F1:IIS': 'I2C Audio, connect to AC97 Audio IC',
514 'ULPI2/8': 'USB-OTG, connect to ULPI OTG PHY (for charging)\n'
515 'as well as USB Host or USB Device',
516 'ULPI1/8': 'USB2 Host, connect to ULPI PHY',
517 'SD1': 'internal, multiplexed with JTAG1\n'
518 'and UART2, for debug purposes',
519 'C3:UART0': 'Connect to HSPA UART',
520 'E2:UART1': 'Connect to BT UART',
521 'E2:SD3': 'Connect to WIFI',
522 'C2:SPI2': 'HSPA SPI',
523 'QSPI': 'Boot Storage (connection to companion / debug / boot MCU)\n'
524 'Only actually needs MISO/MOSI, bootstrap loader v. small\n'
525 'Bootstrap loader checks eMMC, USB-OTG, SD/MMC, SPI, etc.\n'
526 'MCU implements keyboard-matrix for keyboard (also trackpad?)',
527 'D2:TWI3': 'Connect to PMIC',
528 'D3:TWI1': 'Connect to sensors CTP',
529 'GPIO': 'Plenty of spare GPIO pins for miscellaneous functions\n'
530 'MCU EINT-capable GPIO may be used to generate extra EINTs\n'
531 'on the single MCU_INT line, if really needed',
532 'F2:PWM_0': 'LCD Backlight',
533 'GPIOD4': 'WL_WAKE_AP',
534 'GPIOD5': 'BT_WAKE_AP',
535 'GPIOD6': 'AP_WAKE_BT',
536 'GPIOD7': 'AP_CK32KO',
537 'GPIOD8': 'HSPA_PWRON',
538 'GPIOD9': 'BT_RST_N',
539 'GPIOE5': 'HSPA_ON_OFF',
540 'GPIOD2': 'HSPA_SHUTDOWN',
541 'GPIOD3': 'CTP_RST',
542 'GPIOD12': 'LCD_RDN',
543 'GPIOD17': 'LCD_WRN',
544 'GPIOD18': 'LCD_RS',
545 'GPIOD21': 'LCD_CSN',
546
547 'EINT_5': 'HSPA_MST_RDY',
548 'EINT_6': 'HSPA_SL_RDY',
549 'EINT_7': 'HSPA_RING',
550 'EINT_8': 'WL_PMU_EN',
551 'EINT_9': 'HSPA_GPIO1',
552 'EINT_10': 'IR_DT',
553 'EINT_11': 'BT_PCM_CLK',
554 'EINT_12': 'BT_PCM_DIN',
555 'EINT_13': 'BT_PCM_SYNC',
556 'EINT_14': 'BT_PCM_DOUT',
557
558 'EINT_16': 'USB_DRVVBUS',
559 'EINT_17': 'USB_VBUSDET',
560 'EINT_21': 'USB_ID',
561 'EINT_30': 'CTP_INT',
562 'EINT_31': 'SD_DETN',
563 }
564 unused_pins = check_functions("IoT",
565 bankspec, fns, pinouts,
566 iot, iot_eint, iot_pwm,
567 descriptions)
568
569 print "# Reference Datasheets"
570 print
571 print "datasheets and pinout links"
572 print
573 print "* <http://datasheets.chipdb.org/AMD/8018x/80186/amd-80186.pdf>"
574 print "* <http://hands.com/~lkcl/eoma/shenzen/frida/FRD144A2701.pdf>"
575 print "* <http://pinouts.ru/Memory/sdcard_pinout.shtml>"
576 print "* p8 <http://www.onfi.org/~/media/onfi/specs/onfi_2_0_gold.pdf?la=en>"
577 print "* <https://www.heyrick.co.uk/blog/files/datasheets/dm9000aep.pdf>"
578 print "* <http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4393.pdf>"
579 print "* <https://www.nxp.com/docs/en/data-sheet/MCF54418.pdf>"
580 print "* ULPI OTG PHY, ST <http://www.st.com/en/interfaces-and-transceivers/stulpi01a.html>"
581 print "* ULPI OTG PHY, TI TUSB1210 <http://ti.com/product/TUSB1210/>"
582
583 return pinouts, bankspec, fixedpins