2 * linux/arch/arm/mach-pxa/z2.c
4 * Support for the Zipit Z2 Handheld device.
6 * Copyright (C) 2009-2010 Marek Vasut <marek.vasut@gmail.com>
8 * Based on research and code by: Ken McGuire
9 * Based on mainstone.c as modified for the Zipit Z2.
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.
16 #include <linux/platform_device.h>
17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/partitions.h>
19 #include <linux/pwm_backlight.h>
20 #include <linux/z2_battery.h>
21 #include <linux/dma-mapping.h>
22 #include <linux/spi/spi.h>
23 #include <linux/spi/pxa2xx_spi.h>
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>
31 #include <linux/regulator/machine.h>
32 #include <linux/i2c/pxa-i2c.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
37 #include <mach/pxa27x.h>
38 #include <mach/mfp-pxa27x.h>
40 #include <linux/platform_data/video-pxafb.h>
41 #include <linux/platform_data/mmc-pxamci.h>
42 #include <linux/platform_data/keypad-pxa27x.h>
48 /******************************************************************************
50 ******************************************************************************/
51 static unsigned long z2_pin_config[] = {
53 /* LCD - 16bpp Active TFT */
74 GPIO19_GPIO, /* LCD reset */
75 GPIO88_GPIO, /* LCD chipselect */
78 GPIO115_PWM1_OUT, /* Keypad Backlight */
79 GPIO11_PWM2_OUT, /* LCD Backlight */
88 GPIO96_GPIO, /* SD detect */
116 GPIO23_SSP1_SCLK, /* SSP1_SCK */
117 GPIO25_SSP1_TXD, /* SSP1_TXD */
118 GPIO26_SSP1_RXD, /* SSP1_RXD */
121 GPIO22_SSP2_SCLK, /* SSP2_SCK */
122 GPIO13_SSP2_TXD, /* SSP2_TXD */
123 GPIO40_SSP2_RXD, /* SSP2_RXD */
126 GPIO10_GPIO, /* WiFi LED */
127 GPIO83_GPIO, /* Charging LED */
128 GPIO85_GPIO, /* Charged LED */
131 GPIO28_I2S_BITCLK_OUT,
133 GPIO30_I2S_SDATA_OUT,
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 Power */
143 GPIO24_GPIO, /* WiFi CS */
144 GPIO36_GPIO, /* WiFi IRQ */
145 GPIO88_GPIO, /* LCD CS */
148 /******************************************************************************
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,
158 static struct mtd_partition z2_flash_parts[] = {
160 .name = "U-Boot Bootloader",
164 .name = "U-Boot Environment",
170 .size = MTDPART_SIZ_FULL,
174 static struct physmap_flash_data z2_flash_data = {
176 .parts = z2_flash_parts,
177 .nr_parts = ARRAY_SIZE(z2_flash_parts),
180 static struct platform_device z2_flash = {
181 .name = "physmap-flash",
183 .resource = &z2_flash_resource,
186 .platform_data = &z2_flash_data,
190 static void __init z2_nor_init(void)
192 platform_device_register(&z2_flash);
195 static inline void z2_nor_init(void) {}
198 /******************************************************************************
200 ******************************************************************************/
201 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
202 static struct platform_pwm_backlight_data z2_backlight_data[] = {
204 /* Keypad Backlight */
206 .max_brightness = 1023,
208 .pwm_period_ns = 1260320,
214 .max_brightness = 1023,
215 .dft_brightness = 512,
216 .pwm_period_ns = 1260320,
221 static struct platform_device z2_backlight_devices[2] = {
223 .name = "pwm-backlight",
226 .platform_data = &z2_backlight_data[1],
230 .name = "pwm-backlight",
233 .platform_data = &z2_backlight_data[0],
237 static void __init z2_pwm_init(void)
239 platform_device_register(&z2_backlight_devices[0]);
240 platform_device_register(&z2_backlight_devices[1]);
243 static inline void z2_pwm_init(void) {}
246 /******************************************************************************
248 ******************************************************************************/
249 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
250 static struct pxafb_mode_info z2_lcd_modes[] = {
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,
274 static void __init z2_lcd_init(void)
276 pxa_set_fb_info(NULL, &z2_lcd_screen);
279 static inline void z2_lcd_init(void) {}
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,
288 .gpio_card_detect = GPIO96_ZIPITZ2_SD_DETECT,
291 .detect_delay_ms = 200,
294 static void __init z2_mmc_init(void)
296 pxa_set_mci_info(&z2_mci_platform_data);
299 static inline void z2_mmc_init(void) {}
302 /******************************************************************************
304 ******************************************************************************/
305 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
306 struct gpio_led z2_gpio_leds[] = {
308 .name = "z2:green:wifi",
309 .default_trigger = "none",
310 .gpio = GPIO10_ZIPITZ2_LED_WIFI,
313 .name = "z2:green:charged",
314 .default_trigger = "mmc0",
315 .gpio = GPIO85_ZIPITZ2_LED_CHARGED,
318 .name = "z2:amber:charging",
319 .default_trigger = "Z2-charging-or-full",
320 .gpio = GPIO83_ZIPITZ2_LED_CHARGING,
325 static struct gpio_led_platform_data z2_gpio_led_info = {
326 .leds = z2_gpio_leds,
327 .num_leds = ARRAY_SIZE(z2_gpio_leds),
330 static struct platform_device z2_leds = {
334 .platform_data = &z2_gpio_led_info,
338 static void __init z2_leds_init(void)
340 platform_device_register(&z2_leds);
343 static inline void z2_leds_init(void) {}
346 /******************************************************************************
348 ******************************************************************************/
349 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
350 static const unsigned int z2_matrix_keys[] = {
351 KEY(0, 0, KEY_OPTION),
355 KEY(4, 0, KEY_RIGHT),
357 KEY(6, 0, KEY_KPPLUS),
364 KEY(5, 1, KEY_ENTER),
365 KEY(6, 1, KEY_KPMINUS),
367 KEY(0, 2, KEY_PAGEUP),
372 KEY(5, 2, KEY_LEFTALT),
374 KEY(0, 3, KEY_PAGEDOWN),
379 KEY(5, 3, KEY_LEFTSHIFT),
386 KEY(5, 4, KEY_LEFTCTRL),
393 KEY(5, 5, KEY_SPACE),
395 KEY(0, 6, KEY_STOPCD),
398 KEY(3, 6, KEY_BACKSPACE),
400 KEY(5, 6, KEY_COMMA),
402 KEY(0, 7, KEY_PLAYCD),
406 KEY(4, 7, KEY_SEMICOLON),
410 static struct matrix_keymap_data z2_matrix_keymap_data = {
411 .keymap = z2_matrix_keys,
412 .keymap_size = ARRAY_SIZE(z2_matrix_keys),
415 static struct pxa27x_keypad_platform_data z2_keypad_platform_data = {
416 .matrix_key_rows = 7,
417 .matrix_key_cols = 8,
418 .matrix_keymap_data = &z2_matrix_keymap_data,
420 .debounce_interval = 30,
423 static void __init z2_mkp_init(void)
425 pxa_set_keypad_info(&z2_keypad_platform_data);
428 static inline void z2_mkp_init(void) {}
431 /******************************************************************************
433 ******************************************************************************/
434 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
435 static struct gpio_keys_button z2_pxa_buttons[] = {
438 .gpio = GPIO1_ZIPITZ2_POWER_BUTTON,
440 .desc = "Power Button",
446 .gpio = GPIO98_ZIPITZ2_LID_BUTTON,
448 .desc = "Lid Switch",
454 static struct gpio_keys_platform_data z2_pxa_keys_data = {
455 .buttons = z2_pxa_buttons,
456 .nbuttons = ARRAY_SIZE(z2_pxa_buttons),
459 static struct platform_device z2_pxa_keys = {
463 .platform_data = &z2_pxa_keys_data,
467 static void __init z2_keys_init(void)
469 platform_device_register(&z2_pxa_keys);
472 static inline void z2_keys_init(void) {}
475 /******************************************************************************
477 ******************************************************************************/
478 #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
479 static struct z2_battery_info batt_chip_info = {
481 .batt_I2C_addr = 0x55,
483 .charge_gpio = GPIO0_ZIPITZ2_AC_DETECT,
484 .min_voltage = 3475000,
485 .max_voltage = 4190000,
487 .batt_mult = 1000000,
488 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LION,
492 static struct i2c_board_info __initdata z2_i2c_board_info[] = {
494 I2C_BOARD_INFO("aer915", 0x55),
495 .platform_data = &batt_chip_info,
497 I2C_BOARD_INFO("wm8750", 0x1b),
502 static void __init z2_i2c_init(void)
504 pxa_set_i2c_info(NULL);
505 i2c_register_board_info(0, ARRAY_AND_SIZE(z2_i2c_board_info));
508 static inline void z2_i2c_init(void) {}
511 /******************************************************************************
512 * SSP Devices - WiFi and LCD control
513 ******************************************************************************/
514 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
516 static int z2_lbs_spi_setup(struct spi_device *spi)
520 ret = gpio_request(GPIO14_ZIPITZ2_WIFI_POWER, "WiFi Power");
524 ret = gpio_direction_output(GPIO14_ZIPITZ2_WIFI_POWER, 1);
528 /* Wait until card is powered on */
531 spi->bits_per_word = 16;
532 spi->mode = SPI_MODE_2,
539 gpio_free(GPIO14_ZIPITZ2_WIFI_POWER);
544 static int z2_lbs_spi_teardown(struct spi_device *spi)
546 gpio_set_value(GPIO14_ZIPITZ2_WIFI_POWER, 0);
547 gpio_free(GPIO14_ZIPITZ2_WIFI_POWER);
552 static struct pxa2xx_spi_chip z2_lbs_chip_info = {
556 .gpio_cs = GPIO24_ZIPITZ2_WIFI_CS,
559 static struct libertas_spi_platform_data z2_lbs_pdata = {
560 .use_dummy_writes = 1,
561 .setup = z2_lbs_spi_setup,
562 .teardown = z2_lbs_spi_teardown,
566 static struct pxa2xx_spi_chip lms283_chip_info = {
570 .gpio_cs = GPIO88_ZIPITZ2_LCD_CS,
573 static const struct lms283gf05_pdata lms283_pdata = {
574 .reset_gpio = GPIO19_ZIPITZ2_LCD_RESET,
577 static struct spi_board_info spi_board_info[] __initdata = {
579 .modalias = "libertas_spi",
580 .platform_data = &z2_lbs_pdata,
581 .controller_data = &z2_lbs_chip_info,
582 .irq = PXA_GPIO_TO_IRQ(GPIO36_ZIPITZ2_WIFI_IRQ),
583 .max_speed_hz = 13000000,
588 .modalias = "lms283gf05",
589 .controller_data = &lms283_chip_info,
590 .platform_data = &lms283_pdata,
591 .max_speed_hz = 400000,
597 static struct pxa2xx_spi_master pxa_ssp1_master_info = {
598 .clock_enable = CKEN_SSP,
603 static struct pxa2xx_spi_master pxa_ssp2_master_info = {
604 .clock_enable = CKEN_SSP2,
608 static void __init z2_spi_init(void)
610 pxa2xx_set_spi_info(1, &pxa_ssp1_master_info);
611 pxa2xx_set_spi_info(2, &pxa_ssp2_master_info);
612 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
615 static inline void z2_spi_init(void) {}
618 /******************************************************************************
619 * Core power regulator
620 ******************************************************************************/
621 #if defined(CONFIG_REGULATOR_TPS65023) || \
622 defined(CONFIG_REGULATOR_TPS65023_MODULE)
623 static struct regulator_consumer_supply z2_tps65021_consumers[] = {
624 REGULATOR_SUPPLY("vcc_core", NULL),
627 static struct regulator_init_data z2_tps65021_info[] = {
630 .name = "vcc_core range",
634 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
636 .consumer_supplies = z2_tps65021_consumers,
637 .num_consumer_supplies = ARRAY_SIZE(z2_tps65021_consumers),
669 static struct i2c_board_info __initdata z2_pi2c_board_info[] = {
671 I2C_BOARD_INFO("tps65021", 0x48),
672 .platform_data = &z2_tps65021_info,
676 static void __init z2_pmic_init(void)
678 pxa27x_set_i2c_power_info(NULL);
679 i2c_register_board_info(1, ARRAY_AND_SIZE(z2_pi2c_board_info));
682 static inline void z2_pmic_init(void) {}
686 static void z2_power_off(void)
688 /* We're using deep sleep as poweroff, so clear PSPR to ensure that
689 * bootloader will jump to its entry point in resume handler
693 pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);
694 pxa27x_cpu_pm_enter(PM_SUSPEND_MEM);
697 #define z2_power_off NULL
700 /******************************************************************************
702 ******************************************************************************/
703 static void __init z2_init(void)
705 pxa2xx_mfp_config(ARRAY_AND_SIZE(z2_pin_config));
707 pxa_set_ffuart_info(NULL);
708 pxa_set_btuart_info(NULL);
709 pxa_set_stuart_info(NULL);
722 pm_power_off = z2_power_off;
725 MACHINE_START(ZIPIT2, "Zipit Z2")
726 .atag_offset = 0x100,
727 .map_io = pxa27x_map_io,
728 .nr_irqs = PXA_NR_IRQS,
729 .init_irq = pxa27x_init_irq,
730 .handle_irq = pxa27x_handle_irq,
731 .init_time = pxa_timer_init,
732 .init_machine = z2_init,
733 .restart = pxa_restart,