eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 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> |
Eric Miao | 80796f2 | 2008-11-25 11:03:03 +0800 | [diff] [blame] | 23 | #include <linux/gpio.h> |
Eric Miao | 24ff4cd | 2008-09-01 06:56:07 +0800 | [diff] [blame] | 24 | #include <linux/spi/spi.h> |
Eric Miao | e1719da | 2008-06-24 16:49:41 +0800 | [diff] [blame] | 25 | #include <linux/smc91x.h> |
Eric Miao | 3b24f30 | 2008-12-10 17:04:38 +0800 | [diff] [blame] | 26 | #include <linux/i2c.h> |
| 27 | #include <linux/leds.h> |
| 28 | #include <linux/mfd/da903x.h> |
| 29 | #include <linux/i2c/max732x.h> |
eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 30 | |
| 31 | #include <asm/types.h> |
| 32 | #include <asm/setup.h> |
| 33 | #include <asm/memory.h> |
| 34 | #include <asm/mach-types.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 35 | #include <mach/hardware.h> |
eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 36 | #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 Miao | 51c6298 | 2009-01-02 23:17:22 +0800 | [diff] [blame] | 42 | #include <mach/pxa300.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 43 | #include <mach/pxafb.h> |
| 44 | #include <mach/ssp.h> |
Eric Miao | 24ff4cd | 2008-09-01 06:56:07 +0800 | [diff] [blame] | 45 | #include <mach/pxa2xx_spi.h> |
Eric Miao | 3b24f30 | 2008-12-10 17:04:38 +0800 | [diff] [blame] | 46 | #include <mach/i2c.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 47 | #include <mach/pxa27x_keypad.h> |
| 48 | #include <mach/pxa3xx_nand.h> |
| 49 | #include <mach/littleton.h> |
eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 50 | |
| 51 | #include "generic.h" |
| 52 | |
eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 53 | /* Littleton MFP configurations */ |
| 54 | static mfp_cfg_t littleton_mfp_cfg[] __initdata = { |
| 55 | /* LCD */ |
| 56 | GPIO54_LCD_LDD_0, |
| 57 | GPIO55_LCD_LDD_1, |
| 58 | GPIO56_LCD_LDD_2, |
| 59 | GPIO57_LCD_LDD_3, |
| 60 | GPIO58_LCD_LDD_4, |
| 61 | GPIO59_LCD_LDD_5, |
| 62 | GPIO60_LCD_LDD_6, |
| 63 | GPIO61_LCD_LDD_7, |
| 64 | GPIO62_LCD_LDD_8, |
| 65 | GPIO63_LCD_LDD_9, |
| 66 | GPIO64_LCD_LDD_10, |
| 67 | GPIO65_LCD_LDD_11, |
| 68 | GPIO66_LCD_LDD_12, |
| 69 | GPIO67_LCD_LDD_13, |
| 70 | GPIO68_LCD_LDD_14, |
| 71 | GPIO69_LCD_LDD_15, |
| 72 | GPIO70_LCD_LDD_16, |
| 73 | GPIO71_LCD_LDD_17, |
| 74 | GPIO72_LCD_FCLK, |
| 75 | GPIO73_LCD_LCLK, |
| 76 | GPIO74_LCD_PCLK, |
| 77 | GPIO75_LCD_BIAS, |
| 78 | |
| 79 | /* SSP2 */ |
| 80 | GPIO25_SSP2_SCLK, |
eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 81 | GPIO27_SSP2_TXD, |
Eric Miao | 24ff4cd | 2008-09-01 06:56:07 +0800 | [diff] [blame] | 82 | GPIO17_GPIO, /* SFRM as chip-select */ |
eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 83 | |
| 84 | /* Debug Ethernet */ |
| 85 | GPIO90_GPIO, |
eric miao | 5fa4151 | 2008-01-23 15:07:22 +0800 | [diff] [blame] | 86 | |
| 87 | /* Keypad */ |
| 88 | GPIO107_KP_DKIN_0, |
| 89 | GPIO108_KP_DKIN_1, |
| 90 | GPIO115_KP_MKIN_0, |
| 91 | GPIO116_KP_MKIN_1, |
| 92 | GPIO117_KP_MKIN_2, |
| 93 | GPIO118_KP_MKIN_3, |
| 94 | GPIO119_KP_MKIN_4, |
| 95 | GPIO120_KP_MKIN_5, |
| 96 | GPIO121_KP_MKOUT_0, |
| 97 | GPIO122_KP_MKOUT_1, |
| 98 | GPIO123_KP_MKOUT_2, |
| 99 | GPIO124_KP_MKOUT_3, |
| 100 | GPIO125_KP_MKOUT_4, |
eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | static struct resource smc91x_resources[] = { |
| 104 | [0] = { |
| 105 | .start = (LITTLETON_ETH_PHYS + 0x300), |
| 106 | .end = (LITTLETON_ETH_PHYS + 0xfffff), |
| 107 | .flags = IORESOURCE_MEM, |
| 108 | }, |
| 109 | [1] = { |
| 110 | .start = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO90)), |
| 111 | .end = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO90)), |
Eric Miao | 8a6e887 | 2008-06-02 13:30:24 +0800 | [diff] [blame] | 112 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE, |
eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 113 | } |
| 114 | }; |
| 115 | |
Eric Miao | e1719da | 2008-06-24 16:49:41 +0800 | [diff] [blame] | 116 | static struct smc91x_platdata littleton_smc91x_info = { |
| 117 | .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | |
| 118 | SMC91X_NOWAIT | SMC91X_USE_DMA, |
| 119 | }; |
| 120 | |
eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 121 | static struct platform_device smc91x_device = { |
| 122 | .name = "smc91x", |
| 123 | .id = 0, |
| 124 | .num_resources = ARRAY_SIZE(smc91x_resources), |
| 125 | .resource = smc91x_resources, |
Eric Miao | e1719da | 2008-06-24 16:49:41 +0800 | [diff] [blame] | 126 | .dev = { |
| 127 | .platform_data = &littleton_smc91x_info, |
| 128 | }, |
eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 129 | }; |
| 130 | |
Eric Miao | 36caeb4 | 2008-06-02 13:32:42 +0800 | [diff] [blame] | 131 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) |
eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 132 | static struct pxafb_mode_info tpo_tdo24mtea1_modes[] = { |
| 133 | [0] = { |
| 134 | /* VGA */ |
| 135 | .pixclock = 38250, |
| 136 | .xres = 480, |
| 137 | .yres = 640, |
| 138 | .bpp = 16, |
| 139 | .hsync_len = 8, |
| 140 | .left_margin = 8, |
| 141 | .right_margin = 24, |
| 142 | .vsync_len = 2, |
| 143 | .upper_margin = 2, |
| 144 | .lower_margin = 4, |
| 145 | .sync = 0, |
| 146 | }, |
| 147 | [1] = { |
| 148 | /* QVGA */ |
| 149 | .pixclock = 153000, |
| 150 | .xres = 240, |
| 151 | .yres = 320, |
| 152 | .bpp = 16, |
| 153 | .hsync_len = 8, |
| 154 | .left_margin = 8, |
| 155 | .right_margin = 88, |
| 156 | .vsync_len = 2, |
| 157 | .upper_margin = 2, |
| 158 | .lower_margin = 2, |
| 159 | .sync = 0, |
| 160 | }, |
| 161 | }; |
| 162 | |
| 163 | static struct pxafb_mach_info littleton_lcd_info = { |
| 164 | .modes = tpo_tdo24mtea1_modes, |
| 165 | .num_modes = 2, |
eric miao | 0454bd0 | 2008-04-30 00:52:23 -0700 | [diff] [blame] | 166 | .lcd_conn = LCD_COLOR_TFT_16BPP, |
eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 167 | }; |
| 168 | |
| 169 | static void littleton_init_lcd(void) |
| 170 | { |
| 171 | set_pxa_fb_info(&littleton_lcd_info); |
| 172 | } |
| 173 | #else |
| 174 | static inline void littleton_init_lcd(void) {}; |
Eric Miao | 36caeb4 | 2008-06-02 13:32:42 +0800 | [diff] [blame] | 175 | #endif /* CONFIG_FB_PXA || CONFIG_FB_PXA_MODULE */ |
eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 176 | |
Eric Miao | 24ff4cd | 2008-09-01 06:56:07 +0800 | [diff] [blame] | 177 | #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE) |
| 178 | static struct pxa2xx_spi_master littleton_spi_info = { |
| 179 | .num_chipselect = 1, |
| 180 | }; |
| 181 | |
| 182 | static void littleton_tdo24m_cs(u32 cmd) |
| 183 | { |
| 184 | gpio_set_value(LITTLETON_GPIO_LCD_CS, !(cmd == PXA2XX_CS_ASSERT)); |
| 185 | } |
| 186 | |
| 187 | static struct pxa2xx_spi_chip littleton_tdo24m_chip = { |
| 188 | .rx_threshold = 1, |
| 189 | .tx_threshold = 1, |
| 190 | .cs_control = littleton_tdo24m_cs, |
| 191 | }; |
| 192 | |
| 193 | static struct spi_board_info littleton_spi_devices[] __initdata = { |
| 194 | { |
| 195 | .modalias = "tdo24m", |
| 196 | .max_speed_hz = 1000000, |
| 197 | .bus_num = 2, |
| 198 | .chip_select = 0, |
| 199 | .controller_data= &littleton_tdo24m_chip, |
| 200 | }, |
| 201 | }; |
| 202 | |
| 203 | static void __init littleton_init_spi(void) |
| 204 | { |
| 205 | int err; |
| 206 | |
| 207 | err = gpio_request(LITTLETON_GPIO_LCD_CS, "LCD_CS"); |
| 208 | if (err) { |
| 209 | pr_warning("failed to request GPIO for LCS CS\n"); |
| 210 | return; |
| 211 | } |
| 212 | |
| 213 | gpio_direction_output(LITTLETON_GPIO_LCD_CS, 1); |
| 214 | |
| 215 | pxa2xx_set_spi_info(2, &littleton_spi_info); |
| 216 | spi_register_board_info(ARRAY_AND_SIZE(littleton_spi_devices)); |
| 217 | } |
| 218 | #else |
| 219 | static inline void littleton_init_spi(void) {} |
| 220 | #endif |
| 221 | |
Eric Miao | 36caeb4 | 2008-06-02 13:32:42 +0800 | [diff] [blame] | 222 | #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE) |
eric miao | 5fa4151 | 2008-01-23 15:07:22 +0800 | [diff] [blame] | 223 | static unsigned int littleton_matrix_key_map[] = { |
| 224 | /* KEY(row, col, key_code) */ |
| 225 | KEY(1, 3, KEY_0), KEY(0, 0, KEY_1), KEY(1, 0, KEY_2), KEY(2, 0, KEY_3), |
| 226 | KEY(0, 1, KEY_4), KEY(1, 1, KEY_5), KEY(2, 1, KEY_6), KEY(0, 2, KEY_7), |
| 227 | KEY(1, 2, KEY_8), KEY(2, 2, KEY_9), |
| 228 | |
| 229 | KEY(0, 3, KEY_KPASTERISK), /* * */ |
| 230 | KEY(2, 3, KEY_KPDOT), /* # */ |
| 231 | |
| 232 | KEY(5, 4, KEY_ENTER), |
| 233 | |
| 234 | KEY(5, 0, KEY_UP), |
| 235 | KEY(5, 1, KEY_DOWN), |
| 236 | KEY(5, 2, KEY_LEFT), |
| 237 | KEY(5, 3, KEY_RIGHT), |
| 238 | KEY(3, 2, KEY_HOME), |
| 239 | KEY(4, 1, KEY_END), |
| 240 | KEY(3, 3, KEY_BACK), |
| 241 | |
| 242 | KEY(4, 0, KEY_SEND), |
| 243 | KEY(4, 2, KEY_VOLUMEUP), |
| 244 | KEY(4, 3, KEY_VOLUMEDOWN), |
| 245 | |
| 246 | KEY(3, 0, KEY_F22), /* soft1 */ |
| 247 | KEY(3, 1, KEY_F23), /* soft2 */ |
| 248 | }; |
| 249 | |
| 250 | static struct pxa27x_keypad_platform_data littleton_keypad_info = { |
| 251 | .matrix_key_rows = 6, |
| 252 | .matrix_key_cols = 5, |
| 253 | .matrix_key_map = littleton_matrix_key_map, |
| 254 | .matrix_key_map_size = ARRAY_SIZE(littleton_matrix_key_map), |
| 255 | |
| 256 | .enable_rotary0 = 1, |
| 257 | .rotary0_up_key = KEY_UP, |
| 258 | .rotary0_down_key = KEY_DOWN, |
| 259 | |
| 260 | .debounce_interval = 30, |
| 261 | }; |
| 262 | static void __init littleton_init_keypad(void) |
| 263 | { |
| 264 | pxa_set_keypad_info(&littleton_keypad_info); |
| 265 | } |
| 266 | #else |
| 267 | static inline void littleton_init_keypad(void) {} |
| 268 | #endif |
| 269 | |
Eric Miao | 9c1db1a | 2008-06-02 15:42:14 +0800 | [diff] [blame] | 270 | #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE) |
| 271 | static struct mtd_partition littleton_nand_partitions[] = { |
| 272 | [0] = { |
| 273 | .name = "Bootloader", |
| 274 | .offset = 0, |
| 275 | .size = 0x060000, |
| 276 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 277 | }, |
| 278 | [1] = { |
| 279 | .name = "Kernel", |
| 280 | .offset = 0x060000, |
| 281 | .size = 0x200000, |
| 282 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 283 | }, |
| 284 | [2] = { |
| 285 | .name = "Filesystem", |
| 286 | .offset = 0x0260000, |
| 287 | .size = 0x3000000, /* 48M - rootfs */ |
| 288 | }, |
| 289 | [3] = { |
| 290 | .name = "MassStorage", |
| 291 | .offset = 0x3260000, |
| 292 | .size = 0x3d40000, |
| 293 | }, |
| 294 | [4] = { |
| 295 | .name = "BBT", |
| 296 | .offset = 0x6FA0000, |
| 297 | .size = 0x80000, |
| 298 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 299 | }, |
| 300 | /* NOTE: we reserve some blocks at the end of the NAND flash for |
| 301 | * bad block management, and the max number of relocation blocks |
| 302 | * differs on different platforms. Please take care with it when |
| 303 | * defining the partition table. |
| 304 | */ |
| 305 | }; |
| 306 | |
| 307 | static struct pxa3xx_nand_platform_data littleton_nand_info = { |
| 308 | .enable_arbiter = 1, |
| 309 | .parts = littleton_nand_partitions, |
| 310 | .nr_parts = ARRAY_SIZE(littleton_nand_partitions), |
| 311 | }; |
| 312 | |
| 313 | static void __init littleton_init_nand(void) |
| 314 | { |
| 315 | pxa3xx_set_nand_info(&littleton_nand_info); |
| 316 | } |
| 317 | #else |
| 318 | static inline void littleton_init_nand(void) {} |
| 319 | #endif /* CONFIG_MTD_NAND_PXA3xx || CONFIG_MTD_NAND_PXA3xx_MODULE */ |
| 320 | |
Eric Miao | 3b24f30 | 2008-12-10 17:04:38 +0800 | [diff] [blame] | 321 | #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE) |
| 322 | static struct led_info littleton_da9034_leds[] = { |
| 323 | [0] = { |
| 324 | .name = "littleton:keypad1", |
| 325 | .flags = DA9034_LED_RAMP, |
| 326 | }, |
| 327 | [1] = { |
| 328 | .name = "littleton:keypad2", |
| 329 | .flags = DA9034_LED_RAMP, |
| 330 | }, |
| 331 | [2] = { |
| 332 | .name = "littleton:vibra", |
| 333 | .flags = 0, |
| 334 | }, |
| 335 | }; |
| 336 | |
Eric Miao | fc76132 | 2009-04-13 11:06:49 +0800 | [diff] [blame] | 337 | static struct da9034_touch_pdata littleton_da9034_touch = { |
| 338 | .x_inverted = 1, |
| 339 | .interval_ms = 20, |
| 340 | }; |
| 341 | |
Eric Miao | 3b24f30 | 2008-12-10 17:04:38 +0800 | [diff] [blame] | 342 | static struct da903x_subdev_info littleton_da9034_subdevs[] = { |
| 343 | { |
| 344 | .name = "da903x-led", |
| 345 | .id = DA9034_ID_LED_1, |
| 346 | .platform_data = &littleton_da9034_leds[0], |
| 347 | }, { |
| 348 | .name = "da903x-led", |
| 349 | .id = DA9034_ID_LED_2, |
| 350 | .platform_data = &littleton_da9034_leds[1], |
| 351 | }, { |
| 352 | .name = "da903x-led", |
| 353 | .id = DA9034_ID_VIBRA, |
| 354 | .platform_data = &littleton_da9034_leds[2], |
| 355 | }, { |
| 356 | .name = "da903x-backlight", |
| 357 | .id = DA9034_ID_WLED, |
Eric Miao | fc76132 | 2009-04-13 11:06:49 +0800 | [diff] [blame] | 358 | }, { |
| 359 | .name = "da9034-touch", |
| 360 | .id = DA9034_ID_TOUCH, |
| 361 | .platform_data = &littleton_da9034_touch, |
Eric Miao | 3b24f30 | 2008-12-10 17:04:38 +0800 | [diff] [blame] | 362 | }, |
| 363 | }; |
| 364 | |
| 365 | static struct da903x_platform_data littleton_da9034_info = { |
| 366 | .num_subdevs = ARRAY_SIZE(littleton_da9034_subdevs), |
| 367 | .subdevs = littleton_da9034_subdevs, |
| 368 | }; |
| 369 | |
| 370 | static struct max732x_platform_data littleton_max7320_info = { |
| 371 | .gpio_base = EXT0_GPIO_BASE, |
| 372 | }; |
| 373 | |
| 374 | static struct i2c_board_info littleton_i2c_info[] = { |
| 375 | [0] = { |
| 376 | .type = "da9034", |
| 377 | .addr = 0x34, |
| 378 | .platform_data = &littleton_da9034_info, |
| 379 | .irq = gpio_to_irq(mfp_to_gpio(MFP_PIN_GPIO18)), |
| 380 | }, |
| 381 | [1] = { |
| 382 | .type = "max7320", |
| 383 | .addr = 0x50, |
| 384 | .platform_data = &littleton_max7320_info, |
| 385 | }, |
| 386 | }; |
| 387 | |
| 388 | static void __init littleton_init_i2c(void) |
| 389 | { |
| 390 | pxa_set_i2c_info(NULL); |
| 391 | i2c_register_board_info(0, ARRAY_AND_SIZE(littleton_i2c_info)); |
| 392 | } |
| 393 | #else |
| 394 | static inline void littleton_init_i2c(void) {} |
| 395 | #endif /* CONFIG_I2C_PXA || CONFIG_I2C_PXA_MODULE */ |
| 396 | |
eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 397 | static void __init littleton_init(void) |
| 398 | { |
| 399 | /* initialize MFP configurations */ |
| 400 | pxa3xx_mfp_config(ARRAY_AND_SIZE(littleton_mfp_cfg)); |
| 401 | |
| 402 | /* |
| 403 | * Note: we depend bootloader set the correct |
| 404 | * value to MSC register for SMC91x. |
| 405 | */ |
| 406 | platform_device_register(&smc91x_device); |
| 407 | |
Eric Miao | 24ff4cd | 2008-09-01 06:56:07 +0800 | [diff] [blame] | 408 | littleton_init_spi(); |
Eric Miao | 3b24f30 | 2008-12-10 17:04:38 +0800 | [diff] [blame] | 409 | littleton_init_i2c(); |
eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 410 | littleton_init_lcd(); |
eric miao | 5fa4151 | 2008-01-23 15:07:22 +0800 | [diff] [blame] | 411 | littleton_init_keypad(); |
Eric Miao | 9c1db1a | 2008-06-02 15:42:14 +0800 | [diff] [blame] | 412 | littleton_init_nand(); |
eric miao | e1d9b95 | 2007-12-13 10:41:43 +0800 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | MACHINE_START(LITTLETON, "Marvell Form Factor Development Platform (aka Littleton)") |
| 416 | .phys_io = 0x40000000, |
| 417 | .boot_params = 0xa0000100, |
| 418 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
| 419 | .map_io = pxa_map_io, |
| 420 | .init_irq = pxa3xx_init_irq, |
| 421 | .timer = &pxa_timer, |
| 422 | .init_machine = littleton_init, |
| 423 | MACHINE_END |