1/* 2 * linux/arch/arm/mach-pxa/zylonite.c 3 * 4 * Support for the PXA3xx Development Platform (aka Zylonite) 5 * 6 * Copyright (C) 2006 Marvell International Ltd. 7 * 8 * 2007-09-04: eric miao <eric.miao@marvell.com> 9 * rewrite to align with latest kernel 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License version 2 as 13 * published by the Free Software Foundation. 14 */ 15 16#include <linux/module.h> 17#include <linux/kernel.h> 18#include <linux/interrupt.h> 19#include <linux/init.h> 20#include <linux/platform_device.h> 21#include <linux/gpio.h> 22#include <linux/pwm.h> 23#include <linux/pwm_backlight.h> 24#include <linux/smc91x.h> 25 26#include <asm/mach-types.h> 27#include <asm/mach/arch.h> 28#include <mach/pxa3xx.h> 29#include <mach/audio.h> 30#include <linux/platform_data/video-pxafb.h> 31#include <mach/zylonite.h> 32#include <linux/platform_data/mmc-pxamci.h> 33#include <linux/platform_data/usb-ohci-pxa27x.h> 34#include <linux/platform_data/keypad-pxa27x.h> 35#include <linux/platform_data/mtd-nand-pxa3xx.h> 36 37#include "devices.h" 38#include "generic.h" 39 40int gpio_eth_irq; 41int gpio_debug_led1; 42int gpio_debug_led2; 43 44int wm9713_irq; 45 46int lcd_id; 47int lcd_orientation; 48 49struct platform_device pxa_device_wm9713_audio = { 50 .name = "wm9713-codec", 51 .id = -1, 52}; 53 54static void __init zylonite_init_wm9713_audio(void) 55{ 56 platform_device_register(&pxa_device_wm9713_audio); 57} 58 59static struct resource smc91x_resources[] = { 60 [0] = { 61 .start = ZYLONITE_ETH_PHYS + 0x300, 62 .end = ZYLONITE_ETH_PHYS + 0xfffff, 63 .flags = IORESOURCE_MEM, 64 }, 65 [1] = { 66 .start = -1, /* for run-time assignment */ 67 .end = -1, 68 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, 69 } 70}; 71 72static struct smc91x_platdata zylonite_smc91x_info = { 73 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | 74 SMC91X_NOWAIT | SMC91X_USE_DMA, 75}; 76 77static struct platform_device smc91x_device = { 78 .name = "smc91x", 79 .id = 0, 80 .num_resources = ARRAY_SIZE(smc91x_resources), 81 .resource = smc91x_resources, 82 .dev = { 83 .platform_data = &zylonite_smc91x_info, 84 }, 85}; 86 87#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) 88static struct gpio_led zylonite_debug_leds[] = { 89 [0] = { 90 .name = "zylonite:yellow:1", 91 .default_trigger = "heartbeat", 92 }, 93 [1] = { 94 .name = "zylonite:yellow:2", 95 .default_trigger = "default-on", 96 }, 97}; 98 99static struct gpio_led_platform_data zylonite_debug_leds_info = { 100 .leds = zylonite_debug_leds, 101 .num_leds = ARRAY_SIZE(zylonite_debug_leds), 102}; 103 104static struct platform_device zylonite_device_leds = { 105 .name = "leds-gpio", 106 .id = -1, 107 .dev = { 108 .platform_data = &zylonite_debug_leds_info, 109 } 110}; 111 112static void __init zylonite_init_leds(void) 113{ 114 zylonite_debug_leds[0].gpio = gpio_debug_led1; 115 zylonite_debug_leds[1].gpio = gpio_debug_led2; 116 117 platform_device_register(&zylonite_device_leds); 118} 119#else 120static inline void zylonite_init_leds(void) {} 121#endif 122 123#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) 124static struct pwm_lookup zylonite_pwm_lookup[] = { 125 PWM_LOOKUP("pxa27x-pwm.1", 1, "pwm-backlight.0", NULL, 10000, 126 PWM_POLARITY_NORMAL), 127}; 128 129static struct platform_pwm_backlight_data zylonite_backlight_data = { 130 .max_brightness = 100, 131 .dft_brightness = 100, 132 .enable_gpio = -1, 133}; 134 135static struct platform_device zylonite_backlight_device = { 136 .name = "pwm-backlight", 137 .dev = { 138 .parent = &pxa27x_device_pwm1.dev, 139 .platform_data = &zylonite_backlight_data, 140 }, 141}; 142 143static struct pxafb_mode_info toshiba_ltm035a776c_mode = { 144 .pixclock = 110000, 145 .xres = 240, 146 .yres = 320, 147 .bpp = 16, 148 .hsync_len = 4, 149 .left_margin = 6, 150 .right_margin = 4, 151 .vsync_len = 2, 152 .upper_margin = 2, 153 .lower_margin = 3, 154 .sync = FB_SYNC_VERT_HIGH_ACT, 155}; 156 157static struct pxafb_mode_info toshiba_ltm04c380k_mode = { 158 .pixclock = 50000, 159 .xres = 640, 160 .yres = 480, 161 .bpp = 16, 162 .hsync_len = 1, 163 .left_margin = 0x9f, 164 .right_margin = 1, 165 .vsync_len = 44, 166 .upper_margin = 0, 167 .lower_margin = 0, 168 .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, 169}; 170 171static struct pxafb_mach_info zylonite_toshiba_lcd_info = { 172 .num_modes = 1, 173 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, 174}; 175 176static struct pxafb_mode_info sharp_ls037_modes[] = { 177 [0] = { 178 .pixclock = 158000, 179 .xres = 240, 180 .yres = 320, 181 .bpp = 16, 182 .hsync_len = 4, 183 .left_margin = 39, 184 .right_margin = 39, 185 .vsync_len = 1, 186 .upper_margin = 2, 187 .lower_margin = 3, 188 .sync = 0, 189 }, 190 [1] = { 191 .pixclock = 39700, 192 .xres = 480, 193 .yres = 640, 194 .bpp = 16, 195 .hsync_len = 8, 196 .left_margin = 81, 197 .right_margin = 81, 198 .vsync_len = 1, 199 .upper_margin = 2, 200 .lower_margin = 7, 201 .sync = 0, 202 }, 203}; 204 205static struct pxafb_mach_info zylonite_sharp_lcd_info = { 206 .modes = sharp_ls037_modes, 207 .num_modes = 2, 208 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, 209}; 210 211static void __init zylonite_init_lcd(void) 212{ 213 pwm_add_table(zylonite_pwm_lookup, ARRAY_SIZE(zylonite_pwm_lookup)); 214 platform_device_register(&zylonite_backlight_device); 215 216 if (lcd_id & 0x20) { 217 pxa_set_fb_info(NULL, &zylonite_sharp_lcd_info); 218 return; 219 } 220 221 /* legacy LCD panels, it would be handy here if LCD panel type can 222 * be decided at run-time 223 */ 224 if (1) 225 zylonite_toshiba_lcd_info.modes = &toshiba_ltm035a776c_mode; 226 else 227 zylonite_toshiba_lcd_info.modes = &toshiba_ltm04c380k_mode; 228 229 pxa_set_fb_info(NULL, &zylonite_toshiba_lcd_info); 230} 231#else 232static inline void zylonite_init_lcd(void) {} 233#endif 234 235#if defined(CONFIG_MMC) 236static struct pxamci_platform_data zylonite_mci_platform_data = { 237 .detect_delay_ms= 200, 238 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 239 .gpio_card_detect = EXT_GPIO(0), 240 .gpio_card_ro = EXT_GPIO(2), 241 .gpio_power = -1, 242}; 243 244static struct pxamci_platform_data zylonite_mci2_platform_data = { 245 .detect_delay_ms= 200, 246 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 247 .gpio_card_detect = EXT_GPIO(1), 248 .gpio_card_ro = EXT_GPIO(3), 249 .gpio_power = -1, 250}; 251 252static struct pxamci_platform_data zylonite_mci3_platform_data = { 253 .detect_delay_ms= 200, 254 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 255 .gpio_card_detect = EXT_GPIO(30), 256 .gpio_card_ro = EXT_GPIO(31), 257 .gpio_power = -1, 258}; 259 260static void __init zylonite_init_mmc(void) 261{ 262 pxa_set_mci_info(&zylonite_mci_platform_data); 263 pxa3xx_set_mci2_info(&zylonite_mci2_platform_data); 264 if (cpu_is_pxa310()) 265 pxa3xx_set_mci3_info(&zylonite_mci3_platform_data); 266} 267#else 268static inline void zylonite_init_mmc(void) {} 269#endif 270 271#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE) 272static const unsigned int zylonite_matrix_key_map[] = { 273 /* KEY(row, col, key_code) */ 274 KEY(0, 0, KEY_A), KEY(0, 1, KEY_B), KEY(0, 2, KEY_C), KEY(0, 5, KEY_D), 275 KEY(1, 0, KEY_E), KEY(1, 1, KEY_F), KEY(1, 2, KEY_G), KEY(1, 5, KEY_H), 276 KEY(2, 0, KEY_I), KEY(2, 1, KEY_J), KEY(2, 2, KEY_K), KEY(2, 5, KEY_L), 277 KEY(3, 0, KEY_M), KEY(3, 1, KEY_N), KEY(3, 2, KEY_O), KEY(3, 5, KEY_P), 278 KEY(5, 0, KEY_Q), KEY(5, 1, KEY_R), KEY(5, 2, KEY_S), KEY(5, 5, KEY_T), 279 KEY(6, 0, KEY_U), KEY(6, 1, KEY_V), KEY(6, 2, KEY_W), KEY(6, 5, KEY_X), 280 KEY(7, 1, KEY_Y), KEY(7, 2, KEY_Z), 281 282 KEY(4, 4, KEY_0), KEY(1, 3, KEY_1), KEY(4, 1, KEY_2), KEY(1, 4, KEY_3), 283 KEY(2, 3, KEY_4), KEY(4, 2, KEY_5), KEY(2, 4, KEY_6), KEY(3, 3, KEY_7), 284 KEY(4, 3, KEY_8), KEY(3, 4, KEY_9), 285 286 KEY(4, 5, KEY_SPACE), 287 KEY(5, 3, KEY_KPASTERISK), /* * */ 288 KEY(5, 4, KEY_KPDOT), /* #" */ 289 290 KEY(0, 7, KEY_UP), 291 KEY(1, 7, KEY_DOWN), 292 KEY(2, 7, KEY_LEFT), 293 KEY(3, 7, KEY_RIGHT), 294 KEY(2, 6, KEY_HOME), 295 KEY(3, 6, KEY_END), 296 KEY(6, 4, KEY_DELETE), 297 KEY(6, 6, KEY_BACK), 298 KEY(6, 3, KEY_CAPSLOCK), /* KEY_LEFTSHIFT), */ 299 300 KEY(4, 6, KEY_ENTER), /* scroll push */ 301 KEY(5, 7, KEY_ENTER), /* keypad action */ 302 303 KEY(0, 4, KEY_EMAIL), 304 KEY(5, 6, KEY_SEND), 305 KEY(4, 0, KEY_CALENDAR), 306 KEY(7, 6, KEY_RECORD), 307 KEY(6, 7, KEY_VOLUMEUP), 308 KEY(7, 7, KEY_VOLUMEDOWN), 309 310 KEY(0, 6, KEY_F22), /* soft1 */ 311 KEY(1, 6, KEY_F23), /* soft2 */ 312 KEY(0, 3, KEY_AUX), /* contact */ 313}; 314 315static struct matrix_keymap_data zylonite_matrix_keymap_data = { 316 .keymap = zylonite_matrix_key_map, 317 .keymap_size = ARRAY_SIZE(zylonite_matrix_key_map), 318}; 319 320static struct pxa27x_keypad_platform_data zylonite_keypad_info = { 321 .matrix_key_rows = 8, 322 .matrix_key_cols = 8, 323 .matrix_keymap_data = &zylonite_matrix_keymap_data, 324 325 .enable_rotary0 = 1, 326 .rotary0_up_key = KEY_UP, 327 .rotary0_down_key = KEY_DOWN, 328 329 .debounce_interval = 30, 330}; 331 332static void __init zylonite_init_keypad(void) 333{ 334 pxa_set_keypad_info(&zylonite_keypad_info); 335} 336#else 337static inline void zylonite_init_keypad(void) {} 338#endif 339 340#if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE) 341static struct mtd_partition zylonite_nand_partitions[] = { 342 [0] = { 343 .name = "Bootloader", 344 .offset = 0, 345 .size = 0x060000, 346 .mask_flags = MTD_WRITEABLE, /* force read-only */ 347 }, 348 [1] = { 349 .name = "Kernel", 350 .offset = 0x060000, 351 .size = 0x200000, 352 .mask_flags = MTD_WRITEABLE, /* force read-only */ 353 }, 354 [2] = { 355 .name = "Filesystem", 356 .offset = 0x0260000, 357 .size = 0x3000000, /* 48M - rootfs */ 358 }, 359 [3] = { 360 .name = "MassStorage", 361 .offset = 0x3260000, 362 .size = 0x3d40000, 363 }, 364 [4] = { 365 .name = "BBT", 366 .offset = 0x6FA0000, 367 .size = 0x80000, 368 .mask_flags = MTD_WRITEABLE, /* force read-only */ 369 }, 370 /* NOTE: we reserve some blocks at the end of the NAND flash for 371 * bad block management, and the max number of relocation blocks 372 * differs on different platforms. Please take care with it when 373 * defining the partition table. 374 */ 375}; 376 377static struct pxa3xx_nand_platform_data zylonite_nand_info = { 378 .enable_arbiter = 1, 379 .num_cs = 1, 380 .parts[0] = zylonite_nand_partitions, 381 .nr_parts[0] = ARRAY_SIZE(zylonite_nand_partitions), 382}; 383 384static void __init zylonite_init_nand(void) 385{ 386 pxa3xx_set_nand_info(&zylonite_nand_info); 387} 388#else 389static inline void zylonite_init_nand(void) {} 390#endif /* CONFIG_MTD_NAND_PXA3xx || CONFIG_MTD_NAND_PXA3xx_MODULE */ 391 392#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 393static struct pxaohci_platform_data zylonite_ohci_info = { 394 .port_mode = PMM_PERPORT_MODE, 395 .flags = ENABLE_PORT1 | ENABLE_PORT2 | 396 POWER_CONTROL_LOW | POWER_SENSE_LOW, 397}; 398 399static void __init zylonite_init_ohci(void) 400{ 401 pxa_set_ohci_info(&zylonite_ohci_info); 402} 403#else 404static inline void zylonite_init_ohci(void) {} 405#endif /* CONFIG_USB_OHCI_HCD || CONFIG_USB_OHCI_HCD_MODULE */ 406 407static void __init zylonite_init(void) 408{ 409 pxa_set_ffuart_info(NULL); 410 pxa_set_btuart_info(NULL); 411 pxa_set_stuart_info(NULL); 412 413 /* board-processor specific initialization */ 414 zylonite_pxa300_init(); 415 zylonite_pxa320_init(); 416 417 /* 418 * Note: We depend that the bootloader set 419 * the correct value to MSC register for SMC91x. 420 */ 421 smc91x_resources[1].start = PXA_GPIO_TO_IRQ(gpio_eth_irq); 422 smc91x_resources[1].end = PXA_GPIO_TO_IRQ(gpio_eth_irq); 423 platform_device_register(&smc91x_device); 424 425 pxa_set_ac97_info(NULL); 426 zylonite_init_lcd(); 427 zylonite_init_mmc(); 428 zylonite_init_keypad(); 429 zylonite_init_nand(); 430 zylonite_init_leds(); 431 zylonite_init_ohci(); 432 zylonite_init_wm9713_audio(); 433} 434 435MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)") 436 .atag_offset = 0x100, 437 .map_io = pxa3xx_map_io, 438 .nr_irqs = ZYLONITE_NR_IRQS, 439 .init_irq = pxa3xx_init_irq, 440 .handle_irq = pxa3xx_handle_irq, 441 .init_time = pxa_timer_init, 442 .init_machine = zylonite_init, 443 .restart = pxa_restart, 444MACHINE_END 445