Commit | Line | Data |
---|---|---|
6b91edde IC |
1 | /* |
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. | |
6b91edde IC |
15 | */ |
16 | ||
17 | #include <linux/platform_device.h> | |
18 | #include <linux/mtd/mtd.h> | |
19 | #include <linux/mtd/physmap.h> | |
20 | #include <linux/gpio.h> | |
21 | #include <mach/common.h> | |
22 | #include <mach/hardware.h> | |
23 | #include <asm/mach-types.h> | |
24 | #include <asm/mach/arch.h> | |
25 | #include <asm/mach/time.h> | |
26 | #include <asm/mach/map.h> | |
e835d88e | 27 | #include <mach/iomux-mx21.h> |
6b91edde IC |
28 | #include <mach/mxc_nand.h> |
29 | #include <mach/mmc.h> | |
6b91edde | 30 | |
1f8d721c | 31 | #include "devices-imx21.h" |
6b91edde IC |
32 | #include "devices.h" |
33 | ||
d393d43f UKK |
34 | /* |
35 | * Memory-mapped I/O on MX21ADS base board | |
36 | */ | |
37 | #define MX21ADS_MMIO_BASE_ADDR 0xf5000000 | |
38 | #define MX21ADS_MMIO_SIZE SZ_16M | |
39 | ||
40 | #define MX21ADS_REG_ADDR(offset) (void __force __iomem *) \ | |
41 | (MX21ADS_MMIO_BASE_ADDR + (offset)) | |
42 | ||
43 | #define MX21ADS_CS8900A_IRQ IRQ_GPIOE(11) | |
44 | #define MX21ADS_CS8900A_IOBASE_REG MX21ADS_REG_ADDR(0x000000) | |
45 | #define MX21ADS_ST16C255_IOBASE_REG MX21ADS_REG_ADDR(0x200000) | |
46 | #define MX21ADS_VERSION_REG MX21ADS_REG_ADDR(0x400000) | |
47 | #define MX21ADS_IO_REG MX21ADS_REG_ADDR(0x800000) | |
48 | ||
49 | /* MX21ADS_IO_REG bit definitions */ | |
50 | #define MX21ADS_IO_SD_WP 0x0001 /* read */ | |
51 | #define MX21ADS_IO_TP6 0x0001 /* write */ | |
52 | #define MX21ADS_IO_SW_SEL 0x0002 /* read */ | |
53 | #define MX21ADS_IO_TP7 0x0002 /* write */ | |
54 | #define MX21ADS_IO_RESET_E_UART 0x0004 | |
55 | #define MX21ADS_IO_RESET_BASE 0x0008 | |
56 | #define MX21ADS_IO_CSI_CTL2 0x0010 | |
57 | #define MX21ADS_IO_CSI_CTL1 0x0020 | |
58 | #define MX21ADS_IO_CSI_CTL0 0x0040 | |
59 | #define MX21ADS_IO_UART1_EN 0x0080 | |
60 | #define MX21ADS_IO_UART4_EN 0x0100 | |
61 | #define MX21ADS_IO_LCDON 0x0200 | |
62 | #define MX21ADS_IO_IRDA_EN 0x0400 | |
63 | #define MX21ADS_IO_IRDA_FIR_SEL 0x0800 | |
64 | #define MX21ADS_IO_IRDA_MD0_B 0x1000 | |
65 | #define MX21ADS_IO_IRDA_MD1 0x2000 | |
66 | #define MX21ADS_IO_LED4_ON 0x4000 | |
67 | #define MX21ADS_IO_LED3_ON 0x8000 | |
68 | ||
6c80ee51 | 69 | static const int mx21ads_pins[] __initconst = { |
6b91edde IC |
70 | |
71 | /* CS8900A */ | |
72 | (GPIO_PORTE | GPIO_GPIO | GPIO_IN | 11), | |
73 | ||
74 | /* UART1 */ | |
75 | PE12_PF_UART1_TXD, | |
76 | PE13_PF_UART1_RXD, | |
77 | PE14_PF_UART1_CTS, | |
78 | PE15_PF_UART1_RTS, | |
79 | ||
80 | /* UART3 (IrDA) - only TXD and RXD */ | |
81 | PE8_PF_UART3_TXD, | |
82 | PE9_PF_UART3_RXD, | |
83 | ||
84 | /* UART4 */ | |
85 | PB26_AF_UART4_RTS, | |
86 | PB28_AF_UART4_TXD, | |
87 | PB29_AF_UART4_CTS, | |
88 | PB31_AF_UART4_RXD, | |
89 | ||
90 | /* LCDC */ | |
91 | PA5_PF_LSCLK, | |
92 | PA6_PF_LD0, | |
93 | PA7_PF_LD1, | |
94 | PA8_PF_LD2, | |
95 | PA9_PF_LD3, | |
96 | PA10_PF_LD4, | |
97 | PA11_PF_LD5, | |
98 | PA12_PF_LD6, | |
99 | PA13_PF_LD7, | |
100 | PA14_PF_LD8, | |
101 | PA15_PF_LD9, | |
102 | PA16_PF_LD10, | |
103 | PA17_PF_LD11, | |
104 | PA18_PF_LD12, | |
105 | PA19_PF_LD13, | |
106 | PA20_PF_LD14, | |
107 | PA21_PF_LD15, | |
108 | PA22_PF_LD16, | |
109 | PA24_PF_REV, /* Sharp panel dedicated signal */ | |
110 | PA25_PF_CLS, /* Sharp panel dedicated signal */ | |
111 | PA26_PF_PS, /* Sharp panel dedicated signal */ | |
112 | PA27_PF_SPL_SPR, /* Sharp panel dedicated signal */ | |
113 | PA28_PF_HSYNC, | |
114 | PA29_PF_VSYNC, | |
115 | PA30_PF_CONTRAST, | |
116 | PA31_PF_OE_ACD, | |
117 | ||
118 | /* MMC/SDHC */ | |
119 | PE18_PF_SD1_D0, | |
120 | PE19_PF_SD1_D1, | |
121 | PE20_PF_SD1_D2, | |
122 | PE21_PF_SD1_D3, | |
123 | PE22_PF_SD1_CMD, | |
124 | PE23_PF_SD1_CLK, | |
125 | ||
126 | /* NFC */ | |
127 | PF0_PF_NRFB, | |
128 | PF1_PF_NFCE, | |
129 | PF2_PF_NFWP, | |
130 | PF3_PF_NFCLE, | |
131 | PF4_PF_NFALE, | |
132 | PF5_PF_NFRE, | |
133 | PF6_PF_NFWE, | |
134 | PF7_PF_NFIO0, | |
135 | PF8_PF_NFIO1, | |
136 | PF9_PF_NFIO2, | |
137 | PF10_PF_NFIO3, | |
138 | PF11_PF_NFIO4, | |
139 | PF12_PF_NFIO5, | |
140 | PF13_PF_NFIO6, | |
141 | PF14_PF_NFIO7, | |
142 | }; | |
143 | ||
144 | /* ADS's NOR flash: 2x AM29BDS128HE9VKI on 32-bit bus */ | |
145 | static struct physmap_flash_data mx21ads_flash_data = { | |
146 | .width = 4, | |
147 | }; | |
148 | ||
149 | static struct resource mx21ads_flash_resource = { | |
3f35d1f5 UKK |
150 | .start = MX21_CS0_BASE_ADDR, |
151 | .end = MX21_CS0_BASE_ADDR + 0x02000000 - 1, | |
6b91edde IC |
152 | .flags = IORESOURCE_MEM, |
153 | }; | |
154 | ||
155 | static struct platform_device mx21ads_nor_mtd_device = { | |
156 | .name = "physmap-flash", | |
157 | .id = 0, | |
158 | .dev = { | |
159 | .platform_data = &mx21ads_flash_data, | |
160 | }, | |
161 | .num_resources = 1, | |
162 | .resource = &mx21ads_flash_resource, | |
163 | }; | |
164 | ||
3c5227fd | 165 | static const struct imxuart_platform_data uart_pdata_rts __initconst = { |
6b91edde IC |
166 | .flags = IMXUART_HAVE_RTSCTS, |
167 | }; | |
168 | ||
3c5227fd | 169 | static const struct imxuart_platform_data uart_pdata_norts __initconst = { |
6b91edde IC |
170 | }; |
171 | ||
6b91edde IC |
172 | static int mx21ads_fb_init(struct platform_device *pdev) |
173 | { | |
174 | u16 tmp; | |
175 | ||
176 | tmp = __raw_readw(MX21ADS_IO_REG); | |
177 | tmp |= MX21ADS_IO_LCDON; | |
178 | __raw_writew(tmp, MX21ADS_IO_REG); | |
179 | return 0; | |
180 | } | |
181 | ||
182 | static void mx21ads_fb_exit(struct platform_device *pdev) | |
183 | { | |
184 | u16 tmp; | |
185 | ||
186 | tmp = __raw_readw(MX21ADS_IO_REG); | |
187 | tmp &= ~MX21ADS_IO_LCDON; | |
188 | __raw_writew(tmp, MX21ADS_IO_REG); | |
189 | } | |
190 | ||
191 | /* | |
192 | * Connected is a portrait Sharp-QVGA display | |
193 | * of type: LQ035Q7DB02 | |
194 | */ | |
c35d3a41 SH |
195 | static struct imx_fb_videomode mx21ads_modes[] = { |
196 | { | |
197 | .mode = { | |
198 | .name = "Sharp-LQ035Q7", | |
199 | .refresh = 60, | |
200 | .xres = 240, | |
201 | .yres = 320, | |
202 | .pixclock = 188679, /* in ps (5.3MHz) */ | |
203 | .hsync_len = 2, | |
204 | .left_margin = 6, | |
205 | .right_margin = 16, | |
206 | .vsync_len = 1, | |
207 | .upper_margin = 8, | |
208 | .lower_margin = 10, | |
209 | }, | |
210 | .pcr = 0xfb108bc7, | |
211 | .bpp = 16, | |
212 | }, | |
213 | }; | |
214 | ||
ad851bff | 215 | static const struct imx_fb_platform_data mx21ads_fb_data __initconst = { |
c35d3a41 SH |
216 | .mode = mx21ads_modes, |
217 | .num_modes = ARRAY_SIZE(mx21ads_modes), | |
218 | ||
219 | .pwmr = 0x00a903ff, | |
220 | .lscr1 = 0x00120300, | |
221 | .dmacr = 0x00020008, | |
6b91edde IC |
222 | |
223 | .init = mx21ads_fb_init, | |
224 | .exit = mx21ads_fb_exit, | |
225 | }; | |
226 | ||
227 | static int mx21ads_sdhc_get_ro(struct device *dev) | |
228 | { | |
229 | return (__raw_readw(MX21ADS_IO_REG) & MX21ADS_IO_SD_WP) ? 1 : 0; | |
230 | } | |
231 | ||
232 | static int mx21ads_sdhc_init(struct device *dev, irq_handler_t detect_irq, | |
233 | void *data) | |
234 | { | |
235 | int ret; | |
236 | ||
237 | ret = request_irq(IRQ_GPIOD(25), detect_irq, | |
238 | IRQF_TRIGGER_FALLING, "mmc-detect", data); | |
239 | if (ret) | |
240 | goto out; | |
241 | return 0; | |
242 | out: | |
243 | return ret; | |
244 | } | |
245 | ||
246 | static void mx21ads_sdhc_exit(struct device *dev, void *data) | |
247 | { | |
248 | free_irq(IRQ_GPIOD(25), data); | |
249 | } | |
250 | ||
251 | static struct imxmmc_platform_data mx21ads_sdhc_pdata = { | |
252 | .ocr_avail = MMC_VDD_29_30 | MMC_VDD_30_31, /* 3.0V */ | |
253 | .get_ro = mx21ads_sdhc_get_ro, | |
254 | .init = mx21ads_sdhc_init, | |
255 | .exit = mx21ads_sdhc_exit, | |
256 | }; | |
257 | ||
1f8d721c UKK |
258 | static const struct mxc_nand_platform_data |
259 | mx21ads_nand_board_info __initconst = { | |
6b91edde IC |
260 | .width = 1, |
261 | .hw_ecc = 1, | |
262 | }; | |
263 | ||
264 | static struct map_desc mx21ads_io_desc[] __initdata = { | |
265 | /* | |
266 | * Memory-mapped I/O on MX21ADS Base board: | |
267 | * - CS8900A Ethernet controller | |
268 | * - ST16C2552CJ UART | |
269 | * - CPU and Base board version | |
270 | * - Base board I/O register | |
271 | */ | |
272 | { | |
273 | .virtual = MX21ADS_MMIO_BASE_ADDR, | |
3f35d1f5 | 274 | .pfn = __phys_to_pfn(MX21_CS1_BASE_ADDR), |
6b91edde IC |
275 | .length = MX21ADS_MMIO_SIZE, |
276 | .type = MT_DEVICE, | |
277 | }, | |
278 | }; | |
279 | ||
280 | static void __init mx21ads_map_io(void) | |
281 | { | |
282 | mx21_map_io(); | |
283 | iotable_init(mx21ads_io_desc, ARRAY_SIZE(mx21ads_io_desc)); | |
284 | } | |
285 | ||
286 | static struct platform_device *platform_devices[] __initdata = { | |
287 | &mx21ads_nor_mtd_device, | |
288 | }; | |
289 | ||
290 | static void __init mx21ads_board_init(void) | |
291 | { | |
292 | mxc_gpio_setup_multiple_pins(mx21ads_pins, ARRAY_SIZE(mx21ads_pins), | |
293 | "mx21ads"); | |
294 | ||
3c5227fd UKK |
295 | imx21_add_imx_uart0(&uart_pdata_rts); |
296 | imx21_add_imx_uart2(&uart_pdata_norts); | |
297 | imx21_add_imx_uart3(&uart_pdata_rts); | |
ad851bff | 298 | imx21_add_imx_fb(&mx21ads_fb_data); |
6b91edde | 299 | mxc_register_device(&mxc_sdhc_device0, &mx21ads_sdhc_pdata); |
1f8d721c | 300 | imx21_add_mxc_nand(&mx21ads_nand_board_info); |
6b91edde IC |
301 | |
302 | platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); | |
303 | } | |
304 | ||
305 | static void __init mx21ads_timer_init(void) | |
306 | { | |
307 | mx21_clocks_init(32768, 26000000); | |
308 | } | |
309 | ||
310 | static struct sys_timer mx21ads_timer = { | |
311 | .init = mx21ads_timer_init, | |
312 | }; | |
313 | ||
314 | MACHINE_START(MX21ADS, "Freescale i.MX21ADS") | |
315 | /* maintainer: Freescale Semiconductor, Inc. */ | |
34101237 | 316 | .boot_params = MX21_PHYS_OFFSET + 0x100, |
6b91edde | 317 | .map_io = mx21ads_map_io, |
c5aa0ad0 | 318 | .init_irq = mx21_init_irq, |
6b91edde IC |
319 | .init_machine = mx21ads_board_init, |
320 | .timer = &mx21ads_timer, | |
321 | MACHINE_END |