2 * linux/arch/arm/mach-pxa/z2.c
4 * Support for the Zipit Z2 Handheld device.
7 * Created: Jan 25, 2009
8 * Based on mainstone.c as modified for the Zipit Z2.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/platform_device.h>
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/partitions.h>
18 #include <linux/pwm_backlight.h>
19 #include <linux/dma-mapping.h>
20 #include <linux/spi/spi.h>
21 #include <linux/spi/libertas_spi.h>
22 #include <linux/spi/lms283gf05.h>
23 #include <linux/power_supply.h>
24 #include <linux/mtd/physmap.h>
25 #include <linux/gpio.h>
26 #include <linux/gpio_keys.h>
27 #include <linux/delay.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
32 #include <mach/pxa27x.h>
33 #include <mach/mfp-pxa27x.h>
35 #include <mach/pxafb.h>
37 #include <mach/pxa27x_keypad.h>
38 #include <mach/pxa2xx_spi.h>
45 /******************************************************************************
47 ******************************************************************************/
48 static unsigned long z2_pin_config[] = {
50 /* LCD - 16bpp Active TFT */
71 GPIO19_GPIO, /* LCD reset */
72 GPIO88_GPIO, /* LCD chipselect */
75 GPIO115_PWM1_OUT, /* Keypad Backlight */
76 GPIO11_PWM2_OUT, /* LCD Backlight */
85 GPIO96_GPIO, /* SD detect */
92 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
93 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
94 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
95 GPIO34_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
96 GPIO38_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
97 GPIO16_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
98 GPIO17_KP_MKIN_6 | WAKEUP_ON_LEVEL_HIGH,
113 GPIO23_SSP1_SCLK, /* SSP1_SCK */
114 GPIO25_SSP1_TXD, /* SSP1_TXD */
115 GPIO26_SSP1_RXD, /* SSP1_RXD */
118 GPIO22_SSP2_SCLK, /* SSP2_SCK */
119 GPIO13_SSP2_TXD, /* SSP2_TXD */
120 GPIO40_SSP2_RXD, /* SSP2_RXD */
123 GPIO10_GPIO, /* WiFi LED */
124 GPIO83_GPIO, /* Charging LED */
125 GPIO85_GPIO, /* Charged LED */
128 GPIO28_I2S_BITCLK_OUT,
130 GPIO30_I2S_SDATA_OUT,
135 GPIO0_GPIO, /* AC power detect */
136 GPIO1_GPIO, /* Power button */
137 GPIO37_GPIO, /* Headphone detect */
138 GPIO98_GPIO, /* Lid switch */
139 GPIO14_GPIO, /* WiFi Reset */
140 GPIO15_GPIO, /* WiFi Power */
141 GPIO24_GPIO, /* WiFi CS */
142 GPIO36_GPIO, /* WiFi IRQ */
143 GPIO88_GPIO, /* LCD CS */
146 /******************************************************************************
148 ******************************************************************************/
149 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
150 static struct resource z2_flash_resource = {
151 .start = PXA_CS0_PHYS,
152 .end = PXA_CS0_PHYS + SZ_8M - 1,
153 .flags = IORESOURCE_MEM,
156 static struct mtd_partition z2_flash_parts[] = {
158 .name = "U-Boot Bootloader",
163 .name = "Linux Kernel",
168 .name = "Filesystem",
173 .name = "U-Boot Environment",
175 .size = MTDPART_SIZ_FULL,
179 static struct physmap_flash_data z2_flash_data = {
181 .parts = z2_flash_parts,
182 .nr_parts = ARRAY_SIZE(z2_flash_parts),
185 static struct platform_device z2_flash = {
186 .name = "physmap-flash",
188 .resource = &z2_flash_resource,
191 .platform_data = &z2_flash_data,
195 static void __init z2_nor_init(void)
197 platform_device_register(&z2_flash);
200 static inline void z2_nor_init(void) {}
203 /******************************************************************************
205 ******************************************************************************/
206 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
207 static struct platform_pwm_backlight_data z2_backlight_data[] = {
209 /* Keypad Backlight */
211 .max_brightness = 1023,
212 .dft_brightness = 512,
213 .pwm_period_ns = 1260320,
218 .max_brightness = 1023,
219 .dft_brightness = 512,
220 .pwm_period_ns = 1260320,
224 static struct platform_device z2_backlight_devices[2] = {
226 .name = "pwm-backlight",
229 .platform_data = &z2_backlight_data[1],
233 .name = "pwm-backlight",
236 .platform_data = &z2_backlight_data[0],
240 static void __init z2_pwm_init(void)
242 platform_device_register(&z2_backlight_devices[0]);
243 platform_device_register(&z2_backlight_devices[1]);
246 static inline void z2_pwm_init(void) {}
249 /******************************************************************************
251 ******************************************************************************/
252 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
253 static struct pxafb_mode_info z2_lcd_modes[] = {
270 static struct pxafb_mach_info z2_lcd_screen = {
271 .modes = z2_lcd_modes,
272 .num_modes = ARRAY_SIZE(z2_lcd_modes),
273 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_BIAS_ACTIVE_LOW |
274 LCD_ALTERNATE_MAPPING,
277 static void __init z2_lcd_init(void)
279 set_pxa_fb_info(&z2_lcd_screen);
282 static inline void z2_lcd_init(void) {}
285 /******************************************************************************
286 * SD/MMC card controller
287 ******************************************************************************/
288 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
289 static struct pxamci_platform_data z2_mci_platform_data = {
290 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
291 .gpio_card_detect = GPIO96_ZIPITZ2_SD_DETECT,
294 .detect_delay_ms = 200,
297 static void __init z2_mmc_init(void)
299 pxa_set_mci_info(&z2_mci_platform_data);
302 static inline void z2_mmc_init(void) {}
305 /******************************************************************************
307 ******************************************************************************/
308 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
309 struct gpio_led z2_gpio_leds[] = {
311 .name = "z2:green:wifi",
312 .default_trigger = "none",
313 .gpio = GPIO10_ZIPITZ2_LED_WIFI,
316 .name = "z2:green:charged",
317 .default_trigger = "none",
318 .gpio = GPIO85_ZIPITZ2_LED_CHARGED,
321 .name = "z2:amber:charging",
322 .default_trigger = "none",
323 .gpio = GPIO83_ZIPITZ2_LED_CHARGING,
328 static struct gpio_led_platform_data z2_gpio_led_info = {
329 .leds = z2_gpio_leds,
330 .num_leds = ARRAY_SIZE(z2_gpio_leds),
333 static struct platform_device z2_leds = {
337 .platform_data = &z2_gpio_led_info,
341 static void __init z2_leds_init(void)
343 platform_device_register(&z2_leds);
346 static inline void z2_leds_init(void) {}
349 /******************************************************************************
351 ******************************************************************************/
352 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
353 static unsigned int z2_matrix_keys[] = {
354 KEY(0, 0, KEY_OPTION),
358 KEY(4, 0, KEY_RIGHT),
360 KEY(6, 0, KEY_KPPLUS),
367 KEY(5, 1, KEY_ENTER),
368 KEY(6, 1, KEY_KPMINUS),
370 KEY(0, 2, KEY_PAGEUP),
375 KEY(5, 2, KEY_LEFTALT),
377 KEY(0, 3, KEY_PAGEDOWN),
382 KEY(5, 3, KEY_LEFTSHIFT),
389 KEY(5, 4, KEY_LEFTCTRL),
396 KEY(5, 5, KEY_SPACE),
398 KEY(0, 6, KEY_STOPCD),
401 KEY(3, 6, KEY_BACKSPACE),
403 KEY(5, 6, KEY_COMMA),
405 KEY(0, 7, KEY_PLAYCD),
409 KEY(4, 7, KEY_SEMICOLON),
413 static struct pxa27x_keypad_platform_data z2_keypad_platform_data = {
414 .matrix_key_rows = 7,
415 .matrix_key_cols = 8,
416 .matrix_key_map = z2_matrix_keys,
417 .matrix_key_map_size = ARRAY_SIZE(z2_matrix_keys),
419 .debounce_interval = 30,
422 static void __init z2_mkp_init(void)
424 pxa_set_keypad_info(&z2_keypad_platform_data);
427 static inline void z2_mkp_init(void) {}
430 /******************************************************************************
432 ******************************************************************************/
433 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
434 static struct gpio_keys_button z2_pxa_buttons[] = {
435 {KEY_POWER, GPIO1_ZIPITZ2_POWER_BUTTON, 0, "Power Button" },
436 {KEY_CLOSE, GPIO98_ZIPITZ2_LID_BUTTON, 0, "Lid Button" },
439 static struct gpio_keys_platform_data z2_pxa_keys_data = {
440 .buttons = z2_pxa_buttons,
441 .nbuttons = ARRAY_SIZE(z2_pxa_buttons),
444 static struct platform_device z2_pxa_keys = {
448 .platform_data = &z2_pxa_keys_data,
452 static void __init z2_keys_init(void)
454 platform_device_register(&z2_pxa_keys);
457 static inline void z2_keys_init(void) {}
460 /******************************************************************************
461 * SSP Devices - WiFi and LCD control
462 ******************************************************************************/
463 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
465 static int z2_lbs_spi_setup(struct spi_device *spi)
469 ret = gpio_request(GPIO15_ZIPITZ2_WIFI_POWER, "WiFi Power");
473 ret = gpio_direction_output(GPIO15_ZIPITZ2_WIFI_POWER, 1);
477 ret = gpio_request(GPIO14_ZIPITZ2_WIFI_RESET, "WiFi Reset");
481 ret = gpio_direction_output(GPIO14_ZIPITZ2_WIFI_RESET, 0);
487 gpio_set_value(GPIO14_ZIPITZ2_WIFI_RESET, 1);
490 spi->bits_per_word = 16;
491 spi->mode = SPI_MODE_2,
498 gpio_free(GPIO14_ZIPITZ2_WIFI_RESET);
500 gpio_free(GPIO15_ZIPITZ2_WIFI_POWER);
505 static int z2_lbs_spi_teardown(struct spi_device *spi)
507 gpio_set_value(GPIO14_ZIPITZ2_WIFI_RESET, 0);
508 gpio_set_value(GPIO15_ZIPITZ2_WIFI_POWER, 0);
509 gpio_free(GPIO14_ZIPITZ2_WIFI_RESET);
510 gpio_free(GPIO15_ZIPITZ2_WIFI_POWER);
515 static struct pxa2xx_spi_chip z2_lbs_chip_info = {
519 .gpio_cs = GPIO24_ZIPITZ2_WIFI_CS,
522 static struct libertas_spi_platform_data z2_lbs_pdata = {
523 .use_dummy_writes = 1,
524 .setup = z2_lbs_spi_setup,
525 .teardown = z2_lbs_spi_teardown,
529 static struct pxa2xx_spi_chip lms283_chip_info = {
533 .gpio_cs = GPIO88_ZIPITZ2_LCD_CS,
536 static const struct lms283gf05_pdata lms283_pdata = {
537 .reset_gpio = GPIO19_ZIPITZ2_LCD_RESET,
540 static struct spi_board_info spi_board_info[] __initdata = {
542 .modalias = "libertas_spi",
543 .platform_data = &z2_lbs_pdata,
544 .controller_data = &z2_lbs_chip_info,
545 .irq = gpio_to_irq(GPIO36_ZIPITZ2_WIFI_IRQ),
546 .max_speed_hz = 13000000,
551 .modalias = "lms283gf05",
552 .controller_data = &lms283_chip_info,
553 .platform_data = &lms283_pdata,
554 .max_speed_hz = 400000,
560 static struct pxa2xx_spi_master pxa_ssp1_master_info = {
561 .clock_enable = CKEN_SSP,
566 static struct pxa2xx_spi_master pxa_ssp2_master_info = {
567 .clock_enable = CKEN_SSP2,
571 static void __init z2_spi_init(void)
573 pxa2xx_set_spi_info(1, &pxa_ssp1_master_info);
574 pxa2xx_set_spi_info(2, &pxa_ssp2_master_info);
575 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
578 static inline void z2_spi_init(void) {}
581 /******************************************************************************
583 ******************************************************************************/
584 static void __init z2_init(void)
586 pxa2xx_mfp_config(ARRAY_AND_SIZE(z2_pin_config));
592 pxa_set_i2c_info(NULL);
601 MACHINE_START(ZIPIT2, "Zipit Z2")
602 .phys_io = 0x40000000,
603 .boot_params = 0xa0000100,
604 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
605 .map_io = pxa_map_io,
606 .init_irq = pxa27x_init_irq,
608 .init_machine = z2_init,