blob: 5d07c2ab47114d98d4ea8fa92169f8093bcafec1 [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>
38#include <mach/i2c.h>
Uwe Kleine-Könige835d882010-02-16 11:07:49 +010039#include <mach/iomux-mx27.h>
Eric Benardaf5b1df2009-07-16 16:26:33 +020040#include <mach/imx-uart.h>
41#include <mach/mxc_nand.h>
42
Uwe Kleine-König0e7a29a2010-06-16 07:35:31 +020043#include "devices-imx27.h"
Eric Benardaf5b1df2009-07-16 16:26:33 +020044#include "devices.h"
45
46static int eukrea_cpuimx27_pins[] = {
47 /* UART1 */
48 PE12_PF_UART1_TXD,
49 PE13_PF_UART1_RXD,
50 PE14_PF_UART1_CTS,
51 PE15_PF_UART1_RTS,
52 /* UART4 */
53 PB26_AF_UART4_RTS,
54 PB28_AF_UART4_TXD,
55 PB29_AF_UART4_CTS,
56 PB31_AF_UART4_RXD,
57 /* FEC */
58 PD0_AIN_FEC_TXD0,
59 PD1_AIN_FEC_TXD1,
60 PD2_AIN_FEC_TXD2,
61 PD3_AIN_FEC_TXD3,
62 PD4_AOUT_FEC_RX_ER,
63 PD5_AOUT_FEC_RXD1,
64 PD6_AOUT_FEC_RXD2,
65 PD7_AOUT_FEC_RXD3,
66 PD8_AF_FEC_MDIO,
67 PD9_AIN_FEC_MDC,
68 PD10_AOUT_FEC_CRS,
69 PD11_AOUT_FEC_TX_CLK,
70 PD12_AOUT_FEC_RXD0,
71 PD13_AOUT_FEC_RX_DV,
72 PD14_AOUT_FEC_RX_CLK,
73 PD15_AOUT_FEC_COL,
74 PD16_AIN_FEC_TX_ER,
75 PF23_AIN_FEC_TX_EN,
76 /* I2C1 */
77 PD17_PF_I2C_DATA,
78 PD18_PF_I2C_CLK,
79 /* SDHC2 */
80 PB4_PF_SD2_D0,
81 PB5_PF_SD2_D1,
82 PB6_PF_SD2_D2,
83 PB7_PF_SD2_D3,
84 PB8_PF_SD2_CMD,
85 PB9_PF_SD2_CLK,
86#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
87 /* Quad UART's IRQ */
88 GPIO_PORTD | 22 | GPIO_GPIO | GPIO_IN,
89 GPIO_PORTD | 23 | GPIO_GPIO | GPIO_IN,
90 GPIO_PORTD | 27 | GPIO_GPIO | GPIO_IN,
91 GPIO_PORTD | 30 | GPIO_GPIO | GPIO_IN,
92#endif
93};
94
95static struct physmap_flash_data eukrea_cpuimx27_flash_data = {
96 .width = 2,
97};
98
99static struct resource eukrea_cpuimx27_flash_resource = {
100 .start = 0xc0000000,
101 .end = 0xc3ffffff,
102 .flags = IORESOURCE_MEM,
103};
104
105static struct platform_device eukrea_cpuimx27_nor_mtd_device = {
106 .name = "physmap-flash",
107 .id = 0,
108 .dev = {
109 .platform_data = &eukrea_cpuimx27_flash_data,
110 },
111 .num_resources = 1,
112 .resource = &eukrea_cpuimx27_flash_resource,
113};
114
115static struct imxuart_platform_data uart_pdata[] = {
116 {
117 .flags = IMXUART_HAVE_RTSCTS,
118 }, {
119 .flags = IMXUART_HAVE_RTSCTS,
120 },
121};
122
Uwe Kleine-König0e7a29a2010-06-16 07:35:31 +0200123static const struct mxc_nand_platform_data
124cpuimx27_nand_board_info __initconst = {
Eric Benardaf5b1df2009-07-16 16:26:33 +0200125 .width = 1,
126 .hw_ecc = 1,
127};
128
129static struct platform_device *platform_devices[] __initdata = {
130 &eukrea_cpuimx27_nor_mtd_device,
131 &mxc_fec_device,
132};
133
134static struct imxi2c_platform_data eukrea_cpuimx27_i2c_1_data = {
135 .bitrate = 100000,
136};
137
138static struct i2c_board_info eukrea_cpuimx27_i2c_devices[] = {
139 {
Sascha Hauercf87a6e2009-07-20 08:18:47 +0200140 I2C_BOARD_INFO("pcf8563", 0x51),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200141 },
142};
143
144#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
145static struct plat_serial8250_port serial_platform_data[] = {
146 {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100147 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x200000),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200148 .irq = IRQ_GPIOB(23),
149 .uartclk = 14745600,
150 .regshift = 1,
151 .iotype = UPIO_MEM,
152 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
153 }, {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100154 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x400000),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200155 .irq = IRQ_GPIOB(22),
156 .uartclk = 14745600,
157 .regshift = 1,
158 .iotype = UPIO_MEM,
159 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
160 }, {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100161 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x800000),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200162 .irq = IRQ_GPIOB(27),
163 .uartclk = 14745600,
164 .regshift = 1,
165 .iotype = UPIO_MEM,
166 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
167 }, {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100168 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x1000000),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200169 .irq = IRQ_GPIOB(30),
170 .uartclk = 14745600,
171 .regshift = 1,
172 .iotype = UPIO_MEM,
173 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP,
174 }, {
175 }
176};
177
178static struct platform_device serial_device = {
179 .name = "serial8250",
180 .id = 0,
181 .dev = {
182 .platform_data = serial_platform_data,
183 },
184};
185#endif
186
187static void __init eukrea_cpuimx27_init(void)
188{
189 mxc_gpio_setup_multiple_pins(eukrea_cpuimx27_pins,
190 ARRAY_SIZE(eukrea_cpuimx27_pins), "CPUIMX27");
191
Uwe Kleine-König551823e2010-06-11 09:08:02 +0200192 mxc_register_device(&imx2x_uart_device0, &uart_pdata[0]);
Eric Benardaf5b1df2009-07-16 16:26:33 +0200193
Uwe Kleine-König0e7a29a2010-06-16 07:35:31 +0200194 imx27_add_mxc_nand(&cpuimx27_nand_board_info);
Eric Benardaf5b1df2009-07-16 16:26:33 +0200195
196 i2c_register_board_info(0, eukrea_cpuimx27_i2c_devices,
197 ARRAY_SIZE(eukrea_cpuimx27_i2c_devices));
198
199 mxc_register_device(&mxc_i2c_device0, &eukrea_cpuimx27_i2c_1_data);
200
201 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
202
203#if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2)
204 /* SDHC2 can be used for Wifi */
205 mxc_register_device(&mxc_sdhc_device1, NULL);
206 /* in which case UART4 is also used for Bluetooth */
Uwe Kleine-König551823e2010-06-11 09:08:02 +0200207 mxc_register_device(&imx2x_uart_device3, &uart_pdata[1]);
Eric Benardaf5b1df2009-07-16 16:26:33 +0200208#endif
209
210#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
211 platform_device_register(&serial_device);
212#endif
213
214#ifdef CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD
215 eukrea_mbimx27_baseboard_init();
216#endif
217}
218
219static void __init eukrea_cpuimx27_timer_init(void)
220{
221 mx27_clocks_init(26000000);
222}
223
224static struct sys_timer eukrea_cpuimx27_timer = {
225 .init = eukrea_cpuimx27_timer_init,
226};
227
228MACHINE_START(CPUIMX27, "EUKREA CPUIMX27")
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100229 .phys_io = MX27_AIPI_BASE_ADDR,
230 .io_pg_offst = ((MX27_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
Uwe Kleine-König34101232010-01-29 17:36:05 +0100231 .boot_params = MX27_PHYS_OFFSET + 0x100,
Eric Benardaf5b1df2009-07-16 16:26:33 +0200232 .map_io = mx27_map_io,
233 .init_irq = mx27_init_irq,
234 .init_machine = eukrea_cpuimx27_init,
235 .timer = &eukrea_cpuimx27_timer,
236MACHINE_END