blob: 55b3788fd1ae9c8aa4cc8ec8d47e9ab1ad48a8e6 [file] [log] [blame]
eric miaoe1d9b952007-12-13 10:41:43 +08001/*
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>
Eric Miao80796f22008-11-25 11:03:03 +080023#include <linux/gpio.h>
Eric Miao24ff4cd2008-09-01 06:56:07 +080024#include <linux/spi/spi.h>
Eric Miaoe1719da2008-06-24 16:49:41 +080025#include <linux/smc91x.h>
Eric Miao3b24f302008-12-10 17:04:38 +080026#include <linux/i2c.h>
27#include <linux/leds.h>
28#include <linux/mfd/da903x.h>
29#include <linux/i2c/max732x.h>
eric miaoe1d9b952007-12-13 10:41:43 +080030
31#include <asm/types.h>
32#include <asm/setup.h>
33#include <asm/memory.h>
34#include <asm/mach-types.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010035#include <mach/hardware.h>
eric miaoe1d9b952007-12-13 10:41:43 +080036#include <asm/irq.h>
37
38#include <asm/mach/arch.h>
39#include <asm/mach/map.h>
40#include <asm/mach/irq.h>
41
Eric Miao51c62982009-01-02 23:17:22 +080042#include <mach/pxa300.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010043#include <mach/pxafb.h>
44#include <mach/ssp.h>
Eric Miao361778d2009-06-05 16:42:29 +080045#include <mach/mmc.h>
Eric Miao24ff4cd2008-09-01 06:56:07 +080046#include <mach/pxa2xx_spi.h>
Eric Miaof0a83702009-04-13 15:03:11 +080047#include <plat/i2c.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010048#include <mach/pxa27x_keypad.h>
49#include <mach/pxa3xx_nand.h>
50#include <mach/littleton.h>
eric miaoe1d9b952007-12-13 10:41:43 +080051
52#include "generic.h"
53
Eric Miao361778d2009-06-05 16:42:29 +080054#define GPIO_MMC1_CARD_DETECT mfp_to_gpio(MFP_PIN_GPIO15)
55
eric miaoe1d9b952007-12-13 10:41:43 +080056/* Littleton MFP configurations */
57static mfp_cfg_t littleton_mfp_cfg[] __initdata = {
58 /* LCD */
59 GPIO54_LCD_LDD_0,
60 GPIO55_LCD_LDD_1,
61 GPIO56_LCD_LDD_2,
62 GPIO57_LCD_LDD_3,
63 GPIO58_LCD_LDD_4,
64 GPIO59_LCD_LDD_5,
65 GPIO60_LCD_LDD_6,
66 GPIO61_LCD_LDD_7,
67 GPIO62_LCD_LDD_8,
68 GPIO63_LCD_LDD_9,
69 GPIO64_LCD_LDD_10,
70 GPIO65_LCD_LDD_11,
71 GPIO66_LCD_LDD_12,
72 GPIO67_LCD_LDD_13,
73 GPIO68_LCD_LDD_14,
74 GPIO69_LCD_LDD_15,
75 GPIO70_LCD_LDD_16,
76 GPIO71_LCD_LDD_17,
77 GPIO72_LCD_FCLK,
78 GPIO73_LCD_LCLK,
79 GPIO74_LCD_PCLK,
80 GPIO75_LCD_BIAS,
81
82 /* SSP2 */
83 GPIO25_SSP2_SCLK,
eric miaoe1d9b952007-12-13 10:41:43 +080084 GPIO27_SSP2_TXD,
Eric Miao24ff4cd2008-09-01 06:56:07 +080085 GPIO17_GPIO, /* SFRM as chip-select */
eric miaoe1d9b952007-12-13 10:41:43 +080086
87 /* Debug Ethernet */
88 GPIO90_GPIO,
eric miao5fa41512008-01-23 15:07:22 +080089
90 /* Keypad */
91 GPIO107_KP_DKIN_0,
92 GPIO108_KP_DKIN_1,
93 GPIO115_KP_MKIN_0,
94 GPIO116_KP_MKIN_1,
95 GPIO117_KP_MKIN_2,
96 GPIO118_KP_MKIN_3,
97 GPIO119_KP_MKIN_4,
98 GPIO120_KP_MKIN_5,
99 GPIO121_KP_MKOUT_0,
100 GPIO122_KP_MKOUT_1,
101 GPIO123_KP_MKOUT_2,
102 GPIO124_KP_MKOUT_3,
103 GPIO125_KP_MKOUT_4,
Eric Miao361778d2009-06-05 16:42:29 +0800104
105 /* MMC1 */
106 GPIO3_MMC1_DAT0,
107 GPIO4_MMC1_DAT1,
108 GPIO5_MMC1_DAT2,
109 GPIO6_MMC1_DAT3,
110 GPIO7_MMC1_CLK,
111 GPIO8_MMC1_CMD,
112 GPIO15_GPIO, /* card detect */
eric miaoe1d9b952007-12-13 10:41:43 +0800113};
114
115static struct resource smc91x_resources[] = {
116 [0] = {
117 .start = (LITTLETON_ETH_PHYS + 0x300),
118 .end = (LITTLETON_ETH_PHYS + 0xfffff),
119 .flags = IORESOURCE_MEM,
120 },
121 [1] = {
122 .start = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO90)),
123 .end = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO90)),
Eric Miao8a6e8872008-06-02 13:30:24 +0800124 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
eric miaoe1d9b952007-12-13 10:41:43 +0800125 }
126};
127
Eric Miaoe1719da2008-06-24 16:49:41 +0800128static struct smc91x_platdata littleton_smc91x_info = {
129 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT |
130 SMC91X_NOWAIT | SMC91X_USE_DMA,
131};
132
eric miaoe1d9b952007-12-13 10:41:43 +0800133static struct platform_device smc91x_device = {
134 .name = "smc91x",
135 .id = 0,
136 .num_resources = ARRAY_SIZE(smc91x_resources),
137 .resource = smc91x_resources,
Eric Miaoe1719da2008-06-24 16:49:41 +0800138 .dev = {
139 .platform_data = &littleton_smc91x_info,
140 },
eric miaoe1d9b952007-12-13 10:41:43 +0800141};
142
Eric Miao36caeb42008-06-02 13:32:42 +0800143#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
eric miaoe1d9b952007-12-13 10:41:43 +0800144static struct pxafb_mode_info tpo_tdo24mtea1_modes[] = {
145 [0] = {
146 /* VGA */
147 .pixclock = 38250,
148 .xres = 480,
149 .yres = 640,
150 .bpp = 16,
151 .hsync_len = 8,
152 .left_margin = 8,
153 .right_margin = 24,
154 .vsync_len = 2,
155 .upper_margin = 2,
156 .lower_margin = 4,
157 .sync = 0,
158 },
159 [1] = {
160 /* QVGA */
161 .pixclock = 153000,
162 .xres = 240,
163 .yres = 320,
164 .bpp = 16,
165 .hsync_len = 8,
166 .left_margin = 8,
167 .right_margin = 88,
168 .vsync_len = 2,
169 .upper_margin = 2,
170 .lower_margin = 2,
171 .sync = 0,
172 },
173};
174
175static struct pxafb_mach_info littleton_lcd_info = {
176 .modes = tpo_tdo24mtea1_modes,
177 .num_modes = 2,
eric miao0454bd02008-04-30 00:52:23 -0700178 .lcd_conn = LCD_COLOR_TFT_16BPP,
eric miaoe1d9b952007-12-13 10:41:43 +0800179};
180
181static void littleton_init_lcd(void)
182{
183 set_pxa_fb_info(&littleton_lcd_info);
184}
185#else
186static inline void littleton_init_lcd(void) {};
Eric Miao36caeb42008-06-02 13:32:42 +0800187#endif /* CONFIG_FB_PXA || CONFIG_FB_PXA_MODULE */
eric miaoe1d9b952007-12-13 10:41:43 +0800188
Eric Miao24ff4cd2008-09-01 06:56:07 +0800189#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
190static struct pxa2xx_spi_master littleton_spi_info = {
191 .num_chipselect = 1,
192};
193
Eric Miao24ff4cd2008-09-01 06:56:07 +0800194static struct pxa2xx_spi_chip littleton_tdo24m_chip = {
195 .rx_threshold = 1,
196 .tx_threshold = 1,
Mike Rapoport46580c02009-04-14 08:33:49 +0300197 .gpio_cs = LITTLETON_GPIO_LCD_CS,
Eric Miao24ff4cd2008-09-01 06:56:07 +0800198};
199
200static struct spi_board_info littleton_spi_devices[] __initdata = {
201 {
202 .modalias = "tdo24m",
203 .max_speed_hz = 1000000,
204 .bus_num = 2,
205 .chip_select = 0,
206 .controller_data= &littleton_tdo24m_chip,
207 },
208};
209
210static void __init littleton_init_spi(void)
211{
Eric Miao24ff4cd2008-09-01 06:56:07 +0800212 pxa2xx_set_spi_info(2, &littleton_spi_info);
213 spi_register_board_info(ARRAY_AND_SIZE(littleton_spi_devices));
214}
215#else
216static inline void littleton_init_spi(void) {}
217#endif
218
Eric Miao36caeb42008-06-02 13:32:42 +0800219#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
eric miao5fa41512008-01-23 15:07:22 +0800220static unsigned int littleton_matrix_key_map[] = {
221 /* KEY(row, col, key_code) */
222 KEY(1, 3, KEY_0), KEY(0, 0, KEY_1), KEY(1, 0, KEY_2), KEY(2, 0, KEY_3),
223 KEY(0, 1, KEY_4), KEY(1, 1, KEY_5), KEY(2, 1, KEY_6), KEY(0, 2, KEY_7),
224 KEY(1, 2, KEY_8), KEY(2, 2, KEY_9),
225
226 KEY(0, 3, KEY_KPASTERISK), /* * */
227 KEY(2, 3, KEY_KPDOT), /* # */
228
229 KEY(5, 4, KEY_ENTER),
230
231 KEY(5, 0, KEY_UP),
232 KEY(5, 1, KEY_DOWN),
233 KEY(5, 2, KEY_LEFT),
234 KEY(5, 3, KEY_RIGHT),
235 KEY(3, 2, KEY_HOME),
236 KEY(4, 1, KEY_END),
237 KEY(3, 3, KEY_BACK),
238
239 KEY(4, 0, KEY_SEND),
240 KEY(4, 2, KEY_VOLUMEUP),
241 KEY(4, 3, KEY_VOLUMEDOWN),
242
243 KEY(3, 0, KEY_F22), /* soft1 */
244 KEY(3, 1, KEY_F23), /* soft2 */
245};
246
247static struct pxa27x_keypad_platform_data littleton_keypad_info = {
248 .matrix_key_rows = 6,
249 .matrix_key_cols = 5,
250 .matrix_key_map = littleton_matrix_key_map,
251 .matrix_key_map_size = ARRAY_SIZE(littleton_matrix_key_map),
252
253 .enable_rotary0 = 1,
254 .rotary0_up_key = KEY_UP,
255 .rotary0_down_key = KEY_DOWN,
256
257 .debounce_interval = 30,
258};
259static void __init littleton_init_keypad(void)
260{
261 pxa_set_keypad_info(&littleton_keypad_info);
262}
263#else
264static inline void littleton_init_keypad(void) {}
265#endif
266
Eric Miao361778d2009-06-05 16:42:29 +0800267#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
268static int littleton_mci_init(struct device *dev,
269 irq_handler_t littleton_detect_int, void *data)
270{
271 int err, gpio_cd = GPIO_MMC1_CARD_DETECT;
272
273 err = gpio_request(gpio_cd, "mmc card detect");
274 if (err)
275 goto err_request_cd;
276
277 gpio_direction_input(gpio_cd);
278
279 err = request_irq(gpio_to_irq(gpio_cd), littleton_detect_int,
280 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
281 "mmc card detect", data);
282 if (err) {
283 dev_err(dev, "failed to request card detect IRQ\n");
284 goto err_request_irq;
285 }
286 return 0;
287
288err_request_irq:
289 gpio_free(gpio_cd);
290err_request_cd:
291 return err;
292}
293
294static void littleton_mci_exit(struct device *dev, void *data)
295{
296 int gpio_cd = GPIO_MMC1_CARD_DETECT;
297
298 free_irq(gpio_to_irq(gpio_cd), data);
299 gpio_free(gpio_cd);
300}
301
302static struct pxamci_platform_data littleton_mci_platform_data = {
303 .detect_delay = 20,
304 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
305 .init = littleton_mci_init,
306 .exit = littleton_mci_exit,
307};
308
309static void __init littleton_init_mmc(void)
310{
311 pxa_set_mci_info(&littleton_mci_platform_data);
312}
313#else
314static inline void littleton_init_mmc(void) {}
315#endif
316
Eric Miao9c1db1a2008-06-02 15:42:14 +0800317#if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
318static struct mtd_partition littleton_nand_partitions[] = {
319 [0] = {
320 .name = "Bootloader",
321 .offset = 0,
322 .size = 0x060000,
323 .mask_flags = MTD_WRITEABLE, /* force read-only */
324 },
325 [1] = {
326 .name = "Kernel",
327 .offset = 0x060000,
328 .size = 0x200000,
329 .mask_flags = MTD_WRITEABLE, /* force read-only */
330 },
331 [2] = {
332 .name = "Filesystem",
333 .offset = 0x0260000,
334 .size = 0x3000000, /* 48M - rootfs */
335 },
336 [3] = {
337 .name = "MassStorage",
338 .offset = 0x3260000,
339 .size = 0x3d40000,
340 },
341 [4] = {
342 .name = "BBT",
343 .offset = 0x6FA0000,
344 .size = 0x80000,
345 .mask_flags = MTD_WRITEABLE, /* force read-only */
346 },
347 /* NOTE: we reserve some blocks at the end of the NAND flash for
348 * bad block management, and the max number of relocation blocks
349 * differs on different platforms. Please take care with it when
350 * defining the partition table.
351 */
352};
353
354static struct pxa3xx_nand_platform_data littleton_nand_info = {
355 .enable_arbiter = 1,
356 .parts = littleton_nand_partitions,
357 .nr_parts = ARRAY_SIZE(littleton_nand_partitions),
358};
359
360static void __init littleton_init_nand(void)
361{
362 pxa3xx_set_nand_info(&littleton_nand_info);
363}
364#else
365static inline void littleton_init_nand(void) {}
366#endif /* CONFIG_MTD_NAND_PXA3xx || CONFIG_MTD_NAND_PXA3xx_MODULE */
367
Eric Miao3b24f302008-12-10 17:04:38 +0800368#if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
369static struct led_info littleton_da9034_leds[] = {
370 [0] = {
371 .name = "littleton:keypad1",
372 .flags = DA9034_LED_RAMP,
373 },
374 [1] = {
375 .name = "littleton:keypad2",
376 .flags = DA9034_LED_RAMP,
377 },
378 [2] = {
379 .name = "littleton:vibra",
380 .flags = 0,
381 },
382};
383
Eric Miaofc761322009-04-13 11:06:49 +0800384static struct da9034_touch_pdata littleton_da9034_touch = {
385 .x_inverted = 1,
386 .interval_ms = 20,
387};
388
Eric Miao3b24f302008-12-10 17:04:38 +0800389static struct da903x_subdev_info littleton_da9034_subdevs[] = {
390 {
391 .name = "da903x-led",
392 .id = DA9034_ID_LED_1,
393 .platform_data = &littleton_da9034_leds[0],
394 }, {
395 .name = "da903x-led",
396 .id = DA9034_ID_LED_2,
397 .platform_data = &littleton_da9034_leds[1],
398 }, {
399 .name = "da903x-led",
400 .id = DA9034_ID_VIBRA,
401 .platform_data = &littleton_da9034_leds[2],
402 }, {
403 .name = "da903x-backlight",
404 .id = DA9034_ID_WLED,
Eric Miaofc761322009-04-13 11:06:49 +0800405 }, {
406 .name = "da9034-touch",
407 .id = DA9034_ID_TOUCH,
408 .platform_data = &littleton_da9034_touch,
Eric Miao3b24f302008-12-10 17:04:38 +0800409 },
410};
411
412static struct da903x_platform_data littleton_da9034_info = {
413 .num_subdevs = ARRAY_SIZE(littleton_da9034_subdevs),
414 .subdevs = littleton_da9034_subdevs,
415};
416
417static struct max732x_platform_data littleton_max7320_info = {
418 .gpio_base = EXT0_GPIO_BASE,
419};
420
421static struct i2c_board_info littleton_i2c_info[] = {
422 [0] = {
423 .type = "da9034",
424 .addr = 0x34,
425 .platform_data = &littleton_da9034_info,
426 .irq = gpio_to_irq(mfp_to_gpio(MFP_PIN_GPIO18)),
427 },
428 [1] = {
429 .type = "max7320",
430 .addr = 0x50,
431 .platform_data = &littleton_max7320_info,
432 },
433};
434
435static void __init littleton_init_i2c(void)
436{
437 pxa_set_i2c_info(NULL);
438 i2c_register_board_info(0, ARRAY_AND_SIZE(littleton_i2c_info));
439}
440#else
441static inline void littleton_init_i2c(void) {}
442#endif /* CONFIG_I2C_PXA || CONFIG_I2C_PXA_MODULE */
443
eric miaoe1d9b952007-12-13 10:41:43 +0800444static void __init littleton_init(void)
445{
446 /* initialize MFP configurations */
447 pxa3xx_mfp_config(ARRAY_AND_SIZE(littleton_mfp_cfg));
448
449 /*
450 * Note: we depend bootloader set the correct
451 * value to MSC register for SMC91x.
452 */
453 platform_device_register(&smc91x_device);
454
Eric Miao24ff4cd2008-09-01 06:56:07 +0800455 littleton_init_spi();
Eric Miao3b24f302008-12-10 17:04:38 +0800456 littleton_init_i2c();
Eric Miao361778d2009-06-05 16:42:29 +0800457 littleton_init_mmc();
eric miaoe1d9b952007-12-13 10:41:43 +0800458 littleton_init_lcd();
eric miao5fa41512008-01-23 15:07:22 +0800459 littleton_init_keypad();
Eric Miao9c1db1a2008-06-02 15:42:14 +0800460 littleton_init_nand();
eric miaoe1d9b952007-12-13 10:41:43 +0800461}
462
463MACHINE_START(LITTLETON, "Marvell Form Factor Development Platform (aka Littleton)")
464 .phys_io = 0x40000000,
465 .boot_params = 0xa0000100,
466 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
467 .map_io = pxa_map_io,
468 .init_irq = pxa3xx_init_irq,
469 .timer = &pxa_timer,
470 .init_machine = littleton_init,
471MACHINE_END