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