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> |
Sebastian Andrzej Siewior | 8348c25 | 2010-11-22 17:12:15 -0800 | [diff] [blame] | 23 | #include <linux/spi/pxa2xx_spi.h> |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 24 | #include <linux/spi/libertas_spi.h> |
| 25 | #include <linux/spi/lms283gf05.h> |
| 26 | #include <linux/power_supply.h> |
| 27 | #include <linux/mtd/physmap.h> |
| 28 | #include <linux/gpio.h> |
| 29 | #include <linux/gpio_keys.h> |
| 30 | #include <linux/delay.h> |
Marek Vasut | 320bbb8 | 2010-06-24 16:02:09 +0200 | [diff] [blame] | 31 | #include <linux/regulator/machine.h> |
Sebastian Andrzej Siewior | b459396 | 2011-02-23 12:38:16 +0100 | [diff] [blame] | 32 | #include <linux/i2c/pxa-i2c.h> |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 33 | |
| 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/mach/arch.h> |
| 36 | |
| 37 | #include <mach/pxa27x.h> |
| 38 | #include <mach/mfp-pxa27x.h> |
| 39 | #include <mach/z2.h> |
Arnd Bergmann | 293b2da | 2012-08-24 15:16:48 +0200 | [diff] [blame] | 40 | #include <linux/platform_data/video-pxafb.h> |
| 41 | #include <linux/platform_data/mmc-pxamci.h> |
| 42 | #include <linux/platform_data/keypad-pxa27x.h> |
Vasily Khoruzhick | 41646b2 | 2011-03-15 22:11:17 +0200 | [diff] [blame] | 43 | #include <mach/pm.h> |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 44 | |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 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 */ |
Vasily Khoruzhick | 2e62344 | 2011-03-13 17:19:17 +0200 | [diff] [blame] | 95 | GPIO100_KP_MKIN_0, |
| 96 | GPIO101_KP_MKIN_1, |
| 97 | GPIO102_KP_MKIN_2, |
| 98 | GPIO34_KP_MKIN_3, |
| 99 | GPIO38_KP_MKIN_4, |
| 100 | GPIO16_KP_MKIN_5, |
| 101 | GPIO17_KP_MKIN_6, |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 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 */ |
Vasily Khoruzhick | b8f56a7 | 2011-03-13 17:19:19 +0200 | [diff] [blame] | 142 | GPIO14_GPIO, /* WiFi Power */ |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 143 | GPIO24_GPIO, /* WiFi CS */ |
| 144 | GPIO36_GPIO, /* WiFi IRQ */ |
| 145 | GPIO88_GPIO, /* LCD CS */ |
| 146 | }; |
| 147 | |
| 148 | /****************************************************************************** |
| 149 | * NOR Flash |
| 150 | ******************************************************************************/ |
| 151 | #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) |
| 152 | static struct resource z2_flash_resource = { |
| 153 | .start = PXA_CS0_PHYS, |
| 154 | .end = PXA_CS0_PHYS + SZ_8M - 1, |
| 155 | .flags = IORESOURCE_MEM, |
| 156 | }; |
| 157 | |
| 158 | static struct mtd_partition z2_flash_parts[] = { |
| 159 | { |
| 160 | .name = "U-Boot Bootloader", |
| 161 | .offset = 0x0, |
Marek Vasut | 60adc11 | 2010-06-03 03:50:10 +0200 | [diff] [blame] | 162 | .size = 0x40000, |
| 163 | }, { |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 164 | .name = "U-Boot Environment", |
Marek Vasut | 60adc11 | 2010-06-03 03:50:10 +0200 | [diff] [blame] | 165 | .offset = 0x40000, |
Marek Vasut | 7731084 | 2010-07-22 17:47:15 +0200 | [diff] [blame] | 166 | .size = 0x20000, |
Marek Vasut | 60adc11 | 2010-06-03 03:50:10 +0200 | [diff] [blame] | 167 | }, { |
| 168 | .name = "Flash", |
| 169 | .offset = 0x60000, |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 170 | .size = MTDPART_SIZ_FULL, |
| 171 | }, |
| 172 | }; |
| 173 | |
| 174 | static struct physmap_flash_data z2_flash_data = { |
| 175 | .width = 2, |
| 176 | .parts = z2_flash_parts, |
| 177 | .nr_parts = ARRAY_SIZE(z2_flash_parts), |
| 178 | }; |
| 179 | |
| 180 | static struct platform_device z2_flash = { |
| 181 | .name = "physmap-flash", |
| 182 | .id = -1, |
| 183 | .resource = &z2_flash_resource, |
| 184 | .num_resources = 1, |
| 185 | .dev = { |
| 186 | .platform_data = &z2_flash_data, |
| 187 | }, |
| 188 | }; |
| 189 | |
| 190 | static void __init z2_nor_init(void) |
| 191 | { |
| 192 | platform_device_register(&z2_flash); |
| 193 | } |
| 194 | #else |
| 195 | static inline void z2_nor_init(void) {} |
| 196 | #endif |
| 197 | |
| 198 | /****************************************************************************** |
| 199 | * Backlight |
| 200 | ******************************************************************************/ |
| 201 | #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE) |
| 202 | static struct platform_pwm_backlight_data z2_backlight_data[] = { |
| 203 | [0] = { |
| 204 | /* Keypad Backlight */ |
| 205 | .pwm_id = 1, |
| 206 | .max_brightness = 1023, |
Vasily Khoruzhick | 034e175 | 2011-03-13 17:19:20 +0200 | [diff] [blame] | 207 | .dft_brightness = 0, |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 208 | .pwm_period_ns = 1260320, |
| 209 | }, |
| 210 | [1] = { |
| 211 | /* LCD Backlight */ |
| 212 | .pwm_id = 2, |
| 213 | .max_brightness = 1023, |
| 214 | .dft_brightness = 512, |
| 215 | .pwm_period_ns = 1260320, |
| 216 | }, |
| 217 | }; |
| 218 | |
| 219 | static struct platform_device z2_backlight_devices[2] = { |
| 220 | { |
| 221 | .name = "pwm-backlight", |
| 222 | .id = 0, |
| 223 | .dev = { |
| 224 | .platform_data = &z2_backlight_data[1], |
| 225 | }, |
| 226 | }, |
| 227 | { |
| 228 | .name = "pwm-backlight", |
| 229 | .id = 1, |
| 230 | .dev = { |
| 231 | .platform_data = &z2_backlight_data[0], |
| 232 | }, |
| 233 | }, |
| 234 | }; |
| 235 | static void __init z2_pwm_init(void) |
| 236 | { |
| 237 | platform_device_register(&z2_backlight_devices[0]); |
| 238 | platform_device_register(&z2_backlight_devices[1]); |
| 239 | } |
| 240 | #else |
| 241 | static inline void z2_pwm_init(void) {} |
| 242 | #endif |
| 243 | |
| 244 | /****************************************************************************** |
| 245 | * Framebuffer |
| 246 | ******************************************************************************/ |
| 247 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) |
| 248 | static struct pxafb_mode_info z2_lcd_modes[] = { |
| 249 | { |
| 250 | .pixclock = 192000, |
| 251 | .xres = 240, |
| 252 | .yres = 320, |
| 253 | .bpp = 16, |
| 254 | |
| 255 | .left_margin = 4, |
| 256 | .right_margin = 8, |
| 257 | .upper_margin = 4, |
| 258 | .lower_margin = 8, |
| 259 | |
| 260 | .hsync_len = 4, |
| 261 | .vsync_len = 4, |
| 262 | }, |
| 263 | }; |
| 264 | |
| 265 | static struct pxafb_mach_info z2_lcd_screen = { |
| 266 | .modes = z2_lcd_modes, |
| 267 | .num_modes = ARRAY_SIZE(z2_lcd_modes), |
| 268 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_BIAS_ACTIVE_LOW | |
| 269 | LCD_ALTERNATE_MAPPING, |
| 270 | }; |
| 271 | |
| 272 | static void __init z2_lcd_init(void) |
| 273 | { |
Russell King - ARM Linux | 4321e1a | 2011-02-15 15:37:30 +0800 | [diff] [blame] | 274 | pxa_set_fb_info(NULL, &z2_lcd_screen); |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 275 | } |
| 276 | #else |
| 277 | static inline void z2_lcd_init(void) {} |
| 278 | #endif |
| 279 | |
| 280 | /****************************************************************************** |
| 281 | * SD/MMC card controller |
| 282 | ******************************************************************************/ |
| 283 | #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) |
| 284 | static struct pxamci_platform_data z2_mci_platform_data = { |
| 285 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
| 286 | .gpio_card_detect = GPIO96_ZIPITZ2_SD_DETECT, |
| 287 | .gpio_power = -1, |
| 288 | .gpio_card_ro = -1, |
Eric Miao | f97cab2 | 2010-04-14 07:00:42 +0800 | [diff] [blame] | 289 | .detect_delay_ms = 200, |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 290 | }; |
| 291 | |
| 292 | static void __init z2_mmc_init(void) |
| 293 | { |
| 294 | pxa_set_mci_info(&z2_mci_platform_data); |
| 295 | } |
| 296 | #else |
| 297 | static inline void z2_mmc_init(void) {} |
| 298 | #endif |
| 299 | |
| 300 | /****************************************************************************** |
| 301 | * LEDs |
| 302 | ******************************************************************************/ |
| 303 | #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) |
| 304 | struct gpio_led z2_gpio_leds[] = { |
| 305 | { |
| 306 | .name = "z2:green:wifi", |
| 307 | .default_trigger = "none", |
| 308 | .gpio = GPIO10_ZIPITZ2_LED_WIFI, |
| 309 | .active_low = 1, |
| 310 | }, { |
| 311 | .name = "z2:green:charged", |
Vasily Khoruzhick | 54d5710 | 2011-03-13 17:19:21 +0200 | [diff] [blame] | 312 | .default_trigger = "mmc0", |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 313 | .gpio = GPIO85_ZIPITZ2_LED_CHARGED, |
| 314 | .active_low = 1, |
| 315 | }, { |
| 316 | .name = "z2:amber:charging", |
Vasily Khoruzhick | 54d5710 | 2011-03-13 17:19:21 +0200 | [diff] [blame] | 317 | .default_trigger = "Z2-charging-or-full", |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 318 | .gpio = GPIO83_ZIPITZ2_LED_CHARGING, |
| 319 | .active_low = 1, |
| 320 | }, |
| 321 | }; |
| 322 | |
| 323 | static struct gpio_led_platform_data z2_gpio_led_info = { |
| 324 | .leds = z2_gpio_leds, |
| 325 | .num_leds = ARRAY_SIZE(z2_gpio_leds), |
| 326 | }; |
| 327 | |
| 328 | static struct platform_device z2_leds = { |
| 329 | .name = "leds-gpio", |
| 330 | .id = -1, |
| 331 | .dev = { |
| 332 | .platform_data = &z2_gpio_led_info, |
| 333 | } |
| 334 | }; |
| 335 | |
| 336 | static void __init z2_leds_init(void) |
| 337 | { |
| 338 | platform_device_register(&z2_leds); |
| 339 | } |
| 340 | #else |
| 341 | static inline void z2_leds_init(void) {} |
| 342 | #endif |
| 343 | |
| 344 | /****************************************************************************** |
| 345 | * GPIO keyboard |
| 346 | ******************************************************************************/ |
| 347 | #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE) |
Chao Xie | 0a085a9 | 2013-05-05 20:24:58 -0700 | [diff] [blame] | 348 | static const unsigned int z2_matrix_keys[] = { |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 349 | KEY(0, 0, KEY_OPTION), |
| 350 | KEY(1, 0, KEY_UP), |
| 351 | KEY(2, 0, KEY_DOWN), |
| 352 | KEY(3, 0, KEY_LEFT), |
| 353 | KEY(4, 0, KEY_RIGHT), |
| 354 | KEY(5, 0, KEY_END), |
| 355 | KEY(6, 0, KEY_KPPLUS), |
| 356 | |
| 357 | KEY(0, 1, KEY_HOME), |
| 358 | KEY(1, 1, KEY_Q), |
| 359 | KEY(2, 1, KEY_I), |
| 360 | KEY(3, 1, KEY_G), |
| 361 | KEY(4, 1, KEY_X), |
| 362 | KEY(5, 1, KEY_ENTER), |
| 363 | KEY(6, 1, KEY_KPMINUS), |
| 364 | |
| 365 | KEY(0, 2, KEY_PAGEUP), |
| 366 | KEY(1, 2, KEY_W), |
| 367 | KEY(2, 2, KEY_O), |
| 368 | KEY(3, 2, KEY_H), |
| 369 | KEY(4, 2, KEY_C), |
| 370 | KEY(5, 2, KEY_LEFTALT), |
| 371 | |
| 372 | KEY(0, 3, KEY_PAGEDOWN), |
| 373 | KEY(1, 3, KEY_E), |
| 374 | KEY(2, 3, KEY_P), |
| 375 | KEY(3, 3, KEY_J), |
| 376 | KEY(4, 3, KEY_V), |
| 377 | KEY(5, 3, KEY_LEFTSHIFT), |
| 378 | |
| 379 | KEY(0, 4, KEY_ESC), |
| 380 | KEY(1, 4, KEY_R), |
| 381 | KEY(2, 4, KEY_A), |
| 382 | KEY(3, 4, KEY_K), |
| 383 | KEY(4, 4, KEY_B), |
| 384 | KEY(5, 4, KEY_LEFTCTRL), |
| 385 | |
| 386 | KEY(0, 5, KEY_TAB), |
| 387 | KEY(1, 5, KEY_T), |
| 388 | KEY(2, 5, KEY_S), |
| 389 | KEY(3, 5, KEY_L), |
| 390 | KEY(4, 5, KEY_N), |
| 391 | KEY(5, 5, KEY_SPACE), |
| 392 | |
| 393 | KEY(0, 6, KEY_STOPCD), |
| 394 | KEY(1, 6, KEY_Y), |
| 395 | KEY(2, 6, KEY_D), |
| 396 | KEY(3, 6, KEY_BACKSPACE), |
| 397 | KEY(4, 6, KEY_M), |
| 398 | KEY(5, 6, KEY_COMMA), |
| 399 | |
| 400 | KEY(0, 7, KEY_PLAYCD), |
| 401 | KEY(1, 7, KEY_U), |
| 402 | KEY(2, 7, KEY_F), |
| 403 | KEY(3, 7, KEY_Z), |
| 404 | KEY(4, 7, KEY_SEMICOLON), |
| 405 | KEY(5, 7, KEY_DOT), |
| 406 | }; |
| 407 | |
Chao Xie | 0a085a9 | 2013-05-05 20:24:58 -0700 | [diff] [blame] | 408 | static struct matrix_keymap_data z2_matrix_keymap_data = { |
| 409 | .keymap = z2_matrix_keys, |
| 410 | .keymap_size = ARRAY_SIZE(z2_matrix_keys), |
| 411 | }; |
| 412 | |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 413 | static struct pxa27x_keypad_platform_data z2_keypad_platform_data = { |
| 414 | .matrix_key_rows = 7, |
| 415 | .matrix_key_cols = 8, |
Chao Xie | 0a085a9 | 2013-05-05 20:24:58 -0700 | [diff] [blame] | 416 | .matrix_keymap_data = &z2_matrix_keymap_data, |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 417 | |
| 418 | .debounce_interval = 30, |
| 419 | }; |
| 420 | |
| 421 | static void __init z2_mkp_init(void) |
| 422 | { |
| 423 | pxa_set_keypad_info(&z2_keypad_platform_data); |
| 424 | } |
| 425 | #else |
| 426 | static inline void z2_mkp_init(void) {} |
| 427 | #endif |
| 428 | |
| 429 | /****************************************************************************** |
| 430 | * GPIO keys |
| 431 | ******************************************************************************/ |
| 432 | #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) |
| 433 | static struct gpio_keys_button z2_pxa_buttons[] = { |
Vasily Khoruzhick | 2e62344 | 2011-03-13 17:19:17 +0200 | [diff] [blame] | 434 | { |
| 435 | .code = KEY_POWER, |
| 436 | .gpio = GPIO1_ZIPITZ2_POWER_BUTTON, |
| 437 | .active_low = 0, |
| 438 | .desc = "Power Button", |
| 439 | .wakeup = 1, |
| 440 | .type = EV_KEY, |
| 441 | }, |
| 442 | { |
Vasily Khoruzhick | e3b1cee | 2011-03-13 17:19:22 +0200 | [diff] [blame] | 443 | .code = SW_LID, |
Vasily Khoruzhick | 2e62344 | 2011-03-13 17:19:17 +0200 | [diff] [blame] | 444 | .gpio = GPIO98_ZIPITZ2_LID_BUTTON, |
Vasily Khoruzhick | e3b1cee | 2011-03-13 17:19:22 +0200 | [diff] [blame] | 445 | .active_low = 1, |
| 446 | .desc = "Lid Switch", |
| 447 | .wakeup = 0, |
| 448 | .type = EV_SW, |
Vasily Khoruzhick | 2e62344 | 2011-03-13 17:19:17 +0200 | [diff] [blame] | 449 | }, |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 450 | }; |
| 451 | |
| 452 | static struct gpio_keys_platform_data z2_pxa_keys_data = { |
| 453 | .buttons = z2_pxa_buttons, |
| 454 | .nbuttons = ARRAY_SIZE(z2_pxa_buttons), |
| 455 | }; |
| 456 | |
| 457 | static struct platform_device z2_pxa_keys = { |
| 458 | .name = "gpio-keys", |
| 459 | .id = -1, |
| 460 | .dev = { |
| 461 | .platform_data = &z2_pxa_keys_data, |
| 462 | }, |
| 463 | }; |
| 464 | |
| 465 | static void __init z2_keys_init(void) |
| 466 | { |
| 467 | platform_device_register(&z2_pxa_keys); |
| 468 | } |
| 469 | #else |
| 470 | static inline void z2_keys_init(void) {} |
| 471 | #endif |
| 472 | |
| 473 | /****************************************************************************** |
Marek Vasut | d198290 | 2010-05-31 16:51:50 +0200 | [diff] [blame] | 474 | * Battery |
| 475 | ******************************************************************************/ |
| 476 | #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE) |
| 477 | static struct z2_battery_info batt_chip_info = { |
| 478 | .batt_I2C_bus = 0, |
| 479 | .batt_I2C_addr = 0x55, |
| 480 | .batt_I2C_reg = 2, |
| 481 | .charge_gpio = GPIO0_ZIPITZ2_AC_DETECT, |
Vasily Khoruzhick | 233cdbc | 2011-03-13 17:19:18 +0200 | [diff] [blame] | 482 | .min_voltage = 3475000, |
| 483 | .max_voltage = 4190000, |
| 484 | .batt_div = 59, |
Marek Vasut | d198290 | 2010-05-31 16:51:50 +0200 | [diff] [blame] | 485 | .batt_mult = 1000000, |
| 486 | .batt_tech = POWER_SUPPLY_TECHNOLOGY_LION, |
| 487 | .batt_name = "Z2", |
| 488 | }; |
| 489 | |
| 490 | static struct i2c_board_info __initdata z2_i2c_board_info[] = { |
| 491 | { |
| 492 | I2C_BOARD_INFO("aer915", 0x55), |
| 493 | .platform_data = &batt_chip_info, |
Marek Vasut | 8499ded | 2010-05-31 16:51:52 +0200 | [diff] [blame] | 494 | }, { |
| 495 | I2C_BOARD_INFO("wm8750", 0x1b), |
| 496 | }, |
| 497 | |
Marek Vasut | d198290 | 2010-05-31 16:51:50 +0200 | [diff] [blame] | 498 | }; |
| 499 | |
| 500 | static void __init z2_i2c_init(void) |
| 501 | { |
| 502 | pxa_set_i2c_info(NULL); |
| 503 | i2c_register_board_info(0, ARRAY_AND_SIZE(z2_i2c_board_info)); |
| 504 | } |
| 505 | #else |
| 506 | static inline void z2_i2c_init(void) {} |
| 507 | #endif |
| 508 | |
| 509 | /****************************************************************************** |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 510 | * SSP Devices - WiFi and LCD control |
| 511 | ******************************************************************************/ |
| 512 | #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE) |
| 513 | /* WiFi */ |
| 514 | static int z2_lbs_spi_setup(struct spi_device *spi) |
| 515 | { |
| 516 | int ret = 0; |
| 517 | |
Vasily Khoruzhick | b8f56a7 | 2011-03-13 17:19:19 +0200 | [diff] [blame] | 518 | ret = gpio_request(GPIO14_ZIPITZ2_WIFI_POWER, "WiFi Power"); |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 519 | if (ret) |
| 520 | goto err; |
| 521 | |
Vasily Khoruzhick | b8f56a7 | 2011-03-13 17:19:19 +0200 | [diff] [blame] | 522 | ret = gpio_direction_output(GPIO14_ZIPITZ2_WIFI_POWER, 1); |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 523 | if (ret) |
| 524 | goto err2; |
| 525 | |
Vasily Khoruzhick | b8f56a7 | 2011-03-13 17:19:19 +0200 | [diff] [blame] | 526 | /* Wait until card is powered on */ |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 527 | mdelay(180); |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 528 | |
| 529 | spi->bits_per_word = 16; |
| 530 | spi->mode = SPI_MODE_2, |
| 531 | |
| 532 | spi_setup(spi); |
| 533 | |
| 534 | return 0; |
| 535 | |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 536 | err2: |
Vasily Khoruzhick | b8f56a7 | 2011-03-13 17:19:19 +0200 | [diff] [blame] | 537 | gpio_free(GPIO14_ZIPITZ2_WIFI_POWER); |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 538 | err: |
| 539 | return ret; |
| 540 | }; |
| 541 | |
| 542 | static int z2_lbs_spi_teardown(struct spi_device *spi) |
| 543 | { |
Vasily Khoruzhick | b8f56a7 | 2011-03-13 17:19:19 +0200 | [diff] [blame] | 544 | gpio_set_value(GPIO14_ZIPITZ2_WIFI_POWER, 0); |
| 545 | gpio_free(GPIO14_ZIPITZ2_WIFI_POWER); |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 546 | |
Vasily Khoruzhick | b8f56a7 | 2011-03-13 17:19:19 +0200 | [diff] [blame] | 547 | return 0; |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 548 | }; |
| 549 | |
| 550 | static struct pxa2xx_spi_chip z2_lbs_chip_info = { |
| 551 | .rx_threshold = 8, |
| 552 | .tx_threshold = 8, |
| 553 | .timeout = 1000, |
| 554 | .gpio_cs = GPIO24_ZIPITZ2_WIFI_CS, |
| 555 | }; |
| 556 | |
| 557 | static struct libertas_spi_platform_data z2_lbs_pdata = { |
| 558 | .use_dummy_writes = 1, |
| 559 | .setup = z2_lbs_spi_setup, |
| 560 | .teardown = z2_lbs_spi_teardown, |
| 561 | }; |
| 562 | |
| 563 | /* LCD */ |
| 564 | static struct pxa2xx_spi_chip lms283_chip_info = { |
| 565 | .rx_threshold = 1, |
| 566 | .tx_threshold = 1, |
| 567 | .timeout = 64, |
| 568 | .gpio_cs = GPIO88_ZIPITZ2_LCD_CS, |
| 569 | }; |
| 570 | |
| 571 | static const struct lms283gf05_pdata lms283_pdata = { |
| 572 | .reset_gpio = GPIO19_ZIPITZ2_LCD_RESET, |
| 573 | }; |
| 574 | |
| 575 | static struct spi_board_info spi_board_info[] __initdata = { |
| 576 | { |
| 577 | .modalias = "libertas_spi", |
| 578 | .platform_data = &z2_lbs_pdata, |
| 579 | .controller_data = &z2_lbs_chip_info, |
Haojian Zhuang | 4929f5a | 2011-10-10 16:03:51 +0800 | [diff] [blame] | 580 | .irq = PXA_GPIO_TO_IRQ(GPIO36_ZIPITZ2_WIFI_IRQ), |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 581 | .max_speed_hz = 13000000, |
| 582 | .bus_num = 1, |
| 583 | .chip_select = 0, |
| 584 | }, |
| 585 | { |
| 586 | .modalias = "lms283gf05", |
| 587 | .controller_data = &lms283_chip_info, |
| 588 | .platform_data = &lms283_pdata, |
| 589 | .max_speed_hz = 400000, |
| 590 | .bus_num = 2, |
| 591 | .chip_select = 0, |
| 592 | }, |
| 593 | }; |
| 594 | |
| 595 | static struct pxa2xx_spi_master pxa_ssp1_master_info = { |
| 596 | .clock_enable = CKEN_SSP, |
| 597 | .num_chipselect = 1, |
| 598 | .enable_dma = 1, |
| 599 | }; |
| 600 | |
| 601 | static struct pxa2xx_spi_master pxa_ssp2_master_info = { |
| 602 | .clock_enable = CKEN_SSP2, |
| 603 | .num_chipselect = 1, |
| 604 | }; |
| 605 | |
| 606 | static void __init z2_spi_init(void) |
| 607 | { |
| 608 | pxa2xx_set_spi_info(1, &pxa_ssp1_master_info); |
| 609 | pxa2xx_set_spi_info(2, &pxa_ssp2_master_info); |
| 610 | spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info)); |
| 611 | } |
| 612 | #else |
| 613 | static inline void z2_spi_init(void) {} |
| 614 | #endif |
| 615 | |
| 616 | /****************************************************************************** |
Marek Vasut | 320bbb8 | 2010-06-24 16:02:09 +0200 | [diff] [blame] | 617 | * Core power regulator |
| 618 | ******************************************************************************/ |
| 619 | #if defined(CONFIG_REGULATOR_TPS65023) || \ |
| 620 | defined(CONFIG_REGULATOR_TPS65023_MODULE) |
| 621 | static struct regulator_consumer_supply z2_tps65021_consumers[] = { |
Axel Lin | 0bf189a | 2012-05-08 16:25:10 +0800 | [diff] [blame] | 622 | REGULATOR_SUPPLY("vcc_core", NULL), |
Marek Vasut | 320bbb8 | 2010-06-24 16:02:09 +0200 | [diff] [blame] | 623 | }; |
| 624 | |
| 625 | static struct regulator_init_data z2_tps65021_info[] = { |
| 626 | { |
| 627 | .constraints = { |
| 628 | .name = "vcc_core range", |
| 629 | .min_uV = 800000, |
| 630 | .max_uV = 1600000, |
| 631 | .always_on = 1, |
| 632 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, |
| 633 | }, |
| 634 | .consumer_supplies = z2_tps65021_consumers, |
| 635 | .num_consumer_supplies = ARRAY_SIZE(z2_tps65021_consumers), |
| 636 | }, { |
| 637 | .constraints = { |
| 638 | .name = "DCDC2", |
| 639 | .min_uV = 3300000, |
| 640 | .max_uV = 3300000, |
| 641 | .always_on = 1, |
| 642 | }, |
| 643 | }, { |
| 644 | .constraints = { |
| 645 | .name = "DCDC3", |
| 646 | .min_uV = 1800000, |
| 647 | .max_uV = 1800000, |
| 648 | .always_on = 1, |
| 649 | }, |
| 650 | }, { |
| 651 | .constraints = { |
| 652 | .name = "LDO1", |
| 653 | .min_uV = 1000000, |
| 654 | .max_uV = 3150000, |
| 655 | .always_on = 1, |
| 656 | }, |
| 657 | }, { |
| 658 | .constraints = { |
| 659 | .name = "LDO2", |
| 660 | .min_uV = 1050000, |
| 661 | .max_uV = 3300000, |
| 662 | .always_on = 1, |
| 663 | }, |
| 664 | } |
| 665 | }; |
| 666 | |
| 667 | static struct i2c_board_info __initdata z2_pi2c_board_info[] = { |
| 668 | { |
| 669 | I2C_BOARD_INFO("tps65021", 0x48), |
| 670 | .platform_data = &z2_tps65021_info, |
| 671 | }, |
| 672 | }; |
| 673 | |
| 674 | static void __init z2_pmic_init(void) |
| 675 | { |
| 676 | pxa27x_set_i2c_power_info(NULL); |
| 677 | i2c_register_board_info(1, ARRAY_AND_SIZE(z2_pi2c_board_info)); |
| 678 | } |
| 679 | #else |
| 680 | static inline void z2_pmic_init(void) {} |
| 681 | #endif |
| 682 | |
Vasily Khoruzhick | 41646b2 | 2011-03-15 22:11:17 +0200 | [diff] [blame] | 683 | #ifdef CONFIG_PM |
| 684 | static void z2_power_off(void) |
| 685 | { |
| 686 | /* We're using deep sleep as poweroff, so clear PSPR to ensure that |
| 687 | * bootloader will jump to its entry point in resume handler |
| 688 | */ |
| 689 | PSPR = 0x0; |
| 690 | local_irq_disable(); |
Eric Miao | ba4a90a | 2011-09-11 17:19:11 +0800 | [diff] [blame] | 691 | pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP); |
| 692 | pxa27x_cpu_pm_enter(PM_SUSPEND_MEM); |
Vasily Khoruzhick | 41646b2 | 2011-03-15 22:11:17 +0200 | [diff] [blame] | 693 | } |
| 694 | #else |
| 695 | #define z2_power_off NULL |
| 696 | #endif |
| 697 | |
Marek Vasut | 320bbb8 | 2010-06-24 16:02:09 +0200 | [diff] [blame] | 698 | /****************************************************************************** |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 699 | * Machine init |
| 700 | ******************************************************************************/ |
| 701 | static void __init z2_init(void) |
| 702 | { |
| 703 | pxa2xx_mfp_config(ARRAY_AND_SIZE(z2_pin_config)); |
| 704 | |
Marek Vasut | d198290 | 2010-05-31 16:51:50 +0200 | [diff] [blame] | 705 | pxa_set_ffuart_info(NULL); |
| 706 | pxa_set_btuart_info(NULL); |
| 707 | pxa_set_stuart_info(NULL); |
| 708 | |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 709 | z2_lcd_init(); |
| 710 | z2_mmc_init(); |
| 711 | z2_mkp_init(); |
Marek Vasut | d198290 | 2010-05-31 16:51:50 +0200 | [diff] [blame] | 712 | z2_i2c_init(); |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 713 | z2_spi_init(); |
| 714 | z2_nor_init(); |
| 715 | z2_pwm_init(); |
| 716 | z2_leds_init(); |
| 717 | z2_keys_init(); |
Marek Vasut | 320bbb8 | 2010-06-24 16:02:09 +0200 | [diff] [blame] | 718 | z2_pmic_init(); |
Vasily Khoruzhick | 41646b2 | 2011-03-15 22:11:17 +0200 | [diff] [blame] | 719 | |
| 720 | pm_power_off = z2_power_off; |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | MACHINE_START(ZIPIT2, "Zipit Z2") |
Nicolas Pitre | 7375aba | 2011-07-05 22:38:15 -0400 | [diff] [blame] | 724 | .atag_offset = 0x100, |
Marek Vasut | 851982c | 2010-10-11 02:20:19 +0200 | [diff] [blame] | 725 | .map_io = pxa27x_map_io, |
Rob Herring | 4e61109 | 2012-01-03 16:53:48 -0600 | [diff] [blame] | 726 | .nr_irqs = PXA_NR_IRQS, |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 727 | .init_irq = pxa27x_init_irq, |
Eric Miao | 8a97ae2 | 2011-05-18 21:30:04 +0800 | [diff] [blame] | 728 | .handle_irq = pxa27x_handle_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 729 | .init_time = pxa_timer_init, |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 730 | .init_machine = z2_init, |
Russell King | 271a74f | 2011-11-04 14:15:53 +0000 | [diff] [blame] | 731 | .restart = pxa_restart, |
Marek Vasut | b637799 | 2010-02-28 12:41:23 +0100 | [diff] [blame] | 732 | MACHINE_END |