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