Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-pxa/z2.c |
| 3 | * |
| 4 | * Support for the Zipit Z2 Handheld device. |
| 5 | * |
Marek Vasut | 60adc11 | 2010-06-03 03:50:10 +0200 | [diff] [blame] | 6 | * Copyright (C) 2009-2010 Marek Vasut <marek.vasut@gmail.com> |
| 7 | * |
| 8 | * Based on research and code by: Ken McGuire |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 9 | * Based on mainstone.c as modified for the Zipit Z2. |
| 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/platform_device.h> |
| 17 | #include <linux/mtd/mtd.h> |
| 18 | #include <linux/mtd/partitions.h> |
| 19 | #include <linux/pwm_backlight.h> |
Marek Vasut | d198290 | 2010-05-31 16:51:50 +0200 | [diff] [blame] | 20 | #include <linux/z2_battery.h> |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 21 | #include <linux/dma-mapping.h> |
| 22 | #include <linux/spi/spi.h> |
| 23 | #include <linux/spi/libertas_spi.h> |
| 24 | #include <linux/spi/lms283gf05.h> |
| 25 | #include <linux/power_supply.h> |
| 26 | #include <linux/mtd/physmap.h> |
| 27 | #include <linux/gpio.h> |
| 28 | #include <linux/gpio_keys.h> |
| 29 | #include <linux/delay.h> |
Marek Vasut | 320bbb8 | 2010-06-24 16:02:09 +0200 | [diff] [blame] | 30 | #include <linux/regulator/machine.h> |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 31 | |
| 32 | #include <asm/mach-types.h> |
| 33 | #include <asm/mach/arch.h> |
| 34 | |
| 35 | #include <mach/pxa27x.h> |
| 36 | #include <mach/mfp-pxa27x.h> |
| 37 | #include <mach/z2.h> |
| 38 | #include <mach/pxafb.h> |
| 39 | #include <mach/mmc.h> |
Mark F. Brown | 4a2490e | 2010-09-03 18:28:06 -0400 | [diff] [blame] | 40 | #include <plat/pxa27x_keypad.h> |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 41 | #include <mach/pxa2xx_spi.h> |
| 42 | |
| 43 | #include <plat/i2c.h> |
| 44 | |
| 45 | #include "generic.h" |
| 46 | #include "devices.h" |
| 47 | |
| 48 | /****************************************************************************** |
| 49 | * Pin configuration |
| 50 | ******************************************************************************/ |
| 51 | static unsigned long z2_pin_config[] = { |
| 52 | |
| 53 | /* LCD - 16bpp Active TFT */ |
| 54 | GPIO58_LCD_LDD_0, |
| 55 | GPIO59_LCD_LDD_1, |
| 56 | GPIO60_LCD_LDD_2, |
| 57 | GPIO61_LCD_LDD_3, |
| 58 | GPIO62_LCD_LDD_4, |
| 59 | GPIO63_LCD_LDD_5, |
| 60 | GPIO64_LCD_LDD_6, |
| 61 | GPIO65_LCD_LDD_7, |
| 62 | GPIO66_LCD_LDD_8, |
| 63 | GPIO67_LCD_LDD_9, |
| 64 | GPIO68_LCD_LDD_10, |
| 65 | GPIO69_LCD_LDD_11, |
| 66 | GPIO70_LCD_LDD_12, |
| 67 | GPIO71_LCD_LDD_13, |
| 68 | GPIO72_LCD_LDD_14, |
| 69 | GPIO73_LCD_LDD_15, |
| 70 | GPIO74_LCD_FCLK, |
| 71 | GPIO75_LCD_LCLK, |
| 72 | GPIO76_LCD_PCLK, |
| 73 | GPIO77_LCD_BIAS, |
| 74 | GPIO19_GPIO, /* LCD reset */ |
| 75 | GPIO88_GPIO, /* LCD chipselect */ |
| 76 | |
| 77 | /* PWM */ |
| 78 | GPIO115_PWM1_OUT, /* Keypad Backlight */ |
| 79 | GPIO11_PWM2_OUT, /* LCD Backlight */ |
| 80 | |
| 81 | /* MMC */ |
| 82 | GPIO32_MMC_CLK, |
| 83 | GPIO112_MMC_CMD, |
| 84 | GPIO92_MMC_DAT_0, |
| 85 | GPIO109_MMC_DAT_1, |
| 86 | GPIO110_MMC_DAT_2, |
| 87 | GPIO111_MMC_DAT_3, |
| 88 | GPIO96_GPIO, /* SD detect */ |
| 89 | |
| 90 | /* STUART */ |
| 91 | GPIO46_STUART_RXD, |
| 92 | GPIO47_STUART_TXD, |
| 93 | |
| 94 | /* Keypad */ |
| 95 | GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH, |
| 96 | GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH, |
| 97 | GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH, |
| 98 | GPIO34_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH, |
| 99 | GPIO38_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH, |
| 100 | GPIO16_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH, |
| 101 | GPIO17_KP_MKIN_6 | WAKEUP_ON_LEVEL_HIGH, |
| 102 | GPIO103_KP_MKOUT_0, |
| 103 | GPIO104_KP_MKOUT_1, |
| 104 | GPIO105_KP_MKOUT_2, |
| 105 | GPIO106_KP_MKOUT_3, |
| 106 | GPIO107_KP_MKOUT_4, |
| 107 | GPIO108_KP_MKOUT_5, |
| 108 | GPIO35_KP_MKOUT_6, |
| 109 | GPIO41_KP_MKOUT_7, |
| 110 | |
| 111 | /* I2C */ |
| 112 | GPIO117_I2C_SCL, |
| 113 | GPIO118_I2C_SDA, |
| 114 | |
| 115 | /* SSP1 */ |
| 116 | GPIO23_SSP1_SCLK, /* SSP1_SCK */ |
| 117 | GPIO25_SSP1_TXD, /* SSP1_TXD */ |
| 118 | GPIO26_SSP1_RXD, /* SSP1_RXD */ |
| 119 | |
| 120 | /* SSP2 */ |
| 121 | GPIO22_SSP2_SCLK, /* SSP2_SCK */ |
| 122 | GPIO13_SSP2_TXD, /* SSP2_TXD */ |
| 123 | GPIO40_SSP2_RXD, /* SSP2_RXD */ |
| 124 | |
| 125 | /* LEDs */ |
| 126 | GPIO10_GPIO, /* WiFi LED */ |
| 127 | GPIO83_GPIO, /* Charging LED */ |
| 128 | GPIO85_GPIO, /* Charged LED */ |
| 129 | |
| 130 | /* I2S */ |
| 131 | GPIO28_I2S_BITCLK_OUT, |
| 132 | GPIO29_I2S_SDATA_IN, |
| 133 | GPIO30_I2S_SDATA_OUT, |
| 134 | GPIO31_I2S_SYNC, |
| 135 | GPIO113_I2S_SYSCLK, |
| 136 | |
| 137 | /* MISC */ |
| 138 | GPIO0_GPIO, /* AC power detect */ |
| 139 | GPIO1_GPIO, /* Power button */ |
| 140 | GPIO37_GPIO, /* Headphone detect */ |
| 141 | GPIO98_GPIO, /* Lid switch */ |
| 142 | GPIO14_GPIO, /* WiFi Reset */ |
| 143 | GPIO15_GPIO, /* WiFi Power */ |
| 144 | GPIO24_GPIO, /* WiFi CS */ |
| 145 | GPIO36_GPIO, /* WiFi IRQ */ |
| 146 | GPIO88_GPIO, /* LCD CS */ |
| 147 | }; |
| 148 | |
| 149 | /****************************************************************************** |
| 150 | * NOR Flash |
| 151 | ******************************************************************************/ |
| 152 | #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) |
| 153 | static struct resource z2_flash_resource = { |
| 154 | .start = PXA_CS0_PHYS, |
| 155 | .end = PXA_CS0_PHYS + SZ_8M - 1, |
| 156 | .flags = IORESOURCE_MEM, |
| 157 | }; |
| 158 | |
| 159 | static struct mtd_partition z2_flash_parts[] = { |
| 160 | { |
| 161 | .name = "U-Boot Bootloader", |
| 162 | .offset = 0x0, |
Marek Vasut | 60adc11 | 2010-06-03 03:50:10 +0200 | [diff] [blame] | 163 | .size = 0x40000, |
| 164 | }, { |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 165 | .name = "U-Boot Environment", |
Marek Vasut | 60adc11 | 2010-06-03 03:50:10 +0200 | [diff] [blame] | 166 | .offset = 0x40000, |
Marek Vasut | 7731084 | 2010-07-22 17:47:15 +0200 | [diff] [blame] | 167 | .size = 0x20000, |
Marek Vasut | 60adc11 | 2010-06-03 03:50:10 +0200 | [diff] [blame] | 168 | }, { |
| 169 | .name = "Flash", |
| 170 | .offset = 0x60000, |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 171 | .size = MTDPART_SIZ_FULL, |
| 172 | }, |
| 173 | }; |
| 174 | |
| 175 | static struct physmap_flash_data z2_flash_data = { |
| 176 | .width = 2, |
| 177 | .parts = z2_flash_parts, |
| 178 | .nr_parts = ARRAY_SIZE(z2_flash_parts), |
| 179 | }; |
| 180 | |
| 181 | static struct platform_device z2_flash = { |
| 182 | .name = "physmap-flash", |
| 183 | .id = -1, |
| 184 | .resource = &z2_flash_resource, |
| 185 | .num_resources = 1, |
| 186 | .dev = { |
| 187 | .platform_data = &z2_flash_data, |
| 188 | }, |
| 189 | }; |
| 190 | |
| 191 | static void __init z2_nor_init(void) |
| 192 | { |
| 193 | platform_device_register(&z2_flash); |
| 194 | } |
| 195 | #else |
| 196 | static inline void z2_nor_init(void) {} |
| 197 | #endif |
| 198 | |
| 199 | /****************************************************************************** |
| 200 | * Backlight |
| 201 | ******************************************************************************/ |
| 202 | #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE) |
| 203 | static struct platform_pwm_backlight_data z2_backlight_data[] = { |
| 204 | [0] = { |
| 205 | /* Keypad Backlight */ |
| 206 | .pwm_id = 1, |
| 207 | .max_brightness = 1023, |
| 208 | .dft_brightness = 512, |
| 209 | .pwm_period_ns = 1260320, |
| 210 | }, |
| 211 | [1] = { |
| 212 | /* LCD Backlight */ |
| 213 | .pwm_id = 2, |
| 214 | .max_brightness = 1023, |
| 215 | .dft_brightness = 512, |
| 216 | .pwm_period_ns = 1260320, |
| 217 | }, |
| 218 | }; |
| 219 | |
| 220 | static struct platform_device z2_backlight_devices[2] = { |
| 221 | { |
| 222 | .name = "pwm-backlight", |
| 223 | .id = 0, |
| 224 | .dev = { |
| 225 | .platform_data = &z2_backlight_data[1], |
| 226 | }, |
| 227 | }, |
| 228 | { |
| 229 | .name = "pwm-backlight", |
| 230 | .id = 1, |
| 231 | .dev = { |
| 232 | .platform_data = &z2_backlight_data[0], |
| 233 | }, |
| 234 | }, |
| 235 | }; |
| 236 | static void __init z2_pwm_init(void) |
| 237 | { |
| 238 | platform_device_register(&z2_backlight_devices[0]); |
| 239 | platform_device_register(&z2_backlight_devices[1]); |
| 240 | } |
| 241 | #else |
| 242 | static inline void z2_pwm_init(void) {} |
| 243 | #endif |
| 244 | |
| 245 | /****************************************************************************** |
| 246 | * Framebuffer |
| 247 | ******************************************************************************/ |
| 248 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) |
| 249 | static struct pxafb_mode_info z2_lcd_modes[] = { |
| 250 | { |
| 251 | .pixclock = 192000, |
| 252 | .xres = 240, |
| 253 | .yres = 320, |
| 254 | .bpp = 16, |
| 255 | |
| 256 | .left_margin = 4, |
| 257 | .right_margin = 8, |
| 258 | .upper_margin = 4, |
| 259 | .lower_margin = 8, |
| 260 | |
| 261 | .hsync_len = 4, |
| 262 | .vsync_len = 4, |
| 263 | }, |
| 264 | }; |
| 265 | |
| 266 | static struct pxafb_mach_info z2_lcd_screen = { |
| 267 | .modes = z2_lcd_modes, |
| 268 | .num_modes = ARRAY_SIZE(z2_lcd_modes), |
| 269 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_BIAS_ACTIVE_LOW | |
| 270 | LCD_ALTERNATE_MAPPING, |
| 271 | }; |
| 272 | |
| 273 | static void __init z2_lcd_init(void) |
| 274 | { |
| 275 | set_pxa_fb_info(&z2_lcd_screen); |
| 276 | } |
| 277 | #else |
| 278 | static inline void z2_lcd_init(void) {} |
| 279 | #endif |
| 280 | |
| 281 | /****************************************************************************** |
| 282 | * SD/MMC card controller |
| 283 | ******************************************************************************/ |
| 284 | #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) |
| 285 | static struct pxamci_platform_data z2_mci_platform_data = { |
| 286 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
| 287 | .gpio_card_detect = GPIO96_ZIPITZ2_SD_DETECT, |
| 288 | .gpio_power = -1, |
| 289 | .gpio_card_ro = -1, |
Eric Miao | f97cab2 | 2010-04-14 07:00:42 +0800 | [diff] [blame] | 290 | .detect_delay_ms = 200, |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 291 | }; |
| 292 | |
| 293 | static void __init z2_mmc_init(void) |
| 294 | { |
| 295 | pxa_set_mci_info(&z2_mci_platform_data); |
| 296 | } |
| 297 | #else |
| 298 | static inline void z2_mmc_init(void) {} |
| 299 | #endif |
| 300 | |
| 301 | /****************************************************************************** |
| 302 | * LEDs |
| 303 | ******************************************************************************/ |
| 304 | #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) |
| 305 | struct gpio_led z2_gpio_leds[] = { |
| 306 | { |
| 307 | .name = "z2:green:wifi", |
| 308 | .default_trigger = "none", |
| 309 | .gpio = GPIO10_ZIPITZ2_LED_WIFI, |
| 310 | .active_low = 1, |
| 311 | }, { |
| 312 | .name = "z2:green:charged", |
| 313 | .default_trigger = "none", |
| 314 | .gpio = GPIO85_ZIPITZ2_LED_CHARGED, |
| 315 | .active_low = 1, |
| 316 | }, { |
| 317 | .name = "z2:amber:charging", |
| 318 | .default_trigger = "none", |
| 319 | .gpio = GPIO83_ZIPITZ2_LED_CHARGING, |
| 320 | .active_low = 1, |
| 321 | }, |
| 322 | }; |
| 323 | |
| 324 | static struct gpio_led_platform_data z2_gpio_led_info = { |
| 325 | .leds = z2_gpio_leds, |
| 326 | .num_leds = ARRAY_SIZE(z2_gpio_leds), |
| 327 | }; |
| 328 | |
| 329 | static struct platform_device z2_leds = { |
| 330 | .name = "leds-gpio", |
| 331 | .id = -1, |
| 332 | .dev = { |
| 333 | .platform_data = &z2_gpio_led_info, |
| 334 | } |
| 335 | }; |
| 336 | |
| 337 | static void __init z2_leds_init(void) |
| 338 | { |
| 339 | platform_device_register(&z2_leds); |
| 340 | } |
| 341 | #else |
| 342 | static inline void z2_leds_init(void) {} |
| 343 | #endif |
| 344 | |
| 345 | /****************************************************************************** |
| 346 | * GPIO keyboard |
| 347 | ******************************************************************************/ |
| 348 | #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE) |
| 349 | static unsigned int z2_matrix_keys[] = { |
| 350 | KEY(0, 0, KEY_OPTION), |
| 351 | KEY(1, 0, KEY_UP), |
| 352 | KEY(2, 0, KEY_DOWN), |
| 353 | KEY(3, 0, KEY_LEFT), |
| 354 | KEY(4, 0, KEY_RIGHT), |
| 355 | KEY(5, 0, KEY_END), |
| 356 | KEY(6, 0, KEY_KPPLUS), |
| 357 | |
| 358 | KEY(0, 1, KEY_HOME), |
| 359 | KEY(1, 1, KEY_Q), |
| 360 | KEY(2, 1, KEY_I), |
| 361 | KEY(3, 1, KEY_G), |
| 362 | KEY(4, 1, KEY_X), |
| 363 | KEY(5, 1, KEY_ENTER), |
| 364 | KEY(6, 1, KEY_KPMINUS), |
| 365 | |
| 366 | KEY(0, 2, KEY_PAGEUP), |
| 367 | KEY(1, 2, KEY_W), |
| 368 | KEY(2, 2, KEY_O), |
| 369 | KEY(3, 2, KEY_H), |
| 370 | KEY(4, 2, KEY_C), |
| 371 | KEY(5, 2, KEY_LEFTALT), |
| 372 | |
| 373 | KEY(0, 3, KEY_PAGEDOWN), |
| 374 | KEY(1, 3, KEY_E), |
| 375 | KEY(2, 3, KEY_P), |
| 376 | KEY(3, 3, KEY_J), |
| 377 | KEY(4, 3, KEY_V), |
| 378 | KEY(5, 3, KEY_LEFTSHIFT), |
| 379 | |
| 380 | KEY(0, 4, KEY_ESC), |
| 381 | KEY(1, 4, KEY_R), |
| 382 | KEY(2, 4, KEY_A), |
| 383 | KEY(3, 4, KEY_K), |
| 384 | KEY(4, 4, KEY_B), |
| 385 | KEY(5, 4, KEY_LEFTCTRL), |
| 386 | |
| 387 | KEY(0, 5, KEY_TAB), |
| 388 | KEY(1, 5, KEY_T), |
| 389 | KEY(2, 5, KEY_S), |
| 390 | KEY(3, 5, KEY_L), |
| 391 | KEY(4, 5, KEY_N), |
| 392 | KEY(5, 5, KEY_SPACE), |
| 393 | |
| 394 | KEY(0, 6, KEY_STOPCD), |
| 395 | KEY(1, 6, KEY_Y), |
| 396 | KEY(2, 6, KEY_D), |
| 397 | KEY(3, 6, KEY_BACKSPACE), |
| 398 | KEY(4, 6, KEY_M), |
| 399 | KEY(5, 6, KEY_COMMA), |
| 400 | |
| 401 | KEY(0, 7, KEY_PLAYCD), |
| 402 | KEY(1, 7, KEY_U), |
| 403 | KEY(2, 7, KEY_F), |
| 404 | KEY(3, 7, KEY_Z), |
| 405 | KEY(4, 7, KEY_SEMICOLON), |
| 406 | KEY(5, 7, KEY_DOT), |
| 407 | }; |
| 408 | |
| 409 | static struct pxa27x_keypad_platform_data z2_keypad_platform_data = { |
| 410 | .matrix_key_rows = 7, |
| 411 | .matrix_key_cols = 8, |
| 412 | .matrix_key_map = z2_matrix_keys, |
| 413 | .matrix_key_map_size = ARRAY_SIZE(z2_matrix_keys), |
| 414 | |
| 415 | .debounce_interval = 30, |
| 416 | }; |
| 417 | |
| 418 | static void __init z2_mkp_init(void) |
| 419 | { |
| 420 | pxa_set_keypad_info(&z2_keypad_platform_data); |
| 421 | } |
| 422 | #else |
| 423 | static inline void z2_mkp_init(void) {} |
| 424 | #endif |
| 425 | |
| 426 | /****************************************************************************** |
| 427 | * GPIO keys |
| 428 | ******************************************************************************/ |
| 429 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) |
| 430 | static struct gpio_keys_button z2_pxa_buttons[] = { |
| 431 | {KEY_POWER, GPIO1_ZIPITZ2_POWER_BUTTON, 0, "Power Button" }, |
| 432 | {KEY_CLOSE, GPIO98_ZIPITZ2_LID_BUTTON, 0, "Lid Button" }, |
| 433 | }; |
| 434 | |
| 435 | static struct gpio_keys_platform_data z2_pxa_keys_data = { |
| 436 | .buttons = z2_pxa_buttons, |
| 437 | .nbuttons = ARRAY_SIZE(z2_pxa_buttons), |
| 438 | }; |
| 439 | |
| 440 | static struct platform_device z2_pxa_keys = { |
| 441 | .name = "gpio-keys", |
| 442 | .id = -1, |
| 443 | .dev = { |
| 444 | .platform_data = &z2_pxa_keys_data, |
| 445 | }, |
| 446 | }; |
| 447 | |
| 448 | static void __init z2_keys_init(void) |
| 449 | { |
| 450 | platform_device_register(&z2_pxa_keys); |
| 451 | } |
| 452 | #else |
| 453 | static inline void z2_keys_init(void) {} |
| 454 | #endif |
| 455 | |
| 456 | /****************************************************************************** |
Marek Vasut | d198290 | 2010-05-31 16:51:50 +0200 | [diff] [blame] | 457 | * Battery |
| 458 | ******************************************************************************/ |
| 459 | #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE) |
| 460 | static struct z2_battery_info batt_chip_info = { |
| 461 | .batt_I2C_bus = 0, |
| 462 | .batt_I2C_addr = 0x55, |
| 463 | .batt_I2C_reg = 2, |
| 464 | .charge_gpio = GPIO0_ZIPITZ2_AC_DETECT, |
| 465 | .min_voltage = 2400000, |
| 466 | .max_voltage = 3700000, |
| 467 | .batt_div = 69, |
| 468 | .batt_mult = 1000000, |
| 469 | .batt_tech = POWER_SUPPLY_TECHNOLOGY_LION, |
| 470 | .batt_name = "Z2", |
| 471 | }; |
| 472 | |
| 473 | static struct i2c_board_info __initdata z2_i2c_board_info[] = { |
| 474 | { |
| 475 | I2C_BOARD_INFO("aer915", 0x55), |
| 476 | .platform_data = &batt_chip_info, |
Marek Vasut | 8499ded | 2010-05-31 16:51:52 +0200 | [diff] [blame] | 477 | }, { |
| 478 | I2C_BOARD_INFO("wm8750", 0x1b), |
| 479 | }, |
| 480 | |
Marek Vasut | d198290 | 2010-05-31 16:51:50 +0200 | [diff] [blame] | 481 | }; |
| 482 | |
| 483 | static void __init z2_i2c_init(void) |
| 484 | { |
| 485 | pxa_set_i2c_info(NULL); |
| 486 | i2c_register_board_info(0, ARRAY_AND_SIZE(z2_i2c_board_info)); |
| 487 | } |
| 488 | #else |
| 489 | static inline void z2_i2c_init(void) {} |
| 490 | #endif |
| 491 | |
| 492 | /****************************************************************************** |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 493 | * SSP Devices - WiFi and LCD control |
| 494 | ******************************************************************************/ |
| 495 | #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE) |
| 496 | /* WiFi */ |
| 497 | static int z2_lbs_spi_setup(struct spi_device *spi) |
| 498 | { |
| 499 | int ret = 0; |
| 500 | |
| 501 | ret = gpio_request(GPIO15_ZIPITZ2_WIFI_POWER, "WiFi Power"); |
| 502 | if (ret) |
| 503 | goto err; |
| 504 | |
| 505 | ret = gpio_direction_output(GPIO15_ZIPITZ2_WIFI_POWER, 1); |
| 506 | if (ret) |
| 507 | goto err2; |
| 508 | |
| 509 | ret = gpio_request(GPIO14_ZIPITZ2_WIFI_RESET, "WiFi Reset"); |
| 510 | if (ret) |
| 511 | goto err2; |
| 512 | |
| 513 | ret = gpio_direction_output(GPIO14_ZIPITZ2_WIFI_RESET, 0); |
| 514 | if (ret) |
| 515 | goto err3; |
| 516 | |
| 517 | /* Reset the card */ |
| 518 | mdelay(180); |
| 519 | gpio_set_value(GPIO14_ZIPITZ2_WIFI_RESET, 1); |
| 520 | mdelay(20); |
| 521 | |
| 522 | spi->bits_per_word = 16; |
| 523 | spi->mode = SPI_MODE_2, |
| 524 | |
| 525 | spi_setup(spi); |
| 526 | |
| 527 | return 0; |
| 528 | |
| 529 | err3: |
| 530 | gpio_free(GPIO14_ZIPITZ2_WIFI_RESET); |
| 531 | err2: |
| 532 | gpio_free(GPIO15_ZIPITZ2_WIFI_POWER); |
| 533 | err: |
| 534 | return ret; |
| 535 | }; |
| 536 | |
| 537 | static int z2_lbs_spi_teardown(struct spi_device *spi) |
| 538 | { |
| 539 | gpio_set_value(GPIO14_ZIPITZ2_WIFI_RESET, 0); |
| 540 | gpio_set_value(GPIO15_ZIPITZ2_WIFI_POWER, 0); |
| 541 | gpio_free(GPIO14_ZIPITZ2_WIFI_RESET); |
| 542 | gpio_free(GPIO15_ZIPITZ2_WIFI_POWER); |
| 543 | return 0; |
| 544 | |
| 545 | }; |
| 546 | |
| 547 | static struct pxa2xx_spi_chip z2_lbs_chip_info = { |
| 548 | .rx_threshold = 8, |
| 549 | .tx_threshold = 8, |
| 550 | .timeout = 1000, |
| 551 | .gpio_cs = GPIO24_ZIPITZ2_WIFI_CS, |
| 552 | }; |
| 553 | |
| 554 | static struct libertas_spi_platform_data z2_lbs_pdata = { |
| 555 | .use_dummy_writes = 1, |
| 556 | .setup = z2_lbs_spi_setup, |
| 557 | .teardown = z2_lbs_spi_teardown, |
| 558 | }; |
| 559 | |
| 560 | /* LCD */ |
| 561 | static struct pxa2xx_spi_chip lms283_chip_info = { |
| 562 | .rx_threshold = 1, |
| 563 | .tx_threshold = 1, |
| 564 | .timeout = 64, |
| 565 | .gpio_cs = GPIO88_ZIPITZ2_LCD_CS, |
| 566 | }; |
| 567 | |
| 568 | static const struct lms283gf05_pdata lms283_pdata = { |
| 569 | .reset_gpio = GPIO19_ZIPITZ2_LCD_RESET, |
| 570 | }; |
| 571 | |
| 572 | static struct spi_board_info spi_board_info[] __initdata = { |
| 573 | { |
| 574 | .modalias = "libertas_spi", |
| 575 | .platform_data = &z2_lbs_pdata, |
| 576 | .controller_data = &z2_lbs_chip_info, |
| 577 | .irq = gpio_to_irq(GPIO36_ZIPITZ2_WIFI_IRQ), |
| 578 | .max_speed_hz = 13000000, |
| 579 | .bus_num = 1, |
| 580 | .chip_select = 0, |
| 581 | }, |
| 582 | { |
| 583 | .modalias = "lms283gf05", |
| 584 | .controller_data = &lms283_chip_info, |
| 585 | .platform_data = &lms283_pdata, |
| 586 | .max_speed_hz = 400000, |
| 587 | .bus_num = 2, |
| 588 | .chip_select = 0, |
| 589 | }, |
| 590 | }; |
| 591 | |
| 592 | static struct pxa2xx_spi_master pxa_ssp1_master_info = { |
| 593 | .clock_enable = CKEN_SSP, |
| 594 | .num_chipselect = 1, |
| 595 | .enable_dma = 1, |
| 596 | }; |
| 597 | |
| 598 | static struct pxa2xx_spi_master pxa_ssp2_master_info = { |
| 599 | .clock_enable = CKEN_SSP2, |
| 600 | .num_chipselect = 1, |
| 601 | }; |
| 602 | |
| 603 | static void __init z2_spi_init(void) |
| 604 | { |
| 605 | pxa2xx_set_spi_info(1, &pxa_ssp1_master_info); |
| 606 | pxa2xx_set_spi_info(2, &pxa_ssp2_master_info); |
| 607 | spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info)); |
| 608 | } |
| 609 | #else |
| 610 | static inline void z2_spi_init(void) {} |
| 611 | #endif |
| 612 | |
| 613 | /****************************************************************************** |
Marek Vasut | 320bbb8 | 2010-06-24 16:02:09 +0200 | [diff] [blame] | 614 | * Core power regulator |
| 615 | ******************************************************************************/ |
| 616 | #if defined(CONFIG_REGULATOR_TPS65023) || \ |
| 617 | defined(CONFIG_REGULATOR_TPS65023_MODULE) |
| 618 | static struct regulator_consumer_supply z2_tps65021_consumers[] = { |
| 619 | { |
| 620 | .supply = "vcc_core", |
| 621 | } |
| 622 | }; |
| 623 | |
| 624 | static struct regulator_init_data z2_tps65021_info[] = { |
| 625 | { |
| 626 | .constraints = { |
| 627 | .name = "vcc_core range", |
| 628 | .min_uV = 800000, |
| 629 | .max_uV = 1600000, |
| 630 | .always_on = 1, |
| 631 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, |
| 632 | }, |
| 633 | .consumer_supplies = z2_tps65021_consumers, |
| 634 | .num_consumer_supplies = ARRAY_SIZE(z2_tps65021_consumers), |
| 635 | }, { |
| 636 | .constraints = { |
| 637 | .name = "DCDC2", |
| 638 | .min_uV = 3300000, |
| 639 | .max_uV = 3300000, |
| 640 | .always_on = 1, |
| 641 | }, |
| 642 | }, { |
| 643 | .constraints = { |
| 644 | .name = "DCDC3", |
| 645 | .min_uV = 1800000, |
| 646 | .max_uV = 1800000, |
| 647 | .always_on = 1, |
| 648 | }, |
| 649 | }, { |
| 650 | .constraints = { |
| 651 | .name = "LDO1", |
| 652 | .min_uV = 1000000, |
| 653 | .max_uV = 3150000, |
| 654 | .always_on = 1, |
| 655 | }, |
| 656 | }, { |
| 657 | .constraints = { |
| 658 | .name = "LDO2", |
| 659 | .min_uV = 1050000, |
| 660 | .max_uV = 3300000, |
| 661 | .always_on = 1, |
| 662 | }, |
| 663 | } |
| 664 | }; |
| 665 | |
| 666 | static struct i2c_board_info __initdata z2_pi2c_board_info[] = { |
| 667 | { |
| 668 | I2C_BOARD_INFO("tps65021", 0x48), |
| 669 | .platform_data = &z2_tps65021_info, |
| 670 | }, |
| 671 | }; |
| 672 | |
| 673 | static void __init z2_pmic_init(void) |
| 674 | { |
| 675 | pxa27x_set_i2c_power_info(NULL); |
| 676 | i2c_register_board_info(1, ARRAY_AND_SIZE(z2_pi2c_board_info)); |
| 677 | } |
| 678 | #else |
| 679 | static inline void z2_pmic_init(void) {} |
| 680 | #endif |
| 681 | |
| 682 | /****************************************************************************** |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 683 | * Machine init |
| 684 | ******************************************************************************/ |
| 685 | static void __init z2_init(void) |
| 686 | { |
| 687 | pxa2xx_mfp_config(ARRAY_AND_SIZE(z2_pin_config)); |
| 688 | |
Marek Vasut | d198290 | 2010-05-31 16:51:50 +0200 | [diff] [blame] | 689 | pxa_set_ffuart_info(NULL); |
| 690 | pxa_set_btuart_info(NULL); |
| 691 | pxa_set_stuart_info(NULL); |
| 692 | |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 693 | z2_lcd_init(); |
| 694 | z2_mmc_init(); |
| 695 | z2_mkp_init(); |
Marek Vasut | d198290 | 2010-05-31 16:51:50 +0200 | [diff] [blame] | 696 | z2_i2c_init(); |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 697 | z2_spi_init(); |
| 698 | z2_nor_init(); |
| 699 | z2_pwm_init(); |
| 700 | z2_leds_init(); |
| 701 | z2_keys_init(); |
Marek Vasut | 320bbb8 | 2010-06-24 16:02:09 +0200 | [diff] [blame] | 702 | z2_pmic_init(); |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | MACHINE_START(ZIPIT2, "Zipit Z2") |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 706 | .boot_params = 0xa0000100, |
Marek Vasut | 851982c | 2010-10-11 02:20:19 +0200 | [diff] [blame] | 707 | .map_io = pxa27x_map_io, |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 708 | .init_irq = pxa27x_init_irq, |
| 709 | .timer = &pxa_timer, |
| 710 | .init_machine = z2_init, |
| 711 | MACHINE_END |