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>
33 #include <asm/mach-types.h>
34 #include <asm/mach/arch.h>
36 #include <mach/pxa27x.h>
37 #include <mach/mfp-pxa27x.h>
39 #include <mach/pxafb.h>
41 #include <plat/pxa27x_keypad.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 */
95 GPIO100_KP_MKIN_0
| WAKEUP_ON_LEVEL_HIGH
,
96 GPIO101_KP_MKIN_1
| WAKEUP_ON_LEVEL_HIGH
,
97 GPIO102_KP_MKIN_2
| WAKEUP_ON_LEVEL_HIGH
,
98 GPIO34_KP_MKIN_3
| WAKEUP_ON_LEVEL_HIGH
,
99 GPIO38_KP_MKIN_4
| WAKEUP_ON_LEVEL_HIGH
,
100 GPIO16_KP_MKIN_5
| WAKEUP_ON_LEVEL_HIGH
,
101 GPIO17_KP_MKIN_6
| WAKEUP_ON_LEVEL_HIGH
,
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 Reset */
143 GPIO15_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 platform_pwm_backlight_data z2_backlight_data
[] = {
205 /* Keypad Backlight */
207 .max_brightness
= 1023,
208 .dft_brightness
= 512,
209 .pwm_period_ns
= 1260320,
214 .max_brightness
= 1023,
215 .dft_brightness
= 512,
216 .pwm_period_ns
= 1260320,
220 static struct platform_device z2_backlight_devices
[2] = {
222 .name
= "pwm-backlight",
225 .platform_data
= &z2_backlight_data
[1],
229 .name
= "pwm-backlight",
232 .platform_data
= &z2_backlight_data
[0],
236 static void __init
z2_pwm_init(void)
238 platform_device_register(&z2_backlight_devices
[0]);
239 platform_device_register(&z2_backlight_devices
[1]);
242 static inline void z2_pwm_init(void) {}
245 /******************************************************************************
247 ******************************************************************************/
248 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
249 static struct pxafb_mode_info z2_lcd_modes
[] = {
266 static struct pxafb_mach_info z2_lcd_screen
= {
267 .modes
= z2_lcd_modes
,
268 .num_modes
= ARRAY_SIZE(z2_lcd_modes
),
269 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_BIAS_ACTIVE_LOW
|
270 LCD_ALTERNATE_MAPPING
,
273 static void __init
z2_lcd_init(void)
275 set_pxa_fb_info(&z2_lcd_screen
);
278 static inline void z2_lcd_init(void) {}
281 /******************************************************************************
282 * SD/MMC card controller
283 ******************************************************************************/
284 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
285 static struct pxamci_platform_data z2_mci_platform_data
= {
286 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
287 .gpio_card_detect
= GPIO96_ZIPITZ2_SD_DETECT
,
290 .detect_delay_ms
= 200,
293 static void __init
z2_mmc_init(void)
295 pxa_set_mci_info(&z2_mci_platform_data
);
298 static inline void z2_mmc_init(void) {}
301 /******************************************************************************
303 ******************************************************************************/
304 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
305 struct gpio_led z2_gpio_leds
[] = {
307 .name
= "z2:green:wifi",
308 .default_trigger
= "none",
309 .gpio
= GPIO10_ZIPITZ2_LED_WIFI
,
312 .name
= "z2:green:charged",
313 .default_trigger
= "none",
314 .gpio
= GPIO85_ZIPITZ2_LED_CHARGED
,
317 .name
= "z2:amber:charging",
318 .default_trigger
= "none",
319 .gpio
= GPIO83_ZIPITZ2_LED_CHARGING
,
324 static struct gpio_led_platform_data z2_gpio_led_info
= {
325 .leds
= z2_gpio_leds
,
326 .num_leds
= ARRAY_SIZE(z2_gpio_leds
),
329 static struct platform_device z2_leds
= {
333 .platform_data
= &z2_gpio_led_info
,
337 static void __init
z2_leds_init(void)
339 platform_device_register(&z2_leds
);
342 static inline void z2_leds_init(void) {}
345 /******************************************************************************
347 ******************************************************************************/
348 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
349 static unsigned int z2_matrix_keys
[] = {
350 KEY(0, 0, KEY_OPTION
),
354 KEY(4, 0, KEY_RIGHT
),
356 KEY(6, 0, KEY_KPPLUS
),
363 KEY(5, 1, KEY_ENTER
),
364 KEY(6, 1, KEY_KPMINUS
),
366 KEY(0, 2, KEY_PAGEUP
),
371 KEY(5, 2, KEY_LEFTALT
),
373 KEY(0, 3, KEY_PAGEDOWN
),
378 KEY(5, 3, KEY_LEFTSHIFT
),
385 KEY(5, 4, KEY_LEFTCTRL
),
392 KEY(5, 5, KEY_SPACE
),
394 KEY(0, 6, KEY_STOPCD
),
397 KEY(3, 6, KEY_BACKSPACE
),
399 KEY(5, 6, KEY_COMMA
),
401 KEY(0, 7, KEY_PLAYCD
),
405 KEY(4, 7, KEY_SEMICOLON
),
409 static struct pxa27x_keypad_platform_data z2_keypad_platform_data
= {
410 .matrix_key_rows
= 7,
411 .matrix_key_cols
= 8,
412 .matrix_key_map
= z2_matrix_keys
,
413 .matrix_key_map_size
= ARRAY_SIZE(z2_matrix_keys
),
415 .debounce_interval
= 30,
418 static void __init
z2_mkp_init(void)
420 pxa_set_keypad_info(&z2_keypad_platform_data
);
423 static inline void z2_mkp_init(void) {}
426 /******************************************************************************
428 ******************************************************************************/
429 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
430 static struct gpio_keys_button z2_pxa_buttons
[] = {
431 {KEY_POWER
, GPIO1_ZIPITZ2_POWER_BUTTON
, 0, "Power Button" },
432 {KEY_CLOSE
, GPIO98_ZIPITZ2_LID_BUTTON
, 0, "Lid Button" },
435 static struct gpio_keys_platform_data z2_pxa_keys_data
= {
436 .buttons
= z2_pxa_buttons
,
437 .nbuttons
= ARRAY_SIZE(z2_pxa_buttons
),
440 static struct platform_device z2_pxa_keys
= {
444 .platform_data
= &z2_pxa_keys_data
,
448 static void __init
z2_keys_init(void)
450 platform_device_register(&z2_pxa_keys
);
453 static inline void z2_keys_init(void) {}
456 /******************************************************************************
458 ******************************************************************************/
459 #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
460 static struct z2_battery_info batt_chip_info
= {
462 .batt_I2C_addr
= 0x55,
464 .charge_gpio
= GPIO0_ZIPITZ2_AC_DETECT
,
465 .min_voltage
= 2400000,
466 .max_voltage
= 3700000,
468 .batt_mult
= 1000000,
469 .batt_tech
= POWER_SUPPLY_TECHNOLOGY_LION
,
473 static struct i2c_board_info __initdata z2_i2c_board_info
[] = {
475 I2C_BOARD_INFO("aer915", 0x55),
476 .platform_data
= &batt_chip_info
,
478 I2C_BOARD_INFO("wm8750", 0x1b),
483 static void __init
z2_i2c_init(void)
485 pxa_set_i2c_info(NULL
);
486 i2c_register_board_info(0, ARRAY_AND_SIZE(z2_i2c_board_info
));
489 static inline void z2_i2c_init(void) {}
492 /******************************************************************************
493 * SSP Devices - WiFi and LCD control
494 ******************************************************************************/
495 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
497 static int z2_lbs_spi_setup(struct spi_device
*spi
)
501 ret
= gpio_request(GPIO15_ZIPITZ2_WIFI_POWER
, "WiFi Power");
505 ret
= gpio_direction_output(GPIO15_ZIPITZ2_WIFI_POWER
, 1);
509 ret
= gpio_request(GPIO14_ZIPITZ2_WIFI_RESET
, "WiFi Reset");
513 ret
= gpio_direction_output(GPIO14_ZIPITZ2_WIFI_RESET
, 0);
519 gpio_set_value(GPIO14_ZIPITZ2_WIFI_RESET
, 1);
522 spi
->bits_per_word
= 16;
523 spi
->mode
= SPI_MODE_2
,
530 gpio_free(GPIO14_ZIPITZ2_WIFI_RESET
);
532 gpio_free(GPIO15_ZIPITZ2_WIFI_POWER
);
537 static int z2_lbs_spi_teardown(struct spi_device
*spi
)
539 gpio_set_value(GPIO14_ZIPITZ2_WIFI_RESET
, 0);
540 gpio_set_value(GPIO15_ZIPITZ2_WIFI_POWER
, 0);
541 gpio_free(GPIO14_ZIPITZ2_WIFI_RESET
);
542 gpio_free(GPIO15_ZIPITZ2_WIFI_POWER
);
547 static struct pxa2xx_spi_chip z2_lbs_chip_info
= {
551 .gpio_cs
= GPIO24_ZIPITZ2_WIFI_CS
,
554 static struct libertas_spi_platform_data z2_lbs_pdata
= {
555 .use_dummy_writes
= 1,
556 .setup
= z2_lbs_spi_setup
,
557 .teardown
= z2_lbs_spi_teardown
,
561 static struct pxa2xx_spi_chip lms283_chip_info
= {
565 .gpio_cs
= GPIO88_ZIPITZ2_LCD_CS
,
568 static const struct lms283gf05_pdata lms283_pdata
= {
569 .reset_gpio
= GPIO19_ZIPITZ2_LCD_RESET
,
572 static struct spi_board_info spi_board_info
[] __initdata
= {
574 .modalias
= "libertas_spi",
575 .platform_data
= &z2_lbs_pdata
,
576 .controller_data
= &z2_lbs_chip_info
,
577 .irq
= gpio_to_irq(GPIO36_ZIPITZ2_WIFI_IRQ
),
578 .max_speed_hz
= 13000000,
583 .modalias
= "lms283gf05",
584 .controller_data
= &lms283_chip_info
,
585 .platform_data
= &lms283_pdata
,
586 .max_speed_hz
= 400000,
592 static struct pxa2xx_spi_master pxa_ssp1_master_info
= {
593 .clock_enable
= CKEN_SSP
,
598 static struct pxa2xx_spi_master pxa_ssp2_master_info
= {
599 .clock_enable
= CKEN_SSP2
,
603 static void __init
z2_spi_init(void)
605 pxa2xx_set_spi_info(1, &pxa_ssp1_master_info
);
606 pxa2xx_set_spi_info(2, &pxa_ssp2_master_info
);
607 spi_register_board_info(spi_board_info
, ARRAY_SIZE(spi_board_info
));
610 static inline void z2_spi_init(void) {}
613 /******************************************************************************
614 * Core power regulator
615 ******************************************************************************/
616 #if defined(CONFIG_REGULATOR_TPS65023) || \
617 defined(CONFIG_REGULATOR_TPS65023_MODULE)
618 static struct regulator_consumer_supply z2_tps65021_consumers
[] = {
620 .supply
= "vcc_core",
624 static struct regulator_init_data z2_tps65021_info
[] = {
627 .name
= "vcc_core range",
631 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
,
633 .consumer_supplies
= z2_tps65021_consumers
,
634 .num_consumer_supplies
= ARRAY_SIZE(z2_tps65021_consumers
),
666 static struct i2c_board_info __initdata z2_pi2c_board_info
[] = {
668 I2C_BOARD_INFO("tps65021", 0x48),
669 .platform_data
= &z2_tps65021_info
,
673 static void __init
z2_pmic_init(void)
675 pxa27x_set_i2c_power_info(NULL
);
676 i2c_register_board_info(1, ARRAY_AND_SIZE(z2_pi2c_board_info
));
679 static inline void z2_pmic_init(void) {}
682 /******************************************************************************
684 ******************************************************************************/
685 static void __init
z2_init(void)
687 pxa2xx_mfp_config(ARRAY_AND_SIZE(z2_pin_config
));
689 pxa_set_ffuart_info(NULL
);
690 pxa_set_btuart_info(NULL
);
691 pxa_set_stuart_info(NULL
);
705 MACHINE_START(ZIPIT2
, "Zipit Z2")
706 .boot_params
= 0xa0000100,
707 .map_io
= pxa27x_map_io
,
708 .init_irq
= pxa27x_init_irq
,
710 .init_machine
= z2_init
,