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