| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 1 | /* | 
|  | 2 | *  Support for Sharp SL-C6000x PDAs | 
|  | 3 | *  Model: (Tosa) | 
|  | 4 | * | 
|  | 5 | *  Copyright (c) 2005 Dirk Opfer | 
|  | 6 | * | 
|  | 7 | *	Based on code written by Sharp/Lineo for 2.4 kernels | 
|  | 8 | * | 
|  | 9 | *  This program is free software; you can redistribute it and/or modify | 
|  | 10 | *  it under the terms of the GNU General Public License version 2 as | 
|  | 11 | *  published by the Free Software Foundation. | 
|  | 12 | * | 
|  | 13 | */ | 
|  | 14 |  | 
|  | 15 | #include <linux/kernel.h> | 
|  | 16 | #include <linux/init.h> | 
| Dirk Opfer | 067c904 | 2005-11-21 15:17:06 +0000 | [diff] [blame] | 17 | #include <linux/platform_device.h> | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 18 | #include <linux/major.h> | 
|  | 19 | #include <linux/fs.h> | 
|  | 20 | #include <linux/interrupt.h> | 
| Dmitry Baryshkov | bf0116e | 2008-06-14 11:42:02 +0100 | [diff] [blame] | 21 | #include <linux/delay.h> | 
|  | 22 | #include <linux/fb.h> | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 23 | #include <linux/mmc/host.h> | 
| Dmitry Baryshkov | bf0116e | 2008-06-14 11:42:02 +0100 | [diff] [blame] | 24 | #include <linux/mfd/tc6393xb.h> | 
| Dmitry Baryshkov | 5289fec | 2008-06-27 10:38:44 +0100 | [diff] [blame] | 25 | #include <linux/mfd/tmio.h> | 
|  | 26 | #include <linux/mtd/nand.h> | 
|  | 27 | #include <linux/mtd/partitions.h> | 
| Dmitry Baryshkov | f34ee79 | 2008-11-25 00:57:27 +0300 | [diff] [blame] | 28 | #include <linux/mtd/physmap.h> | 
| Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 29 | #include <linux/pm.h> | 
| Dmitry Baryshkov | 93e9012 | 2008-01-21 01:04:20 -0500 | [diff] [blame] | 30 | #include <linux/gpio_keys.h> | 
|  | 31 | #include <linux/input.h> | 
| Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 32 | #include <linux/gpio.h> | 
| Dmitry Baryshkov | 53b14ea | 2008-06-14 11:43:36 +0100 | [diff] [blame] | 33 | #include <linux/pda_power.h> | 
| Dmitry Baryshkov | 14b7b40 | 2008-09-13 21:06:41 +0400 | [diff] [blame] | 34 | #include <linux/spi/spi.h> | 
| Eric Miao | f69a654 | 2010-01-01 15:28:21 +0800 | [diff] [blame] | 35 | #include <linux/input/matrix_keypad.h> | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 36 |  | 
|  | 37 | #include <asm/setup.h> | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 38 | #include <asm/mach-types.h> | 
| Eric Miao | 51c6298 | 2009-01-02 23:17:22 +0800 | [diff] [blame] | 39 |  | 
|  | 40 | #include <mach/pxa25x.h> | 
| Russell King | afd2fc0 | 2008-08-07 11:05:25 +0100 | [diff] [blame] | 41 | #include <mach/reset.h> | 
| Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 42 | #include <mach/irda.h> | 
| Eric Miao | f0a8370 | 2009-04-13 15:03:11 +0800 | [diff] [blame] | 43 | #include <plat/i2c.h> | 
| Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 44 | #include <mach/mmc.h> | 
|  | 45 | #include <mach/udc.h> | 
|  | 46 | #include <mach/tosa_bt.h> | 
| Dmitry Baryshkov | 14b7b40 | 2008-09-13 21:06:41 +0400 | [diff] [blame] | 47 | #include <mach/pxa2xx_spi.h> | 
| Mark Brown | 80748fb | 2009-04-03 12:45:49 +0100 | [diff] [blame] | 48 | #include <mach/audio.h> | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 49 |  | 
|  | 50 | #include <asm/mach/arch.h> | 
| Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 51 | #include <mach/tosa.h> | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 52 |  | 
|  | 53 | #include <asm/hardware/scoop.h> | 
|  | 54 | #include <asm/mach/sharpsl_param.h> | 
|  | 55 |  | 
|  | 56 | #include "generic.h" | 
| Dmitry Baryshkov | 7bdb22c | 2008-09-10 10:30:37 +0100 | [diff] [blame] | 57 | #include "clock.h" | 
| Russell King | 46c41e6 | 2007-05-15 15:39:36 +0100 | [diff] [blame] | 58 | #include "devices.h" | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 59 |  | 
| Dmitry Baryshkov | 2cb4734 | 2008-04-10 11:00:32 +0100 | [diff] [blame] | 60 | static unsigned long tosa_pin_config[] = { | 
|  | 61 | GPIO78_nCS_2, /* Scoop */ | 
|  | 62 | GPIO80_nCS_4, /* tg6393xb */ | 
|  | 63 | GPIO33_nCS_5, /* Scoop */ | 
|  | 64 |  | 
|  | 65 | // GPIO76 CARD_VCC_ON1 | 
|  | 66 |  | 
|  | 67 | GPIO19_GPIO, /* Reset out */ | 
|  | 68 | GPIO1_RST | WAKEUP_ON_EDGE_FALL, | 
|  | 69 |  | 
|  | 70 | GPIO0_GPIO | WAKEUP_ON_EDGE_FALL, /* WAKE_UP */ | 
|  | 71 | GPIO2_GPIO | WAKEUP_ON_EDGE_BOTH, /* AC_IN */ | 
|  | 72 | GPIO3_GPIO | WAKEUP_ON_EDGE_FALL, /* RECORD */ | 
|  | 73 | GPIO4_GPIO | WAKEUP_ON_EDGE_FALL, /* SYNC */ | 
|  | 74 | GPIO20_GPIO, /* EAR_IN */ | 
|  | 75 | GPIO22_GPIO, /* On */ | 
|  | 76 |  | 
|  | 77 | GPIO5_GPIO, /* USB_IN */ | 
|  | 78 | GPIO32_GPIO, /* Pen IRQ */ | 
|  | 79 |  | 
|  | 80 | GPIO7_GPIO, /* Jacket Detect */ | 
|  | 81 | GPIO14_GPIO, /* BAT0_CRG */ | 
|  | 82 | GPIO12_GPIO, /* BAT1_CRG */ | 
|  | 83 | GPIO17_GPIO, /* BAT0_LOW */ | 
|  | 84 | GPIO84_GPIO, /* BAT1_LOW */ | 
|  | 85 | GPIO38_GPIO, /* BAT_LOCK */ | 
|  | 86 |  | 
|  | 87 | GPIO11_3_6MHz, | 
|  | 88 | GPIO15_GPIO, /* TC6393XB IRQ */ | 
|  | 89 | GPIO18_RDY, | 
|  | 90 | GPIO27_GPIO, /* LCD Sync */ | 
|  | 91 |  | 
|  | 92 | /* MMC */ | 
|  | 93 | GPIO6_MMC_CLK, | 
|  | 94 | GPIO8_MMC_CS0, | 
|  | 95 | GPIO9_GPIO, /* Detect */ | 
| Dmitry Baryshkov | c4d5f8d | 2008-06-09 13:23:50 +0100 | [diff] [blame] | 96 | GPIO10_GPIO, /* nSD_INT */ | 
| Dmitry Baryshkov | 2cb4734 | 2008-04-10 11:00:32 +0100 | [diff] [blame] | 97 |  | 
|  | 98 | /* CF */ | 
|  | 99 | GPIO13_GPIO, /* CD_IRQ */ | 
|  | 100 | GPIO21_GPIO, /* Main Slot IRQ */ | 
|  | 101 | GPIO36_GPIO, /* Jacket Slot IRQ */ | 
|  | 102 | GPIO48_nPOE, | 
|  | 103 | GPIO49_nPWE, | 
|  | 104 | GPIO50_nPIOR, | 
|  | 105 | GPIO51_nPIOW, | 
|  | 106 | GPIO52_nPCE_1, | 
|  | 107 | GPIO53_nPCE_2, | 
|  | 108 | GPIO54_nPSKTSEL, | 
|  | 109 | GPIO55_nPREG, | 
|  | 110 | GPIO56_nPWAIT, | 
|  | 111 | GPIO57_nIOIS16, | 
|  | 112 |  | 
|  | 113 | /* AC97 */ | 
|  | 114 | GPIO31_AC97_SYNC, | 
|  | 115 | GPIO30_AC97_SDATA_OUT, | 
|  | 116 | GPIO28_AC97_BITCLK, | 
|  | 117 | GPIO29_AC97_SDATA_IN_0, | 
|  | 118 | // GPIO79 nAUD_IRQ | 
|  | 119 |  | 
|  | 120 | /* FFUART */ | 
|  | 121 | GPIO34_FFUART_RXD, | 
|  | 122 | GPIO35_FFUART_CTS, | 
|  | 123 | GPIO37_FFUART_DSR, | 
|  | 124 | GPIO39_FFUART_TXD, | 
|  | 125 | GPIO40_FFUART_DTR, | 
|  | 126 | GPIO41_FFUART_RTS, | 
|  | 127 |  | 
|  | 128 | /* BTUART */ | 
|  | 129 | GPIO42_BTUART_RXD, | 
|  | 130 | GPIO43_BTUART_TXD, | 
|  | 131 | GPIO44_BTUART_CTS, | 
|  | 132 | GPIO45_BTUART_RTS, | 
|  | 133 |  | 
| Dmitry Baryshkov | 2cb4734 | 2008-04-10 11:00:32 +0100 | [diff] [blame] | 134 | /* Keybd */ | 
| Eric Miao | f69a654 | 2010-01-01 15:28:21 +0800 | [diff] [blame] | 135 | GPIO58_GPIO | MFP_LPM_DRIVE_LOW,	/* Column 0 */ | 
|  | 136 | GPIO59_GPIO | MFP_LPM_DRIVE_LOW,	/* Column 1 */ | 
|  | 137 | GPIO60_GPIO | MFP_LPM_DRIVE_LOW,	/* Column 2 */ | 
|  | 138 | GPIO61_GPIO | MFP_LPM_DRIVE_LOW,	/* Column 3 */ | 
|  | 139 | GPIO62_GPIO | MFP_LPM_DRIVE_LOW,	/* Column 4 */ | 
|  | 140 | GPIO63_GPIO | MFP_LPM_DRIVE_LOW,	/* Column 5 */ | 
|  | 141 | GPIO64_GPIO | MFP_LPM_DRIVE_LOW,	/* Column 6 */ | 
|  | 142 | GPIO65_GPIO | MFP_LPM_DRIVE_LOW,	/* Column 7 */ | 
|  | 143 | GPIO66_GPIO | MFP_LPM_DRIVE_LOW,	/* Column 8 */ | 
|  | 144 | GPIO67_GPIO | MFP_LPM_DRIVE_LOW,	/* Column 9 */ | 
|  | 145 | GPIO68_GPIO | MFP_LPM_DRIVE_LOW,	/* Column 10 */ | 
|  | 146 | GPIO69_GPIO | MFP_LPM_DRIVE_LOW,	/* Row 0 */ | 
|  | 147 | GPIO70_GPIO | MFP_LPM_DRIVE_LOW,	/* Row 1 */ | 
|  | 148 | GPIO71_GPIO | MFP_LPM_DRIVE_LOW,	/* Row 2 */ | 
|  | 149 | GPIO72_GPIO | MFP_LPM_DRIVE_LOW,	/* Row 3 */ | 
|  | 150 | GPIO73_GPIO | MFP_LPM_DRIVE_LOW,	/* Row 4 */ | 
|  | 151 | GPIO74_GPIO | MFP_LPM_DRIVE_LOW,	/* Row 5 */ | 
|  | 152 | GPIO75_GPIO | MFP_LPM_DRIVE_LOW,	/* Row 6 */ | 
| Dmitry Baryshkov | 2cb4734 | 2008-04-10 11:00:32 +0100 | [diff] [blame] | 153 |  | 
|  | 154 | /* SPI */ | 
|  | 155 | GPIO81_SSP2_CLK_OUT, | 
|  | 156 | GPIO82_SSP2_FRM_OUT, | 
|  | 157 | GPIO83_SSP2_TXD, | 
| Dmitry Baryshkov | 2cb4734 | 2008-04-10 11:00:32 +0100 | [diff] [blame] | 158 |  | 
| Dmitry Baryshkov | 0fc3ff3 | 2008-07-02 13:54:46 +0100 | [diff] [blame] | 159 | /* IrDA is managed in other way */ | 
|  | 160 | GPIO46_GPIO, | 
|  | 161 | GPIO47_GPIO, | 
| Dmitry Baryshkov | b032fcc | 2008-06-12 11:42:07 +0100 | [diff] [blame] | 162 | }; | 
|  | 163 |  | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 164 | /* | 
|  | 165 | * SCOOP Device | 
|  | 166 | */ | 
|  | 167 | static struct resource tosa_scoop_resources[] = { | 
|  | 168 | [0] = { | 
|  | 169 | .start	= TOSA_CF_PHYS, | 
|  | 170 | .end	= TOSA_CF_PHYS + 0xfff, | 
|  | 171 | .flags	= IORESOURCE_MEM, | 
|  | 172 | }, | 
|  | 173 | }; | 
|  | 174 |  | 
|  | 175 | static struct scoop_config tosa_scoop_setup = { | 
|  | 176 | .io_dir 	= TOSA_SCOOP_IO_DIR, | 
| Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 177 | .gpio_base	= TOSA_SCOOP_GPIO_BASE, | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 178 | }; | 
|  | 179 |  | 
| Dmitry Baryshkov | ba4eb7e | 2008-04-19 10:42:25 +0100 | [diff] [blame] | 180 | static struct platform_device tosascoop_device = { | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 181 | .name		= "sharp-scoop", | 
|  | 182 | .id		= 0, | 
|  | 183 | .dev		= { | 
|  | 184 | .platform_data	= &tosa_scoop_setup, | 
|  | 185 | }, | 
|  | 186 | .num_resources	= ARRAY_SIZE(tosa_scoop_resources), | 
|  | 187 | .resource	= tosa_scoop_resources, | 
|  | 188 | }; | 
|  | 189 |  | 
|  | 190 |  | 
|  | 191 | /* | 
|  | 192 | * SCOOP Device Jacket | 
|  | 193 | */ | 
|  | 194 | static struct resource tosa_scoop_jc_resources[] = { | 
|  | 195 | [0] = { | 
|  | 196 | .start		= TOSA_SCOOP_PHYS + 0x40, | 
|  | 197 | .end		= TOSA_SCOOP_PHYS + 0xfff, | 
|  | 198 | .flags		= IORESOURCE_MEM, | 
|  | 199 | }, | 
|  | 200 | }; | 
|  | 201 |  | 
|  | 202 | static struct scoop_config tosa_scoop_jc_setup = { | 
|  | 203 | .io_dir 	= TOSA_SCOOP_JC_IO_DIR, | 
| Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 204 | .gpio_base	= TOSA_SCOOP_JC_GPIO_BASE, | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 205 | }; | 
|  | 206 |  | 
| Dmitry Baryshkov | ba4eb7e | 2008-04-19 10:42:25 +0100 | [diff] [blame] | 207 | static struct platform_device tosascoop_jc_device = { | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 208 | .name		= "sharp-scoop", | 
|  | 209 | .id		= 1, | 
|  | 210 | .dev		= { | 
|  | 211 | .platform_data	= &tosa_scoop_jc_setup, | 
|  | 212 | .parent 	= &tosascoop_device.dev, | 
|  | 213 | }, | 
|  | 214 | .num_resources	= ARRAY_SIZE(tosa_scoop_jc_resources), | 
|  | 215 | .resource	= tosa_scoop_jc_resources, | 
|  | 216 | }; | 
|  | 217 |  | 
| Dirk Opfer | 4c18ad2 | 2005-11-08 19:15:50 +0000 | [diff] [blame] | 218 | /* | 
|  | 219 | * PCMCIA | 
|  | 220 | */ | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 221 | static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = { | 
|  | 222 | { | 
|  | 223 | .dev        = &tosascoop_device.dev, | 
|  | 224 | .irq        = TOSA_IRQ_GPIO_CF_IRQ, | 
|  | 225 | .cd_irq     = TOSA_IRQ_GPIO_CF_CD, | 
|  | 226 | .cd_irq_str = "PCMCIA0 CD", | 
|  | 227 | },{ | 
|  | 228 | .dev        = &tosascoop_jc_device.dev, | 
|  | 229 | .irq        = TOSA_IRQ_GPIO_JC_CF_IRQ, | 
|  | 230 | .cd_irq     = -1, | 
|  | 231 | }, | 
|  | 232 | }; | 
|  | 233 |  | 
| Dirk Opfer | 4c18ad2 | 2005-11-08 19:15:50 +0000 | [diff] [blame] | 234 | static struct scoop_pcmcia_config tosa_pcmcia_config = { | 
|  | 235 | .devs         = &tosa_pcmcia_scoop[0], | 
|  | 236 | .num_devs     = 2, | 
| Dirk Opfer | 4c18ad2 | 2005-11-08 19:15:50 +0000 | [diff] [blame] | 237 | }; | 
|  | 238 |  | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 239 | /* | 
|  | 240 | * USB Device Controller | 
|  | 241 | */ | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 242 | static struct pxa2xx_udc_mach_info udc_info __initdata = { | 
| Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 243 | .gpio_pullup		= TOSA_GPIO_USB_PULLUP, | 
| Dmitry Baryshkov | 487dc92 | 2007-12-21 12:18:01 +0300 | [diff] [blame] | 244 | .gpio_vbus		= TOSA_GPIO_USB_IN, | 
|  | 245 | .gpio_vbus_inverted	= 1, | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 246 | }; | 
|  | 247 |  | 
|  | 248 | /* | 
|  | 249 | * MMC/SD Device | 
|  | 250 | */ | 
| David Howells | 40220c1 | 2006-10-09 12:19:47 +0100 | [diff] [blame] | 251 | static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data) | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 252 | { | 
|  | 253 | int err; | 
|  | 254 |  | 
| Dmitry Baryshkov | c4d5f8d | 2008-06-09 13:23:50 +0100 | [diff] [blame] | 255 | err = gpio_request(TOSA_GPIO_nSD_INT, "SD Int"); | 
|  | 256 | if (err) { | 
|  | 257 | printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n"); | 
|  | 258 | goto err_gpio_int; | 
|  | 259 | } | 
|  | 260 | err = gpio_direction_input(TOSA_GPIO_nSD_INT); | 
|  | 261 | if (err) | 
|  | 262 | goto err_gpio_int_dir; | 
|  | 263 |  | 
| Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 264 | return 0; | 
|  | 265 |  | 
| Dmitry Baryshkov | c4d5f8d | 2008-06-09 13:23:50 +0100 | [diff] [blame] | 266 | err_gpio_int_dir: | 
|  | 267 | gpio_free(TOSA_GPIO_nSD_INT); | 
|  | 268 | err_gpio_int: | 
| Russell King | 2687bd3 | 2008-01-23 14:05:58 +0000 | [diff] [blame] | 269 | return err; | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 270 | } | 
|  | 271 |  | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 272 | static void tosa_mci_exit(struct device *dev, void *data) | 
|  | 273 | { | 
| Dmitry Baryshkov | c4d5f8d | 2008-06-09 13:23:50 +0100 | [diff] [blame] | 274 | gpio_free(TOSA_GPIO_nSD_INT); | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 275 | } | 
|  | 276 |  | 
|  | 277 | static struct pxamci_platform_data tosa_mci_platform_data = { | 
| Robert Jarzmik | 7a64825 | 2009-07-06 22:16:42 +0200 | [diff] [blame] | 278 | .ocr_mask       	= MMC_VDD_32_33|MMC_VDD_33_34, | 
|  | 279 | .init           	= tosa_mci_init, | 
|  | 280 | .exit           	= tosa_mci_exit, | 
|  | 281 | .gpio_card_detect	= TOSA_GPIO_nSD_DETECT, | 
|  | 282 | .gpio_card_ro		= TOSA_GPIO_SD_WP, | 
|  | 283 | .gpio_power		= TOSA_GPIO_PWR_ON, | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 284 | }; | 
|  | 285 |  | 
|  | 286 | /* | 
|  | 287 | * Irda | 
|  | 288 | */ | 
| Dmitry Baryshkov | b032fcc | 2008-06-12 11:42:07 +0100 | [diff] [blame] | 289 | static void tosa_irda_transceiver_mode(struct device *dev, int mode) | 
|  | 290 | { | 
|  | 291 | if (mode & IR_OFF) { | 
|  | 292 | gpio_set_value(TOSA_GPIO_IR_POWERDWN, 0); | 
| Dmitry Baryshkov | 0fc3ff3 | 2008-07-02 13:54:46 +0100 | [diff] [blame] | 293 | pxa2xx_transceiver_mode(dev, mode); | 
| Dmitry Baryshkov | b032fcc | 2008-06-12 11:42:07 +0100 | [diff] [blame] | 294 | gpio_direction_output(TOSA_GPIO_IRDA_TX, 0); | 
|  | 295 | } else { | 
| Dmitry Baryshkov | 0fc3ff3 | 2008-07-02 13:54:46 +0100 | [diff] [blame] | 296 | pxa2xx_transceiver_mode(dev, mode); | 
| Dmitry Baryshkov | b032fcc | 2008-06-12 11:42:07 +0100 | [diff] [blame] | 297 | gpio_set_value(TOSA_GPIO_IR_POWERDWN, 1); | 
|  | 298 | } | 
|  | 299 | } | 
|  | 300 |  | 
| Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 301 | static int tosa_irda_startup(struct device *dev) | 
|  | 302 | { | 
|  | 303 | int ret; | 
|  | 304 |  | 
| Dmitry Baryshkov | b032fcc | 2008-06-12 11:42:07 +0100 | [diff] [blame] | 305 | ret = gpio_request(TOSA_GPIO_IRDA_TX, "IrDA TX"); | 
|  | 306 | if (ret) | 
|  | 307 | goto err_tx; | 
|  | 308 | ret = gpio_direction_output(TOSA_GPIO_IRDA_TX, 0); | 
|  | 309 | if (ret) | 
|  | 310 | goto err_tx_dir; | 
|  | 311 |  | 
| Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 312 | ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown"); | 
|  | 313 | if (ret) | 
| Dmitry Baryshkov | b032fcc | 2008-06-12 11:42:07 +0100 | [diff] [blame] | 314 | goto err_pwr; | 
| Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 315 |  | 
|  | 316 | ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0); | 
|  | 317 | if (ret) | 
| Dmitry Baryshkov | b032fcc | 2008-06-12 11:42:07 +0100 | [diff] [blame] | 318 | goto err_pwr_dir; | 
| Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 319 |  | 
| Dmitry Baryshkov | b032fcc | 2008-06-12 11:42:07 +0100 | [diff] [blame] | 320 | tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF); | 
|  | 321 |  | 
|  | 322 | return 0; | 
|  | 323 |  | 
|  | 324 | err_pwr_dir: | 
|  | 325 | gpio_free(TOSA_GPIO_IR_POWERDWN); | 
|  | 326 | err_pwr: | 
|  | 327 | err_tx_dir: | 
|  | 328 | gpio_free(TOSA_GPIO_IRDA_TX); | 
|  | 329 | err_tx: | 
| Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 330 | return ret; | 
| Dmitry Baryshkov | b032fcc | 2008-06-12 11:42:07 +0100 | [diff] [blame] | 331 | } | 
| Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 332 |  | 
|  | 333 | static void tosa_irda_shutdown(struct device *dev) | 
|  | 334 | { | 
| Dmitry Baryshkov | b032fcc | 2008-06-12 11:42:07 +0100 | [diff] [blame] | 335 | tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF); | 
| Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 336 | gpio_free(TOSA_GPIO_IR_POWERDWN); | 
| Dmitry Baryshkov | b032fcc | 2008-06-12 11:42:07 +0100 | [diff] [blame] | 337 | gpio_free(TOSA_GPIO_IRDA_TX); | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 338 | } | 
|  | 339 |  | 
|  | 340 | static struct pxaficp_platform_data tosa_ficp_platform_data = { | 
| Marek Vasut | c4bd017 | 2009-07-17 12:50:43 +0200 | [diff] [blame] | 341 | .gpio_pwdown		= -1, | 
|  | 342 | .transceiver_cap	= IR_SIRMODE | IR_OFF, | 
|  | 343 | .transceiver_mode	= tosa_irda_transceiver_mode, | 
|  | 344 | .startup		= tosa_irda_startup, | 
|  | 345 | .shutdown		= tosa_irda_shutdown, | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 346 | }; | 
|  | 347 |  | 
|  | 348 | /* | 
| Dmitry Baryshkov | 53b14ea | 2008-06-14 11:43:36 +0100 | [diff] [blame] | 349 | * Tosa AC IN | 
|  | 350 | */ | 
|  | 351 | static int tosa_power_init(struct device *dev) | 
|  | 352 | { | 
|  | 353 | int ret = gpio_request(TOSA_GPIO_AC_IN, "ac in"); | 
|  | 354 | if (ret) | 
|  | 355 | goto err_gpio_req; | 
|  | 356 |  | 
|  | 357 | ret = gpio_direction_input(TOSA_GPIO_AC_IN); | 
|  | 358 | if (ret) | 
|  | 359 | goto err_gpio_in; | 
|  | 360 |  | 
|  | 361 | return 0; | 
|  | 362 |  | 
|  | 363 | err_gpio_in: | 
|  | 364 | gpio_free(TOSA_GPIO_AC_IN); | 
|  | 365 | err_gpio_req: | 
|  | 366 | return ret; | 
|  | 367 | } | 
|  | 368 |  | 
|  | 369 | static void tosa_power_exit(struct device *dev) | 
|  | 370 | { | 
|  | 371 | gpio_free(TOSA_GPIO_AC_IN); | 
|  | 372 | } | 
|  | 373 |  | 
|  | 374 | static int tosa_power_ac_online(void) | 
|  | 375 | { | 
|  | 376 | return gpio_get_value(TOSA_GPIO_AC_IN) == 0; | 
|  | 377 | } | 
|  | 378 |  | 
|  | 379 | static char *tosa_ac_supplied_to[] = { | 
|  | 380 | "main-battery", | 
|  | 381 | "backup-battery", | 
|  | 382 | "jacket-battery", | 
|  | 383 | }; | 
|  | 384 |  | 
|  | 385 | static struct pda_power_pdata tosa_power_data = { | 
|  | 386 | .init			= tosa_power_init, | 
|  | 387 | .is_ac_online		= tosa_power_ac_online, | 
|  | 388 | .exit			= tosa_power_exit, | 
|  | 389 | .supplied_to		= tosa_ac_supplied_to, | 
|  | 390 | .num_supplicants	= ARRAY_SIZE(tosa_ac_supplied_to), | 
|  | 391 | }; | 
|  | 392 |  | 
|  | 393 | static struct resource tosa_power_resource[] = { | 
|  | 394 | { | 
|  | 395 | .name		= "ac", | 
|  | 396 | .start		= gpio_to_irq(TOSA_GPIO_AC_IN), | 
|  | 397 | .end		= gpio_to_irq(TOSA_GPIO_AC_IN), | 
|  | 398 | .flags		= IORESOURCE_IRQ | | 
|  | 399 | IORESOURCE_IRQ_HIGHEDGE | | 
|  | 400 | IORESOURCE_IRQ_LOWEDGE, | 
|  | 401 | }, | 
|  | 402 | }; | 
|  | 403 |  | 
|  | 404 | static struct platform_device tosa_power_device = { | 
|  | 405 | .name			= "pda-power", | 
|  | 406 | .id			= -1, | 
|  | 407 | .dev.platform_data	= &tosa_power_data, | 
|  | 408 | .resource		= tosa_power_resource, | 
|  | 409 | .num_resources		= ARRAY_SIZE(tosa_power_resource), | 
|  | 410 | }; | 
|  | 411 |  | 
|  | 412 | /* | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 413 | * Tosa Keyboard | 
|  | 414 | */ | 
| Eric Miao | f69a654 | 2010-01-01 15:28:21 +0800 | [diff] [blame] | 415 | static const uint32_t tosakbd_keymap[] = { | 
|  | 416 | KEY(0, 2, KEY_W), | 
|  | 417 | KEY(0, 6, KEY_K), | 
|  | 418 | KEY(0, 7, KEY_BACKSPACE), | 
|  | 419 | KEY(0, 8, KEY_P), | 
|  | 420 | KEY(1, 1, KEY_Q), | 
|  | 421 | KEY(1, 2, KEY_E), | 
|  | 422 | KEY(1, 3, KEY_T), | 
|  | 423 | KEY(1, 4, KEY_Y), | 
|  | 424 | KEY(1, 6, KEY_O), | 
|  | 425 | KEY(1, 7, KEY_I), | 
|  | 426 | KEY(1, 8, KEY_COMMA), | 
|  | 427 | KEY(2, 1, KEY_A), | 
|  | 428 | KEY(2, 2, KEY_D), | 
|  | 429 | KEY(2, 3, KEY_G), | 
|  | 430 | KEY(2, 4, KEY_U), | 
|  | 431 | KEY(2, 6, KEY_L), | 
|  | 432 | KEY(2, 7, KEY_ENTER), | 
|  | 433 | KEY(2, 8, KEY_DOT), | 
|  | 434 | KEY(3, 1, KEY_Z), | 
|  | 435 | KEY(3, 2, KEY_C), | 
|  | 436 | KEY(3, 3, KEY_V), | 
|  | 437 | KEY(3, 4, KEY_J), | 
|  | 438 | KEY(3, 5, TOSA_KEY_ADDRESSBOOK), | 
|  | 439 | KEY(3, 6, TOSA_KEY_CANCEL), | 
|  | 440 | KEY(3, 7, TOSA_KEY_CENTER), | 
|  | 441 | KEY(3, 8, TOSA_KEY_OK), | 
|  | 442 | KEY(3, 9, KEY_LEFTSHIFT), | 
|  | 443 | KEY(4, 1, KEY_S), | 
|  | 444 | KEY(4, 2, KEY_R), | 
|  | 445 | KEY(4, 3, KEY_B), | 
|  | 446 | KEY(4, 4, KEY_N), | 
|  | 447 | KEY(4, 5, TOSA_KEY_CALENDAR), | 
|  | 448 | KEY(4, 6, TOSA_KEY_HOMEPAGE), | 
|  | 449 | KEY(4, 7, KEY_LEFTCTRL), | 
|  | 450 | KEY(4, 8, TOSA_KEY_LIGHT), | 
|  | 451 | KEY(4, 10, KEY_RIGHTSHIFT), | 
|  | 452 | KEY(5, 1, KEY_TAB), | 
|  | 453 | KEY(5, 2, KEY_SLASH), | 
|  | 454 | KEY(5, 3, KEY_H), | 
|  | 455 | KEY(5, 4, KEY_M), | 
|  | 456 | KEY(5, 5, TOSA_KEY_MENU), | 
|  | 457 | KEY(5, 7, KEY_UP), | 
|  | 458 | KEY(5, 11, TOSA_KEY_FN), | 
|  | 459 | KEY(6, 1, KEY_X), | 
|  | 460 | KEY(6, 2, KEY_F), | 
|  | 461 | KEY(6, 3, KEY_SPACE), | 
|  | 462 | KEY(6, 4, KEY_APOSTROPHE), | 
|  | 463 | KEY(6, 5, TOSA_KEY_MAIL), | 
|  | 464 | KEY(6, 6, KEY_LEFT), | 
|  | 465 | KEY(6, 7, KEY_DOWN), | 
|  | 466 | KEY(6, 8, KEY_RIGHT), | 
|  | 467 | }; | 
|  | 468 |  | 
|  | 469 | static struct matrix_keymap_data tosakbd_keymap_data = { | 
|  | 470 | .keymap		= tosakbd_keymap, | 
|  | 471 | .keymap_size	= ARRAY_SIZE(tosakbd_keymap), | 
|  | 472 | }; | 
|  | 473 |  | 
|  | 474 | static const int tosakbd_col_gpios[] = | 
|  | 475 | { 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68 }; | 
|  | 476 | static const int tosakbd_row_gpios[] = | 
|  | 477 | { 69, 70, 71, 72, 73, 74, 75 }; | 
|  | 478 |  | 
|  | 479 | static struct matrix_keypad_platform_data tosakbd_pdata = { | 
|  | 480 | .keymap_data		= &tosakbd_keymap_data, | 
|  | 481 | .row_gpios		= tosakbd_row_gpios, | 
|  | 482 | .col_gpios		= tosakbd_col_gpios, | 
|  | 483 | .num_row_gpios		= ARRAY_SIZE(tosakbd_row_gpios), | 
|  | 484 | .num_col_gpios		= ARRAY_SIZE(tosakbd_col_gpios), | 
|  | 485 | .col_scan_delay_us	= 10, | 
|  | 486 | .debounce_ms		= 10, | 
|  | 487 | .wakeup			= 1, | 
|  | 488 | }; | 
|  | 489 |  | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 490 | static struct platform_device tosakbd_device = { | 
| Eric Miao | f69a654 | 2010-01-01 15:28:21 +0800 | [diff] [blame] | 491 | .name		= "matrix-keypad", | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 492 | .id		= -1, | 
| Eric Miao | f69a654 | 2010-01-01 15:28:21 +0800 | [diff] [blame] | 493 | .dev		= { | 
|  | 494 | .platform_data = &tosakbd_pdata, | 
|  | 495 | }, | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 496 | }; | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 497 |  | 
| Dmitry Baryshkov | 93e9012 | 2008-01-21 01:04:20 -0500 | [diff] [blame] | 498 | static struct gpio_keys_button tosa_gpio_keys[] = { | 
| Dmitry Baryshkov | 0aa9756 | 2008-04-12 20:02:50 +0100 | [diff] [blame] | 499 | /* | 
|  | 500 | * Two following keys are directly tied to "ON" button of tosa. Why? | 
|  | 501 | * The first one can be used as a wakeup source, the second can't; | 
|  | 502 | * also the first one is OR of ac_powered and on_button. | 
|  | 503 | */ | 
|  | 504 | { | 
|  | 505 | .type	= EV_PWR, | 
|  | 506 | .code	= KEY_RESERVED, | 
|  | 507 | .gpio	= TOSA_GPIO_POWERON, | 
|  | 508 | .desc	= "Poweron", | 
|  | 509 | .wakeup	= 1, | 
|  | 510 | .active_low = 1, | 
|  | 511 | }, | 
| Dmitry Baryshkov | 93e9012 | 2008-01-21 01:04:20 -0500 | [diff] [blame] | 512 | { | 
|  | 513 | .type	= EV_PWR, | 
|  | 514 | .code	= KEY_SUSPEND, | 
|  | 515 | .gpio	= TOSA_GPIO_ON_KEY, | 
|  | 516 | .desc	= "On key", | 
| Dmitry Baryshkov | 0aa9756 | 2008-04-12 20:02:50 +0100 | [diff] [blame] | 517 | /* | 
|  | 518 | * can't be used as wakeup | 
|  | 519 | * .wakeup	= 1, | 
|  | 520 | */ | 
| Dmitry Baryshkov | 93e9012 | 2008-01-21 01:04:20 -0500 | [diff] [blame] | 521 | .active_low = 1, | 
|  | 522 | }, | 
|  | 523 | { | 
|  | 524 | .type	= EV_KEY, | 
|  | 525 | .code	= TOSA_KEY_RECORD, | 
|  | 526 | .gpio	= TOSA_GPIO_RECORD_BTN, | 
|  | 527 | .desc	= "Record Button", | 
|  | 528 | .wakeup	= 1, | 
|  | 529 | .active_low = 1, | 
|  | 530 | }, | 
|  | 531 | { | 
|  | 532 | .type	= EV_KEY, | 
|  | 533 | .code	= TOSA_KEY_SYNC, | 
|  | 534 | .gpio	= TOSA_GPIO_SYNC, | 
|  | 535 | .desc	= "Sync Button", | 
|  | 536 | .wakeup	= 1, | 
|  | 537 | .active_low = 1, | 
|  | 538 | }, | 
| Dmitry Baryshkov | c33de47 | 2008-09-11 01:28:51 +0100 | [diff] [blame] | 539 | { | 
|  | 540 | .type	= EV_SW, | 
|  | 541 | .code	= SW_HEADPHONE_INSERT, | 
|  | 542 | .gpio	= TOSA_GPIO_EAR_IN, | 
|  | 543 | .desc	= "HeadPhone insert", | 
|  | 544 | .active_low = 1, | 
|  | 545 | .debounce_interval = 300, | 
|  | 546 | }, | 
| Dmitry Baryshkov | 93e9012 | 2008-01-21 01:04:20 -0500 | [diff] [blame] | 547 | }; | 
|  | 548 |  | 
|  | 549 | static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = { | 
|  | 550 | .buttons	= tosa_gpio_keys, | 
|  | 551 | .nbuttons	= ARRAY_SIZE(tosa_gpio_keys), | 
|  | 552 | }; | 
|  | 553 |  | 
|  | 554 | static struct platform_device tosa_gpio_keys_device = { | 
|  | 555 | .name	= "gpio-keys", | 
|  | 556 | .id	= -1, | 
|  | 557 | .dev	= { | 
|  | 558 | .platform_data	= &tosa_gpio_keys_platform_data, | 
|  | 559 | }, | 
|  | 560 | }; | 
|  | 561 |  | 
| Dirk Opfer | 6d0cf3e | 2006-03-31 02:31:12 -0800 | [diff] [blame] | 562 | /* | 
|  | 563 | * Tosa LEDs | 
|  | 564 | */ | 
| Dmitry Baryshkov | ba4eb7e | 2008-04-19 10:42:25 +0100 | [diff] [blame] | 565 | static struct gpio_led tosa_gpio_leds[] = { | 
| Dmitry Baryshkov | 311c736 | 2008-04-12 20:17:02 +0100 | [diff] [blame] | 566 | { | 
|  | 567 | .name			= "tosa:amber:charge", | 
|  | 568 | .default_trigger	= "main-battery-charging", | 
|  | 569 | .gpio			= TOSA_GPIO_CHRG_ERR_LED, | 
|  | 570 | }, | 
|  | 571 | { | 
|  | 572 | .name			= "tosa:green:mail", | 
|  | 573 | .default_trigger	= "nand-disk", | 
|  | 574 | .gpio			= TOSA_GPIO_NOTE_LED, | 
|  | 575 | }, | 
| Dmitry Baryshkov | c546106 | 2008-04-19 10:42:06 +0100 | [diff] [blame] | 576 | { | 
|  | 577 | .name			= "tosa:dual:wlan", | 
|  | 578 | .default_trigger	= "none", | 
|  | 579 | .gpio			= TOSA_GPIO_WLAN_LED, | 
|  | 580 | }, | 
|  | 581 | { | 
|  | 582 | .name			= "tosa:blue:bluetooth", | 
| Dmitry Baryshkov | 16b32fd | 2008-07-05 09:02:48 +0100 | [diff] [blame] | 583 | .default_trigger	= "tosa-bt", | 
| Dmitry Baryshkov | c546106 | 2008-04-19 10:42:06 +0100 | [diff] [blame] | 584 | .gpio			= TOSA_GPIO_BT_LED, | 
|  | 585 | }, | 
| Dmitry Baryshkov | 311c736 | 2008-04-12 20:17:02 +0100 | [diff] [blame] | 586 | }; | 
|  | 587 |  | 
| Dmitry Baryshkov | ba4eb7e | 2008-04-19 10:42:25 +0100 | [diff] [blame] | 588 | static struct gpio_led_platform_data tosa_gpio_leds_platform_data = { | 
| Dmitry Baryshkov | 311c736 | 2008-04-12 20:17:02 +0100 | [diff] [blame] | 589 | .leds		= tosa_gpio_leds, | 
|  | 590 | .num_leds	= ARRAY_SIZE(tosa_gpio_leds), | 
|  | 591 | }; | 
|  | 592 |  | 
| Dirk Opfer | 6d0cf3e | 2006-03-31 02:31:12 -0800 | [diff] [blame] | 593 | static struct platform_device tosaled_device = { | 
| Dmitry Baryshkov | 311c736 | 2008-04-12 20:17:02 +0100 | [diff] [blame] | 594 | .name	= "leds-gpio", | 
|  | 595 | .id	= -1, | 
|  | 596 | .dev	= { | 
|  | 597 | .platform_data	= &tosa_gpio_leds_platform_data, | 
|  | 598 | }, | 
| Dirk Opfer | 6d0cf3e | 2006-03-31 02:31:12 -0800 | [diff] [blame] | 599 | }; | 
|  | 600 |  | 
| Dmitry Baryshkov | bf0116e | 2008-06-14 11:42:02 +0100 | [diff] [blame] | 601 | /* | 
|  | 602 | * Toshiba Mobile IO Controller | 
|  | 603 | */ | 
|  | 604 | static struct resource tc6393xb_resources[] = { | 
|  | 605 | [0] = { | 
|  | 606 | .start	= TOSA_LCDC_PHYS, | 
|  | 607 | .end	= TOSA_LCDC_PHYS + 0x3ffffff, | 
|  | 608 | .flags	= IORESOURCE_MEM, | 
|  | 609 | }, | 
|  | 610 |  | 
|  | 611 | [1] = { | 
|  | 612 | .start	= TOSA_IRQ_GPIO_TC6393XB_INT, | 
|  | 613 | .end	= TOSA_IRQ_GPIO_TC6393XB_INT, | 
|  | 614 | .flags	= IORESOURCE_IRQ, | 
|  | 615 | }, | 
|  | 616 | }; | 
|  | 617 |  | 
|  | 618 |  | 
|  | 619 | static int tosa_tc6393xb_enable(struct platform_device *dev) | 
|  | 620 | { | 
|  | 621 | int rc; | 
|  | 622 |  | 
|  | 623 | rc = gpio_request(TOSA_GPIO_TC6393XB_REST_IN, "tc6393xb #pclr"); | 
|  | 624 | if (rc) | 
|  | 625 | goto err_req_pclr; | 
|  | 626 | rc = gpio_request(TOSA_GPIO_TC6393XB_SUSPEND, "tc6393xb #suspend"); | 
|  | 627 | if (rc) | 
|  | 628 | goto err_req_suspend; | 
| Dmitry Baryshkov | 14b7b40 | 2008-09-13 21:06:41 +0400 | [diff] [blame] | 629 | rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "tc6393xb l3v"); | 
| Dmitry Baryshkov | bf0116e | 2008-06-14 11:42:02 +0100 | [diff] [blame] | 630 | if (rc) | 
|  | 631 | goto err_req_l3v; | 
|  | 632 | rc = gpio_direction_output(TOSA_GPIO_TC6393XB_L3V_ON, 0); | 
|  | 633 | if (rc) | 
|  | 634 | goto err_dir_l3v; | 
|  | 635 | rc = gpio_direction_output(TOSA_GPIO_TC6393XB_SUSPEND, 0); | 
|  | 636 | if (rc) | 
|  | 637 | goto err_dir_suspend; | 
|  | 638 | rc = gpio_direction_output(TOSA_GPIO_TC6393XB_REST_IN, 0); | 
|  | 639 | if (rc) | 
|  | 640 | goto err_dir_pclr; | 
|  | 641 |  | 
|  | 642 | mdelay(1); | 
|  | 643 |  | 
|  | 644 | gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1); | 
|  | 645 |  | 
|  | 646 | mdelay(10); | 
|  | 647 |  | 
|  | 648 | gpio_set_value(TOSA_GPIO_TC6393XB_REST_IN, 1); | 
|  | 649 | gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1); | 
|  | 650 |  | 
|  | 651 | return 0; | 
|  | 652 | err_dir_pclr: | 
|  | 653 | err_dir_suspend: | 
|  | 654 | err_dir_l3v: | 
|  | 655 | gpio_free(TOSA_GPIO_TC6393XB_L3V_ON); | 
|  | 656 | err_req_l3v: | 
|  | 657 | gpio_free(TOSA_GPIO_TC6393XB_SUSPEND); | 
|  | 658 | err_req_suspend: | 
|  | 659 | gpio_free(TOSA_GPIO_TC6393XB_REST_IN); | 
|  | 660 | err_req_pclr: | 
|  | 661 | return rc; | 
|  | 662 | } | 
|  | 663 |  | 
|  | 664 | static int tosa_tc6393xb_disable(struct platform_device *dev) | 
|  | 665 | { | 
|  | 666 | gpio_free(TOSA_GPIO_TC6393XB_L3V_ON); | 
|  | 667 | gpio_free(TOSA_GPIO_TC6393XB_SUSPEND); | 
|  | 668 | gpio_free(TOSA_GPIO_TC6393XB_REST_IN); | 
|  | 669 |  | 
|  | 670 | return 0; | 
|  | 671 | } | 
|  | 672 |  | 
|  | 673 | static int tosa_tc6393xb_resume(struct platform_device *dev) | 
|  | 674 | { | 
|  | 675 | gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1); | 
|  | 676 | mdelay(10); | 
|  | 677 | gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1); | 
|  | 678 | mdelay(10); | 
|  | 679 |  | 
|  | 680 | return 0; | 
|  | 681 | } | 
|  | 682 |  | 
|  | 683 | static int tosa_tc6393xb_suspend(struct platform_device *dev) | 
|  | 684 | { | 
|  | 685 | gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 0); | 
|  | 686 | gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 0); | 
|  | 687 | return 0; | 
|  | 688 | } | 
|  | 689 |  | 
| Dmitry Baryshkov | 5289fec | 2008-06-27 10:38:44 +0100 | [diff] [blame] | 690 | static struct mtd_partition tosa_nand_partition[] = { | 
|  | 691 | { | 
|  | 692 | .name	= "smf", | 
|  | 693 | .offset	= 0, | 
|  | 694 | .size	= 7 * 1024 * 1024, | 
|  | 695 | }, | 
|  | 696 | { | 
|  | 697 | .name	= "root", | 
|  | 698 | .offset	= MTDPART_OFS_APPEND, | 
|  | 699 | .size	= 28 * 1024 * 1024, | 
|  | 700 | }, | 
|  | 701 | { | 
|  | 702 | .name	= "home", | 
|  | 703 | .offset	= MTDPART_OFS_APPEND, | 
|  | 704 | .size	= MTDPART_SIZ_FULL, | 
|  | 705 | }, | 
|  | 706 | }; | 
|  | 707 |  | 
|  | 708 | static uint8_t scan_ff_pattern[] = { 0xff, 0xff }; | 
|  | 709 |  | 
|  | 710 | static struct nand_bbt_descr tosa_tc6393xb_nand_bbt = { | 
|  | 711 | .options	= 0, | 
|  | 712 | .offs		= 4, | 
|  | 713 | .len		= 2, | 
|  | 714 | .pattern	= scan_ff_pattern | 
|  | 715 | }; | 
|  | 716 |  | 
|  | 717 | static struct tmio_nand_data tosa_tc6393xb_nand_config = { | 
|  | 718 | .num_partitions	= ARRAY_SIZE(tosa_nand_partition), | 
|  | 719 | .partition	= tosa_nand_partition, | 
|  | 720 | .badblock_pattern = &tosa_tc6393xb_nand_bbt, | 
|  | 721 | }; | 
|  | 722 |  | 
| Dmitry Baryshkov | 1c1b6ff | 2008-09-24 23:36:23 +0200 | [diff] [blame] | 723 | static int tosa_tc6393xb_setup(struct platform_device *dev) | 
|  | 724 | { | 
|  | 725 | int rc; | 
|  | 726 |  | 
|  | 727 | rc = gpio_request(TOSA_GPIO_CARD_VCC_ON, "CARD_VCC_ON"); | 
|  | 728 | if (rc) | 
|  | 729 | goto err_req; | 
|  | 730 |  | 
|  | 731 | rc = gpio_direction_output(TOSA_GPIO_CARD_VCC_ON, 1); | 
|  | 732 | if (rc) | 
|  | 733 | goto err_dir; | 
|  | 734 |  | 
|  | 735 | return rc; | 
|  | 736 |  | 
|  | 737 | err_dir: | 
|  | 738 | gpio_free(TOSA_GPIO_CARD_VCC_ON); | 
|  | 739 | err_req: | 
|  | 740 | return rc; | 
|  | 741 | } | 
|  | 742 |  | 
|  | 743 | static void tosa_tc6393xb_teardown(struct platform_device *dev) | 
|  | 744 | { | 
|  | 745 | gpio_free(TOSA_GPIO_CARD_VCC_ON); | 
|  | 746 | } | 
|  | 747 |  | 
| Dmitry Baryshkov | ddfb33c | 2008-11-27 01:25:09 +0300 | [diff] [blame] | 748 | #ifdef CONFIG_MFD_TC6393XB | 
| Dmitry Baryshkov | 31c9b28 | 2008-10-28 18:40:37 +0300 | [diff] [blame] | 749 | static struct fb_videomode tosa_tc6393xb_lcd_mode[] = { | 
|  | 750 | { | 
|  | 751 | .xres = 480, | 
|  | 752 | .yres = 640, | 
|  | 753 | .pixclock = 0x002cdf00,/* PLL divisor */ | 
|  | 754 | .left_margin = 0x004c, | 
|  | 755 | .right_margin = 0x005b, | 
|  | 756 | .upper_margin = 0x0001, | 
|  | 757 | .lower_margin = 0x000d, | 
|  | 758 | .hsync_len = 0x0002, | 
|  | 759 | .vsync_len = 0x0001, | 
|  | 760 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, | 
|  | 761 | .vmode = FB_VMODE_NONINTERLACED, | 
|  | 762 | },{ | 
|  | 763 | .xres = 240, | 
|  | 764 | .yres = 320, | 
|  | 765 | .pixclock = 0x00e7f203,/* PLL divisor */ | 
|  | 766 | .left_margin = 0x0024, | 
|  | 767 | .right_margin = 0x002f, | 
|  | 768 | .upper_margin = 0x0001, | 
|  | 769 | .lower_margin = 0x000d, | 
|  | 770 | .hsync_len = 0x0002, | 
|  | 771 | .vsync_len = 0x0001, | 
|  | 772 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, | 
|  | 773 | .vmode = FB_VMODE_NONINTERLACED, | 
|  | 774 | } | 
|  | 775 | }; | 
|  | 776 |  | 
|  | 777 | static struct tmio_fb_data tosa_tc6393xb_fb_config = { | 
|  | 778 | .lcd_set_power	= tc6393xb_lcd_set_power, | 
|  | 779 | .lcd_mode	= tc6393xb_lcd_mode, | 
|  | 780 | .num_modes	= ARRAY_SIZE(tosa_tc6393xb_lcd_mode), | 
|  | 781 | .modes		= &tosa_tc6393xb_lcd_mode[0], | 
|  | 782 | .height		= 82, | 
|  | 783 | .width		= 60, | 
|  | 784 | }; | 
| Dmitry Baryshkov | ddfb33c | 2008-11-27 01:25:09 +0300 | [diff] [blame] | 785 | #endif | 
| Dmitry Baryshkov | 31c9b28 | 2008-10-28 18:40:37 +0300 | [diff] [blame] | 786 |  | 
| Dmitry Baryshkov | 1c1b6ff | 2008-09-24 23:36:23 +0200 | [diff] [blame] | 787 | static struct tc6393xb_platform_data tosa_tc6393xb_data = { | 
| Dmitry Baryshkov | bf0116e | 2008-06-14 11:42:02 +0100 | [diff] [blame] | 788 | .scr_pll2cr	= 0x0cc1, | 
|  | 789 | .scr_gper	= 0x3300, | 
| Dmitry Baryshkov | bf0116e | 2008-06-14 11:42:02 +0100 | [diff] [blame] | 790 |  | 
|  | 791 | .irq_base	= IRQ_BOARD_START, | 
|  | 792 | .gpio_base	= TOSA_TC6393XB_GPIO_BASE, | 
| Dmitry Baryshkov | 1c1b6ff | 2008-09-24 23:36:23 +0200 | [diff] [blame] | 793 | .setup		= tosa_tc6393xb_setup, | 
|  | 794 | .teardown	= tosa_tc6393xb_teardown, | 
| Dmitry Baryshkov | bf0116e | 2008-06-14 11:42:02 +0100 | [diff] [blame] | 795 |  | 
|  | 796 | .enable		= tosa_tc6393xb_enable, | 
|  | 797 | .disable	= tosa_tc6393xb_disable, | 
|  | 798 | .suspend	= tosa_tc6393xb_suspend, | 
|  | 799 | .resume		= tosa_tc6393xb_resume, | 
| Dmitry Baryshkov | 5289fec | 2008-06-27 10:38:44 +0100 | [diff] [blame] | 800 |  | 
|  | 801 | .nand_data	= &tosa_tc6393xb_nand_config, | 
| Dmitry Baryshkov | ddfb33c | 2008-11-27 01:25:09 +0300 | [diff] [blame] | 802 | #ifdef CONFIG_MFD_TC6393XB | 
| Dmitry Baryshkov | 31c9b28 | 2008-10-28 18:40:37 +0300 | [diff] [blame] | 803 | .fb_data	= &tosa_tc6393xb_fb_config, | 
| Dmitry Baryshkov | ddfb33c | 2008-11-27 01:25:09 +0300 | [diff] [blame] | 804 | #endif | 
| Dmitry Baryshkov | f98a0bd | 2008-09-24 23:46:10 +0200 | [diff] [blame] | 805 |  | 
|  | 806 | .resume_restore = 1, | 
| Dmitry Baryshkov | bf0116e | 2008-06-14 11:42:02 +0100 | [diff] [blame] | 807 | }; | 
|  | 808 |  | 
|  | 809 |  | 
|  | 810 | static struct platform_device tc6393xb_device = { | 
|  | 811 | .name	= "tc6393xb", | 
|  | 812 | .id	= -1, | 
|  | 813 | .dev	= { | 
| Dmitry Baryshkov | 1c1b6ff | 2008-09-24 23:36:23 +0200 | [diff] [blame] | 814 | .platform_data	= &tosa_tc6393xb_data, | 
| Dmitry Baryshkov | bf0116e | 2008-06-14 11:42:02 +0100 | [diff] [blame] | 815 | }, | 
|  | 816 | .num_resources	= ARRAY_SIZE(tc6393xb_resources), | 
|  | 817 | .resource	= tc6393xb_resources, | 
|  | 818 | }; | 
|  | 819 |  | 
| Dmitry Baryshkov | 16b32fd | 2008-07-05 09:02:48 +0100 | [diff] [blame] | 820 | static struct tosa_bt_data tosa_bt_data = { | 
|  | 821 | .gpio_pwr	= TOSA_GPIO_BT_PWR_EN, | 
|  | 822 | .gpio_reset	= TOSA_GPIO_BT_RESET, | 
|  | 823 | }; | 
|  | 824 |  | 
|  | 825 | static struct platform_device tosa_bt_device = { | 
|  | 826 | .name	= "tosa-bt", | 
|  | 827 | .id	= -1, | 
|  | 828 | .dev.platform_data = &tosa_bt_data, | 
|  | 829 | }; | 
|  | 830 |  | 
| Dmitry Baryshkov | 14b7b40 | 2008-09-13 21:06:41 +0400 | [diff] [blame] | 831 | static struct pxa2xx_spi_master pxa_ssp_master_info = { | 
|  | 832 | .num_chipselect	= 1, | 
|  | 833 | }; | 
|  | 834 |  | 
|  | 835 | static struct spi_board_info spi_board_info[] __initdata = { | 
|  | 836 | { | 
|  | 837 | .modalias	= "tosa-lcd", | 
|  | 838 | // .platform_data | 
|  | 839 | .max_speed_hz	= 28750, | 
|  | 840 | .bus_num	= 2, | 
|  | 841 | .chip_select	= 0, | 
|  | 842 | .mode		= SPI_MODE_0, | 
|  | 843 | }, | 
|  | 844 | }; | 
| Dmitry Baryshkov | 16b32fd | 2008-07-05 09:02:48 +0100 | [diff] [blame] | 845 |  | 
| Dmitry Baryshkov | f34ee79 | 2008-11-25 00:57:27 +0300 | [diff] [blame] | 846 | static struct mtd_partition sharpsl_rom_parts[] = { | 
|  | 847 | { | 
|  | 848 | .name	="Boot PROM Filesystem", | 
|  | 849 | .offset	= 0x00160000, | 
|  | 850 | .size	= MTDPART_SIZ_FULL, | 
|  | 851 | }, | 
|  | 852 | }; | 
|  | 853 |  | 
|  | 854 | static struct physmap_flash_data sharpsl_rom_data = { | 
|  | 855 | .width		= 2, | 
|  | 856 | .nr_parts	= ARRAY_SIZE(sharpsl_rom_parts), | 
|  | 857 | .parts		= sharpsl_rom_parts, | 
|  | 858 | }; | 
|  | 859 |  | 
|  | 860 | static struct resource sharpsl_rom_resources[] = { | 
|  | 861 | { | 
|  | 862 | .start	= 0x00000000, | 
|  | 863 | .end	= 0x007fffff, | 
|  | 864 | .flags	= IORESOURCE_MEM, | 
|  | 865 | }, | 
|  | 866 | }; | 
|  | 867 |  | 
|  | 868 | static struct platform_device sharpsl_rom_device = { | 
|  | 869 | .name	= "physmap-flash", | 
|  | 870 | .id	= -1, | 
|  | 871 | .resource = sharpsl_rom_resources, | 
|  | 872 | .num_resources = ARRAY_SIZE(sharpsl_rom_resources), | 
|  | 873 | .dev.platform_data = &sharpsl_rom_data, | 
|  | 874 | }; | 
|  | 875 |  | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 876 | static struct platform_device *devices[] __initdata = { | 
|  | 877 | &tosascoop_device, | 
|  | 878 | &tosascoop_jc_device, | 
| Dmitry Baryshkov | bf0116e | 2008-06-14 11:42:02 +0100 | [diff] [blame] | 879 | &tc6393xb_device, | 
| Dmitry Baryshkov | 53b14ea | 2008-06-14 11:43:36 +0100 | [diff] [blame] | 880 | &tosa_power_device, | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 881 | &tosakbd_device, | 
| Dmitry Baryshkov | 93e9012 | 2008-01-21 01:04:20 -0500 | [diff] [blame] | 882 | &tosa_gpio_keys_device, | 
| Dirk Opfer | 6d0cf3e | 2006-03-31 02:31:12 -0800 | [diff] [blame] | 883 | &tosaled_device, | 
| Dmitry Baryshkov | 16b32fd | 2008-07-05 09:02:48 +0100 | [diff] [blame] | 884 | &tosa_bt_device, | 
| Dmitry Baryshkov | f34ee79 | 2008-11-25 00:57:27 +0300 | [diff] [blame] | 885 | &sharpsl_rom_device, | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 886 | }; | 
|  | 887 |  | 
| Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 888 | static void tosa_poweroff(void) | 
|  | 889 | { | 
| Russell King | be093be | 2009-03-19 16:20:24 +0000 | [diff] [blame] | 890 | arm_machine_restart('g', NULL); | 
| Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 891 | } | 
|  | 892 |  | 
| Russell King | be093be | 2009-03-19 16:20:24 +0000 | [diff] [blame] | 893 | static void tosa_restart(char mode, const char *cmd) | 
| Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 894 | { | 
|  | 895 | /* Bootloader magic for a reboot */ | 
|  | 896 | if((MSC0 & 0xffff0000) == 0x7ff00000) | 
|  | 897 | MSC0 = (MSC0 & 0xffff) | 0x7ee00000; | 
|  | 898 |  | 
|  | 899 | tosa_poweroff(); | 
|  | 900 | } | 
|  | 901 |  | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 902 | static void __init tosa_init(void) | 
|  | 903 | { | 
| Dmitry Baryshkov | bf0116e | 2008-06-14 11:42:02 +0100 | [diff] [blame] | 904 | int dummy; | 
|  | 905 |  | 
| Dmitry Baryshkov | 2cb4734 | 2008-04-10 11:00:32 +0100 | [diff] [blame] | 906 | pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config)); | 
| Russell King | cc155c6 | 2009-11-09 13:34:08 +0800 | [diff] [blame] | 907 |  | 
|  | 908 | pxa_set_ffuart_info(NULL); | 
|  | 909 | pxa_set_btuart_info(NULL); | 
|  | 910 | pxa_set_stuart_info(NULL); | 
|  | 911 |  | 
| Dmitry Baryshkov | 2cb4734 | 2008-04-10 11:00:32 +0100 | [diff] [blame] | 912 | gpio_set_wake(MFP_PIN_GPIO1, 1); | 
|  | 913 | /* We can't pass to gpio-keys since it will drop the Reset altfunc */ | 
|  | 914 |  | 
| Daniel Ribeiro | 216e3b7 | 2009-05-05 22:43:18 -0300 | [diff] [blame] | 915 | init_gpio_reset(TOSA_GPIO_ON_RESET, 0, 0); | 
| Dmitry Baryshkov | 86159a9 | 2008-05-22 16:21:48 +0100 | [diff] [blame] | 916 |  | 
| Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 917 | pm_power_off = tosa_poweroff; | 
|  | 918 | arm_pm_restart = tosa_restart; | 
|  | 919 |  | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 920 | PCFR |= PCFR_OPDE; | 
|  | 921 |  | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 922 | /* enable batt_fault */ | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 923 | PMCR = 0x01; | 
|  | 924 |  | 
| Dmitry Baryshkov | bf0116e | 2008-06-14 11:42:02 +0100 | [diff] [blame] | 925 | dummy = gpiochip_reserve(TOSA_SCOOP_GPIO_BASE, 12); | 
|  | 926 | dummy = gpiochip_reserve(TOSA_SCOOP_JC_GPIO_BASE, 12); | 
|  | 927 | dummy = gpiochip_reserve(TOSA_TC6393XB_GPIO_BASE, 16); | 
|  | 928 |  | 
| Robert Jarzmik | 7a64825 | 2009-07-06 22:16:42 +0200 | [diff] [blame] | 929 | tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250); | 
| Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 930 | pxa_set_mci_info(&tosa_mci_platform_data); | 
|  | 931 | pxa_set_udc_info(&udc_info); | 
|  | 932 | pxa_set_ficp_info(&tosa_ficp_platform_data); | 
| Dmitry Baryshkov | 481ea5a | 2008-04-10 15:43:18 +0100 | [diff] [blame] | 933 | pxa_set_i2c_info(NULL); | 
| Mark Brown | 80748fb | 2009-04-03 12:45:49 +0100 | [diff] [blame] | 934 | pxa_set_ac97_info(NULL); | 
| Dirk Opfer | 4c18ad2 | 2005-11-08 19:15:50 +0000 | [diff] [blame] | 935 | platform_scoop_config = &tosa_pcmcia_config; | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 936 |  | 
| Dmitry Baryshkov | 14b7b40 | 2008-09-13 21:06:41 +0400 | [diff] [blame] | 937 | pxa2xx_set_spi_info(2, &pxa_ssp_master_info); | 
|  | 938 | spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info)); | 
|  | 939 |  | 
| Dmitry Eremin-Solenikov | c68ffdd | 2009-03-05 18:17:53 +0300 | [diff] [blame] | 940 | clk_add_alias("CLK_CK3P6MI", tc6393xb_device.name, "GPIO11_CLK", NULL); | 
| Dmitry Baryshkov | 7bdb22c | 2008-09-10 10:30:37 +0100 | [diff] [blame] | 941 |  | 
| Dirk Opfer | 4c18ad2 | 2005-11-08 19:15:50 +0000 | [diff] [blame] | 942 | platform_add_devices(devices, ARRAY_SIZE(devices)); | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 943 | } | 
|  | 944 |  | 
|  | 945 | static void __init fixup_tosa(struct machine_desc *desc, | 
|  | 946 | struct tag *tags, char **cmdline, struct meminfo *mi) | 
|  | 947 | { | 
|  | 948 | sharpsl_save_param(); | 
|  | 949 | mi->nr_banks=1; | 
|  | 950 | mi->bank[0].start = 0xa0000000; | 
|  | 951 | mi->bank[0].node = 0; | 
|  | 952 | mi->bank[0].size = (64*1024*1024); | 
|  | 953 | } | 
|  | 954 |  | 
|  | 955 | MACHINE_START(TOSA, "SHARP Tosa") | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 956 | .phys_io	= 0x40000000, | 
|  | 957 | .io_pg_offst	= (io_p2v(0x40000000) >> 18) & 0xfffc, | 
|  | 958 | .fixup          = fixup_tosa, | 
|  | 959 | .map_io         = pxa_map_io, | 
| Eric Miao | cd49104 | 2007-06-22 04:14:09 +0100 | [diff] [blame] | 960 | .init_irq       = pxa25x_init_irq, | 
| Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 961 | .init_machine   = tosa_init, | 
|  | 962 | .timer          = &pxa_timer, | 
|  | 963 | MACHINE_END |