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