blob: a3449ed7c45c7e9bdc480c2a682890befdddd1e1 [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
43#include "devices.h"
44
45static 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 */
Eric Bénard2d66c782010-05-19 18:45:59 +020052#if defined(MACH_EUKREA_CPUIMX27_USEUART4)
Eric Benardaf5b1df2009-07-16 16:26:33 +020053 PB26_AF_UART4_RTS,
54 PB28_AF_UART4_TXD,
55 PB29_AF_UART4_CTS,
56 PB31_AF_UART4_RXD,
Eric Bénard2d66c782010-05-19 18:45:59 +020057#endif
Eric Benardaf5b1df2009-07-16 16:26:33 +020058 /* 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 */
Eric Bénard2d66c782010-05-19 18:45:59 +020081#if defined(CONFIG_MACH_EUKREA_CPUIMX27_USESDHC2)
Eric Benardaf5b1df2009-07-16 16:26:33 +020082 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,
Eric Bénard2d66c782010-05-19 18:45:59 +020088#endif
Eric Benardaf5b1df2009-07-16 16:26:33 +020089#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
90 /* Quad UART's IRQ */
Eric Bénardebb4fc82010-05-19 18:46:00 +020091 GPIO_PORTB | 22 | GPIO_GPIO | GPIO_IN,
92 GPIO_PORTB | 23 | GPIO_GPIO | GPIO_IN,
93 GPIO_PORTB | 27 | GPIO_GPIO | GPIO_IN,
94 GPIO_PORTB | 30 | GPIO_GPIO | GPIO_IN,
Eric Benardaf5b1df2009-07-16 16:26:33 +020095#endif
96};
97
98static struct physmap_flash_data eukrea_cpuimx27_flash_data = {
99 .width = 2,
100};
101
102static struct resource eukrea_cpuimx27_flash_resource = {
103 .start = 0xc0000000,
104 .end = 0xc3ffffff,
105 .flags = IORESOURCE_MEM,
106};
107
108static 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
118static struct imxuart_platform_data uart_pdata[] = {
119 {
120 .flags = IMXUART_HAVE_RTSCTS,
121 }, {
122 .flags = IMXUART_HAVE_RTSCTS,
123 },
124};
125
126static struct mxc_nand_platform_data eukrea_cpuimx27_nand_board_info = {
127 .width = 1,
128 .hw_ecc = 1,
129};
130
131static struct platform_device *platform_devices[] __initdata = {
132 &eukrea_cpuimx27_nor_mtd_device,
133 &mxc_fec_device,
134};
135
136static struct imxi2c_platform_data eukrea_cpuimx27_i2c_1_data = {
137 .bitrate = 100000,
138};
139
140static struct i2c_board_info eukrea_cpuimx27_i2c_devices[] = {
141 {
Sascha Hauercf87a6e2009-07-20 08:18:47 +0200142 I2C_BOARD_INFO("pcf8563", 0x51),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200143 },
144};
145
146#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
147static struct plat_serial8250_port serial_platform_data[] = {
148 {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100149 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x200000),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200150 .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 }, {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100156 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x400000),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200157 .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 }, {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100163 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x800000),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200164 .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 }, {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100170 .mapbase = (unsigned long)(MX27_CS3_BASE_ADDR + 0x1000000),
Eric Benardaf5b1df2009-07-16 16:26:33 +0200171 .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
180static struct platform_device serial_device = {
181 .name = "serial8250",
182 .id = 0,
183 .dev = {
184 .platform_data = serial_platform_data,
185 },
186};
187#endif
188
189static 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
Uwe Kleine-König3636a142010-02-11 16:31:49 +0100196 mxc_register_device(&imx27_nand_device,
197 &eukrea_cpuimx27_nand_board_info);
Eric Benardaf5b1df2009-07-16 16:26:33 +0200198
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);
Eric Bénard2d66c782010-05-19 18:45:59 +0200209#endif
210#if defined(MACH_EUKREA_CPUIMX27_USEUART4)
Eric Benardaf5b1df2009-07-16 16:26:33 +0200211 /* 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
224static void __init eukrea_cpuimx27_timer_init(void)
225{
226 mx27_clocks_init(26000000);
227}
228
229static struct sys_timer eukrea_cpuimx27_timer = {
230 .init = eukrea_cpuimx27_timer_init,
231};
232
233MACHINE_START(CPUIMX27, "EUKREA CPUIMX27")
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100234 .phys_io = MX27_AIPI_BASE_ADDR,
235 .io_pg_offst = ((MX27_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
Uwe Kleine-König34101232010-01-29 17:36:05 +0100236 .boot_params = MX27_PHYS_OFFSET + 0x100,
Eric Benardaf5b1df2009-07-16 16:26:33 +0200237 .map_io = mx27_map_io,
238 .init_irq = mx27_init_irq,
239 .init_machine = eukrea_cpuimx27_init,
240 .timer = &eukrea_cpuimx27_timer,
241MACHINE_END