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.h>
20 #include <linux/pwm_backlight.h>
21 #include <linux/z2_battery.h>
22 #include <linux/dma-mapping.h>
23 #include <linux/spi/spi.h>
24 #include <linux/spi/pxa2xx_spi.h>
25 #include <linux/spi/libertas_spi.h>
26 #include <linux/spi/lms283gf05.h>
27 #include <linux/power_supply.h>
28 #include <linux/mtd/physmap.h>
29 #include <linux/gpio.h>
30 #include <linux/gpio_keys.h>
31 #include <linux/delay.h>
32 #include <linux/regulator/machine.h>
33 #include <linux/platform_data/i2c-pxa.h>
35 #include <asm/mach-types.h>
36 #include <asm/mach/arch.h>
39 #include "mfp-pxa27x.h"
41 #include <linux/platform_data/video-pxafb.h>
42 #include <linux/platform_data/mmc-pxamci.h>
43 #include <linux/platform_data/keypad-pxa27x.h>
49 /******************************************************************************
51 ******************************************************************************/
52 static unsigned long z2_pin_config
[] = {
54 /* LCD - 16bpp Active TFT */
75 GPIO19_GPIO
, /* LCD reset */
76 GPIO88_GPIO
, /* LCD chipselect */
79 GPIO115_PWM1_OUT
, /* Keypad Backlight */
80 GPIO11_PWM2_OUT
, /* LCD Backlight */
89 GPIO96_GPIO
, /* SD detect */
117 GPIO23_SSP1_SCLK
, /* SSP1_SCK */
118 GPIO25_SSP1_TXD
, /* SSP1_TXD */
119 GPIO26_SSP1_RXD
, /* SSP1_RXD */
122 GPIO22_SSP2_SCLK
, /* SSP2_SCK */
123 GPIO13_SSP2_TXD
, /* SSP2_TXD */
124 GPIO40_SSP2_RXD
, /* SSP2_RXD */
127 GPIO10_GPIO
, /* WiFi LED */
128 GPIO83_GPIO
, /* Charging LED */
129 GPIO85_GPIO
, /* Charged LED */
132 GPIO28_I2S_BITCLK_OUT
,
134 GPIO30_I2S_SDATA_OUT
,
139 GPIO0_GPIO
, /* AC power detect */
140 GPIO1_GPIO
, /* Power button */
141 GPIO37_GPIO
, /* Headphone detect */
142 GPIO98_GPIO
, /* Lid switch */
143 GPIO14_GPIO
, /* WiFi Power */
144 GPIO24_GPIO
, /* WiFi CS */
145 GPIO36_GPIO
, /* WiFi IRQ */
146 GPIO88_GPIO
, /* LCD CS */
149 /******************************************************************************
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
,
159 static struct mtd_partition z2_flash_parts
[] = {
161 .name
= "U-Boot Bootloader",
165 .name
= "U-Boot Environment",
171 .size
= MTDPART_SIZ_FULL
,
175 static struct physmap_flash_data z2_flash_data
= {
177 .parts
= z2_flash_parts
,
178 .nr_parts
= ARRAY_SIZE(z2_flash_parts
),
181 static struct platform_device z2_flash
= {
182 .name
= "physmap-flash",
184 .resource
= &z2_flash_resource
,
187 .platform_data
= &z2_flash_data
,
191 static void __init
z2_nor_init(void)
193 platform_device_register(&z2_flash
);
196 static inline void z2_nor_init(void) {}
199 /******************************************************************************
201 ******************************************************************************/
202 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
203 static struct pwm_lookup z2_pwm_lookup
[] = {
204 PWM_LOOKUP("pxa27x-pwm.1", 0, "pwm-backlight.0", NULL
, 1260320,
205 PWM_POLARITY_NORMAL
),
206 PWM_LOOKUP("pxa27x-pwm.0", 1, "pwm-backlight.1", NULL
, 1260320,
207 PWM_POLARITY_NORMAL
),
210 static struct platform_pwm_backlight_data z2_backlight_data
[] = {
212 /* Keypad Backlight */
213 .max_brightness
= 1023,
219 .max_brightness
= 1023,
220 .dft_brightness
= 512,
225 static struct platform_device z2_backlight_devices
[2] = {
227 .name
= "pwm-backlight",
230 .platform_data
= &z2_backlight_data
[1],
234 .name
= "pwm-backlight",
237 .platform_data
= &z2_backlight_data
[0],
241 static void __init
z2_pwm_init(void)
243 pwm_add_table(z2_pwm_lookup
, ARRAY_SIZE(z2_pwm_lookup
));
244 platform_device_register(&z2_backlight_devices
[0]);
245 platform_device_register(&z2_backlight_devices
[1]);
248 static inline void z2_pwm_init(void) {}
251 /******************************************************************************
253 ******************************************************************************/
254 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
255 static struct pxafb_mode_info z2_lcd_modes
[] = {
272 static struct pxafb_mach_info z2_lcd_screen
= {
273 .modes
= z2_lcd_modes
,
274 .num_modes
= ARRAY_SIZE(z2_lcd_modes
),
275 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_BIAS_ACTIVE_LOW
|
276 LCD_ALTERNATE_MAPPING
,
279 static void __init
z2_lcd_init(void)
281 pxa_set_fb_info(NULL
, &z2_lcd_screen
);
284 static inline void z2_lcd_init(void) {}
287 /******************************************************************************
288 * SD/MMC card controller
289 ******************************************************************************/
290 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
291 static struct pxamci_platform_data z2_mci_platform_data
= {
292 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
293 .gpio_card_detect
= GPIO96_ZIPITZ2_SD_DETECT
,
296 .detect_delay_ms
= 200,
299 static void __init
z2_mmc_init(void)
301 pxa_set_mci_info(&z2_mci_platform_data
);
304 static inline void z2_mmc_init(void) {}
307 /******************************************************************************
309 ******************************************************************************/
310 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
311 struct gpio_led z2_gpio_leds
[] = {
313 .name
= "z2:green:wifi",
314 .default_trigger
= "none",
315 .gpio
= GPIO10_ZIPITZ2_LED_WIFI
,
318 .name
= "z2:green:charged",
319 .default_trigger
= "mmc0",
320 .gpio
= GPIO85_ZIPITZ2_LED_CHARGED
,
323 .name
= "z2:amber:charging",
324 .default_trigger
= "Z2-charging-or-full",
325 .gpio
= GPIO83_ZIPITZ2_LED_CHARGING
,
330 static struct gpio_led_platform_data z2_gpio_led_info
= {
331 .leds
= z2_gpio_leds
,
332 .num_leds
= ARRAY_SIZE(z2_gpio_leds
),
335 static struct platform_device z2_leds
= {
339 .platform_data
= &z2_gpio_led_info
,
343 static void __init
z2_leds_init(void)
345 platform_device_register(&z2_leds
);
348 static inline void z2_leds_init(void) {}
351 /******************************************************************************
353 ******************************************************************************/
354 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
355 static const unsigned int z2_matrix_keys
[] = {
356 KEY(0, 0, KEY_OPTION
),
360 KEY(4, 0, KEY_RIGHT
),
362 KEY(6, 0, KEY_KPPLUS
),
369 KEY(5, 1, KEY_ENTER
),
370 KEY(6, 1, KEY_KPMINUS
),
372 KEY(0, 2, KEY_PAGEUP
),
377 KEY(5, 2, KEY_LEFTALT
),
379 KEY(0, 3, KEY_PAGEDOWN
),
384 KEY(5, 3, KEY_LEFTSHIFT
),
391 KEY(5, 4, KEY_LEFTCTRL
),
398 KEY(5, 5, KEY_SPACE
),
400 KEY(0, 6, KEY_STOPCD
),
403 KEY(3, 6, KEY_BACKSPACE
),
405 KEY(5, 6, KEY_COMMA
),
407 KEY(0, 7, KEY_PLAYCD
),
411 KEY(4, 7, KEY_SEMICOLON
),
415 static struct matrix_keymap_data z2_matrix_keymap_data
= {
416 .keymap
= z2_matrix_keys
,
417 .keymap_size
= ARRAY_SIZE(z2_matrix_keys
),
420 static struct pxa27x_keypad_platform_data z2_keypad_platform_data
= {
421 .matrix_key_rows
= 7,
422 .matrix_key_cols
= 8,
423 .matrix_keymap_data
= &z2_matrix_keymap_data
,
425 .debounce_interval
= 30,
428 static void __init
z2_mkp_init(void)
430 pxa_set_keypad_info(&z2_keypad_platform_data
);
433 static inline void z2_mkp_init(void) {}
436 /******************************************************************************
438 ******************************************************************************/
439 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
440 static struct gpio_keys_button z2_pxa_buttons
[] = {
443 .gpio
= GPIO1_ZIPITZ2_POWER_BUTTON
,
445 .desc
= "Power Button",
451 .gpio
= GPIO98_ZIPITZ2_LID_BUTTON
,
453 .desc
= "Lid Switch",
459 static struct gpio_keys_platform_data z2_pxa_keys_data
= {
460 .buttons
= z2_pxa_buttons
,
461 .nbuttons
= ARRAY_SIZE(z2_pxa_buttons
),
464 static struct platform_device z2_pxa_keys
= {
468 .platform_data
= &z2_pxa_keys_data
,
472 static void __init
z2_keys_init(void)
474 platform_device_register(&z2_pxa_keys
);
477 static inline void z2_keys_init(void) {}
480 /******************************************************************************
482 ******************************************************************************/
483 #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
484 static struct z2_battery_info batt_chip_info
= {
486 .batt_I2C_addr
= 0x55,
488 .charge_gpio
= GPIO0_ZIPITZ2_AC_DETECT
,
489 .min_voltage
= 3475000,
490 .max_voltage
= 4190000,
492 .batt_mult
= 1000000,
493 .batt_tech
= POWER_SUPPLY_TECHNOLOGY_LION
,
497 static struct i2c_board_info __initdata z2_i2c_board_info
[] = {
499 I2C_BOARD_INFO("aer915", 0x55),
500 .platform_data
= &batt_chip_info
,
502 I2C_BOARD_INFO("wm8750", 0x1b),
507 static void __init
z2_i2c_init(void)
509 pxa_set_i2c_info(NULL
);
510 i2c_register_board_info(0, ARRAY_AND_SIZE(z2_i2c_board_info
));
513 static inline void z2_i2c_init(void) {}
516 /******************************************************************************
517 * SSP Devices - WiFi and LCD control
518 ******************************************************************************/
519 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
521 static int z2_lbs_spi_setup(struct spi_device
*spi
)
525 ret
= gpio_request(GPIO14_ZIPITZ2_WIFI_POWER
, "WiFi Power");
529 ret
= gpio_direction_output(GPIO14_ZIPITZ2_WIFI_POWER
, 1);
533 /* Wait until card is powered on */
536 spi
->bits_per_word
= 16;
537 spi
->mode
= SPI_MODE_2
,
544 gpio_free(GPIO14_ZIPITZ2_WIFI_POWER
);
549 static int z2_lbs_spi_teardown(struct spi_device
*spi
)
551 gpio_set_value(GPIO14_ZIPITZ2_WIFI_POWER
, 0);
552 gpio_free(GPIO14_ZIPITZ2_WIFI_POWER
);
557 static struct pxa2xx_spi_chip z2_lbs_chip_info
= {
561 .gpio_cs
= GPIO24_ZIPITZ2_WIFI_CS
,
564 static struct libertas_spi_platform_data z2_lbs_pdata
= {
565 .use_dummy_writes
= 1,
566 .setup
= z2_lbs_spi_setup
,
567 .teardown
= z2_lbs_spi_teardown
,
571 static struct pxa2xx_spi_chip lms283_chip_info
= {
575 .gpio_cs
= GPIO88_ZIPITZ2_LCD_CS
,
578 static const struct lms283gf05_pdata lms283_pdata
= {
579 .reset_gpio
= GPIO19_ZIPITZ2_LCD_RESET
,
582 static struct spi_board_info spi_board_info
[] __initdata
= {
584 .modalias
= "libertas_spi",
585 .platform_data
= &z2_lbs_pdata
,
586 .controller_data
= &z2_lbs_chip_info
,
587 .irq
= PXA_GPIO_TO_IRQ(GPIO36_ZIPITZ2_WIFI_IRQ
),
588 .max_speed_hz
= 13000000,
593 .modalias
= "lms283gf05",
594 .controller_data
= &lms283_chip_info
,
595 .platform_data
= &lms283_pdata
,
596 .max_speed_hz
= 400000,
602 static struct pxa2xx_spi_master pxa_ssp1_master_info
= {
607 static struct pxa2xx_spi_master pxa_ssp2_master_info
= {
611 static void __init
z2_spi_init(void)
613 pxa2xx_set_spi_info(1, &pxa_ssp1_master_info
);
614 pxa2xx_set_spi_info(2, &pxa_ssp2_master_info
);
615 spi_register_board_info(spi_board_info
, ARRAY_SIZE(spi_board_info
));
618 static inline void z2_spi_init(void) {}
621 /******************************************************************************
622 * Core power regulator
623 ******************************************************************************/
624 #if defined(CONFIG_REGULATOR_TPS65023) || \
625 defined(CONFIG_REGULATOR_TPS65023_MODULE)
626 static struct regulator_consumer_supply z2_tps65021_consumers
[] = {
627 REGULATOR_SUPPLY("vcc_core", NULL
),
630 static struct regulator_init_data z2_tps65021_info
[] = {
633 .name
= "vcc_core range",
637 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
,
639 .consumer_supplies
= z2_tps65021_consumers
,
640 .num_consumer_supplies
= ARRAY_SIZE(z2_tps65021_consumers
),
672 static struct i2c_board_info __initdata z2_pi2c_board_info
[] = {
674 I2C_BOARD_INFO("tps65021", 0x48),
675 .platform_data
= &z2_tps65021_info
,
679 static void __init
z2_pmic_init(void)
681 pxa27x_set_i2c_power_info(NULL
);
682 i2c_register_board_info(1, ARRAY_AND_SIZE(z2_pi2c_board_info
));
685 static inline void z2_pmic_init(void) {}
689 static void z2_power_off(void)
691 /* We're using deep sleep as poweroff, so clear PSPR to ensure that
692 * bootloader will jump to its entry point in resume handler
696 pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP
);
697 pxa27x_cpu_pm_enter(PM_SUSPEND_MEM
);
700 #define z2_power_off NULL
703 /******************************************************************************
705 ******************************************************************************/
706 static void __init
z2_init(void)
708 pxa2xx_mfp_config(ARRAY_AND_SIZE(z2_pin_config
));
710 pxa_set_ffuart_info(NULL
);
711 pxa_set_btuart_info(NULL
);
712 pxa_set_stuart_info(NULL
);
725 pm_power_off
= z2_power_off
;
728 MACHINE_START(ZIPIT2
, "Zipit Z2")
729 .atag_offset
= 0x100,
730 .map_io
= pxa27x_map_io
,
731 .nr_irqs
= PXA_NR_IRQS
,
732 .init_irq
= pxa27x_init_irq
,
733 .handle_irq
= pxa27x_handle_irq
,
734 .init_time
= pxa_timer_init
,
735 .init_machine
= z2_init
,
736 .restart
= pxa_restart
,