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