blob: 91a1e4bbccbc9c713e413de44913fc978da24f67 [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>
22#include <asm/mach/arch.h>
23#include <asm/mach-types.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010024#include <mach/common.h>
25#include <mach/hardware.h>
26#include <mach/iomux-mx1-mx2.h>
Juergen Beisert7e5e9f52008-07-05 10:03:00 +020027#include <asm/mach/time.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010028#include <mach/imx-uart.h>
29#include <mach/board-pcm038.h>
Juergen Beisert7e5e9f52008-07-05 10:03:00 +020030
Sascha Hauer7e905342008-09-09 10:19:41 +020031#include "devices.h"
32
Juergen Beisert7e5e9f52008-07-05 10:03:00 +020033/*
34 * Phytec's phyCORE-i.MX27 comes with 32MiB flash,
35 * 16 bit width
36 */
37static struct physmap_flash_data pcm038_flash_data = {
38 .width = 2,
39};
40
41static struct resource pcm038_flash_resource = {
42 .start = 0xc0000000,
43 .end = 0xc1ffffff,
44 .flags = IORESOURCE_MEM,
45};
46
47static struct platform_device pcm038_nor_mtd_device = {
48 .name = "physmap-flash",
49 .id = 0,
50 .dev = {
51 .platform_data = &pcm038_flash_data,
52 },
53 .num_resources = 1,
54 .resource = &pcm038_flash_resource,
55};
56
57static int mxc_uart0_pins[] = {
58 PE12_PF_UART1_TXD,
59 PE13_PF_UART1_RXD,
60 PE14_PF_UART1_CTS,
61 PE15_PF_UART1_RTS
62};
63
64static int uart_mxc_port0_init(struct platform_device *pdev)
65{
66 return mxc_gpio_setup_multiple_pins(mxc_uart0_pins,
Sascha Hauer7bd18222008-11-04 16:48:46 +010067 ARRAY_SIZE(mxc_uart0_pins), "UART0");
Juergen Beisert7e5e9f52008-07-05 10:03:00 +020068}
69
70static int uart_mxc_port0_exit(struct platform_device *pdev)
71{
Sascha Hauer7bd18222008-11-04 16:48:46 +010072 mxc_gpio_release_multiple_pins(mxc_uart0_pins,
73 ARRAY_SIZE(mxc_uart0_pins));
74 return 0;
Juergen Beisert7e5e9f52008-07-05 10:03:00 +020075}
76
77static int mxc_uart1_pins[] = {
78 PE3_PF_UART2_CTS,
79 PE4_PF_UART2_RTS,
80 PE6_PF_UART2_TXD,
81 PE7_PF_UART2_RXD
82};
83
84static int uart_mxc_port1_init(struct platform_device *pdev)
85{
86 return mxc_gpio_setup_multiple_pins(mxc_uart1_pins,
Sascha Hauer7bd18222008-11-04 16:48:46 +010087 ARRAY_SIZE(mxc_uart1_pins), "UART1");
Juergen Beisert7e5e9f52008-07-05 10:03:00 +020088}
89
90static int uart_mxc_port1_exit(struct platform_device *pdev)
91{
Sascha Hauer7bd18222008-11-04 16:48:46 +010092 mxc_gpio_release_multiple_pins(mxc_uart1_pins,
93 ARRAY_SIZE(mxc_uart1_pins));
94 return 0;
Juergen Beisert7e5e9f52008-07-05 10:03:00 +020095}
96
97static int mxc_uart2_pins[] = { PE10_PF_UART3_CTS,
98 PE9_PF_UART3_RXD,
99 PE10_PF_UART3_CTS,
100 PE9_PF_UART3_RXD };
101
102static int uart_mxc_port2_init(struct platform_device *pdev)
103{
104 return mxc_gpio_setup_multiple_pins(mxc_uart2_pins,
Sascha Hauer7bd18222008-11-04 16:48:46 +0100105 ARRAY_SIZE(mxc_uart2_pins), "UART2");
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200106}
107
108static int uart_mxc_port2_exit(struct platform_device *pdev)
109{
Sascha Hauer7bd18222008-11-04 16:48:46 +0100110 mxc_gpio_release_multiple_pins(mxc_uart2_pins,
111 ARRAY_SIZE(mxc_uart2_pins));
112 return 0;
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200113}
114
115static struct imxuart_platform_data uart_pdata[] = {
116 {
117 .init = uart_mxc_port0_init,
118 .exit = uart_mxc_port0_exit,
119 .flags = IMXUART_HAVE_RTSCTS,
120 }, {
121 .init = uart_mxc_port1_init,
122 .exit = uart_mxc_port1_exit,
123 .flags = IMXUART_HAVE_RTSCTS,
124 }, {
125 .init = uart_mxc_port2_init,
126 .exit = uart_mxc_port2_exit,
127 .flags = IMXUART_HAVE_RTSCTS,
128 },
129};
130
131static int mxc_fec_pins[] = {
132 PD0_AIN_FEC_TXD0,
133 PD1_AIN_FEC_TXD1,
134 PD2_AIN_FEC_TXD2,
135 PD3_AIN_FEC_TXD3,
136 PD4_AOUT_FEC_RX_ER,
137 PD5_AOUT_FEC_RXD1,
138 PD6_AOUT_FEC_RXD2,
139 PD7_AOUT_FEC_RXD3,
140 PD8_AF_FEC_MDIO,
141 PD9_AIN_FEC_MDC,
142 PD10_AOUT_FEC_CRS,
143 PD11_AOUT_FEC_TX_CLK,
144 PD12_AOUT_FEC_RXD0,
145 PD13_AOUT_FEC_RX_DV,
146 PD14_AOUT_FEC_CLR,
147 PD15_AOUT_FEC_COL,
148 PD16_AIN_FEC_TX_ER,
149 PF23_AIN_FEC_TX_EN
150};
151
152static void gpio_fec_active(void)
153{
154 mxc_gpio_setup_multiple_pins(mxc_fec_pins,
Sascha Hauer7bd18222008-11-04 16:48:46 +0100155 ARRAY_SIZE(mxc_fec_pins), "FEC");
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200156}
157
158static void gpio_fec_inactive(void)
159{
Sascha Hauer7bd18222008-11-04 16:48:46 +0100160 mxc_gpio_release_multiple_pins(mxc_fec_pins,
161 ARRAY_SIZE(mxc_fec_pins));
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200162}
163
164static struct platform_device *platform_devices[] __initdata = {
165 &pcm038_nor_mtd_device,
Sascha Hauerd40a0992008-12-01 14:15:40 -0800166 &mxc_w1_master_device,
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200167};
168
169static void __init pcm038_init(void)
170{
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200171 gpio_fec_active();
172
Sascha Hauer7e905342008-09-09 10:19:41 +0200173 mxc_register_device(&mxc_uart_device0, &uart_pdata[0]);
174 mxc_register_device(&mxc_uart_device1, &uart_pdata[1]);
175 mxc_register_device(&mxc_uart_device2, &uart_pdata[2]);
Sascha Hauerd40a0992008-12-01 14:15:40 -0800176 mxc_gpio_mode(PE16_AF_RTCK); /* OWIRE */
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200177
178 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
Juergen Beisertff6552e2008-07-05 10:03:01 +0200179
180#ifdef CONFIG_MACH_PCM970_BASEBOARD
181 pcm970_baseboard_init();
182#endif
Juergen Beisert7e5e9f52008-07-05 10:03:00 +0200183}
184
185static void __init pcm038_timer_init(void)
186{
187 mxc_clocks_init(26000000);
188 mxc_timer_init("gpt_clk.0");
189}
190
191struct sys_timer pcm038_timer = {
192 .init = pcm038_timer_init,
193};
194
195MACHINE_START(PCM038, "phyCORE-i.MX27")
196 .phys_io = AIPI_BASE_ADDR,
197 .io_pg_offst = ((AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
198 .boot_params = PHYS_OFFSET + 0x100,
199 .map_io = mxc_map_io,
200 .init_irq = mxc_init_irq,
201 .init_machine = pcm038_init,
202 .timer = &pcm038_timer,
203MACHINE_END