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> |
| 21 | #include <linux/mmc/host.h> |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 22 | #include <linux/pm.h> |
Russell King | 905f146 | 2006-06-20 23:27:37 +0100 | [diff] [blame] | 23 | #include <linux/delay.h> |
Dmitry Baryshkov | 93e9012 | 2008-01-21 01:04:20 -0500 | [diff] [blame] | 24 | #include <linux/gpio_keys.h> |
| 25 | #include <linux/input.h> |
Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 26 | #include <linux/gpio.h> |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 27 | |
| 28 | #include <asm/setup.h> |
| 29 | #include <asm/memory.h> |
| 30 | #include <asm/mach-types.h> |
| 31 | #include <asm/hardware.h> |
| 32 | #include <asm/irq.h> |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 33 | #include <asm/system.h> |
Richard Purdie | 7748303 | 2007-03-07 00:02:15 +0100 | [diff] [blame] | 34 | #include <asm/arch/pxa-regs.h> |
eric miao | bb548dd | 2008-01-30 09:39:48 +0100 | [diff] [blame] | 35 | #include <asm/arch/pxa2xx-regs.h> |
Dmitry Baryshkov | 2cb4734 | 2008-04-10 11:00:32 +0100 | [diff] [blame] | 36 | #include <asm/arch/mfp-pxa25x.h> |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 37 | #include <asm/arch/irda.h> |
Dmitry Baryshkov | 481ea5a | 2008-04-10 15:43:18 +0100 | [diff] [blame] | 38 | #include <asm/arch/i2c.h> |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 39 | #include <asm/arch/mmc.h> |
| 40 | #include <asm/arch/udc.h> |
| 41 | |
| 42 | #include <asm/mach/arch.h> |
| 43 | #include <asm/mach/map.h> |
| 44 | #include <asm/mach/irq.h> |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 45 | #include <asm/arch/tosa.h> |
| 46 | |
| 47 | #include <asm/hardware/scoop.h> |
| 48 | #include <asm/mach/sharpsl_param.h> |
| 49 | |
| 50 | #include "generic.h" |
Russell King | 46c41e6 | 2007-05-15 15:39:36 +0100 | [diff] [blame] | 51 | #include "devices.h" |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 52 | |
Dmitry Baryshkov | 2cb4734 | 2008-04-10 11:00:32 +0100 | [diff] [blame] | 53 | static unsigned long tosa_pin_config[] = { |
| 54 | GPIO78_nCS_2, /* Scoop */ |
| 55 | GPIO80_nCS_4, /* tg6393xb */ |
| 56 | GPIO33_nCS_5, /* Scoop */ |
| 57 | |
| 58 | // GPIO76 CARD_VCC_ON1 |
| 59 | |
| 60 | GPIO19_GPIO, /* Reset out */ |
| 61 | GPIO1_RST | WAKEUP_ON_EDGE_FALL, |
| 62 | |
| 63 | GPIO0_GPIO | WAKEUP_ON_EDGE_FALL, /* WAKE_UP */ |
| 64 | GPIO2_GPIO | WAKEUP_ON_EDGE_BOTH, /* AC_IN */ |
| 65 | GPIO3_GPIO | WAKEUP_ON_EDGE_FALL, /* RECORD */ |
| 66 | GPIO4_GPIO | WAKEUP_ON_EDGE_FALL, /* SYNC */ |
| 67 | GPIO20_GPIO, /* EAR_IN */ |
| 68 | GPIO22_GPIO, /* On */ |
| 69 | |
| 70 | GPIO5_GPIO, /* USB_IN */ |
| 71 | GPIO32_GPIO, /* Pen IRQ */ |
| 72 | |
| 73 | GPIO7_GPIO, /* Jacket Detect */ |
| 74 | GPIO14_GPIO, /* BAT0_CRG */ |
| 75 | GPIO12_GPIO, /* BAT1_CRG */ |
| 76 | GPIO17_GPIO, /* BAT0_LOW */ |
| 77 | GPIO84_GPIO, /* BAT1_LOW */ |
| 78 | GPIO38_GPIO, /* BAT_LOCK */ |
| 79 | |
| 80 | GPIO11_3_6MHz, |
| 81 | GPIO15_GPIO, /* TC6393XB IRQ */ |
| 82 | GPIO18_RDY, |
| 83 | GPIO27_GPIO, /* LCD Sync */ |
| 84 | |
| 85 | /* MMC */ |
| 86 | GPIO6_MMC_CLK, |
| 87 | GPIO8_MMC_CS0, |
| 88 | GPIO9_GPIO, /* Detect */ |
| 89 | // GPIO10 nSD_INT |
| 90 | |
| 91 | /* CF */ |
| 92 | GPIO13_GPIO, /* CD_IRQ */ |
| 93 | GPIO21_GPIO, /* Main Slot IRQ */ |
| 94 | GPIO36_GPIO, /* Jacket Slot IRQ */ |
| 95 | GPIO48_nPOE, |
| 96 | GPIO49_nPWE, |
| 97 | GPIO50_nPIOR, |
| 98 | GPIO51_nPIOW, |
| 99 | GPIO52_nPCE_1, |
| 100 | GPIO53_nPCE_2, |
| 101 | GPIO54_nPSKTSEL, |
| 102 | GPIO55_nPREG, |
| 103 | GPIO56_nPWAIT, |
| 104 | GPIO57_nIOIS16, |
| 105 | |
| 106 | /* AC97 */ |
| 107 | GPIO31_AC97_SYNC, |
| 108 | GPIO30_AC97_SDATA_OUT, |
| 109 | GPIO28_AC97_BITCLK, |
| 110 | GPIO29_AC97_SDATA_IN_0, |
| 111 | // GPIO79 nAUD_IRQ |
| 112 | |
| 113 | /* FFUART */ |
| 114 | GPIO34_FFUART_RXD, |
| 115 | GPIO35_FFUART_CTS, |
| 116 | GPIO37_FFUART_DSR, |
| 117 | GPIO39_FFUART_TXD, |
| 118 | GPIO40_FFUART_DTR, |
| 119 | GPIO41_FFUART_RTS, |
| 120 | |
| 121 | /* BTUART */ |
| 122 | GPIO42_BTUART_RXD, |
| 123 | GPIO43_BTUART_TXD, |
| 124 | GPIO44_BTUART_CTS, |
| 125 | GPIO45_BTUART_RTS, |
| 126 | |
| 127 | /* IrDA */ |
| 128 | GPIO46_STUART_RXD, |
| 129 | GPIO47_STUART_TXD, |
| 130 | |
| 131 | /* Keybd */ |
| 132 | GPIO58_GPIO, |
| 133 | GPIO59_GPIO, |
| 134 | GPIO60_GPIO, |
| 135 | GPIO61_GPIO, |
| 136 | GPIO62_GPIO, |
| 137 | GPIO63_GPIO, |
| 138 | GPIO64_GPIO, |
| 139 | GPIO65_GPIO, |
| 140 | GPIO66_GPIO, |
| 141 | GPIO67_GPIO, |
| 142 | GPIO68_GPIO, |
| 143 | GPIO69_GPIO, |
| 144 | GPIO70_GPIO, |
| 145 | GPIO71_GPIO, |
| 146 | GPIO72_GPIO, |
| 147 | GPIO73_GPIO, |
| 148 | GPIO74_GPIO, |
| 149 | GPIO75_GPIO, |
| 150 | |
| 151 | /* SPI */ |
| 152 | GPIO81_SSP2_CLK_OUT, |
| 153 | GPIO82_SSP2_FRM_OUT, |
| 154 | GPIO83_SSP2_TXD, |
| 155 | }; |
| 156 | |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 157 | /* |
| 158 | * SCOOP Device |
| 159 | */ |
| 160 | static struct resource tosa_scoop_resources[] = { |
| 161 | [0] = { |
| 162 | .start = TOSA_CF_PHYS, |
| 163 | .end = TOSA_CF_PHYS + 0xfff, |
| 164 | .flags = IORESOURCE_MEM, |
| 165 | }, |
| 166 | }; |
| 167 | |
| 168 | static struct scoop_config tosa_scoop_setup = { |
| 169 | .io_dir = TOSA_SCOOP_IO_DIR, |
Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 170 | .gpio_base = TOSA_SCOOP_GPIO_BASE, |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 171 | }; |
| 172 | |
Dmitry Baryshkov | ba4eb7e | 2008-04-19 10:42:25 +0100 | [diff] [blame] | 173 | static struct platform_device tosascoop_device = { |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 174 | .name = "sharp-scoop", |
| 175 | .id = 0, |
| 176 | .dev = { |
| 177 | .platform_data = &tosa_scoop_setup, |
| 178 | }, |
| 179 | .num_resources = ARRAY_SIZE(tosa_scoop_resources), |
| 180 | .resource = tosa_scoop_resources, |
| 181 | }; |
| 182 | |
| 183 | |
| 184 | /* |
| 185 | * SCOOP Device Jacket |
| 186 | */ |
| 187 | static struct resource tosa_scoop_jc_resources[] = { |
| 188 | [0] = { |
| 189 | .start = TOSA_SCOOP_PHYS + 0x40, |
| 190 | .end = TOSA_SCOOP_PHYS + 0xfff, |
| 191 | .flags = IORESOURCE_MEM, |
| 192 | }, |
| 193 | }; |
| 194 | |
| 195 | static struct scoop_config tosa_scoop_jc_setup = { |
| 196 | .io_dir = TOSA_SCOOP_JC_IO_DIR, |
Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 197 | .gpio_base = TOSA_SCOOP_JC_GPIO_BASE, |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 198 | }; |
| 199 | |
Dmitry Baryshkov | ba4eb7e | 2008-04-19 10:42:25 +0100 | [diff] [blame] | 200 | static struct platform_device tosascoop_jc_device = { |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 201 | .name = "sharp-scoop", |
| 202 | .id = 1, |
| 203 | .dev = { |
| 204 | .platform_data = &tosa_scoop_jc_setup, |
| 205 | .parent = &tosascoop_device.dev, |
| 206 | }, |
| 207 | .num_resources = ARRAY_SIZE(tosa_scoop_jc_resources), |
| 208 | .resource = tosa_scoop_jc_resources, |
| 209 | }; |
| 210 | |
Dirk Opfer | 4c18ad2 | 2005-11-08 19:15:50 +0000 | [diff] [blame] | 211 | /* |
| 212 | * PCMCIA |
| 213 | */ |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 214 | static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = { |
| 215 | { |
| 216 | .dev = &tosascoop_device.dev, |
| 217 | .irq = TOSA_IRQ_GPIO_CF_IRQ, |
| 218 | .cd_irq = TOSA_IRQ_GPIO_CF_CD, |
| 219 | .cd_irq_str = "PCMCIA0 CD", |
| 220 | },{ |
| 221 | .dev = &tosascoop_jc_device.dev, |
| 222 | .irq = TOSA_IRQ_GPIO_JC_CF_IRQ, |
| 223 | .cd_irq = -1, |
| 224 | }, |
| 225 | }; |
| 226 | |
Dirk Opfer | 4c18ad2 | 2005-11-08 19:15:50 +0000 | [diff] [blame] | 227 | static struct scoop_pcmcia_config tosa_pcmcia_config = { |
| 228 | .devs = &tosa_pcmcia_scoop[0], |
| 229 | .num_devs = 2, |
Dirk Opfer | 4c18ad2 | 2005-11-08 19:15:50 +0000 | [diff] [blame] | 230 | }; |
| 231 | |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 232 | /* |
| 233 | * USB Device Controller |
| 234 | */ |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 235 | static struct pxa2xx_udc_mach_info udc_info __initdata = { |
Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 236 | .gpio_pullup = TOSA_GPIO_USB_PULLUP, |
Dmitry Baryshkov | 487dc92 | 2007-12-21 12:18:01 +0300 | [diff] [blame] | 237 | .gpio_vbus = TOSA_GPIO_USB_IN, |
| 238 | .gpio_vbus_inverted = 1, |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 239 | }; |
| 240 | |
| 241 | /* |
| 242 | * MMC/SD Device |
| 243 | */ |
| 244 | static struct pxamci_platform_data tosa_mci_platform_data; |
| 245 | |
David Howells | 40220c1 | 2006-10-09 12:19:47 +0100 | [diff] [blame] | 246 | 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] | 247 | { |
| 248 | int err; |
| 249 | |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 250 | tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250); |
| 251 | |
Russell King | 2687bd3 | 2008-01-23 14:05:58 +0000 | [diff] [blame] | 252 | err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int, |
| 253 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 254 | "MMC/SD card detect", data); |
Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 255 | if (err) { |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 256 | 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] | 257 | goto err_irq; |
| 258 | } |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 259 | |
Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 260 | err = gpio_request(TOSA_GPIO_SD_WP, "sd_wp"); |
| 261 | if (err) { |
| 262 | printk(KERN_ERR "tosa_mci_init: can't request SD_WP gpio\n"); |
| 263 | goto err_gpio_wp; |
| 264 | } |
| 265 | err = gpio_direction_input(TOSA_GPIO_SD_WP); |
| 266 | if (err) |
| 267 | goto err_gpio_wp_dir; |
| 268 | |
| 269 | err = gpio_request(TOSA_GPIO_PWR_ON, "sd_pwr"); |
| 270 | if (err) { |
| 271 | printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n"); |
| 272 | goto err_gpio_pwr; |
| 273 | } |
| 274 | err = gpio_direction_output(TOSA_GPIO_PWR_ON, 0); |
| 275 | if (err) |
| 276 | goto err_gpio_pwr_dir; |
| 277 | |
| 278 | return 0; |
| 279 | |
| 280 | err_gpio_pwr_dir: |
| 281 | gpio_free(TOSA_GPIO_PWR_ON); |
| 282 | err_gpio_pwr: |
| 283 | err_gpio_wp_dir: |
| 284 | gpio_free(TOSA_GPIO_SD_WP); |
| 285 | err_gpio_wp: |
| 286 | free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data); |
| 287 | err_irq: |
Russell King | 2687bd3 | 2008-01-23 14:05:58 +0000 | [diff] [blame] | 288 | return err; |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | static void tosa_mci_setpower(struct device *dev, unsigned int vdd) |
| 292 | { |
| 293 | struct pxamci_platform_data* p_d = dev->platform_data; |
| 294 | |
| 295 | if (( 1 << vdd) & p_d->ocr_mask) { |
Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 296 | gpio_set_value(TOSA_GPIO_PWR_ON, 1); |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 297 | } else { |
Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 298 | gpio_set_value(TOSA_GPIO_PWR_ON, 0); |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 299 | } |
| 300 | } |
| 301 | |
| 302 | static int tosa_mci_get_ro(struct device *dev) |
| 303 | { |
Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 304 | return gpio_get_value(TOSA_GPIO_SD_WP); |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | static void tosa_mci_exit(struct device *dev, void *data) |
| 308 | { |
Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 309 | gpio_free(TOSA_GPIO_PWR_ON); |
| 310 | gpio_free(TOSA_GPIO_SD_WP); |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 311 | free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data); |
| 312 | } |
| 313 | |
| 314 | static struct pxamci_platform_data tosa_mci_platform_data = { |
| 315 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
| 316 | .init = tosa_mci_init, |
| 317 | .get_ro = tosa_mci_get_ro, |
| 318 | .setpower = tosa_mci_setpower, |
| 319 | .exit = tosa_mci_exit, |
| 320 | }; |
| 321 | |
| 322 | /* |
| 323 | * Irda |
| 324 | */ |
Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 325 | static int tosa_irda_startup(struct device *dev) |
| 326 | { |
| 327 | int ret; |
| 328 | |
| 329 | ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown"); |
| 330 | if (ret) |
| 331 | return ret; |
| 332 | |
| 333 | ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0); |
| 334 | if (ret) |
| 335 | gpio_free(TOSA_GPIO_IR_POWERDWN); |
| 336 | |
| 337 | return ret; |
| 338 | } |
| 339 | |
| 340 | static void tosa_irda_shutdown(struct device *dev) |
| 341 | { |
| 342 | gpio_free(TOSA_GPIO_IR_POWERDWN); |
| 343 | } |
| 344 | |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 345 | static void tosa_irda_transceiver_mode(struct device *dev, int mode) |
| 346 | { |
Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 347 | gpio_set_value(TOSA_GPIO_IR_POWERDWN, !(mode & IR_OFF)); |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | static struct pxaficp_platform_data tosa_ficp_platform_data = { |
| 351 | .transceiver_cap = IR_SIRMODE | IR_OFF, |
| 352 | .transceiver_mode = tosa_irda_transceiver_mode, |
Dmitry Baryshkov | d4e7d09 | 2008-04-12 20:16:16 +0100 | [diff] [blame] | 353 | .startup = tosa_irda_startup, |
| 354 | .shutdown = tosa_irda_shutdown, |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 355 | }; |
| 356 | |
| 357 | /* |
| 358 | * Tosa Keyboard |
| 359 | */ |
| 360 | static struct platform_device tosakbd_device = { |
| 361 | .name = "tosa-keyboard", |
| 362 | .id = -1, |
| 363 | }; |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 364 | |
Dmitry Baryshkov | 93e9012 | 2008-01-21 01:04:20 -0500 | [diff] [blame] | 365 | static struct gpio_keys_button tosa_gpio_keys[] = { |
Dmitry Baryshkov | 0aa97561 | 2008-04-12 20:02:50 +0100 | [diff] [blame] | 366 | /* |
| 367 | * Two following keys are directly tied to "ON" button of tosa. Why? |
| 368 | * The first one can be used as a wakeup source, the second can't; |
| 369 | * also the first one is OR of ac_powered and on_button. |
| 370 | */ |
| 371 | { |
| 372 | .type = EV_PWR, |
| 373 | .code = KEY_RESERVED, |
| 374 | .gpio = TOSA_GPIO_POWERON, |
| 375 | .desc = "Poweron", |
| 376 | .wakeup = 1, |
| 377 | .active_low = 1, |
| 378 | }, |
Dmitry Baryshkov | 93e9012 | 2008-01-21 01:04:20 -0500 | [diff] [blame] | 379 | { |
| 380 | .type = EV_PWR, |
| 381 | .code = KEY_SUSPEND, |
| 382 | .gpio = TOSA_GPIO_ON_KEY, |
| 383 | .desc = "On key", |
Dmitry Baryshkov | 0aa97561 | 2008-04-12 20:02:50 +0100 | [diff] [blame] | 384 | /* |
| 385 | * can't be used as wakeup |
| 386 | * .wakeup = 1, |
| 387 | */ |
Dmitry Baryshkov | 93e9012 | 2008-01-21 01:04:20 -0500 | [diff] [blame] | 388 | .active_low = 1, |
| 389 | }, |
| 390 | { |
| 391 | .type = EV_KEY, |
| 392 | .code = TOSA_KEY_RECORD, |
| 393 | .gpio = TOSA_GPIO_RECORD_BTN, |
| 394 | .desc = "Record Button", |
| 395 | .wakeup = 1, |
| 396 | .active_low = 1, |
| 397 | }, |
| 398 | { |
| 399 | .type = EV_KEY, |
| 400 | .code = TOSA_KEY_SYNC, |
| 401 | .gpio = TOSA_GPIO_SYNC, |
| 402 | .desc = "Sync Button", |
| 403 | .wakeup = 1, |
| 404 | .active_low = 1, |
| 405 | }, |
| 406 | }; |
| 407 | |
| 408 | static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = { |
| 409 | .buttons = tosa_gpio_keys, |
| 410 | .nbuttons = ARRAY_SIZE(tosa_gpio_keys), |
| 411 | }; |
| 412 | |
| 413 | static struct platform_device tosa_gpio_keys_device = { |
| 414 | .name = "gpio-keys", |
| 415 | .id = -1, |
| 416 | .dev = { |
| 417 | .platform_data = &tosa_gpio_keys_platform_data, |
| 418 | }, |
| 419 | }; |
| 420 | |
Dirk Opfer | 6d0cf3e | 2006-03-31 02:31:12 -0800 | [diff] [blame] | 421 | /* |
| 422 | * Tosa LEDs |
| 423 | */ |
Dmitry Baryshkov | ba4eb7e | 2008-04-19 10:42:25 +0100 | [diff] [blame] | 424 | static struct gpio_led tosa_gpio_leds[] = { |
Dmitry Baryshkov | 311c736 | 2008-04-12 20:17:02 +0100 | [diff] [blame] | 425 | { |
| 426 | .name = "tosa:amber:charge", |
| 427 | .default_trigger = "main-battery-charging", |
| 428 | .gpio = TOSA_GPIO_CHRG_ERR_LED, |
| 429 | }, |
| 430 | { |
| 431 | .name = "tosa:green:mail", |
| 432 | .default_trigger = "nand-disk", |
| 433 | .gpio = TOSA_GPIO_NOTE_LED, |
| 434 | }, |
Dmitry Baryshkov | c546106 | 2008-04-19 10:42:06 +0100 | [diff] [blame] | 435 | { |
| 436 | .name = "tosa:dual:wlan", |
| 437 | .default_trigger = "none", |
| 438 | .gpio = TOSA_GPIO_WLAN_LED, |
| 439 | }, |
| 440 | { |
| 441 | .name = "tosa:blue:bluetooth", |
| 442 | .default_trigger = "none", |
| 443 | .gpio = TOSA_GPIO_BT_LED, |
| 444 | }, |
Dmitry Baryshkov | 311c736 | 2008-04-12 20:17:02 +0100 | [diff] [blame] | 445 | }; |
| 446 | |
Dmitry Baryshkov | ba4eb7e | 2008-04-19 10:42:25 +0100 | [diff] [blame] | 447 | static struct gpio_led_platform_data tosa_gpio_leds_platform_data = { |
Dmitry Baryshkov | 311c736 | 2008-04-12 20:17:02 +0100 | [diff] [blame] | 448 | .leds = tosa_gpio_leds, |
| 449 | .num_leds = ARRAY_SIZE(tosa_gpio_leds), |
| 450 | }; |
| 451 | |
Dirk Opfer | 6d0cf3e | 2006-03-31 02:31:12 -0800 | [diff] [blame] | 452 | static struct platform_device tosaled_device = { |
Dmitry Baryshkov | 311c736 | 2008-04-12 20:17:02 +0100 | [diff] [blame] | 453 | .name = "leds-gpio", |
| 454 | .id = -1, |
| 455 | .dev = { |
| 456 | .platform_data = &tosa_gpio_leds_platform_data, |
| 457 | }, |
Dirk Opfer | 6d0cf3e | 2006-03-31 02:31:12 -0800 | [diff] [blame] | 458 | }; |
| 459 | |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 460 | static struct platform_device *devices[] __initdata = { |
| 461 | &tosascoop_device, |
| 462 | &tosascoop_jc_device, |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 463 | &tosakbd_device, |
Dmitry Baryshkov | 93e9012 | 2008-01-21 01:04:20 -0500 | [diff] [blame] | 464 | &tosa_gpio_keys_device, |
Dirk Opfer | 6d0cf3e | 2006-03-31 02:31:12 -0800 | [diff] [blame] | 465 | &tosaled_device, |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 466 | }; |
| 467 | |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 468 | static void tosa_poweroff(void) |
| 469 | { |
| 470 | RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR; |
| 471 | |
| 472 | pxa_gpio_mode(TOSA_GPIO_ON_RESET | GPIO_OUT); |
| 473 | GPSR(TOSA_GPIO_ON_RESET) = GPIO_bit(TOSA_GPIO_ON_RESET); |
| 474 | |
| 475 | mdelay(1000); |
| 476 | arm_machine_restart('h'); |
| 477 | } |
| 478 | |
| 479 | static void tosa_restart(char mode) |
| 480 | { |
| 481 | /* Bootloader magic for a reboot */ |
| 482 | if((MSC0 & 0xffff0000) == 0x7ff00000) |
| 483 | MSC0 = (MSC0 & 0xffff) | 0x7ee00000; |
| 484 | |
| 485 | tosa_poweroff(); |
| 486 | } |
| 487 | |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 488 | static void __init tosa_init(void) |
| 489 | { |
Dmitry Baryshkov | 2cb4734 | 2008-04-10 11:00:32 +0100 | [diff] [blame] | 490 | pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config)); |
| 491 | gpio_set_wake(MFP_PIN_GPIO1, 1); |
| 492 | /* We can't pass to gpio-keys since it will drop the Reset altfunc */ |
| 493 | |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 494 | pm_power_off = tosa_poweroff; |
| 495 | arm_pm_restart = tosa_restart; |
| 496 | |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 497 | PCFR |= PCFR_OPDE; |
| 498 | |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 499 | /* enable batt_fault */ |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 500 | PMCR = 0x01; |
| 501 | |
Dirk Opfer | a93876c | 2005-11-08 19:15:30 +0000 | [diff] [blame] | 502 | pxa_set_mci_info(&tosa_mci_platform_data); |
| 503 | pxa_set_udc_info(&udc_info); |
| 504 | pxa_set_ficp_info(&tosa_ficp_platform_data); |
Dmitry Baryshkov | 481ea5a | 2008-04-10 15:43:18 +0100 | [diff] [blame] | 505 | pxa_set_i2c_info(NULL); |
Dirk Opfer | 4c18ad2 | 2005-11-08 19:15:50 +0000 | [diff] [blame] | 506 | platform_scoop_config = &tosa_pcmcia_config; |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 507 | |
Dirk Opfer | 4c18ad2 | 2005-11-08 19:15:50 +0000 | [diff] [blame] | 508 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | static void __init fixup_tosa(struct machine_desc *desc, |
| 512 | struct tag *tags, char **cmdline, struct meminfo *mi) |
| 513 | { |
| 514 | sharpsl_save_param(); |
| 515 | mi->nr_banks=1; |
| 516 | mi->bank[0].start = 0xa0000000; |
| 517 | mi->bank[0].node = 0; |
| 518 | mi->bank[0].size = (64*1024*1024); |
| 519 | } |
| 520 | |
| 521 | MACHINE_START(TOSA, "SHARP Tosa") |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 522 | .phys_io = 0x40000000, |
| 523 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
| 524 | .fixup = fixup_tosa, |
| 525 | .map_io = pxa_map_io, |
Eric Miao | cd49104 | 2007-06-22 04:14:09 +0100 | [diff] [blame] | 526 | .init_irq = pxa25x_init_irq, |
Dirk Opfer | 8459c15 | 2005-11-06 14:27:52 +0000 | [diff] [blame] | 527 | .init_machine = tosa_init, |
| 528 | .timer = &pxa_timer, |
| 529 | MACHINE_END |