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