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