blob: 38d99e6c9d002f4832128f1859be37bac92743ff [file] [log] [blame]
Alberto Panizzo5e9145e2009-05-19 10:01:03 +02001/*
2 * armadillo5x0.c
3 *
4 * Copyright 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
5 * updates in http://alberdroid.blogspot.com/
6 *
7 * Based on Atmark Techno, Inc. armadillo 500 BSP 2008
8 * Based on mx31ads.c and pcm037.c Great Work!
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 * MA 02110-1301, USA.
24 */
25
26#include <linux/types.h>
27#include <linux/init.h>
28#include <linux/clk.h>
29#include <linux/platform_device.h>
30#include <linux/gpio.h>
31#include <linux/smsc911x.h>
32#include <linux/interrupt.h>
33#include <linux/irq.h>
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +020034#include <linux/mtd/physmap.h>
Alberto Panizzo5e9145e2009-05-19 10:01:03 +020035
36#include <mach/hardware.h>
37#include <asm/mach-types.h>
38#include <asm/mach/arch.h>
39#include <asm/mach/time.h>
40#include <asm/memory.h>
41#include <asm/mach/map.h>
42
43#include <mach/common.h>
44#include <mach/imx-uart.h>
45#include <mach/iomux-mx3.h>
46#include <mach/board-armadillo5x0.h>
47#include <mach/mmc.h>
48#include <mach/ipu.h>
49#include <mach/mx3fb.h>
50
51#include "devices.h"
52
53static int armadillo5x0_pins[] = {
54 /* UART1 */
55 MX31_PIN_CTS1__CTS1,
56 MX31_PIN_RTS1__RTS1,
57 MX31_PIN_TXD1__TXD1,
58 MX31_PIN_RXD1__RXD1,
59 /* UART2 */
60 MX31_PIN_CTS2__CTS2,
61 MX31_PIN_RTS2__RTS2,
62 MX31_PIN_TXD2__TXD2,
63 MX31_PIN_RXD2__RXD2,
64 /* LAN9118_IRQ */
65 IOMUX_MODE(MX31_PIN_GPIO1_0, IOMUX_CONFIG_GPIO),
66 /* SDHC1 */
67 MX31_PIN_SD1_DATA3__SD1_DATA3,
68 MX31_PIN_SD1_DATA2__SD1_DATA2,
69 MX31_PIN_SD1_DATA1__SD1_DATA1,
70 MX31_PIN_SD1_DATA0__SD1_DATA0,
71 MX31_PIN_SD1_CLK__SD1_CLK,
72 MX31_PIN_SD1_CMD__SD1_CMD,
73 /* Framebuffer */
74 MX31_PIN_LD0__LD0,
75 MX31_PIN_LD1__LD1,
76 MX31_PIN_LD2__LD2,
77 MX31_PIN_LD3__LD3,
78 MX31_PIN_LD4__LD4,
79 MX31_PIN_LD5__LD5,
80 MX31_PIN_LD6__LD6,
81 MX31_PIN_LD7__LD7,
82 MX31_PIN_LD8__LD8,
83 MX31_PIN_LD9__LD9,
84 MX31_PIN_LD10__LD10,
85 MX31_PIN_LD11__LD11,
86 MX31_PIN_LD12__LD12,
87 MX31_PIN_LD13__LD13,
88 MX31_PIN_LD14__LD14,
89 MX31_PIN_LD15__LD15,
90 MX31_PIN_LD16__LD16,
91 MX31_PIN_LD17__LD17,
92 MX31_PIN_VSYNC3__VSYNC3,
93 MX31_PIN_HSYNC__HSYNC,
94 MX31_PIN_FPSHIFT__FPSHIFT,
95 MX31_PIN_DRDY0__DRDY0,
96 IOMUX_MODE(MX31_PIN_LCS1, IOMUX_CONFIG_GPIO), /*ADV7125_PSAVE*/
97
98};
99
100/*
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +0200101 * MTD NOR Flash
102 */
103static struct mtd_partition armadillo5x0_nor_flash_partitions[] = {
104 {
105 .name = "nor.bootloader",
106 .offset = 0x00000000,
107 .size = 4*32*1024,
108 }, {
109 .name = "nor.kernel",
110 .offset = MTDPART_OFS_APPEND,
111 .size = 16*128*1024,
112 }, {
113 .name = "nor.userland",
114 .offset = MTDPART_OFS_APPEND,
115 .size = 110*128*1024,
116 }, {
117 .name = "nor.config",
118 .offset = MTDPART_OFS_APPEND,
119 .size = 1*128*1024,
120 },
121};
122
123static struct physmap_flash_data armadillo5x0_nor_flash_pdata = {
124 .width = 2,
125 .parts = armadillo5x0_nor_flash_partitions,
126 .nr_parts = ARRAY_SIZE(armadillo5x0_nor_flash_partitions),
127};
128
129static struct resource armadillo5x0_nor_flash_resource = {
130 .flags = IORESOURCE_MEM,
131 .start = CS0_BASE_ADDR,
132 .end = CS0_BASE_ADDR + SZ_64M - 1,
133};
134
135static struct platform_device armadillo5x0_nor_flash = {
136 .name = "physmap-flash",
137 .id = -1,
138 .num_resources = 1,
139 .resource = &armadillo5x0_nor_flash_resource,
140};
141
142/*
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200143 * FB support
144 */
145static const struct fb_videomode fb_modedb[] = {
146 { /* 640x480 @ 60 Hz */
147 .name = "CRT-VGA",
148 .refresh = 60,
149 .xres = 640,
150 .yres = 480,
151 .pixclock = 39721,
152 .left_margin = 35,
153 .right_margin = 115,
154 .upper_margin = 43,
155 .lower_margin = 1,
156 .hsync_len = 10,
157 .vsync_len = 1,
158 .sync = FB_SYNC_OE_ACT_HIGH,
159 .vmode = FB_VMODE_NONINTERLACED,
160 .flag = 0,
161 }, {/* 800x600 @ 56 Hz */
162 .name = "CRT-SVGA",
163 .refresh = 56,
164 .xres = 800,
165 .yres = 600,
166 .pixclock = 30000,
167 .left_margin = 30,
168 .right_margin = 108,
169 .upper_margin = 13,
170 .lower_margin = 10,
171 .hsync_len = 10,
172 .vsync_len = 1,
173 .sync = FB_SYNC_OE_ACT_HIGH | FB_SYNC_HOR_HIGH_ACT |
174 FB_SYNC_VERT_HIGH_ACT,
175 .vmode = FB_VMODE_NONINTERLACED,
176 .flag = 0,
177 },
178};
179
180static struct ipu_platform_data mx3_ipu_data = {
181 .irq_base = MXC_IPU_IRQ_START,
182};
183
184static struct mx3fb_platform_data mx3fb_pdata = {
185 .dma_dev = &mx3_ipu.dev,
186 .name = "CRT-VGA",
187 .mode = fb_modedb,
188 .num_modes = ARRAY_SIZE(fb_modedb),
189};
190
191/*
192 * SDHC 1
193 * MMC support
194 */
195static int armadillo5x0_sdhc1_get_ro(struct device *dev)
196{
197 return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B));
198}
199
200static int armadillo5x0_sdhc1_init(struct device *dev,
201 irq_handler_t detect_irq, void *data)
202{
203 int ret;
204 int gpio_det, gpio_wp;
205
206 gpio_det = IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK);
207 gpio_wp = IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B);
208
209 ret = gpio_request(gpio_det, "sdhc-card-detect");
210 if (ret)
211 return ret;
212
213 gpio_direction_input(gpio_det);
214
215 ret = gpio_request(gpio_wp, "sdhc-write-protect");
216 if (ret)
217 goto err_gpio_free;
218
219 gpio_direction_input(gpio_wp);
220
221 /* When supported the trigger type have to be BOTH */
222 ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_ATA_DMACK), detect_irq,
223 IRQF_DISABLED | IRQF_TRIGGER_FALLING,
224 "sdhc-detect", data);
225
226 if (ret)
227 goto err_gpio_free_2;
228
229 return 0;
230
231err_gpio_free_2:
232 gpio_free(gpio_wp);
233
234err_gpio_free:
235 gpio_free(gpio_det);
236
237 return ret;
238
239}
240
241static void armadillo5x0_sdhc1_exit(struct device *dev, void *data)
242{
243 free_irq(IOMUX_TO_IRQ(MX31_PIN_ATA_DMACK), data);
244 gpio_free(IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK));
245 gpio_free(IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B));
246}
247
248static struct imxmmc_platform_data sdhc_pdata = {
249 .get_ro = armadillo5x0_sdhc1_get_ro,
250 .init = armadillo5x0_sdhc1_init,
251 .exit = armadillo5x0_sdhc1_exit,
252};
253
254/*
255 * SMSC 9118
256 * Network support
257 */
258static struct resource armadillo5x0_smc911x_resources[] = {
259 {
260 .start = CS3_BASE_ADDR,
261 .end = CS3_BASE_ADDR + SZ_32M - 1,
262 .flags = IORESOURCE_MEM,
263 }, {
264 .start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),
265 .end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_0),
266 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
267 },
268};
269
270static struct smsc911x_platform_config smsc911x_info = {
271 .flags = SMSC911X_USE_32BIT,
272 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
273 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
274};
275
276static struct platform_device armadillo5x0_smc911x_device = {
277 .name = "smsc911x",
278 .id = -1,
279 .num_resources = ARRAY_SIZE(armadillo5x0_smc911x_resources),
280 .resource = armadillo5x0_smc911x_resources,
281 .dev = {
282 .platform_data = &smsc911x_info,
283 },
284};
285
286/* UART device data */
287static struct imxuart_platform_data uart_pdata = {
288 .flags = IMXUART_HAVE_RTSCTS,
289};
290
291static struct platform_device *devices[] __initdata = {
292 &armadillo5x0_smc911x_device,
293};
294
295/*
296 * Perform board specific initializations
297 */
298static void __init armadillo5x0_init(void)
299{
300 mxc_iomux_setup_multiple_pins(armadillo5x0_pins,
301 ARRAY_SIZE(armadillo5x0_pins), "armadillo5x0");
302
303 platform_add_devices(devices, ARRAY_SIZE(devices));
304
305 /* Register UART */
306 mxc_register_device(&mxc_uart_device0, &uart_pdata);
307 mxc_register_device(&mxc_uart_device1, &uart_pdata);
308
309 /* SMSC9118 IRQ pin */
310 gpio_direction_input(MX31_PIN_GPIO1_0);
311
312 /* Register SDHC */
313 mxc_register_device(&mxcsdhc_device0, &sdhc_pdata);
314
315 /* Register FB */
316 mxc_register_device(&mx3_ipu, &mx3_ipu_data);
317 mxc_register_device(&mx3_fb, &mx3fb_pdata);
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +0200318
319 /* Register NOR Flash */
320 mxc_register_device(&armadillo5x0_nor_flash,
321 &armadillo5x0_nor_flash_pdata);
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200322}
323
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200324static void __init armadillo5x0_timer_init(void)
325{
326 mx31_clocks_init(26000000);
327}
328
329static struct sys_timer armadillo5x0_timer = {
330 .init = armadillo5x0_timer_init,
331};
332
333MACHINE_START(ARMADILLO5X0, "Armadillo-500")
334 /* Maintainer: Alberto Panizzo */
335 .phys_io = AIPS1_BASE_ADDR,
336 .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
337 .boot_params = PHYS_OFFSET + 0x00000100,
Alberto Panizzo4e0f0882009-05-25 22:35:38 +0200338 .map_io = mx31_map_io,
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200339 .init_irq = mxc_init_irq,
340 .timer = &armadillo5x0_timer,
341 .init_machine = armadillo5x0_init,
342MACHINE_END