blob: 87425949244a634c29cc6247a726377c7f73a185 [file] [log] [blame]
Ivo Clarysse6b91edd2009-04-15 15:39:27 +02001/*
2 * Copyright (C) 2000 Deep Blue Solutions Ltd
3 * Copyright (C) 2002 Shane Nay (shane@minirl.com)
4 * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Ivo Clarysse6b91edd2009-04-15 15:39:27 +020015 */
16
17#include <linux/platform_device.h>
18#include <linux/mtd/mtd.h>
19#include <linux/mtd/physmap.h>
Alexander Shiyan477fbf12014-03-03 22:37:44 +040020#include <linux/basic_mmio_gpio.h>
Ivo Clarysse6b91edd2009-04-15 15:39:27 +020021#include <linux/gpio.h>
Ivo Clarysse6b91edd2009-04-15 15:39:27 +020022#include <asm/mach-types.h>
23#include <asm/mach/arch.h>
24#include <asm/mach/time.h>
Ivo Clarysse6b91edd2009-04-15 15:39:27 +020025
Shawn Guoe3372472012-09-13 21:01:00 +080026#include "common.h"
Uwe Kleine-König1f8d7212010-06-16 11:17:45 +020027#include "devices-imx21.h"
Shawn Guo50f2de62012-09-14 14:14:45 +080028#include "hardware.h"
Shawn Guo267dd342012-09-13 13:26:00 +080029#include "iomux-mx21.h"
Ivo Clarysse6b91edd2009-04-15 15:39:27 +020030
Alexander Shiyan477fbf12014-03-03 22:37:44 +040031#define MX21ADS_CS8900A_REG (MX21_CS1_BASE_ADDR + 0x000000)
32#define MX21ADS_ST16C255_IOBASE_REG (MX21_CS1_BASE_ADDR + 0x200000)
33#define MX21ADS_VERSION_REG (MX21_CS1_BASE_ADDR + 0x400000)
34#define MX21ADS_IO_REG (MX21_CS1_BASE_ADDR + 0x800000)
Uwe Kleine-Königd393d432010-03-08 11:59:25 +010035
Alexander Shiyan477fbf12014-03-03 22:37:44 +040036#define MX21ADS_MMC_CD IMX_GPIO_NR(4, 25)
37#define MX21ADS_CS8900A_IRQ_GPIO IMX_GPIO_NR(5, 11)
38#define MX21ADS_MMGPIO_BASE (6 * 32)
Uwe Kleine-Königd393d432010-03-08 11:59:25 +010039
40/* MX21ADS_IO_REG bit definitions */
Alexander Shiyan477fbf12014-03-03 22:37:44 +040041#define MX21ADS_IO_SD_WP (MX21ADS_MMGPIO_BASE + 0)
42#define MX21ADS_IO_TP6 (MX21ADS_IO_SD_WP)
43#define MX21ADS_IO_SW_SEL (MX21ADS_MMGPIO_BASE + 1)
44#define MX21ADS_IO_TP7 (MX21ADS_IO_SW_SEL)
45#define MX21ADS_IO_RESET_E_UART (MX21ADS_MMGPIO_BASE + 2)
46#define MX21ADS_IO_RESET_BASE (MX21ADS_MMGPIO_BASE + 3)
47#define MX21ADS_IO_CSI_CTL2 (MX21ADS_MMGPIO_BASE + 4)
48#define MX21ADS_IO_CSI_CTL1 (MX21ADS_MMGPIO_BASE + 5)
49#define MX21ADS_IO_CSI_CTL0 (MX21ADS_MMGPIO_BASE + 6)
50#define MX21ADS_IO_UART1_EN (MX21ADS_MMGPIO_BASE + 7)
51#define MX21ADS_IO_UART4_EN (MX21ADS_MMGPIO_BASE + 8)
52#define MX21ADS_IO_LCDON (MX21ADS_MMGPIO_BASE + 9)
53#define MX21ADS_IO_IRDA_EN (MX21ADS_MMGPIO_BASE + 10)
54#define MX21ADS_IO_IRDA_FIR_SEL (MX21ADS_MMGPIO_BASE + 11)
55#define MX21ADS_IO_IRDA_MD0_B (MX21ADS_MMGPIO_BASE + 12)
56#define MX21ADS_IO_IRDA_MD1 (MX21ADS_MMGPIO_BASE + 13)
57#define MX21ADS_IO_LED4_ON (MX21ADS_MMGPIO_BASE + 14)
58#define MX21ADS_IO_LED3_ON (MX21ADS_MMGPIO_BASE + 15)
Uwe Kleine-Königd393d432010-03-08 11:59:25 +010059
Uwe Kleine-König6c80ee52010-09-28 21:53:31 +020060static const int mx21ads_pins[] __initconst = {
Ivo Clarysse6b91edd2009-04-15 15:39:27 +020061
62 /* CS8900A */
63 (GPIO_PORTE | GPIO_GPIO | GPIO_IN | 11),
64
65 /* UART1 */
66 PE12_PF_UART1_TXD,
67 PE13_PF_UART1_RXD,
68 PE14_PF_UART1_CTS,
69 PE15_PF_UART1_RTS,
70
71 /* UART3 (IrDA) - only TXD and RXD */
72 PE8_PF_UART3_TXD,
73 PE9_PF_UART3_RXD,
74
75 /* UART4 */
76 PB26_AF_UART4_RTS,
77 PB28_AF_UART4_TXD,
78 PB29_AF_UART4_CTS,
79 PB31_AF_UART4_RXD,
80
81 /* LCDC */
82 PA5_PF_LSCLK,
83 PA6_PF_LD0,
84 PA7_PF_LD1,
85 PA8_PF_LD2,
86 PA9_PF_LD3,
87 PA10_PF_LD4,
88 PA11_PF_LD5,
89 PA12_PF_LD6,
90 PA13_PF_LD7,
91 PA14_PF_LD8,
92 PA15_PF_LD9,
93 PA16_PF_LD10,
94 PA17_PF_LD11,
95 PA18_PF_LD12,
96 PA19_PF_LD13,
97 PA20_PF_LD14,
98 PA21_PF_LD15,
99 PA22_PF_LD16,
100 PA24_PF_REV, /* Sharp panel dedicated signal */
101 PA25_PF_CLS, /* Sharp panel dedicated signal */
102 PA26_PF_PS, /* Sharp panel dedicated signal */
103 PA27_PF_SPL_SPR, /* Sharp panel dedicated signal */
104 PA28_PF_HSYNC,
105 PA29_PF_VSYNC,
106 PA30_PF_CONTRAST,
107 PA31_PF_OE_ACD,
108
109 /* MMC/SDHC */
110 PE18_PF_SD1_D0,
111 PE19_PF_SD1_D1,
112 PE20_PF_SD1_D2,
113 PE21_PF_SD1_D3,
114 PE22_PF_SD1_CMD,
115 PE23_PF_SD1_CLK,
116
117 /* NFC */
118 PF0_PF_NRFB,
119 PF1_PF_NFCE,
120 PF2_PF_NFWP,
121 PF3_PF_NFCLE,
122 PF4_PF_NFALE,
123 PF5_PF_NFRE,
124 PF6_PF_NFWE,
125 PF7_PF_NFIO0,
126 PF8_PF_NFIO1,
127 PF9_PF_NFIO2,
128 PF10_PF_NFIO3,
129 PF11_PF_NFIO4,
130 PF12_PF_NFIO5,
131 PF13_PF_NFIO6,
132 PF14_PF_NFIO7,
133};
134
135/* ADS's NOR flash: 2x AM29BDS128HE9VKI on 32-bit bus */
136static struct physmap_flash_data mx21ads_flash_data = {
137 .width = 4,
138};
139
140static struct resource mx21ads_flash_resource = {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100141 .start = MX21_CS0_BASE_ADDR,
142 .end = MX21_CS0_BASE_ADDR + 0x02000000 - 1,
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200143 .flags = IORESOURCE_MEM,
144};
145
146static struct platform_device mx21ads_nor_mtd_device = {
147 .name = "physmap-flash",
148 .id = 0,
149 .dev = {
150 .platform_data = &mx21ads_flash_data,
151 },
152 .num_resources = 1,
153 .resource = &mx21ads_flash_resource,
154};
155
Shawn Guo438196c2011-12-05 10:12:28 +0800156static struct resource mx21ads_cs8900_resources[] __initdata = {
Alexander Shiyan477fbf12014-03-03 22:37:44 +0400157 DEFINE_RES_MEM(MX21_CS1_BASE_ADDR, SZ_1K),
Shawn Guo438196c2011-12-05 10:12:28 +0800158 /* irq number is run-time assigned */
159 DEFINE_RES_IRQ(-1),
Jaccon Bastiaansenc8c9e832012-01-26 21:46:57 +0100160};
161
162static const struct platform_device_info mx21ads_cs8900_devinfo __initconst = {
163 .name = "cs89x0",
164 .id = 0,
165 .res = mx21ads_cs8900_resources,
166 .num_res = ARRAY_SIZE(mx21ads_cs8900_resources),
167};
168
Uwe Kleine-König3c5227f2010-06-22 17:59:58 +0200169static const struct imxuart_platform_data uart_pdata_rts __initconst = {
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200170 .flags = IMXUART_HAVE_RTSCTS,
171};
172
Uwe Kleine-König3c5227f2010-06-22 17:59:58 +0200173static const struct imxuart_platform_data uart_pdata_norts __initconst = {
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200174};
175
Alexander Shiyan477fbf12014-03-03 22:37:44 +0400176static struct resource mx21ads_mmgpio_resource =
177 DEFINE_RES_MEM_NAMED(MX21ADS_IO_REG, SZ_2, "dat");
178
179static struct bgpio_pdata mx21ads_mmgpio_pdata = {
180 .base = MX21ADS_MMGPIO_BASE,
181 .ngpio = 16,
182};
183
184static struct platform_device mx21ads_mmgpio = {
185 .name = "basic-mmio-gpio",
186 .id = PLATFORM_DEVID_AUTO,
187 .resource = &mx21ads_mmgpio_resource,
188 .num_resources = 1,
189 .dev = {
190 .platform_data = &mx21ads_mmgpio_pdata,
191 },
192};
193
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200194static int mx21ads_fb_init(struct platform_device *pdev)
195{
Alexander Shiyan477fbf12014-03-03 22:37:44 +0400196 int ret;
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200197
Alexander Shiyan477fbf12014-03-03 22:37:44 +0400198 ret = gpio_request(MX21ADS_IO_LCDON, "fb-lcdon");
199 if (ret)
200 return ret;
201
202 return gpio_direction_output(MX21ADS_IO_LCDON, 1);
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200203}
204
205static void mx21ads_fb_exit(struct platform_device *pdev)
206{
Alexander Shiyan477fbf12014-03-03 22:37:44 +0400207 gpio_set_value(MX21ADS_IO_LCDON, 0);
208 gpio_free(MX21ADS_IO_LCDON);
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200209}
210
211/*
212 * Connected is a portrait Sharp-QVGA display
213 * of type: LQ035Q7DB02
214 */
Sascha Hauerc35d3a42009-08-13 10:04:44 +0200215static struct imx_fb_videomode mx21ads_modes[] = {
216 {
217 .mode = {
218 .name = "Sharp-LQ035Q7",
219 .refresh = 60,
220 .xres = 240,
221 .yres = 320,
222 .pixclock = 188679, /* in ps (5.3MHz) */
223 .hsync_len = 2,
224 .left_margin = 6,
225 .right_margin = 16,
226 .vsync_len = 1,
227 .upper_margin = 8,
228 .lower_margin = 10,
229 },
230 .pcr = 0xfb108bc7,
231 .bpp = 16,
232 },
233};
234
Uwe Kleine-Königad851bf2010-11-04 17:07:48 +0100235static const struct imx_fb_platform_data mx21ads_fb_data __initconst = {
Sascha Hauerc35d3a42009-08-13 10:04:44 +0200236 .mode = mx21ads_modes,
237 .num_modes = ARRAY_SIZE(mx21ads_modes),
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200238
Sascha Hauerc35d3a42009-08-13 10:04:44 +0200239 .pwmr = 0x00a903ff,
240 .lscr1 = 0x00120300,
241 .dmacr = 0x00020008,
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200242
243 .init = mx21ads_fb_init,
244 .exit = mx21ads_fb_exit,
245};
246
247static int mx21ads_sdhc_get_ro(struct device *dev)
248{
Alexander Shiyan477fbf12014-03-03 22:37:44 +0400249 return gpio_get_value(MX21ADS_IO_SD_WP);
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200250}
251
252static int mx21ads_sdhc_init(struct device *dev, irq_handler_t detect_irq,
253 void *data)
254{
Alexander Shiyan477fbf12014-03-03 22:37:44 +0400255 int ret;
256
257 ret = gpio_request(MX21ADS_IO_SD_WP, "mmc-ro");
258 if (ret)
259 return ret;
260
261 return request_irq(gpio_to_irq(MX21ADS_MMC_CD), detect_irq,
262 IRQF_TRIGGER_FALLING, "mmc-detect", data);
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200263}
264
265static void mx21ads_sdhc_exit(struct device *dev, void *data)
266{
Alexander Shiyan477fbf12014-03-03 22:37:44 +0400267 free_irq(gpio_to_irq(MX21ADS_MMC_CD), data);
268 gpio_free(MX21ADS_IO_SD_WP);
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200269}
270
Uwe Kleine-König9d3d9452010-11-05 17:26:09 +0100271static const struct imxmmc_platform_data mx21ads_sdhc_pdata __initconst = {
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200272 .ocr_avail = MMC_VDD_29_30 | MMC_VDD_30_31, /* 3.0V */
273 .get_ro = mx21ads_sdhc_get_ro,
274 .init = mx21ads_sdhc_init,
275 .exit = mx21ads_sdhc_exit,
276};
277
Uwe Kleine-König1f8d7212010-06-16 11:17:45 +0200278static const struct mxc_nand_platform_data
279mx21ads_nand_board_info __initconst = {
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200280 .width = 1,
281 .hw_ecc = 1,
282};
283
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200284static struct platform_device *platform_devices[] __initdata = {
Alexander Shiyan477fbf12014-03-03 22:37:44 +0400285 &mx21ads_mmgpio,
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200286 &mx21ads_nor_mtd_device,
287};
288
289static void __init mx21ads_board_init(void)
290{
Shawn Guob78d8e52011-06-06 00:07:55 +0800291 imx21_soc_init();
292
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200293 mxc_gpio_setup_multiple_pins(mx21ads_pins, ARRAY_SIZE(mx21ads_pins),
294 "mx21ads");
295
Uwe Kleine-König3c5227f2010-06-22 17:59:58 +0200296 imx21_add_imx_uart0(&uart_pdata_rts);
297 imx21_add_imx_uart2(&uart_pdata_norts);
298 imx21_add_imx_uart3(&uart_pdata_rts);
Uwe Kleine-Königad851bf2010-11-04 17:07:48 +0100299 imx21_add_imx_fb(&mx21ads_fb_data);
Uwe Kleine-König9d3d9452010-11-05 17:26:09 +0100300 imx21_add_mxc_mmc(0, &mx21ads_sdhc_pdata);
Uwe Kleine-König1f8d7212010-06-16 11:17:45 +0200301 imx21_add_mxc_nand(&mx21ads_nand_board_info);
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200302
303 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
Shawn Guo438196c2011-12-05 10:12:28 +0800304
305 mx21ads_cs8900_resources[1].start =
306 gpio_to_irq(MX21ADS_CS8900A_IRQ_GPIO);
307 mx21ads_cs8900_resources[1].end =
308 gpio_to_irq(MX21ADS_CS8900A_IRQ_GPIO);
Uwe Kleine-Königd5be0d72012-03-29 21:58:58 +0200309 platform_device_register_full(&mx21ads_cs8900_devinfo);
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200310}
311
312static void __init mx21ads_timer_init(void)
313{
314 mx21_clocks_init(32768, 26000000);
315}
316
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200317MACHINE_START(MX21ADS, "Freescale i.MX21ADS")
318 /* maintainer: Freescale Semiconductor, Inc. */
Nicolas Pitredc8f1902011-07-05 22:38:12 -0400319 .atag_offset = 0x100,
Alexander Shiyan477fbf12014-03-03 22:37:44 +0400320 .map_io = mx21_map_io,
Uwe Kleine-König3dac2192011-02-07 16:35:19 +0100321 .init_early = imx21_init_early,
322 .init_irq = mx21_init_irq,
Sascha Hauerffa2ea32011-09-20 14:31:24 +0200323 .handle_irq = imx21_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700324 .init_time = mx21ads_timer_init,
Uwe Kleine-König3dac2192011-02-07 16:35:19 +0100325 .init_machine = mx21ads_board_init,
Russell King65ea7882011-11-06 17:12:08 +0000326 .restart = mxc_restart,
Ivo Clarysse6b91edd2009-04-15 15:39:27 +0200327MACHINE_END