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