| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 | /* *  linux/arch/arm/mach-pxa/z2.c * *  Support for the Zipit Z2 Handheld device. * *  Copyright (C) 2009-2010 Marek Vasut <marek.vasut@gmail.com> * *  Based on research and code by: Ken McGuire *  Based on mainstone.c as modified for the Zipit Z2. * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License version 2 as *  published by the Free Software Foundation. */#include <linux/platform_device.h>#include <linux/mtd/mtd.h>#include <linux/mtd/partitions.h>#include <linux/pwm_backlight.h>#include <linux/z2_battery.h>#include <linux/dma-mapping.h>#include <linux/spi/spi.h>#include <linux/spi/pxa2xx_spi.h>#include <linux/spi/libertas_spi.h>#include <linux/spi/lms283gf05.h>#include <linux/power_supply.h>#include <linux/mtd/physmap.h>#include <linux/gpio.h>#include <linux/gpio_keys.h>#include <linux/delay.h>#include <linux/regulator/machine.h>#include <linux/i2c/pxa-i2c.h>#include <asm/mach-types.h>#include <asm/mach/arch.h>#include <mach/pxa27x.h>#include <mach/mfp-pxa27x.h>#include <mach/z2.h>#include <linux/platform_data/video-pxafb.h>#include <linux/platform_data/mmc-pxamci.h>#include <linux/platform_data/keypad-pxa27x.h>#include <mach/pm.h>#include "generic.h"#include "devices.h"/****************************************************************************** * Pin configuration ******************************************************************************/static unsigned long z2_pin_config[] = {	/* LCD - 16bpp Active TFT */	GPIO58_LCD_LDD_0,	GPIO59_LCD_LDD_1,	GPIO60_LCD_LDD_2,	GPIO61_LCD_LDD_3,	GPIO62_LCD_LDD_4,	GPIO63_LCD_LDD_5,	GPIO64_LCD_LDD_6,	GPIO65_LCD_LDD_7,	GPIO66_LCD_LDD_8,	GPIO67_LCD_LDD_9,	GPIO68_LCD_LDD_10,	GPIO69_LCD_LDD_11,	GPIO70_LCD_LDD_12,	GPIO71_LCD_LDD_13,	GPIO72_LCD_LDD_14,	GPIO73_LCD_LDD_15,	GPIO74_LCD_FCLK,	GPIO75_LCD_LCLK,	GPIO76_LCD_PCLK,	GPIO77_LCD_BIAS,	GPIO19_GPIO,		/* LCD reset */	GPIO88_GPIO,		/* LCD chipselect */	/* PWM */	GPIO115_PWM1_OUT,	/* Keypad Backlight */	GPIO11_PWM2_OUT,	/* LCD Backlight */	/* MMC */	GPIO32_MMC_CLK,	GPIO112_MMC_CMD,	GPIO92_MMC_DAT_0,	GPIO109_MMC_DAT_1,	GPIO110_MMC_DAT_2,	GPIO111_MMC_DAT_3,	GPIO96_GPIO,		/* SD detect */	/* STUART */	GPIO46_STUART_RXD,	GPIO47_STUART_TXD,	/* Keypad */	GPIO100_KP_MKIN_0,	GPIO101_KP_MKIN_1,	GPIO102_KP_MKIN_2,	GPIO34_KP_MKIN_3,	GPIO38_KP_MKIN_4,	GPIO16_KP_MKIN_5,	GPIO17_KP_MKIN_6,	GPIO103_KP_MKOUT_0,	GPIO104_KP_MKOUT_1,	GPIO105_KP_MKOUT_2,	GPIO106_KP_MKOUT_3,	GPIO107_KP_MKOUT_4,	GPIO108_KP_MKOUT_5,	GPIO35_KP_MKOUT_6,	GPIO41_KP_MKOUT_7,	/* I2C */	GPIO117_I2C_SCL,	GPIO118_I2C_SDA,	/* SSP1 */	GPIO23_SSP1_SCLK,	/* SSP1_SCK */	GPIO25_SSP1_TXD,	/* SSP1_TXD */	GPIO26_SSP1_RXD,	/* SSP1_RXD */	/* SSP2 */	GPIO22_SSP2_SCLK,	/* SSP2_SCK */	GPIO13_SSP2_TXD,	/* SSP2_TXD */	GPIO40_SSP2_RXD,	/* SSP2_RXD */	/* LEDs */	GPIO10_GPIO,		/* WiFi LED */	GPIO83_GPIO,		/* Charging LED */	GPIO85_GPIO,		/* Charged LED */	/* I2S */	GPIO28_I2S_BITCLK_OUT,	GPIO29_I2S_SDATA_IN,	GPIO30_I2S_SDATA_OUT,	GPIO31_I2S_SYNC,	GPIO113_I2S_SYSCLK,	/* MISC */	GPIO0_GPIO,		/* AC power detect */	GPIO1_GPIO,		/* Power button */	GPIO37_GPIO,		/* Headphone detect */	GPIO98_GPIO,		/* Lid switch */	GPIO14_GPIO,		/* WiFi Power */	GPIO24_GPIO,		/* WiFi CS */	GPIO36_GPIO,		/* WiFi IRQ */	GPIO88_GPIO,		/* LCD CS */};/****************************************************************************** * NOR Flash ******************************************************************************/#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)static struct resource z2_flash_resource = {	.start	= PXA_CS0_PHYS,	.end	= PXA_CS0_PHYS + SZ_8M - 1,	.flags	= IORESOURCE_MEM,};static struct mtd_partition z2_flash_parts[] = {	{		.name	= "U-Boot Bootloader",		.offset	= 0x0,		.size	= 0x40000,	}, {		.name	= "U-Boot Environment",		.offset	= 0x40000,		.size	= 0x20000,	}, {		.name	= "Flash",		.offset	= 0x60000,		.size	= MTDPART_SIZ_FULL,	},};static struct physmap_flash_data z2_flash_data = {	.width		= 2,	.parts		= z2_flash_parts,	.nr_parts	= ARRAY_SIZE(z2_flash_parts),};static struct platform_device z2_flash = {	.name		= "physmap-flash",	.id		= -1,	.resource	= &z2_flash_resource,	.num_resources	= 1,	.dev = {		.platform_data	= &z2_flash_data,	},};static void __init z2_nor_init(void){	platform_device_register(&z2_flash);}#elsestatic inline void z2_nor_init(void) {}#endif/****************************************************************************** * Backlight ******************************************************************************/#if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)static struct platform_pwm_backlight_data z2_backlight_data[] = {	[0] = {		/* Keypad Backlight */		.pwm_id		= 1,		.max_brightness	= 1023,		.dft_brightness	= 0,		.pwm_period_ns	= 1260320,	},	[1] = {		/* LCD Backlight */		.pwm_id		= 2,		.max_brightness	= 1023,		.dft_brightness	= 512,		.pwm_period_ns	= 1260320,	},};static struct platform_device z2_backlight_devices[2] = {	{		.name	= "pwm-backlight",		.id	= 0,		.dev	= {			.platform_data	= &z2_backlight_data[1],		},	},	{		.name	= "pwm-backlight",		.id	= 1,		.dev	= {			.platform_data	= &z2_backlight_data[0],		},	},};static void __init z2_pwm_init(void){	platform_device_register(&z2_backlight_devices[0]);	platform_device_register(&z2_backlight_devices[1]);}#elsestatic inline void z2_pwm_init(void) {}#endif/****************************************************************************** * Framebuffer ******************************************************************************/#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)static struct pxafb_mode_info z2_lcd_modes[] = {{	.pixclock	= 192000,	.xres		= 240,	.yres		= 320,	.bpp		= 16,	.left_margin	= 4,	.right_margin	= 8,	.upper_margin	= 4,	.lower_margin	= 8,	.hsync_len	= 4,	.vsync_len	= 4,},};static struct pxafb_mach_info z2_lcd_screen = {	.modes		= z2_lcd_modes,	.num_modes      = ARRAY_SIZE(z2_lcd_modes),	.lcd_conn	= LCD_COLOR_TFT_16BPP | LCD_BIAS_ACTIVE_LOW |			  LCD_ALTERNATE_MAPPING,};static void __init z2_lcd_init(void){	pxa_set_fb_info(NULL, &z2_lcd_screen);}#elsestatic inline void z2_lcd_init(void) {}#endif/****************************************************************************** * SD/MMC card controller ******************************************************************************/#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)static struct pxamci_platform_data z2_mci_platform_data = {	.ocr_mask		= MMC_VDD_32_33 | MMC_VDD_33_34,	.gpio_card_detect	= GPIO96_ZIPITZ2_SD_DETECT,	.gpio_power		= -1,	.gpio_card_ro		= -1,	.detect_delay_ms	= 200,};static void __init z2_mmc_init(void){	pxa_set_mci_info(&z2_mci_platform_data);}#elsestatic inline void z2_mmc_init(void) {}#endif/****************************************************************************** * LEDs ******************************************************************************/#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)struct gpio_led z2_gpio_leds[] = {{	.name			= "z2:green:wifi",	.default_trigger	= "none",	.gpio			= GPIO10_ZIPITZ2_LED_WIFI,	.active_low		= 1,}, {
 |