| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  *  Support for Sharp SL-C6000x PDAs | 
					
						
							|  |  |  |  *  Model: (Tosa) | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *  Copyright (c) 2005 Dirk Opfer | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *	Based on code written by Sharp/Lineo for 2.4 kernels | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *  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/kernel.h>
 | 
					
						
							|  |  |  | #include <linux/init.h>
 | 
					
						
							| 
									
										
										
										
											2005-11-21 15:17:06 +00:00
										 |  |  | #include <linux/platform_device.h>
 | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | #include <linux/major.h>
 | 
					
						
							|  |  |  | #include <linux/fs.h>
 | 
					
						
							|  |  |  | #include <linux/interrupt.h>
 | 
					
						
							|  |  |  | #include <linux/mmc/host.h>
 | 
					
						
							| 
									
										
										
										
											2006-06-19 19:57:12 +01:00
										 |  |  | #include <linux/pm.h>
 | 
					
						
							| 
									
										
										
										
											2006-06-20 23:27:37 +01:00
										 |  |  | #include <linux/delay.h>
 | 
					
						
							| 
									
										
										
										
											2008-01-21 01:04:20 -05:00
										 |  |  | #include <linux/gpio_keys.h>
 | 
					
						
							|  |  |  | #include <linux/input.h>
 | 
					
						
							| 
									
										
										
										
											2008-04-12 20:16:16 +01:00
										 |  |  | #include <linux/gpio.h>
 | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <asm/setup.h>
 | 
					
						
							|  |  |  | #include <asm/memory.h>
 | 
					
						
							|  |  |  | #include <asm/mach-types.h>
 | 
					
						
							|  |  |  | #include <asm/hardware.h>
 | 
					
						
							|  |  |  | #include <asm/irq.h>
 | 
					
						
							| 
									
										
										
										
											2006-06-19 19:57:12 +01:00
										 |  |  | #include <asm/system.h>
 | 
					
						
							| 
									
										
										
										
											2007-03-07 00:02:15 +01:00
										 |  |  | #include <asm/arch/pxa-regs.h>
 | 
					
						
							| 
									
										
										
										
											2008-01-30 09:39:48 +01:00
										 |  |  | #include <asm/arch/pxa2xx-regs.h>
 | 
					
						
							| 
									
										
										
										
											2008-04-10 11:00:32 +01:00
										 |  |  | #include <asm/arch/mfp-pxa25x.h>
 | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | #include <asm/arch/irda.h>
 | 
					
						
							| 
									
										
										
										
											2008-04-10 15:43:18 +01:00
										 |  |  | #include <asm/arch/i2c.h>
 | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | #include <asm/arch/mmc.h>
 | 
					
						
							|  |  |  | #include <asm/arch/udc.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <asm/mach/arch.h>
 | 
					
						
							|  |  |  | #include <asm/mach/map.h>
 | 
					
						
							|  |  |  | #include <asm/mach/irq.h>
 | 
					
						
							|  |  |  | #include <asm/arch/tosa.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <asm/hardware/scoop.h>
 | 
					
						
							|  |  |  | #include <asm/mach/sharpsl_param.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "generic.h"
 | 
					
						
							| 
									
										
										
										
											2007-05-15 15:39:36 +01:00
										 |  |  | #include "devices.h"
 | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-10 11:00:32 +01:00
										 |  |  | static unsigned long tosa_pin_config[] = { | 
					
						
							|  |  |  | 	GPIO78_nCS_2, /* Scoop */ | 
					
						
							|  |  |  | 	GPIO80_nCS_4, /* tg6393xb */ | 
					
						
							|  |  |  | 	GPIO33_nCS_5, /* Scoop */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// GPIO76 CARD_VCC_ON1
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	GPIO19_GPIO, /* Reset out */ | 
					
						
							|  |  |  | 	GPIO1_RST | WAKEUP_ON_EDGE_FALL, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	GPIO0_GPIO | WAKEUP_ON_EDGE_FALL, /* WAKE_UP */ | 
					
						
							|  |  |  | 	GPIO2_GPIO | WAKEUP_ON_EDGE_BOTH, /* AC_IN */ | 
					
						
							|  |  |  | 	GPIO3_GPIO | WAKEUP_ON_EDGE_FALL, /* RECORD */ | 
					
						
							|  |  |  | 	GPIO4_GPIO | WAKEUP_ON_EDGE_FALL, /* SYNC */ | 
					
						
							|  |  |  | 	GPIO20_GPIO, /* EAR_IN */ | 
					
						
							|  |  |  | 	GPIO22_GPIO, /* On */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	GPIO5_GPIO, /* USB_IN */ | 
					
						
							|  |  |  | 	GPIO32_GPIO, /* Pen IRQ */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	GPIO7_GPIO, /* Jacket Detect */ | 
					
						
							|  |  |  | 	GPIO14_GPIO, /* BAT0_CRG */ | 
					
						
							|  |  |  | 	GPIO12_GPIO, /* BAT1_CRG */ | 
					
						
							|  |  |  | 	GPIO17_GPIO, /* BAT0_LOW */ | 
					
						
							|  |  |  | 	GPIO84_GPIO, /* BAT1_LOW */ | 
					
						
							|  |  |  | 	GPIO38_GPIO, /* BAT_LOCK */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	GPIO11_3_6MHz, | 
					
						
							|  |  |  | 	GPIO15_GPIO, /* TC6393XB IRQ */ | 
					
						
							|  |  |  | 	GPIO18_RDY, | 
					
						
							|  |  |  | 	GPIO27_GPIO, /* LCD Sync */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* MMC */ | 
					
						
							|  |  |  | 	GPIO6_MMC_CLK, | 
					
						
							|  |  |  | 	GPIO8_MMC_CS0, | 
					
						
							|  |  |  | 	GPIO9_GPIO, /* Detect */ | 
					
						
							|  |  |  | 	// GPIO10 nSD_INT
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* CF */ | 
					
						
							|  |  |  | 	GPIO13_GPIO, /* CD_IRQ */ | 
					
						
							|  |  |  | 	GPIO21_GPIO, /* Main Slot IRQ */ | 
					
						
							|  |  |  | 	GPIO36_GPIO, /* Jacket Slot IRQ */ | 
					
						
							|  |  |  | 	GPIO48_nPOE, | 
					
						
							|  |  |  | 	GPIO49_nPWE, | 
					
						
							|  |  |  | 	GPIO50_nPIOR, | 
					
						
							|  |  |  | 	GPIO51_nPIOW, | 
					
						
							|  |  |  | 	GPIO52_nPCE_1, | 
					
						
							|  |  |  | 	GPIO53_nPCE_2, | 
					
						
							|  |  |  | 	GPIO54_nPSKTSEL, | 
					
						
							|  |  |  | 	GPIO55_nPREG, | 
					
						
							|  |  |  | 	GPIO56_nPWAIT, | 
					
						
							|  |  |  | 	GPIO57_nIOIS16, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* AC97 */ | 
					
						
							|  |  |  | 	GPIO31_AC97_SYNC, | 
					
						
							|  |  |  | 	GPIO30_AC97_SDATA_OUT, | 
					
						
							|  |  |  | 	GPIO28_AC97_BITCLK, | 
					
						
							|  |  |  | 	GPIO29_AC97_SDATA_IN_0, | 
					
						
							|  |  |  | 	// GPIO79 nAUD_IRQ
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* FFUART */ | 
					
						
							|  |  |  | 	GPIO34_FFUART_RXD, | 
					
						
							|  |  |  | 	GPIO35_FFUART_CTS, | 
					
						
							|  |  |  | 	GPIO37_FFUART_DSR, | 
					
						
							|  |  |  | 	GPIO39_FFUART_TXD, | 
					
						
							|  |  |  | 	GPIO40_FFUART_DTR, | 
					
						
							|  |  |  | 	GPIO41_FFUART_RTS, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* BTUART */ | 
					
						
							|  |  |  | 	GPIO42_BTUART_RXD, | 
					
						
							|  |  |  | 	GPIO43_BTUART_TXD, | 
					
						
							|  |  |  | 	GPIO44_BTUART_CTS, | 
					
						
							|  |  |  | 	GPIO45_BTUART_RTS, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* IrDA */ | 
					
						
							|  |  |  | 	GPIO46_STUART_RXD, | 
					
						
							|  |  |  | 	GPIO47_STUART_TXD, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Keybd */ | 
					
						
							|  |  |  | 	GPIO58_GPIO, | 
					
						
							|  |  |  | 	GPIO59_GPIO, | 
					
						
							|  |  |  | 	GPIO60_GPIO, | 
					
						
							|  |  |  | 	GPIO61_GPIO, | 
					
						
							|  |  |  | 	GPIO62_GPIO, | 
					
						
							|  |  |  | 	GPIO63_GPIO, | 
					
						
							|  |  |  | 	GPIO64_GPIO, | 
					
						
							|  |  |  | 	GPIO65_GPIO, | 
					
						
							|  |  |  | 	GPIO66_GPIO, | 
					
						
							|  |  |  | 	GPIO67_GPIO, | 
					
						
							|  |  |  | 	GPIO68_GPIO, | 
					
						
							|  |  |  | 	GPIO69_GPIO, | 
					
						
							|  |  |  | 	GPIO70_GPIO, | 
					
						
							|  |  |  | 	GPIO71_GPIO, | 
					
						
							|  |  |  | 	GPIO72_GPIO, | 
					
						
							|  |  |  | 	GPIO73_GPIO, | 
					
						
							|  |  |  | 	GPIO74_GPIO, | 
					
						
							|  |  |  | 	GPIO75_GPIO, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* SPI */ | 
					
						
							|  |  |  | 	GPIO81_SSP2_CLK_OUT, | 
					
						
							|  |  |  | 	GPIO82_SSP2_FRM_OUT, | 
					
						
							|  |  |  | 	GPIO83_SSP2_TXD, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * SCOOP Device | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static struct resource tosa_scoop_resources[] = { | 
					
						
							|  |  |  | 	[0] = { | 
					
						
							|  |  |  | 		.start	= TOSA_CF_PHYS, | 
					
						
							|  |  |  | 		.end	= TOSA_CF_PHYS + 0xfff, | 
					
						
							|  |  |  | 		.flags	= IORESOURCE_MEM, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct scoop_config tosa_scoop_setup = { | 
					
						
							|  |  |  | 	.io_dir 	= TOSA_SCOOP_IO_DIR, | 
					
						
							| 
									
										
										
										
											2008-04-12 20:16:16 +01:00
										 |  |  | 	.gpio_base	= TOSA_SCOOP_GPIO_BASE, | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-19 10:42:25 +01:00
										 |  |  | static struct platform_device tosascoop_device = { | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | 	.name		= "sharp-scoop", | 
					
						
							|  |  |  | 	.id		= 0, | 
					
						
							|  |  |  | 	.dev		= { | 
					
						
							|  |  |  |  		.platform_data	= &tosa_scoop_setup, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	.num_resources	= ARRAY_SIZE(tosa_scoop_resources), | 
					
						
							|  |  |  | 	.resource	= tosa_scoop_resources, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * SCOOP Device Jacket | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static struct resource tosa_scoop_jc_resources[] = { | 
					
						
							|  |  |  | 	[0] = { | 
					
						
							|  |  |  | 		.start		= TOSA_SCOOP_PHYS + 0x40, | 
					
						
							|  |  |  | 		.end		= TOSA_SCOOP_PHYS + 0xfff, | 
					
						
							|  |  |  | 		.flags		= IORESOURCE_MEM, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct scoop_config tosa_scoop_jc_setup = { | 
					
						
							|  |  |  | 	.io_dir 	= TOSA_SCOOP_JC_IO_DIR, | 
					
						
							| 
									
										
										
										
											2008-04-12 20:16:16 +01:00
										 |  |  | 	.gpio_base	= TOSA_SCOOP_JC_GPIO_BASE, | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-19 10:42:25 +01:00
										 |  |  | static struct platform_device tosascoop_jc_device = { | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | 	.name		= "sharp-scoop", | 
					
						
							|  |  |  | 	.id		= 1, | 
					
						
							|  |  |  | 	.dev		= { | 
					
						
							|  |  |  |  		.platform_data	= &tosa_scoop_jc_setup, | 
					
						
							|  |  |  | 		.parent 	= &tosascoop_device.dev, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	.num_resources	= ARRAY_SIZE(tosa_scoop_jc_resources), | 
					
						
							|  |  |  | 	.resource	= tosa_scoop_jc_resources, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:50 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * PCMCIA | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = { | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	.dev        = &tosascoop_device.dev, | 
					
						
							|  |  |  | 	.irq        = TOSA_IRQ_GPIO_CF_IRQ, | 
					
						
							|  |  |  | 	.cd_irq     = TOSA_IRQ_GPIO_CF_CD, | 
					
						
							|  |  |  | 	.cd_irq_str = "PCMCIA0 CD", | 
					
						
							|  |  |  | },{ | 
					
						
							|  |  |  | 	.dev        = &tosascoop_jc_device.dev, | 
					
						
							|  |  |  | 	.irq        = TOSA_IRQ_GPIO_JC_CF_IRQ, | 
					
						
							|  |  |  | 	.cd_irq     = -1, | 
					
						
							|  |  |  | }, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:50 +00:00
										 |  |  | static struct scoop_pcmcia_config tosa_pcmcia_config = { | 
					
						
							|  |  |  | 	.devs         = &tosa_pcmcia_scoop[0], | 
					
						
							|  |  |  | 	.num_devs     = 2, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * USB Device Controller | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static struct pxa2xx_udc_mach_info udc_info __initdata = { | 
					
						
							| 
									
										
										
										
											2008-04-12 20:16:16 +01:00
										 |  |  | 	.gpio_pullup		= TOSA_GPIO_USB_PULLUP, | 
					
						
							| 
									
										
										
										
											2007-12-21 12:18:01 +03:00
										 |  |  | 	.gpio_vbus		= TOSA_GPIO_USB_IN, | 
					
						
							|  |  |  | 	.gpio_vbus_inverted	= 1, | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * MMC/SD Device | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static struct pxamci_platform_data tosa_mci_platform_data; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-09 12:19:47 +01:00
										 |  |  | static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data) | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-23 14:05:58 +00:00
										 |  |  | 	err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int, | 
					
						
							|  |  |  | 			  IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | 				"MMC/SD card detect", data); | 
					
						
							| 
									
										
										
										
											2008-04-12 20:16:16 +01:00
										 |  |  | 	if (err) { | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | 		printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n"); | 
					
						
							| 
									
										
										
										
											2008-04-12 20:16:16 +01:00
										 |  |  | 		goto err_irq; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	err = gpio_request(TOSA_GPIO_SD_WP, "sd_wp"); | 
					
						
							|  |  |  | 	if (err) { | 
					
						
							|  |  |  | 		printk(KERN_ERR "tosa_mci_init: can't request SD_WP gpio\n"); | 
					
						
							|  |  |  | 		goto err_gpio_wp; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	err = gpio_direction_input(TOSA_GPIO_SD_WP); | 
					
						
							|  |  |  | 	if (err) | 
					
						
							|  |  |  | 		goto err_gpio_wp_dir; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	err = gpio_request(TOSA_GPIO_PWR_ON, "sd_pwr"); | 
					
						
							|  |  |  | 	if (err) { | 
					
						
							|  |  |  | 		printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n"); | 
					
						
							|  |  |  | 		goto err_gpio_pwr; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	err = gpio_direction_output(TOSA_GPIO_PWR_ON, 0); | 
					
						
							|  |  |  | 	if (err) | 
					
						
							|  |  |  | 		goto err_gpio_pwr_dir; | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-12 20:16:16 +01:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | err_gpio_pwr_dir: | 
					
						
							|  |  |  | 	gpio_free(TOSA_GPIO_PWR_ON); | 
					
						
							|  |  |  | err_gpio_pwr: | 
					
						
							|  |  |  | err_gpio_wp_dir: | 
					
						
							|  |  |  | 	gpio_free(TOSA_GPIO_SD_WP); | 
					
						
							|  |  |  | err_gpio_wp: | 
					
						
							|  |  |  | 	free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data); | 
					
						
							|  |  |  | err_irq: | 
					
						
							| 
									
										
										
										
											2008-01-23 14:05:58 +00:00
										 |  |  | 	return err; | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void tosa_mci_setpower(struct device *dev, unsigned int vdd) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct pxamci_platform_data* p_d = dev->platform_data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (( 1 << vdd) & p_d->ocr_mask) { | 
					
						
							| 
									
										
										
										
											2008-04-12 20:16:16 +01:00
										 |  |  | 		gpio_set_value(TOSA_GPIO_PWR_ON, 1); | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2008-04-12 20:16:16 +01:00
										 |  |  | 		gpio_set_value(TOSA_GPIO_PWR_ON, 0); | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int tosa_mci_get_ro(struct device *dev) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2008-04-12 20:16:16 +01:00
										 |  |  | 	return gpio_get_value(TOSA_GPIO_SD_WP); | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void tosa_mci_exit(struct device *dev, void *data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2008-04-12 20:16:16 +01:00
										 |  |  | 	gpio_free(TOSA_GPIO_PWR_ON); | 
					
						
							|  |  |  | 	gpio_free(TOSA_GPIO_SD_WP); | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | 	free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct pxamci_platform_data tosa_mci_platform_data = { | 
					
						
							|  |  |  | 	.ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34, | 
					
						
							|  |  |  | 	.init           = tosa_mci_init, | 
					
						
							|  |  |  | 	.get_ro		= tosa_mci_get_ro, | 
					
						
							|  |  |  | 	.setpower       = tosa_mci_setpower, | 
					
						
							|  |  |  | 	.exit           = tosa_mci_exit, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Irda | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2008-04-12 20:16:16 +01:00
										 |  |  | static int tosa_irda_startup(struct device *dev) | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2008-04-12 20:16:16 +01:00
										 |  |  | 	int ret; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown"); | 
					
						
							|  |  |  | 	if (ret) | 
					
						
							|  |  |  | 		return ret; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0); | 
					
						
							|  |  |  | 	if (ret) | 
					
						
							|  |  |  | 		gpio_free(TOSA_GPIO_IR_POWERDWN); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-04-12 20:16:16 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | static void tosa_irda_shutdown(struct device *dev) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	gpio_free(TOSA_GPIO_IR_POWERDWN); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void tosa_irda_transceiver_mode(struct device *dev, int mode) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	gpio_set_value(TOSA_GPIO_IR_POWERDWN, !(mode & IR_OFF)); | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct pxaficp_platform_data tosa_ficp_platform_data = { | 
					
						
							|  |  |  | 	.transceiver_cap  = IR_SIRMODE | IR_OFF, | 
					
						
							|  |  |  | 	.transceiver_mode = tosa_irda_transceiver_mode, | 
					
						
							| 
									
										
										
										
											2008-04-12 20:16:16 +01:00
										 |  |  | 	.startup = tosa_irda_startup, | 
					
						
							|  |  |  | 	.shutdown = tosa_irda_shutdown, | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Tosa Keyboard | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static struct platform_device tosakbd_device = { | 
					
						
							|  |  |  | 	.name		= "tosa-keyboard", | 
					
						
							|  |  |  | 	.id		= -1, | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-21 01:04:20 -05:00
										 |  |  | static struct gpio_keys_button tosa_gpio_keys[] = { | 
					
						
							| 
									
										
										
										
											2008-04-12 20:02:50 +01:00
										 |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * Two following keys are directly tied to "ON" button of tosa. Why? | 
					
						
							|  |  |  | 	 * The first one can be used as a wakeup source, the second can't; | 
					
						
							|  |  |  | 	 * also the first one is OR of ac_powered and on_button. | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		.type	= EV_PWR, | 
					
						
							|  |  |  | 		.code	= KEY_RESERVED, | 
					
						
							|  |  |  | 		.gpio	= TOSA_GPIO_POWERON, | 
					
						
							|  |  |  | 		.desc	= "Poweron", | 
					
						
							|  |  |  | 		.wakeup	= 1, | 
					
						
							|  |  |  | 		.active_low = 1, | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2008-01-21 01:04:20 -05:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		.type	= EV_PWR, | 
					
						
							|  |  |  | 		.code	= KEY_SUSPEND, | 
					
						
							|  |  |  | 		.gpio	= TOSA_GPIO_ON_KEY, | 
					
						
							|  |  |  | 		.desc	= "On key", | 
					
						
							| 
									
										
										
										
											2008-04-12 20:02:50 +01:00
										 |  |  | 		/*
 | 
					
						
							|  |  |  | 		 * can't be used as wakeup | 
					
						
							|  |  |  | 		 * .wakeup	= 1, | 
					
						
							|  |  |  | 		 */ | 
					
						
							| 
									
										
										
										
											2008-01-21 01:04:20 -05:00
										 |  |  | 		.active_low = 1, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		.type	= EV_KEY, | 
					
						
							|  |  |  | 		.code	= TOSA_KEY_RECORD, | 
					
						
							|  |  |  | 		.gpio	= TOSA_GPIO_RECORD_BTN, | 
					
						
							|  |  |  | 		.desc	= "Record Button", | 
					
						
							|  |  |  | 		.wakeup	= 1, | 
					
						
							|  |  |  | 		.active_low = 1, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		.type	= EV_KEY, | 
					
						
							|  |  |  | 		.code	= TOSA_KEY_SYNC, | 
					
						
							|  |  |  | 		.gpio	= TOSA_GPIO_SYNC, | 
					
						
							|  |  |  | 		.desc	= "Sync Button", | 
					
						
							|  |  |  | 		.wakeup	= 1, | 
					
						
							|  |  |  | 		.active_low = 1, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = { | 
					
						
							|  |  |  | 	.buttons	= tosa_gpio_keys, | 
					
						
							|  |  |  | 	.nbuttons	= ARRAY_SIZE(tosa_gpio_keys), | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct platform_device tosa_gpio_keys_device = { | 
					
						
							|  |  |  | 	.name	= "gpio-keys", | 
					
						
							|  |  |  | 	.id	= -1, | 
					
						
							|  |  |  | 	.dev	= { | 
					
						
							|  |  |  | 		.platform_data	= &tosa_gpio_keys_platform_data, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-31 02:31:12 -08:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Tosa LEDs | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2008-04-19 10:42:25 +01:00
										 |  |  | static struct gpio_led tosa_gpio_leds[] = { | 
					
						
							| 
									
										
										
										
											2008-04-12 20:17:02 +01:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		.name			= "tosa:amber:charge", | 
					
						
							|  |  |  | 		.default_trigger	= "main-battery-charging", | 
					
						
							|  |  |  | 		.gpio			= TOSA_GPIO_CHRG_ERR_LED, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		.name			= "tosa:green:mail", | 
					
						
							|  |  |  | 		.default_trigger	= "nand-disk", | 
					
						
							|  |  |  | 		.gpio			= TOSA_GPIO_NOTE_LED, | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2008-04-19 10:42:06 +01:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		.name			= "tosa:dual:wlan", | 
					
						
							|  |  |  | 		.default_trigger	= "none", | 
					
						
							|  |  |  | 		.gpio			= TOSA_GPIO_WLAN_LED, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		.name			= "tosa:blue:bluetooth", | 
					
						
							|  |  |  | 		.default_trigger	= "none", | 
					
						
							|  |  |  | 		.gpio			= TOSA_GPIO_BT_LED, | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2008-04-12 20:17:02 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-19 10:42:25 +01:00
										 |  |  | static struct gpio_led_platform_data tosa_gpio_leds_platform_data = { | 
					
						
							| 
									
										
										
										
											2008-04-12 20:17:02 +01:00
										 |  |  | 	.leds		= tosa_gpio_leds, | 
					
						
							|  |  |  | 	.num_leds	= ARRAY_SIZE(tosa_gpio_leds), | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-03-31 02:31:12 -08:00
										 |  |  | static struct platform_device tosaled_device = { | 
					
						
							| 
									
										
										
										
											2008-04-12 20:17:02 +01:00
										 |  |  | 	.name	= "leds-gpio", | 
					
						
							|  |  |  | 	.id	= -1, | 
					
						
							|  |  |  | 	.dev	= { | 
					
						
							|  |  |  | 		.platform_data	= &tosa_gpio_leds_platform_data, | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2006-03-31 02:31:12 -08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | static struct platform_device *devices[] __initdata = { | 
					
						
							|  |  |  | 	&tosascoop_device, | 
					
						
							|  |  |  | 	&tosascoop_jc_device, | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | 	&tosakbd_device, | 
					
						
							| 
									
										
										
										
											2008-01-21 01:04:20 -05:00
										 |  |  | 	&tosa_gpio_keys_device, | 
					
						
							| 
									
										
										
										
											2006-03-31 02:31:12 -08:00
										 |  |  | 	&tosaled_device, | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-06-19 19:57:12 +01:00
										 |  |  | static void tosa_poweroff(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pxa_gpio_mode(TOSA_GPIO_ON_RESET | GPIO_OUT); | 
					
						
							|  |  |  | 	GPSR(TOSA_GPIO_ON_RESET) = GPIO_bit(TOSA_GPIO_ON_RESET); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	mdelay(1000); | 
					
						
							|  |  |  | 	arm_machine_restart('h'); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void tosa_restart(char mode) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	/* Bootloader magic for a reboot */ | 
					
						
							|  |  |  | 	if((MSC0 & 0xffff0000) == 0x7ff00000) | 
					
						
							|  |  |  | 		MSC0 = (MSC0 & 0xffff) | 0x7ee00000; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tosa_poweroff(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | static void __init tosa_init(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2008-04-10 11:00:32 +01:00
										 |  |  | 	pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config)); | 
					
						
							|  |  |  | 	gpio_set_wake(MFP_PIN_GPIO1, 1); | 
					
						
							|  |  |  | 	/* We can't pass to gpio-keys since it will drop the Reset altfunc */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-06-19 19:57:12 +01:00
										 |  |  | 	pm_power_off = tosa_poweroff; | 
					
						
							|  |  |  | 	arm_pm_restart = tosa_restart; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | 	PCFR |= PCFR_OPDE; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | 	/* enable batt_fault */ | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | 	PMCR = 0x01; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:30 +00:00
										 |  |  | 	pxa_set_mci_info(&tosa_mci_platform_data); | 
					
						
							|  |  |  | 	pxa_set_udc_info(&udc_info); | 
					
						
							|  |  |  | 	pxa_set_ficp_info(&tosa_ficp_platform_data); | 
					
						
							| 
									
										
										
										
											2008-04-10 15:43:18 +01:00
										 |  |  | 	pxa_set_i2c_info(NULL); | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:50 +00:00
										 |  |  | 	platform_scoop_config = &tosa_pcmcia_config; | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-08 19:15:50 +00:00
										 |  |  | 	platform_add_devices(devices, ARRAY_SIZE(devices)); | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void __init fixup_tosa(struct machine_desc *desc, | 
					
						
							|  |  |  | 		struct tag *tags, char **cmdline, struct meminfo *mi) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	sharpsl_save_param(); | 
					
						
							|  |  |  | 	mi->nr_banks=1; | 
					
						
							|  |  |  | 	mi->bank[0].start = 0xa0000000; | 
					
						
							|  |  |  | 	mi->bank[0].node = 0; | 
					
						
							|  |  |  | 	mi->bank[0].size = (64*1024*1024); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MACHINE_START(TOSA, "SHARP Tosa") | 
					
						
							|  |  |  | 	.phys_io	= 0x40000000, | 
					
						
							|  |  |  | 	.io_pg_offst	= (io_p2v(0x40000000) >> 18) & 0xfffc, | 
					
						
							|  |  |  | 	.fixup          = fixup_tosa, | 
					
						
							|  |  |  | 	.map_io         = pxa_map_io, | 
					
						
							| 
									
										
										
										
											2007-06-22 04:14:09 +01:00
										 |  |  | 	.init_irq       = pxa25x_init_irq, | 
					
						
							| 
									
										
										
										
											2005-11-06 14:27:52 +00:00
										 |  |  | 	.init_machine   = tosa_init, | 
					
						
							|  |  |  | 	.timer          = &pxa_timer, | 
					
						
							|  |  |  | MACHINE_END |