Merge branch 's3c24xx-updates' of git://git.fluff.org/bjdooks/linux
[sfrench/cifs-2.6.git] / arch / arm / mach-mx2 / mxt_td60.c
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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include <linux/platform_device.h>
22 #include <linux/mtd/mtd.h>
23 #include <linux/mtd/map.h>
24 #include <linux/mtd/partitions.h>
25 #include <linux/mtd/physmap.h>
26 #include <linux/i2c.h>
27 #include <linux/irq.h>
28 #include <mach/common.h>
29 #include <mach/hardware.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/time.h>
33 #include <asm/mach/map.h>
34 #include <linux/gpio.h>
35 #include <mach/imx-uart.h>
36 #include <mach/iomux.h>
37 #include <mach/mxc_nand.h>
38 #include <mach/i2c.h>
39 #include <linux/i2c/pca953x.h>
40 #include <mach/imxfb.h>
41 #include <mach/mmc.h>
42
43 #include "devices.h"
44
45 static unsigned int mxt_td60_pins[] __initdata = {
46         /* UART0 */
47         PE12_PF_UART1_TXD,
48         PE13_PF_UART1_RXD,
49         PE14_PF_UART1_CTS,
50         PE15_PF_UART1_RTS,
51         /* UART1 */
52         PE3_PF_UART2_CTS,
53         PE4_PF_UART2_RTS,
54         PE6_PF_UART2_TXD,
55         PE7_PF_UART2_RXD,
56         /* UART2 */
57         PE8_PF_UART3_TXD,
58         PE9_PF_UART3_RXD,
59         PE10_PF_UART3_CTS,
60         PE11_PF_UART3_RTS,
61         /* UART3 */
62         PB26_AF_UART4_RTS,
63         PB28_AF_UART4_TXD,
64         PB29_AF_UART4_CTS,
65         PB31_AF_UART4_RXD,
66         /* UART4 */
67         PB18_AF_UART5_TXD,
68         PB19_AF_UART5_RXD,
69         PB20_AF_UART5_CTS,
70         PB21_AF_UART5_RTS,
71         /* UART5 */
72         PB10_AF_UART6_TXD,
73         PB12_AF_UART6_CTS,
74         PB11_AF_UART6_RXD,
75         PB13_AF_UART6_RTS,
76         /* FEC */
77         PD0_AIN_FEC_TXD0,
78         PD1_AIN_FEC_TXD1,
79         PD2_AIN_FEC_TXD2,
80         PD3_AIN_FEC_TXD3,
81         PD4_AOUT_FEC_RX_ER,
82         PD5_AOUT_FEC_RXD1,
83         PD6_AOUT_FEC_RXD2,
84         PD7_AOUT_FEC_RXD3,
85         PD8_AF_FEC_MDIO,
86         PD9_AIN_FEC_MDC,
87         PD10_AOUT_FEC_CRS,
88         PD11_AOUT_FEC_TX_CLK,
89         PD12_AOUT_FEC_RXD0,
90         PD13_AOUT_FEC_RX_DV,
91         PD14_AOUT_FEC_RX_CLK,
92         PD15_AOUT_FEC_COL,
93         PD16_AIN_FEC_TX_ER,
94         PF23_AIN_FEC_TX_EN,
95         /* I2C1 */
96         PD17_PF_I2C_DATA,
97         PD18_PF_I2C_CLK,
98         /* I2C2 */
99         PC5_PF_I2C2_SDA,
100         PC6_PF_I2C2_SCL,
101         /* FB */
102         PA5_PF_LSCLK,
103         PA6_PF_LD0,
104         PA7_PF_LD1,
105         PA8_PF_LD2,
106         PA9_PF_LD3,
107         PA10_PF_LD4,
108         PA11_PF_LD5,
109         PA12_PF_LD6,
110         PA13_PF_LD7,
111         PA14_PF_LD8,
112         PA15_PF_LD9,
113         PA16_PF_LD10,
114         PA17_PF_LD11,
115         PA18_PF_LD12,
116         PA19_PF_LD13,
117         PA20_PF_LD14,
118         PA21_PF_LD15,
119         PA22_PF_LD16,
120         PA23_PF_LD17,
121         PA25_PF_CLS,
122         PA27_PF_SPL_SPR,
123         PA28_PF_HSYNC,
124         PA29_PF_VSYNC,
125         PA30_PF_CONTRAST,
126         PA31_PF_OE_ACD,
127         /* OWIRE */
128         PE16_AF_OWIRE,
129         /* SDHC1*/
130         PE18_PF_SD1_D0,
131         PE19_PF_SD1_D1,
132         PE20_PF_SD1_D2,
133         PE21_PF_SD1_D3,
134         PE22_PF_SD1_CMD,
135         PE23_PF_SD1_CLK,
136         PF8_AF_ATA_IORDY,
137         /* SDHC2*/
138         PB4_PF_SD2_D0,
139         PB5_PF_SD2_D1,
140         PB6_PF_SD2_D2,
141         PB7_PF_SD2_D3,
142         PB8_PF_SD2_CMD,
143         PB9_PF_SD2_CLK,
144 };
145
146 static struct mxc_nand_platform_data mxt_td60_nand_board_info = {
147         .width = 1,
148         .hw_ecc = 1,
149 };
150
151 static struct imxi2c_platform_data mxt_td60_i2c_data = {
152         .bitrate = 100000,
153 };
154
155 /* PCA9557 */
156 static int mxt_td60_pca9557_setup(struct i2c_client *client,
157                                 unsigned gpio_base, unsigned ngpio,
158                                 void *context)
159 {
160         static int mxt_td60_gpio_value[] = {
161                 -1, -1, -1, -1, -1, -1, -1, 1
162         };
163         int n;
164
165         for (n = 0; n < ARRAY_SIZE(mxt_td60_gpio_value); ++n) {
166                 gpio_request(gpio_base + n, "MXT_TD60 GPIO Exp");
167                 if (mxt_td60_gpio_value[n] < 0)
168                         gpio_direction_input(gpio_base + n);
169                 else
170                         gpio_direction_output(gpio_base + n,
171                                                 mxt_td60_gpio_value[n]);
172                 gpio_export(gpio_base + n, 0);
173         }
174
175         return 0;
176 }
177
178 static struct pca953x_platform_data mxt_td60_pca9557_pdata = {
179         .gpio_base      = 240, /* place PCA9557 after all MX27 gpio pins */
180         .invert         = 0, /* Do not invert */
181         .setup          = mxt_td60_pca9557_setup,
182 };
183
184 static struct i2c_board_info mxt_td60_i2c_devices[] = {
185         {
186                 I2C_BOARD_INFO("pca9557", 0x18),
187                 .platform_data = &mxt_td60_pca9557_pdata,
188         },
189 };
190
191 static struct imxi2c_platform_data mxt_td60_i2c2_data = {
192         .bitrate = 100000,
193 };
194
195 static struct i2c_board_info mxt_td60_i2c2_devices[] = {
196 };
197
198 static struct imx_fb_videomode mxt_td60_modes[] = {
199         {
200                 .mode = {
201                         .name           = "Chimei LW700AT9003",
202                         .refresh        = 60,
203                         .xres           = 800,
204                         .yres           = 480,
205                         .pixclock       = 30303,
206                         .hsync_len      = 64,
207                         .left_margin    = 0x67,
208                         .right_margin   = 0x68,
209                         .vsync_len      = 16,
210                         .upper_margin   = 0x0f,
211                         .lower_margin   = 0x0f,
212                 },
213                 .bpp            = 16,
214                 .pcr            = 0xFA208B83,
215         },
216 };
217
218 static struct imx_fb_platform_data mxt_td60_fb_data = {
219         .mode = mxt_td60_modes,
220         .num_modes = ARRAY_SIZE(mxt_td60_modes),
221
222         /*
223          * - HSYNC active high
224          * - VSYNC active high
225          * - clk notenabled while idle
226          * - clock inverted
227          * - data not inverted
228          * - data enable low active
229          * - enable sharp mode
230          */
231         .pwmr           = 0x00A903FF,
232         .lscr1          = 0x00120300,
233         .dmacr          = 0x00020010,
234 };
235
236 static int mxt_td60_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
237                                 void *data)
238 {
239         return request_irq(IRQ_GPIOF(8), detect_irq, IRQF_TRIGGER_FALLING,
240                                 "sdhc1-card-detect", data);
241 }
242
243 static void mxt_td60_sdhc1_exit(struct device *dev, void *data)
244 {
245         free_irq(IRQ_GPIOF(8), data);
246 }
247
248 static struct imxmmc_platform_data sdhc1_pdata = {
249         .init = mxt_td60_sdhc1_init,
250         .exit = mxt_td60_sdhc1_exit,
251 };
252
253 static struct platform_device *platform_devices[] __initdata = {
254         &mxc_fec_device,
255 };
256
257 static struct imxuart_platform_data uart_pdata[] = {
258         {
259                 .flags = IMXUART_HAVE_RTSCTS,
260         }, {
261                 .flags = IMXUART_HAVE_RTSCTS,
262         }, {
263                 .flags = IMXUART_HAVE_RTSCTS,
264         }, {
265                 .flags = IMXUART_HAVE_RTSCTS,
266         }, {
267                 .flags = IMXUART_HAVE_RTSCTS,
268         }, {
269                 .flags = IMXUART_HAVE_RTSCTS,
270         },
271 };
272
273 static void __init mxt_td60_board_init(void)
274 {
275         mxc_gpio_setup_multiple_pins(mxt_td60_pins, ARRAY_SIZE(mxt_td60_pins),
276                         "MXT_TD60");
277
278         mxc_register_device(&mxc_uart_device0, &uart_pdata[0]);
279         mxc_register_device(&mxc_uart_device1, &uart_pdata[1]);
280         mxc_register_device(&mxc_uart_device2, &uart_pdata[2]);
281         mxc_register_device(&mxc_uart_device3, &uart_pdata[3]);
282         mxc_register_device(&mxc_uart_device4, &uart_pdata[4]);
283         mxc_register_device(&mxc_uart_device5, &uart_pdata[5]);
284         mxc_register_device(&mxc_nand_device, &mxt_td60_nand_board_info);
285
286         i2c_register_board_info(0, mxt_td60_i2c_devices,
287                                 ARRAY_SIZE(mxt_td60_i2c_devices));
288
289         i2c_register_board_info(1, mxt_td60_i2c2_devices,
290                                 ARRAY_SIZE(mxt_td60_i2c2_devices));
291
292         mxc_register_device(&mxc_i2c_device0, &mxt_td60_i2c_data);
293         mxc_register_device(&mxc_i2c_device1, &mxt_td60_i2c2_data);
294         mxc_register_device(&mxc_fb_device, &mxt_td60_fb_data);
295         mxc_register_device(&mxc_sdhc_device0, &sdhc1_pdata);
296
297         platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
298 }
299
300 static void __init mxt_td60_timer_init(void)
301 {
302         mx27_clocks_init(26000000);
303 }
304
305 static struct sys_timer mxt_td60_timer = {
306         .init   = mxt_td60_timer_init,
307 };
308
309 MACHINE_START(MXT_TD60, "Maxtrack i-MXT TD60")
310         /* maintainer: Maxtrack Industrial */
311         .phys_io        = AIPI_BASE_ADDR,
312         .io_pg_offst    = ((AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
313         .boot_params    = PHYS_OFFSET + 0x100,
314         .map_io         = mx27_map_io,
315         .init_irq       = mx27_init_irq,
316         .init_machine   = mxt_td60_board_init,
317         .timer          = &mxt_td60_timer,
318 MACHINE_END
319