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 <mach/pxafb.h>
42 #include <plat/pxa27x_keypad.h>
47 /******************************************************************************
49 ******************************************************************************/
50 static unsigned long z2_pin_config
[] = {
52 /* LCD - 16bpp Active TFT */
73 GPIO19_GPIO
, /* LCD reset */
74 GPIO88_GPIO
, /* LCD chipselect */
77 GPIO115_PWM1_OUT
, /* Keypad Backlight */
78 GPIO11_PWM2_OUT
, /* LCD Backlight */
87 GPIO96_GPIO
, /* SD detect */
115 GPIO23_SSP1_SCLK
, /* SSP1_SCK */
116 GPIO25_SSP1_TXD
, /* SSP1_TXD */
117 GPIO26_SSP1_RXD
, /* SSP1_RXD */
120 GPIO22_SSP2_SCLK
, /* SSP2_SCK */
121 GPIO13_SSP2_TXD
, /* SSP2_TXD */
122 GPIO40_SSP2_RXD
, /* SSP2_RXD */
125 GPIO10_GPIO
, /* WiFi LED */
126 GPIO83_GPIO
, /* Charging LED */
127 GPIO85_GPIO
, /* Charged LED */
130 GPIO28_I2S_BITCLK_OUT
,
132 GPIO30_I2S_SDATA_OUT
,
137 GPIO0_GPIO
, /* AC power detect */
138 GPIO1_GPIO
, /* Power button */
139 GPIO37_GPIO
, /* Headphone detect */
140 GPIO98_GPIO
, /* Lid switch */
141 GPIO14_GPIO
, /* WiFi Power */
142 GPIO24_GPIO
, /* WiFi CS */
143 GPIO36_GPIO
, /* WiFi IRQ */
144 GPIO88_GPIO
, /* LCD CS */
147 /******************************************************************************
149 ******************************************************************************/
150 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
151 static struct resource z2_flash_resource
= {
152 .start
= PXA_CS0_PHYS
,
153 .end
= PXA_CS0_PHYS
+ SZ_8M
- 1,
154 .flags
= IORESOURCE_MEM
,
157 static struct mtd_partition z2_flash_parts
[] = {
159 .name
= "U-Boot Bootloader",
163 .name
= "U-Boot Environment",
169 .size
= MTDPART_SIZ_FULL
,
173 static struct physmap_flash_data z2_flash_data
= {
175 .parts
= z2_flash_parts
,
176 .nr_parts
= ARRAY_SIZE(z2_flash_parts
),
179 static struct platform_device z2_flash
= {
180 .name
= "physmap-flash",
182 .resource
= &z2_flash_resource
,
185 .platform_data
= &z2_flash_data
,
189 static void __init
z2_nor_init(void)
191 platform_device_register(&z2_flash
);
194 static inline void z2_nor_init(void) {}
197 /******************************************************************************
199 ******************************************************************************/
200 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
201 static struct platform_pwm_backlight_data z2_backlight_data
[] = {
203 /* Keypad Backlight */
205 .max_brightness
= 1023,
207 .pwm_period_ns
= 1260320,
212 .max_brightness
= 1023,
213 .dft_brightness
= 512,
214 .pwm_period_ns
= 1260320,
218 static struct platform_device z2_backlight_devices
[2] = {
220 .name
= "pwm-backlight",
223 .platform_data
= &z2_backlight_data
[1],
227 .name
= "pwm-backlight",
230 .platform_data
= &z2_backlight_data
[0],
234 static void __init
z2_pwm_init(void)
236 platform_device_register(&z2_backlight_devices
[0]);
237 platform_device_register(&z2_backlight_devices
[1]);
240 static inline void z2_pwm_init(void) {}
243 /******************************************************************************
245 ******************************************************************************/
246 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
247 static struct pxafb_mode_info z2_lcd_modes
[] = {
264 static struct pxafb_mach_info z2_lcd_screen
= {
265 .modes
= z2_lcd_modes
,
266 .num_modes
= ARRAY_SIZE(z2_lcd_modes
),
267 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_BIAS_ACTIVE_LOW
|
268 LCD_ALTERNATE_MAPPING
,
271 static void __init
z2_lcd_init(void)
273 pxa_set_fb_info(NULL
, &z2_lcd_screen
);
276 static inline void z2_lcd_init(void) {}
279 /******************************************************************************
280 * SD/MMC card controller
281 ******************************************************************************/
282 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
283 static struct pxamci_platform_data z2_mci_platform_data
= {
284 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
285 .gpio_card_detect
= GPIO96_ZIPITZ2_SD_DETECT
,
288 .detect_delay_ms
= 200,
291 static void __init
z2_mmc_init(void)
293 pxa_set_mci_info(&z2_mci_platform_data
);
296 static inline void z2_mmc_init(void) {}
299 /******************************************************************************
301 ******************************************************************************/
302 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
303 struct gpio_led z2_gpio_leds
[] = {
305 .name
= "z2:green:wifi",
306 .default_trigger
= "none",
307 .gpio
= GPIO10_ZIPITZ2_LED_WIFI
,
310 .name
= "z2:green:charged",
311 .default_trigger
= "mmc0",
312 .gpio
= GPIO85_ZIPITZ2_LED_CHARGED
,
315 .name
= "z2:amber:charging",
316 .default_trigger
= "Z2-charging-or-full",
317 .gpio
= GPIO83_ZIPITZ2_LED_CHARGING
,
322 static struct gpio_led_platform_data z2_gpio_led_info
= {
323 .leds
= z2_gpio_leds
,
324 .num_leds
= ARRAY_SIZE(z2_gpio_leds
),
327 static struct platform_device z2_leds
= {
331 .platform_data
= &z2_gpio_led_info
,
335 static void __init
z2_leds_init(void)
337 platform_device_register(&z2_leds
);
340 static inline void z2_leds_init(void) {}
343 /******************************************************************************
345 ******************************************************************************/
346 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
347 static unsigned int z2_matrix_keys
[] = {
348 KEY(0, 0, KEY_OPTION
),
352 KEY(4, 0, KEY_RIGHT
),
354 KEY(6, 0, KEY_KPPLUS
),
361 KEY(5, 1, KEY_ENTER
),
362 KEY(6, 1, KEY_KPMINUS
),
364 KEY(0, 2, KEY_PAGEUP
),
369 KEY(5, 2, KEY_LEFTALT
),
371 KEY(0, 3, KEY_PAGEDOWN
),
376 KEY(5, 3, KEY_LEFTSHIFT
),
383 KEY(5, 4, KEY_LEFTCTRL
),
390 KEY(5, 5, KEY_SPACE
),
392 KEY(0, 6, KEY_STOPCD
),
395 KEY(3, 6, KEY_BACKSPACE
),
397 KEY(5, 6, KEY_COMMA
),
399 KEY(0, 7, KEY_PLAYCD
),
403 KEY(4, 7, KEY_SEMICOLON
),
407 static struct pxa27x_keypad_platform_data z2_keypad_platform_data
= {
408 .matrix_key_rows
= 7,
409 .matrix_key_cols
= 8,
410 .matrix_key_map
= z2_matrix_keys
,
411 .matrix_key_map_size
= ARRAY_SIZE(z2_matrix_keys
),
413 .debounce_interval
= 30,
416 static void __init
z2_mkp_init(void)
418 pxa_set_keypad_info(&z2_keypad_platform_data
);
421 static inline void z2_mkp_init(void) {}
424 /******************************************************************************
426 ******************************************************************************/
427 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
428 static struct gpio_keys_button z2_pxa_buttons
[] = {
431 .gpio
= GPIO1_ZIPITZ2_POWER_BUTTON
,
433 .desc
= "Power Button",
439 .gpio
= GPIO98_ZIPITZ2_LID_BUTTON
,
441 .desc
= "Lid Switch",
447 static struct gpio_keys_platform_data z2_pxa_keys_data
= {
448 .buttons
= z2_pxa_buttons
,
449 .nbuttons
= ARRAY_SIZE(z2_pxa_buttons
),
452 static struct platform_device z2_pxa_keys
= {
456 .platform_data
= &z2_pxa_keys_data
,
460 static void __init
z2_keys_init(void)
462 platform_device_register(&z2_pxa_keys
);
465 static inline void z2_keys_init(void) {}
468 /******************************************************************************
470 ******************************************************************************/
471 #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
472 static struct z2_battery_info batt_chip_info
= {
474 .batt_I2C_addr
= 0x55,
476 .charge_gpio
= GPIO0_ZIPITZ2_AC_DETECT
,
477 .min_voltage
= 3475000,
478 .max_voltage
= 4190000,
480 .batt_mult
= 1000000,
481 .batt_tech
= POWER_SUPPLY_TECHNOLOGY_LION
,
485 static struct i2c_board_info __initdata z2_i2c_board_info
[] = {
487 I2C_BOARD_INFO("aer915", 0x55),
488 .platform_data
= &batt_chip_info
,
490 I2C_BOARD_INFO("wm8750", 0x1b),
495 static void __init
z2_i2c_init(void)
497 pxa_set_i2c_info(NULL
);
498 i2c_register_board_info(0, ARRAY_AND_SIZE(z2_i2c_board_info
));
501 static inline void z2_i2c_init(void) {}
504 /******************************************************************************
505 * SSP Devices - WiFi and LCD control
506 ******************************************************************************/
507 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
509 static int z2_lbs_spi_setup(struct spi_device
*spi
)
513 ret
= gpio_request(GPIO14_ZIPITZ2_WIFI_POWER
, "WiFi Power");
517 ret
= gpio_direction_output(GPIO14_ZIPITZ2_WIFI_POWER
, 1);
521 /* Wait until card is powered on */
524 spi
->bits_per_word
= 16;
525 spi
->mode
= SPI_MODE_2
,
532 gpio_free(GPIO14_ZIPITZ2_WIFI_POWER
);
537 static int z2_lbs_spi_teardown(struct spi_device
*spi
)
539 gpio_set_value(GPIO14_ZIPITZ2_WIFI_POWER
, 0);
540 gpio_free(GPIO14_ZIPITZ2_WIFI_POWER
);
545 static struct pxa2xx_spi_chip z2_lbs_chip_info
= {
549 .gpio_cs
= GPIO24_ZIPITZ2_WIFI_CS
,
552 static struct libertas_spi_platform_data z2_lbs_pdata
= {
553 .use_dummy_writes
= 1,
554 .setup
= z2_lbs_spi_setup
,
555 .teardown
= z2_lbs_spi_teardown
,
559 static struct pxa2xx_spi_chip lms283_chip_info
= {
563 .gpio_cs
= GPIO88_ZIPITZ2_LCD_CS
,
566 static const struct lms283gf05_pdata lms283_pdata
= {
567 .reset_gpio
= GPIO19_ZIPITZ2_LCD_RESET
,
570 static struct spi_board_info spi_board_info
[] __initdata
= {
572 .modalias
= "libertas_spi",
573 .platform_data
= &z2_lbs_pdata
,
574 .controller_data
= &z2_lbs_chip_info
,
575 .irq
= gpio_to_irq(GPIO36_ZIPITZ2_WIFI_IRQ
),
576 .max_speed_hz
= 13000000,
581 .modalias
= "lms283gf05",
582 .controller_data
= &lms283_chip_info
,
583 .platform_data
= &lms283_pdata
,
584 .max_speed_hz
= 400000,
590 static struct pxa2xx_spi_master pxa_ssp1_master_info
= {
591 .clock_enable
= CKEN_SSP
,
596 static struct pxa2xx_spi_master pxa_ssp2_master_info
= {
597 .clock_enable
= CKEN_SSP2
,
601 static void __init
z2_spi_init(void)
603 pxa2xx_set_spi_info(1, &pxa_ssp1_master_info
);
604 pxa2xx_set_spi_info(2, &pxa_ssp2_master_info
);
605 spi_register_board_info(spi_board_info
, ARRAY_SIZE(spi_board_info
));
608 static inline void z2_spi_init(void) {}
611 /******************************************************************************
612 * Core power regulator
613 ******************************************************************************/
614 #if defined(CONFIG_REGULATOR_TPS65023) || \
615 defined(CONFIG_REGULATOR_TPS65023_MODULE)
616 static struct regulator_consumer_supply z2_tps65021_consumers
[] = {
618 .supply
= "vcc_core",
622 static struct regulator_init_data z2_tps65021_info
[] = {
625 .name
= "vcc_core range",
629 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
,
631 .consumer_supplies
= z2_tps65021_consumers
,
632 .num_consumer_supplies
= ARRAY_SIZE(z2_tps65021_consumers
),
664 static struct i2c_board_info __initdata z2_pi2c_board_info
[] = {
666 I2C_BOARD_INFO("tps65021", 0x48),
667 .platform_data
= &z2_tps65021_info
,
671 static void __init
z2_pmic_init(void)
673 pxa27x_set_i2c_power_info(NULL
);
674 i2c_register_board_info(1, ARRAY_AND_SIZE(z2_pi2c_board_info
));
677 static inline void z2_pmic_init(void) {}
680 /******************************************************************************
682 ******************************************************************************/
683 static void __init
z2_init(void)
685 pxa2xx_mfp_config(ARRAY_AND_SIZE(z2_pin_config
));
687 pxa_set_ffuart_info(NULL
);
688 pxa_set_btuart_info(NULL
);
689 pxa_set_stuart_info(NULL
);
703 MACHINE_START(ZIPIT2
, "Zipit Z2")
704 .boot_params
= 0xa0000100,
705 .map_io
= pxa27x_map_io
,
706 .init_irq
= pxa27x_init_irq
,
708 .init_machine
= z2_init
,