Merge branches 'metronomefb', 'pxa-cm2xx', 'pxa-gumstix', 'pxa-misc', 'pxa-mitac...
[linux-2.6] / arch / arm / mach-pxa / littleton.c
1 /*
2  *  linux/arch/arm/mach-pxa/littleton.c
3  *
4  *  Support for the Marvell Littleton Development Platform.
5  *
6  *  Author:     Jason Chagas (largely modified code)
7  *  Created:    Nov 20, 2006
8  *  Copyright:  (C) Copyright 2006 Marvell International Ltd.
9  *
10  *  2007-11-22  modified to align with latest kernel
11  *              eric miao <eric.miao@marvell.com>
12  *
13  *  This program is free software; you can redistribute it and/or modify
14  *  it under the terms of the GNU General Public License version 2 as
15  *  publishhed by the Free Software Foundation.
16  */
17
18 #include <linux/init.h>
19 #include <linux/interrupt.h>
20 #include <linux/delay.h>
21 #include <linux/platform_device.h>
22 #include <linux/clk.h>
23 #include <linux/spi/spi.h>
24 #include <linux/smc91x.h>
25
26 #include <asm/types.h>
27 #include <asm/setup.h>
28 #include <asm/memory.h>
29 #include <asm/mach-types.h>
30 #include <mach/hardware.h>
31 #include <asm/irq.h>
32
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
35 #include <asm/mach/irq.h>
36
37 #include <mach/pxa-regs.h>
38 #include <mach/mfp-pxa300.h>
39 #include <mach/gpio.h>
40 #include <mach/pxafb.h>
41 #include <mach/ssp.h>
42 #include <mach/pxa2xx_spi.h>
43 #include <mach/pxa27x_keypad.h>
44 #include <mach/pxa3xx_nand.h>
45 #include <mach/littleton.h>
46
47 #include "generic.h"
48
49 /* Littleton MFP configurations */
50 static mfp_cfg_t littleton_mfp_cfg[] __initdata = {
51         /* LCD */
52         GPIO54_LCD_LDD_0,
53         GPIO55_LCD_LDD_1,
54         GPIO56_LCD_LDD_2,
55         GPIO57_LCD_LDD_3,
56         GPIO58_LCD_LDD_4,
57         GPIO59_LCD_LDD_5,
58         GPIO60_LCD_LDD_6,
59         GPIO61_LCD_LDD_7,
60         GPIO62_LCD_LDD_8,
61         GPIO63_LCD_LDD_9,
62         GPIO64_LCD_LDD_10,
63         GPIO65_LCD_LDD_11,
64         GPIO66_LCD_LDD_12,
65         GPIO67_LCD_LDD_13,
66         GPIO68_LCD_LDD_14,
67         GPIO69_LCD_LDD_15,
68         GPIO70_LCD_LDD_16,
69         GPIO71_LCD_LDD_17,
70         GPIO72_LCD_FCLK,
71         GPIO73_LCD_LCLK,
72         GPIO74_LCD_PCLK,
73         GPIO75_LCD_BIAS,
74
75         /* SSP2 */
76         GPIO25_SSP2_SCLK,
77         GPIO27_SSP2_TXD,
78         GPIO17_GPIO,    /* SFRM as chip-select */
79
80         /* Debug Ethernet */
81         GPIO90_GPIO,
82
83         /* Keypad */
84         GPIO107_KP_DKIN_0,
85         GPIO108_KP_DKIN_1,
86         GPIO115_KP_MKIN_0,
87         GPIO116_KP_MKIN_1,
88         GPIO117_KP_MKIN_2,
89         GPIO118_KP_MKIN_3,
90         GPIO119_KP_MKIN_4,
91         GPIO120_KP_MKIN_5,
92         GPIO121_KP_MKOUT_0,
93         GPIO122_KP_MKOUT_1,
94         GPIO123_KP_MKOUT_2,
95         GPIO124_KP_MKOUT_3,
96         GPIO125_KP_MKOUT_4,
97 };
98
99 static struct resource smc91x_resources[] = {
100         [0] = {
101                 .start  = (LITTLETON_ETH_PHYS + 0x300),
102                 .end    = (LITTLETON_ETH_PHYS + 0xfffff),
103                 .flags  = IORESOURCE_MEM,
104         },
105         [1] = {
106                 .start  = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO90)),
107                 .end    = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO90)),
108                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
109         }
110 };
111
112 static struct smc91x_platdata littleton_smc91x_info = {
113         .flags  = SMC91X_USE_8BIT | SMC91X_USE_16BIT |
114                   SMC91X_NOWAIT | SMC91X_USE_DMA,
115 };
116
117 static struct platform_device smc91x_device = {
118         .name           = "smc91x",
119         .id             = 0,
120         .num_resources  = ARRAY_SIZE(smc91x_resources),
121         .resource       = smc91x_resources,
122         .dev            = {
123                 .platform_data = &littleton_smc91x_info,
124         },
125 };
126
127 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
128 static struct pxafb_mode_info tpo_tdo24mtea1_modes[] = {
129         [0] = {
130                 /* VGA */
131                 .pixclock       = 38250,
132                 .xres           = 480,
133                 .yres           = 640,
134                 .bpp            = 16,
135                 .hsync_len      = 8,
136                 .left_margin    = 8,
137                 .right_margin   = 24,
138                 .vsync_len      = 2,
139                 .upper_margin   = 2,
140                 .lower_margin   = 4,
141                 .sync           = 0,
142         },
143         [1] = {
144                 /* QVGA */
145                 .pixclock       = 153000,
146                 .xres           = 240,
147                 .yres           = 320,
148                 .bpp            = 16,
149                 .hsync_len      = 8,
150                 .left_margin    = 8,
151                 .right_margin   = 88,
152                 .vsync_len      = 2,
153                 .upper_margin   = 2,
154                 .lower_margin   = 2,
155                 .sync           = 0,
156         },
157 };
158
159 static struct pxafb_mach_info littleton_lcd_info = {
160         .modes                  = tpo_tdo24mtea1_modes,
161         .num_modes              = 2,
162         .lcd_conn               = LCD_COLOR_TFT_16BPP,
163 };
164
165 static void littleton_init_lcd(void)
166 {
167         set_pxa_fb_info(&littleton_lcd_info);
168 }
169 #else
170 static inline void littleton_init_lcd(void) {};
171 #endif /* CONFIG_FB_PXA || CONFIG_FB_PXA_MODULE */
172
173 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
174 static struct pxa2xx_spi_master littleton_spi_info = {
175         .num_chipselect         = 1,
176 };
177
178 static void littleton_tdo24m_cs(u32 cmd)
179 {
180         gpio_set_value(LITTLETON_GPIO_LCD_CS, !(cmd == PXA2XX_CS_ASSERT));
181 }
182
183 static struct pxa2xx_spi_chip littleton_tdo24m_chip = {
184         .rx_threshold   = 1,
185         .tx_threshold   = 1,
186         .cs_control     = littleton_tdo24m_cs,
187 };
188
189 static struct spi_board_info littleton_spi_devices[] __initdata = {
190         {
191                 .modalias       = "tdo24m",
192                 .max_speed_hz   = 1000000,
193                 .bus_num        = 2,
194                 .chip_select    = 0,
195                 .controller_data= &littleton_tdo24m_chip,
196         },
197 };
198
199 static void __init littleton_init_spi(void)
200 {
201         int err;
202
203         err = gpio_request(LITTLETON_GPIO_LCD_CS, "LCD_CS");
204         if (err) {
205                 pr_warning("failed to request GPIO for LCS CS\n");
206                 return;
207         }
208
209         gpio_direction_output(LITTLETON_GPIO_LCD_CS, 1);
210
211         pxa2xx_set_spi_info(2, &littleton_spi_info);
212         spi_register_board_info(ARRAY_AND_SIZE(littleton_spi_devices));
213 }
214 #else
215 static inline void littleton_init_spi(void) {}
216 #endif
217
218 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
219 static unsigned int littleton_matrix_key_map[] = {
220         /* KEY(row, col, key_code) */
221         KEY(1, 3, KEY_0), KEY(0, 0, KEY_1), KEY(1, 0, KEY_2), KEY(2, 0, KEY_3),
222         KEY(0, 1, KEY_4), KEY(1, 1, KEY_5), KEY(2, 1, KEY_6), KEY(0, 2, KEY_7),
223         KEY(1, 2, KEY_8), KEY(2, 2, KEY_9),
224
225         KEY(0, 3, KEY_KPASTERISK),      /* * */
226         KEY(2, 3, KEY_KPDOT),           /* # */
227
228         KEY(5, 4, KEY_ENTER),
229
230         KEY(5, 0, KEY_UP),
231         KEY(5, 1, KEY_DOWN),
232         KEY(5, 2, KEY_LEFT),
233         KEY(5, 3, KEY_RIGHT),
234         KEY(3, 2, KEY_HOME),
235         KEY(4, 1, KEY_END),
236         KEY(3, 3, KEY_BACK),
237
238         KEY(4, 0, KEY_SEND),
239         KEY(4, 2, KEY_VOLUMEUP),
240         KEY(4, 3, KEY_VOLUMEDOWN),
241
242         KEY(3, 0, KEY_F22),     /* soft1 */
243         KEY(3, 1, KEY_F23),     /* soft2 */
244 };
245
246 static struct pxa27x_keypad_platform_data littleton_keypad_info = {
247         .matrix_key_rows        = 6,
248         .matrix_key_cols        = 5,
249         .matrix_key_map         = littleton_matrix_key_map,
250         .matrix_key_map_size    = ARRAY_SIZE(littleton_matrix_key_map),
251
252         .enable_rotary0         = 1,
253         .rotary0_up_key         = KEY_UP,
254         .rotary0_down_key       = KEY_DOWN,
255
256         .debounce_interval      = 30,
257 };
258 static void __init littleton_init_keypad(void)
259 {
260         pxa_set_keypad_info(&littleton_keypad_info);
261 }
262 #else
263 static inline void littleton_init_keypad(void) {}
264 #endif
265
266 #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
267 static struct mtd_partition littleton_nand_partitions[] = {
268         [0] = {
269                 .name        = "Bootloader",
270                 .offset      = 0,
271                 .size        = 0x060000,
272                 .mask_flags  = MTD_WRITEABLE, /* force read-only */
273         },
274         [1] = {
275                 .name        = "Kernel",
276                 .offset      = 0x060000,
277                 .size        = 0x200000,
278                 .mask_flags  = MTD_WRITEABLE, /* force read-only */
279         },
280         [2] = {
281                 .name        = "Filesystem",
282                 .offset      = 0x0260000,
283                 .size        = 0x3000000,     /* 48M - rootfs */
284         },
285         [3] = {
286                 .name        = "MassStorage",
287                 .offset      = 0x3260000,
288                 .size        = 0x3d40000,
289         },
290         [4] = {
291                 .name        = "BBT",
292                 .offset      = 0x6FA0000,
293                 .size        = 0x80000,
294                 .mask_flags  = MTD_WRITEABLE,  /* force read-only */
295         },
296         /* NOTE: we reserve some blocks at the end of the NAND flash for
297          * bad block management, and the max number of relocation blocks
298          * differs on different platforms. Please take care with it when
299          * defining the partition table.
300          */
301 };
302
303 static struct pxa3xx_nand_platform_data littleton_nand_info = {
304         .enable_arbiter = 1,
305         .parts          = littleton_nand_partitions,
306         .nr_parts       = ARRAY_SIZE(littleton_nand_partitions),
307 };
308
309 static void __init littleton_init_nand(void)
310 {
311         pxa3xx_set_nand_info(&littleton_nand_info);
312 }
313 #else
314 static inline void littleton_init_nand(void) {}
315 #endif /* CONFIG_MTD_NAND_PXA3xx || CONFIG_MTD_NAND_PXA3xx_MODULE */
316
317 static void __init littleton_init(void)
318 {
319         /* initialize MFP configurations */
320         pxa3xx_mfp_config(ARRAY_AND_SIZE(littleton_mfp_cfg));
321
322         /*
323          * Note: we depend bootloader set the correct
324          * value to MSC register for SMC91x.
325          */
326         platform_device_register(&smc91x_device);
327
328         littleton_init_spi();
329         littleton_init_lcd();
330         littleton_init_keypad();
331         littleton_init_nand();
332 }
333
334 MACHINE_START(LITTLETON, "Marvell Form Factor Development Platform (aka Littleton)")
335         .phys_io        = 0x40000000,
336         .boot_params    = 0xa0000100,
337         .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
338         .map_io         = pxa_map_io,
339         .init_irq       = pxa3xx_init_irq,
340         .timer          = &pxa_timer,
341         .init_machine   = littleton_init,
342 MACHINE_END