Commit | Line | Data |
---|---|---|
af5b1df7 EB |
1 | /* |
2 | * Copyright (C) 2009 Eric Benard - eric@eukrea.com | |
3 | * | |
4 | * Based on pcm038.c which is : | |
5 | * Copyright 2007 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix | |
6 | * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de) | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public License | |
10 | * as published by the Free Software Foundation; either version 2 | |
11 | * of the License, or (at your option) any later version. | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
20 | * MA 02110-1301, USA. | |
21 | */ | |
22 | ||
23 | #include <linux/i2c.h> | |
24 | #include <linux/io.h> | |
25 | #include <linux/mtd/plat-ram.h> | |
26 | #include <linux/mtd/physmap.h> | |
27 | #include <linux/platform_device.h> | |
28 | #include <linux/serial_8250.h> | |
29 | ||
30 | #include <asm/mach-types.h> | |
31 | #include <asm/mach/arch.h> | |
32 | #include <asm/mach/time.h> | |
33 | #include <asm/mach/map.h> | |
34 | ||
35 | #include <mach/board-eukrea_cpuimx27.h> | |
36 | #include <mach/common.h> | |
37 | #include <mach/hardware.h> | |
38 | #include <mach/i2c.h> | |
e835d88e | 39 | #include <mach/iomux-mx27.h> |
af5b1df7 EB |
40 | #include <mach/imx-uart.h> |
41 | #include <mach/mxc_nand.h> | |
42 | ||
43 | #include "devices.h" | |
44 | ||
45 | static int eukrea_cpuimx27_pins[] = { | |
46 | /* UART1 */ | |
47 | PE12_PF_UART1_TXD, | |
48 | PE13_PF_UART1_RXD, | |
49 | PE14_PF_UART1_CTS, | |
50 | PE15_PF_UART1_RTS, | |
51 | /* UART4 */ | |
2d66c780 | 52 | #if defined(MACH_EUKREA_CPUIMX27_USEUART4) |
af5b1df7 EB |
53 | PB26_AF_UART4_RTS, |
54 | PB28_AF_UART4_TXD, | |
55 | PB29_AF_UART4_CTS, | |
56 | PB31_AF_UART4_RXD, | |
2d66c780 | 57 | #endif |
af5b1df7 EB |
58 | /* FEC */ |
59 | PD0_AIN_FEC_TXD0, | |
60 | PD1_AIN_FEC_TXD1, | |
61 | PD2_AIN_FEC_TXD2, | |
62 | PD3_AIN_FEC_TXD3, | |
63 | PD4_AOUT_FEC_RX_ER, | |
64 | PD5_AOUT_FEC_RXD1, | |
65 | PD6_AOUT_FEC_RXD2, | |
66 | PD7_AOUT_FEC_RXD3, | |
67 | PD8_AF_FEC_MDIO, | |
68 | PD9_AIN_FEC_MDC, | |
69 | PD10_AOUT_FEC_CRS, | |
70 | PD11_AOUT_FEC_TX_CLK, | |
71 | PD12_AOUT_FEC_RXD0, | |
72 | PD13_AOUT_FEC_RX_DV, | |
73 | PD14_AOUT_FEC_RX_CLK, | |
74 | PD15_AOUT_FEC_COL, | |
75 | PD16_AIN_FEC_TX_ER, | |
76 | PF23_AIN_FEC_TX_EN, | |
77 | /* I2C1 */ | |
78 | PD17_PF_I2C_DATA, | |
79 | PD18_PF_I2C_CLK, | |
80 | /* SDHC2 */ | |
2d66c780 | 81 | #if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2) |
af5b1df7 EB |
82 | PB4_PF_SD2_D0, |
83 | PB5_PF_SD2_D1, | |
84 | PB6_PF_SD2_D2, | |
85 | PB7_PF_SD2_D3, | |
86 | PB8_PF_SD2_CMD, | |
87 | PB9_PF_SD2_CLK, | |
2d66c780 | 88 | #endif |
af5b1df7 EB |
89 | #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) |
90 | /* Quad UART's IRQ */ | |
91 | GPIO_PORTD | 22 | GPIO_GPIO | GPIO_IN, | |
92 | GPIO_PORTD | 23 | GPIO_GPIO | GPIO_IN, | |
93 | GPIO_PORTD | 27 | GPIO_GPIO | GPIO_IN, | |
94 | GPIO_PORTD | 30 | GPIO_GPIO | GPIO_IN, | |
95 | #endif | |
96 | }; | |
97 | ||
98 | static struct physmap_flash_data eukrea_cpuimx27_flash_data = { | |
99 | .width = 2, | |
100 | }; | |
101 | ||
102 | static struct resource eukrea_cpuimx27_flash_resource = { | |
103 | .start = 0xc0000000, | |
104 | .end = 0xc3ffffff, | |
105 | .flags = IORESOURCE_MEM, | |
106 | }; | |
107 | ||
108 | static struct platform_device eukrea_cpuimx27_nor_mtd_device = { | |
109 | .name = "physmap-flash", | |
110 | .id = 0, | |
111 | .dev = { | |
112 | .platform_data = &eukrea_cpuimx27_flash_data, | |
113 | }, | |
114 | .num_resources = 1, | |
115 | .resource = &eukrea_cpuimx27_flash_resource, | |
116 | }; | |
117 | ||
118 | static struct imxuart_platform_data uart_pdata[] = { | |
119 | { | |
120 | .flags = IMXUART_HAVE_RTSCTS, | |
121 | }, { | |
122 | .flags = IMXUART_HAVE_RTSCTS, | |
123 | }, | |
124 | }; | |
125 | ||
126 | static struct mxc_nand_platform_data eukrea_cpuimx27_nand_board_info = { | |
127 | .width = 1, | |
128 | .hw_ecc = 1, | |
129 | }; | |
130 | ||
131 | static struct platform_device *platform_devices[] __initdata = { | |
132 | &eukrea_cpuimx27_nor_mtd_device, | |
133 | &mxc_fec_device, | |
134 | }; | |
135 | ||
136 | static struct imxi2c_platform_data eukrea_cpuimx27_i2c_1_data = { | |
137 | .bitrate = 100000, | |
138 | }; | |
139 | ||
140 | static struct i2c_board_info eukrea_cpuimx27_i2c_devices[] = { | |
141 | { | |
cf87a6e2 | 142 | I2C_BOARD_INFO("pcf8563", 0x51), |
af5b1df7 EB |
143 | }, |
144 | }; | |
145 | ||
146 | #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) | |
147 | static struct plat_serial8250_port serial_platform_data[] = { | |
148 | { | |
3f35d1f5 | 149 | .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x200000), |
af5b1df7 EB |
150 | .irq = IRQ_GPIOB(23), |
151 | .uartclk = 14745600, | |
152 | .regshift = 1, | |
153 | .iotype = UPIO_MEM, | |
154 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, | |
155 | }, { | |
3f35d1f5 | 156 | .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x400000), |
af5b1df7 EB |
157 | .irq = IRQ_GPIOB(22), |
158 | .uartclk = 14745600, | |
159 | .regshift = 1, | |
160 | .iotype = UPIO_MEM, | |
161 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, | |
162 | }, { | |
3f35d1f5 | 163 | .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x800000), |
af5b1df7 EB |
164 | .irq = IRQ_GPIOB(27), |
165 | .uartclk = 14745600, | |
166 | .regshift = 1, | |
167 | .iotype = UPIO_MEM, | |
168 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, | |
169 | }, { | |
3f35d1f5 | 170 | .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x1000000), |
af5b1df7 EB |
171 | .irq = IRQ_GPIOB(30), |
172 | .uartclk = 14745600, | |
173 | .regshift = 1, | |
174 | .iotype = UPIO_MEM, | |
175 | .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, | |
176 | }, { | |
177 | } | |
178 | }; | |
179 | ||
180 | static struct platform_device serial_device = { | |
181 | .name = "serial8250", | |
182 | .id = 0, | |
183 | .dev = { | |
184 | .platform_data = serial_platform_data, | |
185 | }, | |
186 | }; | |
187 | #endif | |
188 | ||
189 | static void __init eukrea_cpuimx27_init(void) | |
190 | { | |
191 | mxc_gpio_setup_multiple_pins(eukrea_cpuimx27_pins, | |
192 | ARRAY_SIZE(eukrea_cpuimx27_pins), "CPUIMX27"); | |
193 | ||
194 | mxc_register_device(&mxc_uart_device0, &uart_pdata[0]); | |
195 | ||
3636a145 UKK |
196 | mxc_register_device(&imx27_nand_device, |
197 | &eukrea_cpuimx27_nand_board_info); | |
af5b1df7 EB |
198 | |
199 | i2c_register_board_info(0, eukrea_cpuimx27_i2c_devices, | |
200 | ARRAY_SIZE(eukrea_cpuimx27_i2c_devices)); | |
201 | ||
202 | mxc_register_device(&mxc_i2c_device0, &eukrea_cpuimx27_i2c_1_data); | |
203 | ||
204 | platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); | |
205 | ||
206 | #if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2) | |
207 | /* SDHC2 can be used for Wifi */ | |
208 | mxc_register_device(&mxc_sdhc_device1, NULL); | |
2d66c780 EB |
209 | #endif |
210 | #if defined(MACH_EUKREA_CPUIMX27_USEUART4) | |
af5b1df7 EB |
211 | /* in which case UART4 is also used for Bluetooth */ |
212 | mxc_register_device(&mxc_uart_device3, &uart_pdata[1]); | |
213 | #endif | |
214 | ||
215 | #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) | |
216 | platform_device_register(&serial_device); | |
217 | #endif | |
218 | ||
219 | #ifdef CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD | |
220 | eukrea_mbimx27_baseboard_init(); | |
221 | #endif | |
222 | } | |
223 | ||
224 | static void __init eukrea_cpuimx27_timer_init(void) | |
225 | { | |
226 | mx27_clocks_init(26000000); | |
227 | } | |
228 | ||
229 | static struct sys_timer eukrea_cpuimx27_timer = { | |
230 | .init = eukrea_cpuimx27_timer_init, | |
231 | }; | |
232 | ||
233 | MACHINE_START(CPUIMX27, "EUKREA CPUIMX27") | |
3f35d1f5 UKK |
234 | .phys_io = MX27_AIPI_BASE_ADDR, |
235 | .io_pg_offst = ((MX27_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc, | |
34101237 | 236 | .boot_params = MX27_PHYS_OFFSET + 0x100, |
af5b1df7 EB |
237 | .map_io = mx27_map_io, |
238 | .init_irq = mx27_init_irq, | |
239 | .init_machine = eukrea_cpuimx27_init, | |
240 | .timer = &eukrea_cpuimx27_timer, | |
241 | MACHINE_END |