1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * linux/arch/arm/mach-pxa/capc7117.c
4  *
5  * Support for the Embedian CAPC-7117 Evaluation Kit
6  * based on the Embedian MXM-8x10 Computer on Module
7  *
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/irq.h>
20 #include <linux/platform_device.h>
21 #include <linux/ata_platform.h>
22 #include <linux/serial_8250.h>
23 #include <linux/gpio.h>
24 #include <linux/regulator/machine.h>
25 
26 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
28 
29 #include "pxa320.h"
30 #include "mxm8x10.h"
31 
32 #include "generic.h"
33 
34 /* IDE (PATA) Support */
35 static struct pata_platform_info pata_platform_data = {
36 	.ioport_shift = 1
37 };
38 
39 static struct resource capc7117_ide_resources[] = {
40 	[0] = {
41 	       .start = 0x11000020,
42 	       .end = 0x1100003f,
43 	       .flags = IORESOURCE_MEM
44 	},
45 	[1] = {
46 	       .start = 0x1100001c,
47 	       .end = 0x1100001c,
48 	       .flags = IORESOURCE_MEM
49 	},
50 	[2] = {
51 	       .start = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO76)),
52 	       .end = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO76)),
53 	       .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING
54 	}
55 };
56 
57 static struct platform_device capc7117_ide_device = {
58 	.name = "pata_platform",
59 	.num_resources = ARRAY_SIZE(capc7117_ide_resources),
60 	.resource = capc7117_ide_resources,
61 	.dev = {
62 		.platform_data = &pata_platform_data,
63 		.coherent_dma_mask = ~0		/* grumble */
64 	}
65 };
66 
capc7117_ide_init(void)67 static void __init capc7117_ide_init(void)
68 {
69 	platform_device_register(&capc7117_ide_device);
70 }
71 
72 /* TI16C752 UART support */
73 #define	TI16C752_FLAGS		(UPF_BOOT_AUTOCONF | \
74 					UPF_IOREMAP | \
75 					UPF_BUGGY_UART | \
76 					UPF_SKIP_TEST)
77 #define	TI16C752_UARTCLK	(22118400)
78 static struct plat_serial8250_port ti16c752_platform_data[] = {
79 	[0] = {
80 	       .mapbase = 0x14000000,
81 	       .irq = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO78)),
82 	       .irqflags = IRQF_TRIGGER_RISING,
83 	       .flags = TI16C752_FLAGS,
84 	       .iotype = UPIO_MEM,
85 	       .regshift = 1,
86 	       .uartclk = TI16C752_UARTCLK
87 	},
88 	[1] = {
89 	       .mapbase = 0x14000040,
90 	       .irq = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO79)),
91 	       .irqflags = IRQF_TRIGGER_RISING,
92 	       .flags = TI16C752_FLAGS,
93 	       .iotype = UPIO_MEM,
94 	       .regshift = 1,
95 	       .uartclk = TI16C752_UARTCLK
96 	},
97 	[2] = {
98 	       .mapbase = 0x14000080,
99 	       .irq = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO80)),
100 	       .irqflags = IRQF_TRIGGER_RISING,
101 	       .flags = TI16C752_FLAGS,
102 	       .iotype = UPIO_MEM,
103 	       .regshift = 1,
104 	       .uartclk = TI16C752_UARTCLK
105 	},
106 	[3] = {
107 	       .mapbase = 0x140000c0,
108 	       .irq = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO81)),
109 	       .irqflags = IRQF_TRIGGER_RISING,
110 	       .flags = TI16C752_FLAGS,
111 	       .iotype = UPIO_MEM,
112 	       .regshift = 1,
113 	       .uartclk = TI16C752_UARTCLK
114 	},
115 	[4] = {
116 	       /* end of array */
117 	}
118 };
119 
120 static struct platform_device ti16c752_device = {
121 	.name = "serial8250",
122 	.id = PLAT8250_DEV_PLATFORM,
123 	.dev = {
124 		.platform_data = ti16c752_platform_data
125 	}
126 };
127 
capc7117_uarts_init(void)128 static void __init capc7117_uarts_init(void)
129 {
130 	platform_device_register(&ti16c752_device);
131 }
132 
capc7117_init(void)133 static void __init capc7117_init(void)
134 {
135 	/* Init CoM */
136 	mxm_8x10_barebones_init();
137 
138 	/* Init evaluation board peripherals */
139 	mxm_8x10_ac97_init();
140 	mxm_8x10_usb_host_init();
141 	mxm_8x10_mmc_init();
142 
143 	capc7117_uarts_init();
144 	capc7117_ide_init();
145 
146 	regulator_has_full_constraints();
147 }
148 
149 MACHINE_START(CAPC7117,
150 	      "Embedian CAPC-7117 evaluation kit based on the MXM-8x10 CoM")
151 	.atag_offset = 0x100,
152 	.map_io = pxa3xx_map_io,
153 	.nr_irqs = PXA_NR_IRQS,
154 	.init_irq = pxa3xx_init_irq,
155 	.handle_irq = pxa3xx_handle_irq,
156 	.init_time	= pxa_timer_init,
157 	.init_machine = capc7117_init,
158 	.restart	= pxa_restart,
159 MACHINE_END
160