blob: d246eb1bb3ce82995cbf7d2ebd710159e9212474 [file] [log] [blame]
Juergen Beisert7e5e9f52008-07-05 10:03:00 +02001/*
2 * Copyright 2007 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix
3 * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301, USA.
18 */
19
20#include <linux/platform_device.h>
21#include <linux/mtd/physmap.h>
Sascha Hauer3620c0d2008-11-23 17:31:46 +010022#include <linux/mtd/plat-ram.h>
Holger Schurigccfe30a2009-01-29 10:07:50 +010023#include <linux/io.h>
Juergen Beisert7e5e9f52008-07-05 10:03:00 +020024#include <asm/mach/arch.h>
25#include <asm/mach-types.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010026#include <mach/common.h>
27#include <mach/hardware.h>
Holger Schurigccfe30a2009-01-29 10:07:50 +010028#include <mach/iomux.h>
Juergen Beisert7e5e9f52008-07-05 10:03:00 +020029#include <asm/mach/time.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010030#include <mach/imx-uart.h>
31#include <mach/board-pcm038.h>
Sascha Hauer01f71a32008-09-09 11:30:58 +020032#include <mach/mxc_nand.h>
Juergen Beisert7e5e9f52008-07-05 10:03:00 +020033
Sascha Hauer7e905342008-09-09 10:19:41 +020034#include "devices.h"
35
Juergen Beisert7e5e9f52008-07-05 10:03:00 +020036/*
Sascha Hauer3620c0d2008-11-23 17:31:46 +010037 * Phytec's PCM038 comes with 2MiB battery buffered SRAM,
38 * 16 bit width
39 */
40
41static struct platdata_mtd_ram pcm038_sram_data = {
42 .bankwidth = 2,
43};
44
45static struct resource pcm038_sram_resource = {
46 .start = CS1_BASE_ADDR,
47 .end = CS1_BASE_ADDR + 512 * 1024 - 1,
48 .flags = IORESOURCE_MEM,
49};
50
51static struct platform_device pcm038_sram_mtd_device = {
52 .name = "mtd-ram",
53 .id = 0,
54 .dev = {
55 .platform_data = &pcm038_sram_data,
56 },
57 .num_resources = 1,
58 .resource = &pcm038_sram_resource,
59};
60
61/*
Juergen Beisert7e5e9f52008-07-05 10:03:00 +020062 * Phytec's phyCORE-i.MX27 comes with 32MiB flash,
63 * 16 bit width
64 */
65static struct physmap_flash_data pcm038_flash_data = {
66 .width = 2,
67};
68
69static struct resource pcm038_flash_resource = {
70 .start = 0xc0000000,
71 .end = 0xc1ffffff,
72 .flags = IORESOURCE_MEM,
73};
74
75static struct platform_device pcm038_nor_mtd_device = {
76 .name = "physmap-flash",
77 .id = 0,
78 .dev = {
79 .platform_data = &pcm038_flash_data,
80 },
81 .num_resources = 1,
82 .resource = &pcm038_flash_resource,
83};
84
85static int mxc_uart0_pins[] = {
86 PE12_PF_UART1_TXD,
87 PE13_PF_UART1_RXD,
88 PE14_PF_UART1_CTS,
89 PE15_PF_UART1_RTS
90};
91
92static int uart_mxc_port0_init(struct platform_device *pdev)
93{
94 return mxc_gpio_setup_multiple_pins(mxc_uart0_pins,
Sascha Hauer7bd18222008-11-04 16:48:46 +010095 ARRAY_SIZE(mxc_uart0_pins), "UART0");
Juergen Beisert7e5e9f52008-07-05 10:03:00 +020096}
97
98static int uart_mxc_port0_exit(struct platform_device *pdev)
99{
Sascha Hauer7bd18222008-11-04 16:48:46 +0100100 mxc_gpio_release_multiple_pins(mxc_uart0_pins,
101 ARRAY_SIZE(mxc_uart0_pins));
102 return 0;
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200103}
104
105static int mxc_uart1_pins[] = {
106 PE3_PF_UART2_CTS,
107 PE4_PF_UART2_RTS,
108 PE6_PF_UART2_TXD,
109 PE7_PF_UART2_RXD
110};
111
112static int uart_mxc_port1_init(struct platform_device *pdev)
113{
114 return mxc_gpio_setup_multiple_pins(mxc_uart1_pins,
Sascha Hauer7bd18222008-11-04 16:48:46 +0100115 ARRAY_SIZE(mxc_uart1_pins), "UART1");
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200116}
117
118static int uart_mxc_port1_exit(struct platform_device *pdev)
119{
Sascha Hauer7bd18222008-11-04 16:48:46 +0100120 mxc_gpio_release_multiple_pins(mxc_uart1_pins,
121 ARRAY_SIZE(mxc_uart1_pins));
122 return 0;
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200123}
124
125static int mxc_uart2_pins[] = { PE10_PF_UART3_CTS,
126 PE9_PF_UART3_RXD,
127 PE10_PF_UART3_CTS,
128 PE9_PF_UART3_RXD };
129
130static int uart_mxc_port2_init(struct platform_device *pdev)
131{
132 return mxc_gpio_setup_multiple_pins(mxc_uart2_pins,
Sascha Hauer7bd18222008-11-04 16:48:46 +0100133 ARRAY_SIZE(mxc_uart2_pins), "UART2");
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200134}
135
136static int uart_mxc_port2_exit(struct platform_device *pdev)
137{
Sascha Hauer7bd18222008-11-04 16:48:46 +0100138 mxc_gpio_release_multiple_pins(mxc_uart2_pins,
139 ARRAY_SIZE(mxc_uart2_pins));
140 return 0;
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200141}
142
143static struct imxuart_platform_data uart_pdata[] = {
144 {
145 .init = uart_mxc_port0_init,
146 .exit = uart_mxc_port0_exit,
147 .flags = IMXUART_HAVE_RTSCTS,
148 }, {
149 .init = uart_mxc_port1_init,
150 .exit = uart_mxc_port1_exit,
151 .flags = IMXUART_HAVE_RTSCTS,
152 }, {
153 .init = uart_mxc_port2_init,
154 .exit = uart_mxc_port2_exit,
155 .flags = IMXUART_HAVE_RTSCTS,
156 },
157};
158
159static int mxc_fec_pins[] = {
160 PD0_AIN_FEC_TXD0,
161 PD1_AIN_FEC_TXD1,
162 PD2_AIN_FEC_TXD2,
163 PD3_AIN_FEC_TXD3,
164 PD4_AOUT_FEC_RX_ER,
165 PD5_AOUT_FEC_RXD1,
166 PD6_AOUT_FEC_RXD2,
167 PD7_AOUT_FEC_RXD3,
168 PD8_AF_FEC_MDIO,
169 PD9_AIN_FEC_MDC,
170 PD10_AOUT_FEC_CRS,
171 PD11_AOUT_FEC_TX_CLK,
172 PD12_AOUT_FEC_RXD0,
173 PD13_AOUT_FEC_RX_DV,
Holger Schurigccfe30a2009-01-29 10:07:50 +0100174 PD14_AOUT_FEC_RX_CLK,
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200175 PD15_AOUT_FEC_COL,
176 PD16_AIN_FEC_TX_ER,
177 PF23_AIN_FEC_TX_EN
178};
179
180static void gpio_fec_active(void)
181{
182 mxc_gpio_setup_multiple_pins(mxc_fec_pins,
Sascha Hauer7bd18222008-11-04 16:48:46 +0100183 ARRAY_SIZE(mxc_fec_pins), "FEC");
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200184}
185
Sascha Hauer01f71a32008-09-09 11:30:58 +0200186static struct mxc_nand_platform_data pcm038_nand_board_info = {
187 .width = 1,
188 .hw_ecc = 1,
189};
190
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200191static struct platform_device *platform_devices[] __initdata = {
192 &pcm038_nor_mtd_device,
Sascha Hauerd40a0992008-12-01 14:15:40 -0800193 &mxc_w1_master_device,
Sascha Hauer879fea12009-01-26 17:26:02 +0100194 &mxc_fec_device,
Sascha Hauer3620c0d2008-11-23 17:31:46 +0100195 &pcm038_sram_mtd_device,
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200196};
197
Sascha Hauer3620c0d2008-11-23 17:31:46 +0100198/* On pcm038 there's a sram attached to CS1, we enable the chipselect here and
199 * setup other stuffs to access the sram. */
200static void __init pcm038_init_sram(void)
201{
202 __raw_writel(0x0000d843, CSCR_U(1));
203 __raw_writel(0x22252521, CSCR_L(1));
204 __raw_writel(0x22220a00, CSCR_A(1));
205}
206
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200207static void __init pcm038_init(void)
208{
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200209 gpio_fec_active();
Sascha Hauer3620c0d2008-11-23 17:31:46 +0100210 pcm038_init_sram();
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200211
Sascha Hauer7e905342008-09-09 10:19:41 +0200212 mxc_register_device(&mxc_uart_device0, &uart_pdata[0]);
213 mxc_register_device(&mxc_uart_device1, &uart_pdata[1]);
214 mxc_register_device(&mxc_uart_device2, &uart_pdata[2]);
Sascha Hauer01f71a32008-09-09 11:30:58 +0200215
Holger Schurigccfe30a2009-01-29 10:07:50 +0100216 mxc_gpio_mode(PE16_AF_OWIRE);
Sascha Hauer01f71a32008-09-09 11:30:58 +0200217 mxc_register_device(&mxc_nand_device, &pcm038_nand_board_info);
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200218
219 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
Juergen Beisertff6552e2008-07-05 10:03:01 +0200220
221#ifdef CONFIG_MACH_PCM970_BASEBOARD
222 pcm970_baseboard_init();
223#endif
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200224}
225
226static void __init pcm038_timer_init(void)
227{
Sascha Hauer30c730f2009-02-16 14:36:49 +0100228 mx27_clocks_init(26000000);
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200229}
230
Holger Schurig058b7a62009-01-26 16:34:51 +0100231static struct sys_timer pcm038_timer = {
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200232 .init = pcm038_timer_init,
233};
234
235MACHINE_START(PCM038, "phyCORE-i.MX27")
236 .phys_io = AIPI_BASE_ADDR,
237 .io_pg_offst = ((AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
238 .boot_params = PHYS_OFFSET + 0x100,
239 .map_io = mxc_map_io,
240 .init_irq = mxc_init_irq,
241 .init_machine = pcm038_init,
242 .timer = &pcm038_timer,
243MACHINE_END