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