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