blob: 09cc0c5c251352b3ffeeac14747144bbdd9be93a [file] [log] [blame]
Eric Benardaf5b1df2009-07-16 16:26:33 +02001/*
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>
Uwe Kleine-Könige835d882010-02-16 11:07:49 +010038#include <mach/iomux-mx27.h>
Eric Benardaf5b1df2009-07-16 16:26:33 +020039#include <mach/mxc_nand.h>
40
Uwe Kleine-König0e7a29a2010-06-16 07:35:31 +020041#include "devices-imx27.h"
Eric Benardaf5b1df2009-07-16 16:26:33 +020042#include "devices.h"
43
44static int eukrea_cpuimx27_pins[] = {
45 /* UART1 */
46 PE12_PF_UART1_TXD,
47 PE13_PF_UART1_RXD,
48 PE14_PF_UART1_CTS,
49 PE15_PF_UART1_RTS,
50 /* UART4 */
51 PB26_AF_UART4_RTS,
52 PB28_AF_UART4_TXD,
53 PB29_AF_UART4_CTS,
54 PB31_AF_UART4_RXD,
55 /* FEC */
56 PD0_AIN_FEC_TXD0,
57 PD1_AIN_FEC_TXD1,
58 PD2_AIN_FEC_TXD2,
59 PD3_AIN_FEC_TXD3,
60 PD4_AOUT_FEC_RX_ER,
61 PD5_AOUT_FEC_RXD1,
62 PD6_AOUT_FEC_RXD2,
63 PD7_AOUT_FEC_RXD3,
64 PD8_AF_FEC_MDIO,
65 PD9_AIN_FEC_MDC,
66 PD10_AOUT_FEC_CRS,
67 PD11_AOUT_FEC_TX_CLK,
68 PD12_AOUT_FEC_RXD0,
69 PD13_AOUT_FEC_RX_DV,
70 PD14_AOUT_FEC_RX_CLK,
71 PD15_AOUT_FEC_COL,
72 PD16_AIN_FEC_TX_ER,
73 PF23_AIN_FEC_TX_EN,
74 /* I2C1 */
75 PD17_PF_I2C_DATA,
76 PD18_PF_I2C_CLK,
77 /* SDHC2 */
78 PB4_PF_SD2_D0,
79 PB5_PF_SD2_D1,
80 PB6_PF_SD2_D2,
81 PB7_PF_SD2_D3,
82 PB8_PF_SD2_CMD,
83 PB9_PF_SD2_CLK,
84#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
85 /* Quad UART's IRQ */
86 GPIO_PORTD | 22 | GPIO_GPIO | GPIO_IN,
87 GPIO_PORTD | 23 | GPIO_GPIO | GPIO_IN,
88 GPIO_PORTD | 27 | GPIO_GPIO | GPIO_IN,
89 GPIO_PORTD | 30 | GPIO_GPIO | GPIO_IN,
90#endif
91};
92
93static struct physmap_flash_data eukrea_cpuimx27_flash_data = {
94 .width = 2,
95};
96
97static struct resource eukrea_cpuimx27_flash_resource = {
98 .start = 0xc0000000,
99 .end = 0xc3ffffff,
100 .flags = IORESOURCE_MEM,
101};
102
103static struct platform_device eukrea_cpuimx27_nor_mtd_device = {
104 .name = "physmap-flash",
105 .id = 0,
106 .dev = {
107 .platform_data = &eukrea_cpuimx27_flash_data,
108 },
109 .num_resources = 1,
110 .resource = &eukrea_cpuimx27_flash_resource,
111};
112
Uwe Kleine-Königd5dac4a2010-06-23 09:36:01 +0200113static const struct imxuart_platform_data uart_pdata __initconst = {
114 .flags = IMXUART_HAVE_RTSCTS,
Eric Benardaf5b1df2009-07-16 16:26:33 +0200115};
116
Uwe Kleine-König0e7a29a2010-06-16 07:35:31 +0200117static const struct mxc_nand_platform_data
118cpuimx27_nand_board_info __initconst = {
Eric Benardaf5b1df2009-07-16 16:26:33 +0200119 .width = 1,
120 .hw_ecc = 1,
121};
122
123static struct platform_device *platform_devices[] __initdata = {
124 &eukrea_cpuimx27_nor_mtd_device,
125 &mxc_fec_device,
126};
127
Uwe Kleine-Königc6987152010-06-16 17:25:40 +0200128static const struct imxi2c_platform_data cpuimx27_i2c1_data __initconst = {
Eric Benardaf5b1df2009-07-16 16:26:33 +0200129 .bitrate = 100000,
130};
131
132static struct i2c_board_info eukrea_cpuimx27_i2c_devices[] = {
133 {
Sascha Hauercf87a6e2009-07-20 08:18:47 +0200134 I2C_BOARD_INFO("pcf8563", 0x51),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200135 },
136};
137
138#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
139static struct plat_serial8250_port serial_platform_data[] = {
140 {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100141 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x200000),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200142 .irq = IRQ_GPIOB(23),
143 .uartclk = 14745600,
144 .regshift = 1,
145 .iotype = UPIO_MEM,
146 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
147 }, {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100148 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x400000),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200149 .irq = IRQ_GPIOB(22),
150 .uartclk = 14745600,
151 .regshift = 1,
152 .iotype = UPIO_MEM,
153 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
154 }, {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100155 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x800000),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200156 .irq = IRQ_GPIOB(27),
157 .uartclk = 14745600,
158 .regshift = 1,
159 .iotype = UPIO_MEM,
160 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
161 }, {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100162 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x1000000),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200163 .irq = IRQ_GPIOB(30),
164 .uartclk = 14745600,
165 .regshift = 1,
166 .iotype = UPIO_MEM,
167 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
168 }, {
169 }
170};
171
172static struct platform_device serial_device = {
173 .name = "serial8250",
174 .id = 0,
175 .dev = {
176 .platform_data = serial_platform_data,
177 },
178};
179#endif
180
181static void __init eukrea_cpuimx27_init(void)
182{
183 mxc_gpio_setup_multiple_pins(eukrea_cpuimx27_pins,
184 ARRAY_SIZE(eukrea_cpuimx27_pins), "CPUIMX27");
185
Uwe Kleine-Königd5dac4a2010-06-23 09:36:01 +0200186 imx27_add_imx_uart0(&uart_pdata);
Eric Benardaf5b1df2009-07-16 16:26:33 +0200187
Uwe Kleine-König0e7a29a2010-06-16 07:35:31 +0200188 imx27_add_mxc_nand(&cpuimx27_nand_board_info);
Eric Benardaf5b1df2009-07-16 16:26:33 +0200189
190 i2c_register_board_info(0, eukrea_cpuimx27_i2c_devices,
191 ARRAY_SIZE(eukrea_cpuimx27_i2c_devices));
192
Uwe Kleine-Königc6987152010-06-16 17:25:40 +0200193 imx27_add_i2c_imx1(&cpuimx27_i2c1_data);
Eric Benardaf5b1df2009-07-16 16:26:33 +0200194
195 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
196
197#if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2)
198 /* SDHC2 can be used for Wifi */
199 mxc_register_device(&mxc_sdhc_device1, NULL);
200 /* in which case UART4 is also used for Bluetooth */
Uwe Kleine-Königd5dac4a2010-06-23 09:36:01 +0200201 imx27_add_imx_uart3(&uart_pdata);
Eric Benardaf5b1df2009-07-16 16:26:33 +0200202#endif
203
204#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
205 platform_device_register(&serial_device);
206#endif
207
208#ifdef CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD
209 eukrea_mbimx27_baseboard_init();
210#endif
211}
212
213static void __init eukrea_cpuimx27_timer_init(void)
214{
215 mx27_clocks_init(26000000);
216}
217
218static struct sys_timer eukrea_cpuimx27_timer = {
219 .init = eukrea_cpuimx27_timer_init,
220};
221
222MACHINE_START(CPUIMX27, "EUKREA CPUIMX27")
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100223 .phys_io = MX27_AIPI_BASE_ADDR,
224 .io_pg_offst = ((MX27_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
Uwe Kleine-König34101232010-01-29 17:36:05 +0100225 .boot_params = MX27_PHYS_OFFSET + 0x100,
Eric Benardaf5b1df2009-07-16 16:26:33 +0200226 .map_io = mx27_map_io,
227 .init_irq = mx27_init_irq,
228 .init_machine = eukrea_cpuimx27_init,
229 .timer = &eukrea_cpuimx27_timer,
230MACHINE_END