• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * linux/arch/arm/mach-pxa/mxm8x10.c
4  *
5  * Support for the Embedian MXM-8x10 Computer on Module
6  *
7  * Copyright (C) 2006 Marvell International Ltd.
8  * Copyright (C) 2009 Embedian Inc.
9  * Copyright (C) 2009 TMT Services & Supplies (Pty) Ltd.
10  *
11  * 2007-09-04: eric miao <eric.y.miao@gmail.com>
12  *             rewrite to align with latest kernel
13  *
14  * 2010-01-09: Edwin Peer <epeer@tmtservices.co.za>
15  * 	       Hennie van der Merwe <hvdmerwe@tmtservices.co.za>
16  *             rework for upstream merge
17  */
18 
19 #include <linux/serial_8250.h>
20 #include <linux/dm9000.h>
21 #include <linux/gpio/machine.h>
22 #include <linux/platform_data/i2c-pxa.h>
23 
24 #include <linux/platform_data/mtd-nand-pxa3xx.h>
25 
26 #include <linux/platform_data/video-pxafb.h>
27 #include <linux/platform_data/mmc-pxamci.h>
28 #include <linux/platform_data/usb-ohci-pxa27x.h>
29 #include "pxa320.h"
30 
31 #include "mxm8x10.h"
32 
33 #include "devices.h"
34 #include "generic.h"
35 
36 /* GPIO pin definition
37 
38 External device stuff   - Leave unconfigured for now...
39 ---------------------
40 GPIO0   -   DREQ    (External DMA Request)
41 GPIO3   -   nGCS2   (External Chip Select) Where is nGCS0; nGCS1; nGCS4; nGCS5 ?
42 GPIO4   -   nGCS3
43 GPIO15  -   EXT_GPIO1
44 GPIO16  -   EXT_GPIO2
45 GPIO17  -   EXT_GPIO3
46 GPIO24  -   EXT_GPIO4
47 GPIO25  -   EXT_GPIO5
48 GPIO26  -   EXT_GPIO6
49 GPIO27  -   EXT_GPIO7
50 GPIO28  -   EXT_GPIO8
51 GPIO29  -   EXT_GPIO9
52 GPIO30  -   EXT_GPIO10
53 GPIO31  -   EXT_GPIO11
54 GPIO57  -   EXT_GPIO12
55 GPIO74  -   EXT_IRQ1
56 GPIO75  -   EXT_IRQ2
57 GPIO76  -   EXT_IRQ3
58 GPIO77  -   EXT_IRQ4
59 GPIO78  -   EXT_IRQ5
60 GPIO79  -   EXT_IRQ6
61 GPIO80  -   EXT_IRQ7
62 GPIO81  -   EXT_IRQ8
63 GPIO87  -   VCCIO_PWREN (External Device PWREN)
64 
65 Dallas 1-Wire   - Leave unconfigured for now...
66 -------------
67 GPIO0_2 -   DS - 1Wire
68 
69 Ethernet
70 --------
71 GPIO1   -   DM9000 PWR
72 GPIO9   -   DM9K_nIRQ
73 GPIO36  -   DM9K_RESET
74 
75 Keypad  - Leave unconfigured by for now...
76 ------
77 GPIO1_2 -   KP_DKIN0
78 GPIO5_2 -   KP_MKOUT7
79 GPIO82  -   KP_DKIN1
80 GPIO85  -   KP_DKIN2
81 GPIO86  -   KP_DKIN3
82 GPIO113 -   KP_MKIN0
83 GPIO114 -   KP_MKIN1
84 GPIO115 -   KP_MKIN2
85 GPIO116 -   KP_MKIN3
86 GPIO117 -   KP_MKIN4
87 GPIO118 -   KP_MKIN5
88 GPIO119 -   KP_MKIN6
89 GPIO120 -   KP_MKIN7
90 GPIO121 -   KP_MKOUT0
91 GPIO122 -   KP_MKOUT1
92 GPIO122 -   KP_MKOUT2
93 GPIO123 -   KP_MKOUT3
94 GPIO124 -   KP_MKOUT4
95 GPIO125 -   KP_MKOUT5
96 GPIO127 -   KP_MKOUT6
97 
98 Data Bus    - Leave unconfigured for now...
99 --------
100 GPIO2   -   nWait (Data Bus)
101 
102 USB Device
103 ----------
104 GPIO4_2 -   USBD_PULLUP
105 GPIO10  -   UTM_CLK (USB Device UTM Clk)
106 GPIO49  -   USB 2.0 Device UTM_DATA0
107 GPIO50  -   USB 2.0 Device UTM_DATA1
108 GPIO51  -   USB 2.0 Device UTM_DATA2
109 GPIO52  -   USB 2.0 Device UTM_DATA3
110 GPIO53  -   USB 2.0 Device UTM_DATA4
111 GPIO54  -   USB 2.0 Device UTM_DATA5
112 GPIO55  -   USB 2.0 Device UTM_DATA6
113 GPIO56  -   USB 2.0 Device UTM_DATA7
114 GPIO58  -   UTM_RXVALID (USB 2.0 Device)
115 GPIO59  -   UTM_RXACTIVE (USB 2.0 Device)
116 GPIO60  -   UTM_RXERROR
117 GPIO61  -   UTM_OPMODE0
118 GPIO62  -   UTM_OPMODE1
119 GPIO71  -   USBD_INT    (USB Device?)
120 GPIO73  -   UTM_TXREADY (USB 2.0 Device)
121 GPIO83  -   UTM_TXVALID (USB 2.0 Device)
122 GPIO98  -   UTM_RESET   (USB 2.0 device)
123 GPIO99  -   UTM_XCVR_SELECT
124 GPIO100 -   UTM_TERM_SELECT
125 GPIO101 -   UTM_SUSPENDM_X
126 GPIO102 -   UTM_LINESTATE0
127 GPIO103 -   UTM_LINESTATE1
128 
129 Card-Bus Interface  - Leave unconfigured for now...
130 ------------------
131 GPIO5   -   nPIOR (I/O space output enable)
132 GPIO6   -   nPIOW (I/O space write enable)
133 GPIO7   -   nIOS16 (Input from I/O space telling size of data bus)
134 GPIO8   -   nPWAIT (Input for inserting wait states)
135 
136 LCD
137 ---
138 GPIO6_2     -   LDD0
139 GPIO7_2     -   LDD1
140 GPIO8_2     -   LDD2
141 GPIO9_2     -   LDD3
142 GPIO11_2    -   LDD5
143 GPIO12_2    -   LDD6
144 GPIO13_2    -   LDD7
145 GPIO14_2    -   VSYNC
146 GPIO15_2    -   HSYNC
147 GPIO16_2    -   VCLK
148 GPIO17_2    -   HCLK
149 GPIO18_2    -   VDEN
150 GPIO63      -   LDD8    (CPU LCD)
151 GPIO64      -   LDD9    (CPU LCD)
152 GPIO65      -   LDD10   (CPU LCD)
153 GPIO66      -   LDD11   (CPU LCD)
154 GPIO67      -   LDD12   (CPU LCD)
155 GPIO68      -   LDD13   (CPU LCD)
156 GPIO69      -   LDD14   (CPU LCD)
157 GPIO70      -   LDD15   (CPU LCD)
158 GPIO88      -   VCCLCD_PWREN (LCD Panel PWREN)
159 GPIO97      -   BACKLIGHT_EN
160 GPIO104     -   LCD_PWREN
161 
162 PWM   - Leave unconfigured for now...
163 ---
164 GPIO11  -   PWM0
165 GPIO12  -   PWM1
166 GPIO13  -   PWM2
167 GPIO14  -   PWM3
168 
169 SD-CARD
170 -------
171 GPIO18  -   SDDATA0
172 GPIO19  -   SDDATA1
173 GPIO20  -   SDDATA2
174 GPIO21  -   SDDATA3
175 GPIO22  -   SDCLK
176 GPIO23  -   SDCMD
177 GPIO72  -   SD_WP
178 GPIO84  -   SD_nIRQ_CD  (SD-Card)
179 
180 I2C
181 ---
182 GPIO32  -   I2CSCL
183 GPIO33  -   I2CSDA
184 
185 AC97
186 ----
187 GPIO35  -   AC97_SDATA_IN
188 GPIO37  -   AC97_SDATA_OUT
189 GPIO38  -   AC97_SYNC
190 GPIO39  -   AC97_BITCLK
191 GPIO40  -   AC97_nRESET
192 
193 UART1
194 -----
195 GPIO41  -   UART_RXD1
196 GPIO42  -   UART_TXD1
197 GPIO43  -   UART_CTS1
198 GPIO44  -   UART_DCD1
199 GPIO45  -   UART_DSR1
200 GPIO46  -   UART_nRI1
201 GPIO47  -   UART_DTR1
202 GPIO48  -   UART_RTS1
203 
204 UART2
205 -----
206 GPIO109 -   RTS2
207 GPIO110 -   RXD2
208 GPIO111 -   TXD2
209 GPIO112 -   nCTS2
210 
211 UART3
212 -----
213 GPIO105 -   nCTS3
214 GPIO106 -   nRTS3
215 GPIO107 -   TXD3
216 GPIO108 -   RXD3
217 
218 SSP3    - Leave unconfigured for now...
219 ----
220 GPIO89  -   SSP3_CLK
221 GPIO90  -   SSP3_SFRM
222 GPIO91  -   SSP3_TXD
223 GPIO92  -   SSP3_RXD
224 
225 SSP4
226 GPIO93  -   SSP4_CLK
227 GPIO94  -   SSP4_SFRM
228 GPIO95  -   SSP4_TXD
229 GPIO96  -   SSP4_RXD
230 */
231 
232 static mfp_cfg_t mfp_cfg[] __initdata = {
233 	/* USB */
234 	GPIO10_UTM_CLK,
235 	GPIO49_U2D_PHYDATA_0,
236 	GPIO50_U2D_PHYDATA_1,
237 	GPIO51_U2D_PHYDATA_2,
238 	GPIO52_U2D_PHYDATA_3,
239 	GPIO53_U2D_PHYDATA_4,
240 	GPIO54_U2D_PHYDATA_5,
241 	GPIO55_U2D_PHYDATA_6,
242 	GPIO56_U2D_PHYDATA_7,
243 	GPIO58_UTM_RXVALID,
244 	GPIO59_UTM_RXACTIVE,
245 	GPIO60_U2D_RXERROR,
246 	GPIO61_U2D_OPMODE0,
247 	GPIO62_U2D_OPMODE1,
248 	GPIO71_GPIO, /* USBD_INT */
249 	GPIO73_UTM_TXREADY,
250 	GPIO83_U2D_TXVALID,
251 	GPIO98_U2D_RESET,
252 	GPIO99_U2D_XCVR_SEL,
253 	GPIO100_U2D_TERM_SEL,
254 	GPIO101_U2D_SUSPEND,
255 	GPIO102_UTM_LINESTATE_0,
256 	GPIO103_UTM_LINESTATE_1,
257 	GPIO4_2_GPIO | MFP_PULL_HIGH, /* UTM_PULLUP */
258 
259 	/* DM9000 */
260 	GPIO1_GPIO,
261 	GPIO9_GPIO,
262 	GPIO36_GPIO,
263 
264 	/* AC97 */
265 	GPIO35_AC97_SDATA_IN_0,
266 	GPIO37_AC97_SDATA_OUT,
267 	GPIO38_AC97_SYNC,
268 	GPIO39_AC97_BITCLK,
269 	GPIO40_AC97_nACRESET,
270 
271 	/* UARTS */
272 	GPIO41_UART1_RXD,
273 	GPIO42_UART1_TXD,
274 	GPIO43_UART1_CTS,
275 	GPIO44_UART1_DCD,
276 	GPIO45_UART1_DSR,
277 	GPIO46_UART1_RI,
278 	GPIO47_UART1_DTR,
279 	GPIO48_UART1_RTS,
280 
281 	GPIO109_UART2_RTS,
282 	GPIO110_UART2_RXD,
283 	GPIO111_UART2_TXD,
284 	GPIO112_UART2_CTS,
285 
286 	GPIO105_UART3_CTS,
287 	GPIO106_UART3_RTS,
288 	GPIO107_UART3_TXD,
289 	GPIO108_UART3_RXD,
290 
291 	GPIO78_GPIO,
292 	GPIO79_GPIO,
293 	GPIO80_GPIO,
294 	GPIO81_GPIO,
295 
296 	/* I2C */
297 	GPIO32_I2C_SCL,
298 	GPIO33_I2C_SDA,
299 
300 	/* MMC */
301 	GPIO18_MMC1_DAT0,
302 	GPIO19_MMC1_DAT1,
303 	GPIO20_MMC1_DAT2,
304 	GPIO21_MMC1_DAT3,
305 	GPIO22_MMC1_CLK,
306 	GPIO23_MMC1_CMD,
307 	GPIO72_GPIO | MFP_PULL_HIGH, /* Card Detect */
308 	GPIO84_GPIO | MFP_PULL_LOW, /* Write Protect */
309 
310 	/* IRQ */
311 	GPIO74_GPIO | MFP_LPM_EDGE_RISE, /* EXT_IRQ1 */
312 	GPIO75_GPIO | MFP_LPM_EDGE_RISE, /* EXT_IRQ2 */
313 	GPIO76_GPIO | MFP_LPM_EDGE_RISE, /* EXT_IRQ3 */
314 	GPIO77_GPIO | MFP_LPM_EDGE_RISE, /* EXT_IRQ4 */
315 	GPIO78_GPIO | MFP_LPM_EDGE_RISE, /* EXT_IRQ5 */
316 	GPIO79_GPIO | MFP_LPM_EDGE_RISE, /* EXT_IRQ6 */
317 	GPIO80_GPIO | MFP_LPM_EDGE_RISE, /* EXT_IRQ7 */
318 	GPIO81_GPIO | MFP_LPM_EDGE_RISE  /* EXT_IRQ8 */
319 };
320 
321 /* MMC/MCI Support */
322 #if defined(CONFIG_MMC)
323 static struct pxamci_platform_data mxm_8x10_mci_platform_data = {
324 	.ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
325 	.detect_delay_ms = 10,
326 };
327 
328 static struct gpiod_lookup_table mxm_8x10_mci_gpio_table = {
329 	.dev_id = "pxa2xx-mci.0",
330 	.table = {
331 		/* Card detect on GPIO 72 */
332 		GPIO_LOOKUP("gpio-pxa", MXM_8X10_SD_nCD,
333 			    "cd", GPIO_ACTIVE_LOW),
334 		/* Write protect on GPIO 84 */
335 		GPIO_LOOKUP("gpio-pxa", MXM_8X10_SD_WP,
336 			    "wp", GPIO_ACTIVE_LOW),
337 		{ },
338 	},
339 };
340 
mxm_8x10_mmc_init(void)341 void __init mxm_8x10_mmc_init(void)
342 {
343 	gpiod_add_lookup_table(&mxm_8x10_mci_gpio_table);
344 	pxa_set_mci_info(&mxm_8x10_mci_platform_data);
345 }
346 #endif
347 
348 /* USB Open Host Controller Interface */
349 static struct pxaohci_platform_data mxm_8x10_ohci_platform_data = {
350 	.port_mode = PMM_NPS_MODE,
351 	.flags = ENABLE_PORT_ALL
352 };
353 
mxm_8x10_usb_host_init(void)354 void __init mxm_8x10_usb_host_init(void)
355 {
356 	pxa_set_ohci_info(&mxm_8x10_ohci_platform_data);
357 }
358 
359 /* AC97 Sound Support */
360 static struct platform_device mxm_8x10_ac97_device = {
361 	.name = "pxa2xx-ac97"
362 };
363 
mxm_8x10_ac97_init(void)364 void __init mxm_8x10_ac97_init(void)
365 {
366 	platform_device_register(&mxm_8x10_ac97_device);
367 }
368 
369 /* NAND flash Support */
370 #if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
371 #define NAND_BLOCK_SIZE SZ_128K
372 #define NB(x)           (NAND_BLOCK_SIZE * (x))
373 static struct mtd_partition mxm_8x10_nand_partitions[] = {
374 	[0] = {
375 	       .name = "boot",
376 	       .size = NB(0x002),
377 	       .offset = NB(0x000),
378 	       .mask_flags = MTD_WRITEABLE
379 	},
380 	[1] = {
381 	       .name = "kernel",
382 	       .size = NB(0x010),
383 	       .offset = NB(0x002),
384 	       .mask_flags = MTD_WRITEABLE
385 	},
386 	[2] = {
387 	       .name = "root",
388 	       .size = NB(0x36c),
389 	       .offset = NB(0x012)
390 	},
391 	[3] = {
392 	       .name = "bbt",
393 	       .size = NB(0x082),
394 	       .offset = NB(0x37e),
395 	       .mask_flags = MTD_WRITEABLE
396 	}
397 };
398 
399 static struct pxa3xx_nand_platform_data mxm_8x10_nand_info = {
400 	.keep_config	= 1,
401 	.parts		= mxm_8x10_nand_partitions,
402 	.nr_parts	= ARRAY_SIZE(mxm_8x10_nand_partitions)
403 };
404 
mxm_8x10_nand_init(void)405 static void __init mxm_8x10_nand_init(void)
406 {
407 	pxa3xx_set_nand_info(&mxm_8x10_nand_info);
408 }
409 #else
mxm_8x10_nand_init(void)410 static inline void mxm_8x10_nand_init(void) {}
411 #endif /* IS_ENABLED(CONFIG_MTD_NAND_MARVELL) */
412 
413 /* Ethernet support: Davicom DM9000 */
414 static struct resource dm9k_resources[] = {
415 	[0] = {
416 	       .start = MXM_8X10_ETH_PHYS + 0x300,
417 	       .end = MXM_8X10_ETH_PHYS + 0x300,
418 	       .flags = IORESOURCE_MEM
419 	},
420 	[1] = {
421 	       .start = MXM_8X10_ETH_PHYS + 0x308,
422 	       .end = MXM_8X10_ETH_PHYS + 0x308,
423 	       .flags = IORESOURCE_MEM
424 	},
425 	[2] = {
426 	       .start = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO9)),
427 	       .end = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO9)),
428 	       .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE
429 	}
430 };
431 
432 static struct dm9000_plat_data dm9k_plat_data = {
433 	.flags = DM9000_PLATF_16BITONLY
434 };
435 
436 static struct platform_device dm9k_device = {
437 	.name = "dm9000",
438 	.id = 0,
439 	.num_resources = ARRAY_SIZE(dm9k_resources),
440 	.resource = dm9k_resources,
441 	.dev = {
442 		.platform_data = &dm9k_plat_data
443 	}
444 };
445 
mxm_8x10_ethernet_init(void)446 static void __init mxm_8x10_ethernet_init(void)
447 {
448 	platform_device_register(&dm9k_device);
449 }
450 
451 /* PXA UARTs */
mxm_8x10_uarts_init(void)452 static void __init mxm_8x10_uarts_init(void)
453 {
454 	pxa_set_ffuart_info(NULL);
455 	pxa_set_btuart_info(NULL);
456 	pxa_set_stuart_info(NULL);
457 }
458 
459 /* I2C and Real Time Clock */
460 static struct i2c_board_info __initdata mxm_8x10_i2c_devices[] = {
461 	{
462 		I2C_BOARD_INFO("ds1337", 0x68)
463 	}
464 };
465 
mxm_8x10_i2c_init(void)466 static void __init mxm_8x10_i2c_init(void)
467 {
468 	i2c_register_board_info(0, mxm_8x10_i2c_devices,
469 				ARRAY_SIZE(mxm_8x10_i2c_devices));
470 	pxa_set_i2c_info(NULL);
471 }
472 
mxm_8x10_barebones_init(void)473 void __init mxm_8x10_barebones_init(void)
474 {
475 	pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_cfg));
476 
477 	mxm_8x10_uarts_init();
478 	mxm_8x10_nand_init();
479 	mxm_8x10_i2c_init();
480 	mxm_8x10_ethernet_init();
481 }
482