Marek | 543cd84 | 2010-03-09 04:04:12 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Hardware definitions for Voipac PXA270 |
| 3 | * |
| 4 | * Copyright (C) 2010 |
| 5 | * Marek Vasut <marek.vasut@gmail.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | #include <linux/platform_device.h> |
| 14 | #include <linux/delay.h> |
| 15 | #include <linux/irq.h> |
| 16 | #include <linux/gpio_keys.h> |
| 17 | #include <linux/input.h> |
| 18 | #include <linux/gpio.h> |
| 19 | #include <linux/sysdev.h> |
Marek Vasut | 3d98f88 | 2010-03-10 05:24:27 +0100 | [diff] [blame^] | 20 | #include <linux/usb/gpio_vbus.h> |
Marek | 543cd84 | 2010-03-09 04:04:12 +0100 | [diff] [blame] | 21 | #include <linux/mtd/mtd.h> |
| 22 | #include <linux/mtd/partitions.h> |
| 23 | #include <linux/mtd/physmap.h> |
| 24 | |
| 25 | #include <asm/mach-types.h> |
| 26 | #include <asm/mach/arch.h> |
| 27 | |
| 28 | #include <mach/pxa27x.h> |
| 29 | #include <mach/vpac270.h> |
| 30 | #include <mach/mmc.h> |
| 31 | #include <mach/pxafb.h> |
Marek Vasut | 3d98f88 | 2010-03-10 05:24:27 +0100 | [diff] [blame^] | 32 | #include <mach/ohci.h> |
| 33 | #include <mach/pxa27x-udc.h> |
| 34 | #include <mach/udc.h> |
Marek | 543cd84 | 2010-03-09 04:04:12 +0100 | [diff] [blame] | 35 | |
| 36 | #include "generic.h" |
| 37 | #include "devices.h" |
| 38 | |
| 39 | /****************************************************************************** |
| 40 | * Pin configuration |
| 41 | ******************************************************************************/ |
| 42 | static unsigned long vpac270_pin_config[] __initdata = { |
| 43 | /* MMC */ |
| 44 | GPIO32_MMC_CLK, |
| 45 | GPIO92_MMC_DAT_0, |
| 46 | GPIO109_MMC_DAT_1, |
| 47 | GPIO110_MMC_DAT_2, |
| 48 | GPIO111_MMC_DAT_3, |
| 49 | GPIO112_MMC_CMD, |
| 50 | GPIO53_GPIO, /* SD detect */ |
| 51 | GPIO52_GPIO, /* SD r/o switch */ |
| 52 | |
| 53 | /* GPIO KEYS */ |
| 54 | GPIO1_GPIO, /* USER BTN */ |
| 55 | |
| 56 | /* LEDs */ |
| 57 | GPIO15_GPIO, /* orange led */ |
| 58 | |
| 59 | /* FFUART */ |
| 60 | GPIO34_FFUART_RXD, |
| 61 | GPIO39_FFUART_TXD, |
| 62 | GPIO27_FFUART_RTS, |
| 63 | GPIO100_FFUART_CTS, |
| 64 | GPIO33_FFUART_DSR, |
| 65 | GPIO40_FFUART_DTR, |
| 66 | GPIO10_FFUART_DCD, |
| 67 | GPIO38_FFUART_RI, |
| 68 | |
| 69 | /* LCD */ |
| 70 | GPIO58_LCD_LDD_0, |
| 71 | GPIO59_LCD_LDD_1, |
| 72 | GPIO60_LCD_LDD_2, |
| 73 | GPIO61_LCD_LDD_3, |
| 74 | GPIO62_LCD_LDD_4, |
| 75 | GPIO63_LCD_LDD_5, |
| 76 | GPIO64_LCD_LDD_6, |
| 77 | GPIO65_LCD_LDD_7, |
| 78 | GPIO66_LCD_LDD_8, |
| 79 | GPIO67_LCD_LDD_9, |
| 80 | GPIO68_LCD_LDD_10, |
| 81 | GPIO69_LCD_LDD_11, |
| 82 | GPIO70_LCD_LDD_12, |
| 83 | GPIO71_LCD_LDD_13, |
| 84 | GPIO72_LCD_LDD_14, |
| 85 | GPIO73_LCD_LDD_15, |
| 86 | GPIO86_LCD_LDD_16, |
| 87 | GPIO87_LCD_LDD_17, |
| 88 | GPIO74_LCD_FCLK, |
| 89 | GPIO75_LCD_LCLK, |
| 90 | GPIO76_LCD_PCLK, |
| 91 | GPIO77_LCD_BIAS, |
Marek Vasut | addff0f | 2010-03-10 04:16:28 +0100 | [diff] [blame] | 92 | |
| 93 | /* PCMCIA */ |
| 94 | GPIO48_nPOE, |
| 95 | GPIO49_nPWE, |
| 96 | GPIO50_nPIOR, |
| 97 | GPIO51_nPIOW, |
| 98 | GPIO85_nPCE_1, |
| 99 | GPIO54_nPCE_2, |
| 100 | GPIO55_nPREG, |
| 101 | GPIO57_nIOIS16, |
| 102 | GPIO56_nPWAIT, |
| 103 | GPIO104_PSKTSEL, |
| 104 | GPIO84_GPIO, /* PCMCIA CD */ |
| 105 | GPIO35_GPIO, /* PCMCIA RDY */ |
| 106 | GPIO107_GPIO, /* PCMCIA PPEN */ |
| 107 | GPIO11_GPIO, /* PCMCIA RESET */ |
| 108 | GPIO17_GPIO, /* CF CD */ |
| 109 | GPIO12_GPIO, /* CF RDY */ |
| 110 | GPIO16_GPIO, /* CF RESET */ |
| 111 | |
Marek Vasut | 3d98f88 | 2010-03-10 05:24:27 +0100 | [diff] [blame^] | 112 | /* UHC */ |
| 113 | GPIO88_USBH1_PWR, |
| 114 | GPIO89_USBH1_PEN, |
| 115 | GPIO119_USBH2_PWR, |
| 116 | GPIO120_USBH2_PEN, |
| 117 | |
| 118 | /* UDC */ |
| 119 | GPIO41_GPIO, |
Marek | 543cd84 | 2010-03-09 04:04:12 +0100 | [diff] [blame] | 120 | }; |
| 121 | |
| 122 | /****************************************************************************** |
| 123 | * NOR Flash |
| 124 | ******************************************************************************/ |
| 125 | #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) |
| 126 | static struct mtd_partition vpac270_partitions[] = { |
| 127 | { |
| 128 | .name = "Flash", |
| 129 | .offset = 0x00000000, |
| 130 | .size = MTDPART_SIZ_FULL, |
| 131 | } |
| 132 | }; |
| 133 | |
| 134 | static struct physmap_flash_data vpac270_flash_data[] = { |
| 135 | { |
| 136 | .width = 2, /* bankwidth in bytes */ |
| 137 | .parts = vpac270_partitions, |
| 138 | .nr_parts = ARRAY_SIZE(vpac270_partitions) |
| 139 | } |
| 140 | }; |
| 141 | |
| 142 | static struct resource vpac270_flash_resource = { |
| 143 | .start = PXA_CS0_PHYS, |
| 144 | .end = PXA_CS0_PHYS + SZ_64M - 1, |
| 145 | .flags = IORESOURCE_MEM, |
| 146 | }; |
| 147 | |
| 148 | static struct platform_device vpac270_flash = { |
| 149 | .name = "physmap-flash", |
| 150 | .id = 0, |
| 151 | .resource = &vpac270_flash_resource, |
| 152 | .num_resources = 1, |
| 153 | .dev = { |
| 154 | .platform_data = vpac270_flash_data, |
| 155 | }, |
| 156 | }; |
| 157 | static void __init vpac270_nor_init(void) |
| 158 | { |
| 159 | platform_device_register(&vpac270_flash); |
| 160 | } |
| 161 | #else |
| 162 | static inline void vpac270_nor_init(void) {} |
| 163 | #endif |
| 164 | |
| 165 | /****************************************************************************** |
| 166 | * SD/MMC card controller |
| 167 | ******************************************************************************/ |
| 168 | #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) |
| 169 | static struct pxamci_platform_data vpac270_mci_platform_data = { |
| 170 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
| 171 | .gpio_card_detect = GPIO53_VPAC270_SD_DETECT_N, |
| 172 | .gpio_card_ro = GPIO52_VPAC270_SD_READONLY, |
| 173 | .detect_delay = 20, |
| 174 | }; |
| 175 | |
| 176 | static void __init vpac270_mmc_init(void) |
| 177 | { |
| 178 | pxa_set_mci_info(&vpac270_mci_platform_data); |
| 179 | } |
| 180 | #else |
| 181 | static inline void vpac270_mmc_init(void) {} |
| 182 | #endif |
| 183 | |
| 184 | /****************************************************************************** |
| 185 | * GPIO keys |
| 186 | ******************************************************************************/ |
| 187 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) |
| 188 | static struct gpio_keys_button vpac270_pxa_buttons[] = { |
| 189 | {KEY_POWER, GPIO1_VPAC270_USER_BTN, 0, "USER BTN"}, |
| 190 | }; |
| 191 | |
| 192 | static struct gpio_keys_platform_data vpac270_pxa_keys_data = { |
| 193 | .buttons = vpac270_pxa_buttons, |
| 194 | .nbuttons = ARRAY_SIZE(vpac270_pxa_buttons), |
| 195 | }; |
| 196 | |
| 197 | static struct platform_device vpac270_pxa_keys = { |
| 198 | .name = "gpio-keys", |
| 199 | .id = -1, |
| 200 | .dev = { |
| 201 | .platform_data = &vpac270_pxa_keys_data, |
| 202 | }, |
| 203 | }; |
| 204 | |
| 205 | static void __init vpac270_keys_init(void) |
| 206 | { |
| 207 | platform_device_register(&vpac270_pxa_keys); |
| 208 | } |
| 209 | #else |
| 210 | static inline void vpac270_keys_init(void) {} |
| 211 | #endif |
| 212 | |
| 213 | /****************************************************************************** |
| 214 | * LED |
| 215 | ******************************************************************************/ |
| 216 | #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) |
| 217 | struct gpio_led vpac270_gpio_leds[] = { |
| 218 | { |
| 219 | .name = "vpac270:orange:user", |
| 220 | .default_trigger = "none", |
| 221 | .gpio = GPIO15_VPAC270_LED_ORANGE, |
| 222 | .active_low = 1, |
| 223 | } |
| 224 | }; |
| 225 | |
| 226 | static struct gpio_led_platform_data vpac270_gpio_led_info = { |
| 227 | .leds = vpac270_gpio_leds, |
| 228 | .num_leds = ARRAY_SIZE(vpac270_gpio_leds), |
| 229 | }; |
| 230 | |
| 231 | static struct platform_device vpac270_leds = { |
| 232 | .name = "leds-gpio", |
| 233 | .id = -1, |
| 234 | .dev = { |
| 235 | .platform_data = &vpac270_gpio_led_info, |
| 236 | } |
| 237 | }; |
| 238 | |
| 239 | static void __init vpac270_leds_init(void) |
| 240 | { |
| 241 | platform_device_register(&vpac270_leds); |
| 242 | } |
| 243 | #else |
| 244 | static inline void vpac270_leds_init(void) {} |
| 245 | #endif |
| 246 | |
| 247 | /****************************************************************************** |
Marek Vasut | 3d98f88 | 2010-03-10 05:24:27 +0100 | [diff] [blame^] | 248 | * USB Host |
| 249 | ******************************************************************************/ |
| 250 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
| 251 | static int vpac270_ohci_init(struct device *dev) |
| 252 | { |
| 253 | UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE; |
| 254 | return 0; |
| 255 | } |
| 256 | |
| 257 | static struct pxaohci_platform_data vpac270_ohci_info = { |
| 258 | .port_mode = PMM_PERPORT_MODE, |
| 259 | .flags = ENABLE_PORT1 | ENABLE_PORT2 | |
| 260 | POWER_CONTROL_LOW | POWER_SENSE_LOW, |
| 261 | .init = vpac270_ohci_init, |
| 262 | }; |
| 263 | |
| 264 | static void __init vpac270_uhc_init(void) |
| 265 | { |
| 266 | pxa_set_ohci_info(&vpac270_ohci_info); |
| 267 | } |
| 268 | #else |
| 269 | static inline void vpac270_uhc_init(void) {} |
| 270 | #endif |
| 271 | |
| 272 | /****************************************************************************** |
| 273 | * USB Gadget |
| 274 | ******************************************************************************/ |
| 275 | #if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE) |
| 276 | static struct gpio_vbus_mach_info vpac270_gpio_vbus_info = { |
| 277 | .gpio_vbus = GPIO41_VPAC270_UDC_DETECT, |
| 278 | .gpio_pullup = -1, |
| 279 | }; |
| 280 | |
| 281 | static struct platform_device vpac270_gpio_vbus = { |
| 282 | .name = "gpio-vbus", |
| 283 | .id = -1, |
| 284 | .dev = { |
| 285 | .platform_data = &vpac270_gpio_vbus_info, |
| 286 | }, |
| 287 | }; |
| 288 | |
| 289 | static void vpac270_udc_command(int cmd) |
| 290 | { |
| 291 | if (cmd == PXA2XX_UDC_CMD_CONNECT) |
| 292 | UP2OCR |= UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE; |
| 293 | else if (cmd == PXA2XX_UDC_CMD_DISCONNECT) |
| 294 | UP2OCR &= ~(UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE); |
| 295 | } |
| 296 | |
| 297 | static struct pxa2xx_udc_mach_info vpac270_udc_info __initdata = { |
| 298 | .udc_command = vpac270_udc_command, |
| 299 | .gpio_pullup = -1, |
| 300 | }; |
| 301 | |
| 302 | static void __init vpac270_udc_init(void) |
| 303 | { |
| 304 | pxa_set_udc_info(&vpac270_udc_info); |
| 305 | platform_device_register(&vpac270_gpio_vbus); |
| 306 | } |
| 307 | #else |
| 308 | static inline void vpac270_udc_init(void) {} |
| 309 | #endif |
| 310 | |
| 311 | /****************************************************************************** |
Marek | 543cd84 | 2010-03-09 04:04:12 +0100 | [diff] [blame] | 312 | * Framebuffer |
| 313 | ******************************************************************************/ |
| 314 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) |
| 315 | static struct pxafb_mode_info vpac270_lcd_modes[] = { |
| 316 | { |
| 317 | .pixclock = 57692, |
| 318 | .xres = 640, |
| 319 | .yres = 480, |
| 320 | .bpp = 32, |
| 321 | .depth = 18, |
| 322 | |
| 323 | .left_margin = 144, |
| 324 | .right_margin = 32, |
| 325 | .upper_margin = 13, |
| 326 | .lower_margin = 30, |
| 327 | |
| 328 | .hsync_len = 32, |
| 329 | .vsync_len = 2, |
| 330 | |
| 331 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 332 | }, |
| 333 | }; |
| 334 | |
| 335 | static struct pxafb_mach_info vpac270_lcd_screen = { |
| 336 | .modes = vpac270_lcd_modes, |
| 337 | .num_modes = ARRAY_SIZE(vpac270_lcd_modes), |
| 338 | .lcd_conn = LCD_COLOR_TFT_18BPP, |
| 339 | }; |
| 340 | |
| 341 | static void vpac270_lcd_power(int on, struct fb_var_screeninfo *info) |
| 342 | { |
| 343 | gpio_set_value(GPIO81_VPAC270_BKL_ON, on); |
| 344 | } |
| 345 | |
| 346 | static void __init vpac270_lcd_init(void) |
| 347 | { |
| 348 | int ret; |
| 349 | |
| 350 | ret = gpio_request(GPIO81_VPAC270_BKL_ON, "BKL-ON"); |
| 351 | if (ret) { |
| 352 | pr_err("Requesting BKL-ON GPIO failed!\n"); |
| 353 | goto err; |
| 354 | } |
| 355 | |
| 356 | ret = gpio_direction_output(GPIO81_VPAC270_BKL_ON, 1); |
| 357 | if (ret) { |
| 358 | pr_err("Setting BKL-ON GPIO direction failed!\n"); |
| 359 | goto err2; |
| 360 | } |
| 361 | |
| 362 | vpac270_lcd_screen.pxafb_lcd_power = vpac270_lcd_power; |
| 363 | set_pxa_fb_info(&vpac270_lcd_screen); |
| 364 | return; |
| 365 | |
| 366 | err2: |
| 367 | gpio_free(GPIO81_VPAC270_BKL_ON); |
| 368 | err: |
| 369 | return; |
| 370 | } |
| 371 | #else |
| 372 | static inline void vpac270_lcd_init(void) {} |
| 373 | #endif |
| 374 | |
| 375 | /****************************************************************************** |
| 376 | * Machine init |
| 377 | ******************************************************************************/ |
| 378 | static void __init vpac270_init(void) |
| 379 | { |
| 380 | pxa2xx_mfp_config(ARRAY_AND_SIZE(vpac270_pin_config)); |
| 381 | |
| 382 | pxa_set_ffuart_info(NULL); |
| 383 | pxa_set_btuart_info(NULL); |
| 384 | pxa_set_stuart_info(NULL); |
| 385 | |
| 386 | vpac270_lcd_init(); |
| 387 | vpac270_mmc_init(); |
| 388 | vpac270_nor_init(); |
| 389 | vpac270_leds_init(); |
| 390 | vpac270_keys_init(); |
Marek Vasut | 3d98f88 | 2010-03-10 05:24:27 +0100 | [diff] [blame^] | 391 | vpac270_uhc_init(); |
| 392 | vpac270_udc_init(); |
Marek | 543cd84 | 2010-03-09 04:04:12 +0100 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | MACHINE_START(VPAC270, "Voipac PXA270") |
| 396 | .phys_io = 0x40000000, |
| 397 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
| 398 | .boot_params = 0xa0000100, |
| 399 | .map_io = pxa_map_io, |
| 400 | .init_irq = pxa27x_init_irq, |
| 401 | .timer = &pxa_timer, |
| 402 | .init_machine = vpac270_init |
| 403 | MACHINE_END |