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/machine.h>
31 #include <linux/gpio_keys.h>
32 #include <linux/delay.h>
33 #include <linux/regulator/machine.h>
34 #include <linux/platform_data/i2c-pxa.h>
36 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
40 #include "mfp-pxa27x.h"
42 #include <linux/platform_data/video-pxafb.h>
43 #include <linux/platform_data/mmc-pxamci.h>
44 #include <linux/platform_data/keypad-pxa27x.h>
50 /******************************************************************************
52 ******************************************************************************/
53 static unsigned long z2_pin_config
[] = {
55 /* LCD - 16bpp Active TFT */
76 GPIO19_GPIO
, /* LCD reset */
77 GPIO88_GPIO
, /* LCD chipselect */
80 GPIO115_PWM1_OUT
, /* Keypad Backlight */
81 GPIO11_PWM2_OUT
, /* LCD Backlight */
90 GPIO96_GPIO
, /* SD detect */
118 GPIO23_SSP1_SCLK
, /* SSP1_SCK */
119 GPIO25_SSP1_TXD
, /* SSP1_TXD */
120 GPIO26_SSP1_RXD
, /* SSP1_RXD */
123 GPIO22_SSP2_SCLK
, /* SSP2_SCK */
124 GPIO13_SSP2_TXD
, /* SSP2_TXD */
125 GPIO40_SSP2_RXD
, /* SSP2_RXD */
128 GPIO10_GPIO
, /* WiFi LED */
129 GPIO83_GPIO
, /* Charging LED */
130 GPIO85_GPIO
, /* Charged LED */
133 GPIO28_I2S_BITCLK_OUT
,
135 GPIO30_I2S_SDATA_OUT
,
140 GPIO0_GPIO
, /* AC power detect */
141 GPIO1_GPIO
, /* Power button */
142 GPIO37_GPIO
, /* Headphone detect */
143 GPIO98_GPIO
, /* Lid switch */
144 GPIO14_GPIO
, /* WiFi Power */
145 GPIO24_GPIO
, /* WiFi CS */
146 GPIO36_GPIO
, /* WiFi IRQ */
147 GPIO88_GPIO
, /* LCD CS */
150 /******************************************************************************
152 ******************************************************************************/
153 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
154 static struct resource z2_flash_resource
= {
155 .start
= PXA_CS0_PHYS
,
156 .end
= PXA_CS0_PHYS
+ SZ_8M
- 1,
157 .flags
= IORESOURCE_MEM
,
160 static struct mtd_partition z2_flash_parts
[] = {
162 .name
= "U-Boot Bootloader",
166 .name
= "U-Boot Environment",
172 .size
= MTDPART_SIZ_FULL
,
176 static struct physmap_flash_data z2_flash_data
= {
178 .parts
= z2_flash_parts
,
179 .nr_parts
= ARRAY_SIZE(z2_flash_parts
),
182 static struct platform_device z2_flash
= {
183 .name
= "physmap-flash",
185 .resource
= &z2_flash_resource
,
188 .platform_data
= &z2_flash_data
,
192 static void __init
z2_nor_init(void)
194 platform_device_register(&z2_flash
);
197 static inline void z2_nor_init(void) {}
200 /******************************************************************************
202 ******************************************************************************/
203 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
204 static struct pwm_lookup z2_pwm_lookup
[] = {
205 PWM_LOOKUP("pxa27x-pwm.1", 0, "pwm-backlight.0", NULL
, 1260320,
206 PWM_POLARITY_NORMAL
),
207 PWM_LOOKUP("pxa27x-pwm.0", 1, "pwm-backlight.1", NULL
, 1260320,
208 PWM_POLARITY_NORMAL
),
211 static struct platform_pwm_backlight_data z2_backlight_data
[] = {
213 /* Keypad Backlight */
214 .max_brightness
= 1023,
220 .max_brightness
= 1023,
221 .dft_brightness
= 512,
226 static struct platform_device z2_backlight_devices
[2] = {
228 .name
= "pwm-backlight",
231 .platform_data
= &z2_backlight_data
[1],
235 .name
= "pwm-backlight",
238 .platform_data
= &z2_backlight_data
[0],
242 static void __init
z2_pwm_init(void)
244 pwm_add_table(z2_pwm_lookup
, ARRAY_SIZE(z2_pwm_lookup
));
245 platform_device_register(&z2_backlight_devices
[0]);
246 platform_device_register(&z2_backlight_devices
[1]);
249 static inline void z2_pwm_init(void) {}
252 /******************************************************************************
254 ******************************************************************************/
255 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
256 static struct pxafb_mode_info z2_lcd_modes
[] = {
273 static struct pxafb_mach_info z2_lcd_screen
= {
274 .modes
= z2_lcd_modes
,
275 .num_modes
= ARRAY_SIZE(z2_lcd_modes
),
276 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_BIAS_ACTIVE_LOW
|
277 LCD_ALTERNATE_MAPPING
,
280 static void __init
z2_lcd_init(void)
282 pxa_set_fb_info(NULL
, &z2_lcd_screen
);
285 static inline void z2_lcd_init(void) {}
288 /******************************************************************************
289 * SD/MMC card controller
290 ******************************************************************************/
291 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
292 static struct pxamci_platform_data z2_mci_platform_data
= {
293 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
294 .detect_delay_ms
= 200,
297 static struct gpiod_lookup_table z2_mci_gpio_table
= {
298 .dev_id
= "pxa2xx-mci.0",
300 GPIO_LOOKUP("gpio-pxa", GPIO96_ZIPITZ2_SD_DETECT
,
301 "cd", GPIO_ACTIVE_LOW
),
306 static void __init
z2_mmc_init(void)
308 gpiod_add_lookup_table(&z2_mci_gpio_table
);
309 pxa_set_mci_info(&z2_mci_platform_data
);
312 static inline void z2_mmc_init(void) {}
315 /******************************************************************************
317 ******************************************************************************/
318 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
319 struct gpio_led z2_gpio_leds
[] = {
321 .name
= "z2:green:wifi",
322 .default_trigger
= "none",
323 .gpio
= GPIO10_ZIPITZ2_LED_WIFI
,
326 .name
= "z2:green:charged",
327 .default_trigger
= "mmc0",
328 .gpio
= GPIO85_ZIPITZ2_LED_CHARGED
,
331 .name
= "z2:amber:charging",
332 .default_trigger
= "Z2-charging-or-full",
333 .gpio
= GPIO83_ZIPITZ2_LED_CHARGING
,
338 static struct gpio_led_platform_data z2_gpio_led_info
= {
339 .leds
= z2_gpio_leds
,
340 .num_leds
= ARRAY_SIZE(z2_gpio_leds
),
343 static struct platform_device z2_leds
= {
347 .platform_data
= &z2_gpio_led_info
,
351 static void __init
z2_leds_init(void)
353 platform_device_register(&z2_leds
);
356 static inline void z2_leds_init(void) {}
359 /******************************************************************************
361 ******************************************************************************/
362 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
363 static const unsigned int z2_matrix_keys
[] = {
364 KEY(0, 0, KEY_OPTION
),
368 KEY(4, 0, KEY_RIGHT
),
370 KEY(6, 0, KEY_KPPLUS
),
377 KEY(5, 1, KEY_ENTER
),
378 KEY(6, 1, KEY_KPMINUS
),
380 KEY(0, 2, KEY_PAGEUP
),
385 KEY(5, 2, KEY_LEFTALT
),
387 KEY(0, 3, KEY_PAGEDOWN
),
392 KEY(5, 3, KEY_LEFTSHIFT
),
399 KEY(5, 4, KEY_LEFTCTRL
),
406 KEY(5, 5, KEY_SPACE
),
408 KEY(0, 6, KEY_STOPCD
),
411 KEY(3, 6, KEY_BACKSPACE
),
413 KEY(5, 6, KEY_COMMA
),
415 KEY(0, 7, KEY_PLAYCD
),
419 KEY(4, 7, KEY_SEMICOLON
),
423 static struct matrix_keymap_data z2_matrix_keymap_data
= {
424 .keymap
= z2_matrix_keys
,
425 .keymap_size
= ARRAY_SIZE(z2_matrix_keys
),
428 static struct pxa27x_keypad_platform_data z2_keypad_platform_data
= {
429 .matrix_key_rows
= 7,
430 .matrix_key_cols
= 8,
431 .matrix_keymap_data
= &z2_matrix_keymap_data
,
433 .debounce_interval
= 30,
436 static void __init
z2_mkp_init(void)
438 pxa_set_keypad_info(&z2_keypad_platform_data
);
441 static inline void z2_mkp_init(void) {}
444 /******************************************************************************
446 ******************************************************************************/
447 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
448 static struct gpio_keys_button z2_pxa_buttons
[] = {
451 .gpio
= GPIO1_ZIPITZ2_POWER_BUTTON
,
453 .desc
= "Power Button",
459 .gpio
= GPIO98_ZIPITZ2_LID_BUTTON
,
461 .desc
= "Lid Switch",
467 static struct gpio_keys_platform_data z2_pxa_keys_data
= {
468 .buttons
= z2_pxa_buttons
,
469 .nbuttons
= ARRAY_SIZE(z2_pxa_buttons
),
472 static struct platform_device z2_pxa_keys
= {
476 .platform_data
= &z2_pxa_keys_data
,
480 static void __init
z2_keys_init(void)
482 platform_device_register(&z2_pxa_keys
);
485 static inline void z2_keys_init(void) {}
488 /******************************************************************************
490 ******************************************************************************/
491 #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
492 static struct z2_battery_info batt_chip_info
= {
494 .batt_I2C_addr
= 0x55,
496 .charge_gpio
= GPIO0_ZIPITZ2_AC_DETECT
,
497 .min_voltage
= 3475000,
498 .max_voltage
= 4190000,
500 .batt_mult
= 1000000,
501 .batt_tech
= POWER_SUPPLY_TECHNOLOGY_LION
,
505 static struct i2c_board_info __initdata z2_i2c_board_info
[] = {
507 I2C_BOARD_INFO("aer915", 0x55),
508 .platform_data
= &batt_chip_info
,
510 I2C_BOARD_INFO("wm8750", 0x1b),
515 static void __init
z2_i2c_init(void)
517 pxa_set_i2c_info(NULL
);
518 i2c_register_board_info(0, ARRAY_AND_SIZE(z2_i2c_board_info
));
521 static inline void z2_i2c_init(void) {}
524 /******************************************************************************
525 * SSP Devices - WiFi and LCD control
526 ******************************************************************************/
527 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
529 static int z2_lbs_spi_setup(struct spi_device
*spi
)
533 ret
= gpio_request(GPIO14_ZIPITZ2_WIFI_POWER
, "WiFi Power");
537 ret
= gpio_direction_output(GPIO14_ZIPITZ2_WIFI_POWER
, 1);
541 /* Wait until card is powered on */
544 spi
->bits_per_word
= 16;
545 spi
->mode
= SPI_MODE_2
,
552 gpio_free(GPIO14_ZIPITZ2_WIFI_POWER
);
557 static int z2_lbs_spi_teardown(struct spi_device
*spi
)
559 gpio_set_value(GPIO14_ZIPITZ2_WIFI_POWER
, 0);
560 gpio_free(GPIO14_ZIPITZ2_WIFI_POWER
);
565 static struct pxa2xx_spi_chip z2_lbs_chip_info
= {
569 .gpio_cs
= GPIO24_ZIPITZ2_WIFI_CS
,
572 static struct libertas_spi_platform_data z2_lbs_pdata
= {
573 .use_dummy_writes
= 1,
574 .setup
= z2_lbs_spi_setup
,
575 .teardown
= z2_lbs_spi_teardown
,
579 static struct pxa2xx_spi_chip lms283_chip_info
= {
583 .gpio_cs
= GPIO88_ZIPITZ2_LCD_CS
,
586 static const struct lms283gf05_pdata lms283_pdata
= {
587 .reset_gpio
= GPIO19_ZIPITZ2_LCD_RESET
,
590 static struct spi_board_info spi_board_info
[] __initdata
= {
592 .modalias
= "libertas_spi",
593 .platform_data
= &z2_lbs_pdata
,
594 .controller_data
= &z2_lbs_chip_info
,
595 .irq
= PXA_GPIO_TO_IRQ(GPIO36_ZIPITZ2_WIFI_IRQ
),
596 .max_speed_hz
= 13000000,
601 .modalias
= "lms283gf05",
602 .controller_data
= &lms283_chip_info
,
603 .platform_data
= &lms283_pdata
,
604 .max_speed_hz
= 400000,
610 static struct pxa2xx_spi_controller pxa_ssp1_master_info
= {
615 static struct pxa2xx_spi_controller pxa_ssp2_master_info
= {
619 static void __init
z2_spi_init(void)
621 pxa2xx_set_spi_info(1, &pxa_ssp1_master_info
);
622 pxa2xx_set_spi_info(2, &pxa_ssp2_master_info
);
623 spi_register_board_info(spi_board_info
, ARRAY_SIZE(spi_board_info
));
626 static inline void z2_spi_init(void) {}
629 /******************************************************************************
630 * Core power regulator
631 ******************************************************************************/
632 #if defined(CONFIG_REGULATOR_TPS65023) || \
633 defined(CONFIG_REGULATOR_TPS65023_MODULE)
634 static struct regulator_consumer_supply z2_tps65021_consumers
[] = {
635 REGULATOR_SUPPLY("vcc_core", NULL
),
638 static struct regulator_init_data z2_tps65021_info
[] = {
641 .name
= "vcc_core range",
645 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
,
647 .consumer_supplies
= z2_tps65021_consumers
,
648 .num_consumer_supplies
= ARRAY_SIZE(z2_tps65021_consumers
),
680 static struct i2c_board_info __initdata z2_pi2c_board_info
[] = {
682 I2C_BOARD_INFO("tps65021", 0x48),
683 .platform_data
= &z2_tps65021_info
,
687 static void __init
z2_pmic_init(void)
689 pxa27x_set_i2c_power_info(NULL
);
690 i2c_register_board_info(1, ARRAY_AND_SIZE(z2_pi2c_board_info
));
693 static inline void z2_pmic_init(void) {}
697 static void z2_power_off(void)
699 /* We're using deep sleep as poweroff, so clear PSPR to ensure that
700 * bootloader will jump to its entry point in resume handler
704 pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP
);
705 pxa27x_cpu_pm_enter(PM_SUSPEND_MEM
);
708 #define z2_power_off NULL
711 /******************************************************************************
713 ******************************************************************************/
714 static void __init
z2_init(void)
716 pxa2xx_mfp_config(ARRAY_AND_SIZE(z2_pin_config
));
718 pxa_set_ffuart_info(NULL
);
719 pxa_set_btuart_info(NULL
);
720 pxa_set_stuart_info(NULL
);
733 pm_power_off
= z2_power_off
;
736 MACHINE_START(ZIPIT2
, "Zipit Z2")
737 .atag_offset
= 0x100,
738 .map_io
= pxa27x_map_io
,
739 .nr_irqs
= PXA_NR_IRQS
,
740 .init_irq
= pxa27x_init_irq
,
741 .handle_irq
= pxa27x_handle_irq
,
742 .init_time
= pxa_timer_init
,
743 .init_machine
= z2_init
,
744 .restart
= pxa_restart
,