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