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