Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Support for Sharp SL-Cxx00 Series of PDAs |
| 3 | * Models: SL-C3000 (Spitz), SL-C1000 (Akita) and SL-C3100 (Borzoi) |
| 4 | * |
| 5 | * Copyright (c) 2005 Richard Purdie |
| 6 | * |
| 7 | * Based on Sharp's 2.4 kernel patches/lubbock.c |
| 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> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 17 | #include <linux/platform_device.h> |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 18 | #include <linux/delay.h> |
| 19 | #include <linux/major.h> |
| 20 | #include <linux/fs.h> |
| 21 | #include <linux/interrupt.h> |
| 22 | #include <linux/mmc/host.h> |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 23 | #include <linux/pm.h> |
Richard Purdie | c3f8f65 | 2007-09-03 00:27:00 +0100 | [diff] [blame] | 24 | #include <linux/backlight.h> |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 25 | |
| 26 | #include <asm/setup.h> |
| 27 | #include <asm/memory.h> |
| 28 | #include <asm/mach-types.h> |
| 29 | #include <asm/hardware.h> |
| 30 | #include <asm/irq.h> |
| 31 | #include <asm/io.h> |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 32 | #include <asm/system.h> |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 33 | |
| 34 | #include <asm/mach/arch.h> |
| 35 | #include <asm/mach/map.h> |
| 36 | #include <asm/mach/irq.h> |
| 37 | |
| 38 | #include <asm/arch/pxa-regs.h> |
eric miao | bb548dd | 2008-01-30 09:39:48 +0100 | [diff] [blame] | 39 | #include <asm/arch/pxa2xx-regs.h> |
eric miao | a683b14 | 2008-03-03 09:44:25 +0800 | [diff] [blame] | 40 | #include <asm/arch/pxa2xx-gpio.h> |
Russell King | 53491e0 | 2008-05-17 22:51:35 +0100 | [diff] [blame] | 41 | #include <asm/arch/pxa27x-udc.h> |
Richard Purdie | dc07845 | 2005-10-30 14:50:25 +0000 | [diff] [blame] | 42 | #include <asm/arch/irda.h> |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 43 | #include <asm/arch/mmc.h> |
Richard Purdie | 3125c68 | 2006-01-05 20:44:52 +0000 | [diff] [blame] | 44 | #include <asm/arch/ohci.h> |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 45 | #include <asm/arch/udc.h> |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 46 | #include <asm/arch/pxafb.h> |
| 47 | #include <asm/arch/akita.h> |
| 48 | #include <asm/arch/spitz.h> |
| 49 | #include <asm/arch/sharpsl.h> |
| 50 | |
| 51 | #include <asm/mach/sharpsl_param.h> |
| 52 | #include <asm/hardware/scoop.h> |
| 53 | |
| 54 | #include "generic.h" |
Russell King | 46c41e6 | 2007-05-15 15:39:36 +0100 | [diff] [blame] | 55 | #include "devices.h" |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 56 | #include "sharpsl.h" |
| 57 | |
| 58 | /* |
| 59 | * Spitz SCOOP Device #1 |
| 60 | */ |
| 61 | static struct resource spitz_scoop_resources[] = { |
| 62 | [0] = { |
| 63 | .start = 0x10800000, |
| 64 | .end = 0x10800fff, |
| 65 | .flags = IORESOURCE_MEM, |
| 66 | }, |
| 67 | }; |
| 68 | |
| 69 | static struct scoop_config spitz_scoop_setup = { |
| 70 | .io_dir = SPITZ_SCP_IO_DIR, |
| 71 | .io_out = SPITZ_SCP_IO_OUT, |
| 72 | .suspend_clr = SPITZ_SCP_SUS_CLR, |
| 73 | .suspend_set = SPITZ_SCP_SUS_SET, |
| 74 | }; |
| 75 | |
| 76 | struct platform_device spitzscoop_device = { |
| 77 | .name = "sharp-scoop", |
| 78 | .id = 0, |
| 79 | .dev = { |
| 80 | .platform_data = &spitz_scoop_setup, |
| 81 | }, |
| 82 | .num_resources = ARRAY_SIZE(spitz_scoop_resources), |
| 83 | .resource = spitz_scoop_resources, |
| 84 | }; |
| 85 | |
| 86 | /* |
| 87 | * Spitz SCOOP Device #2 |
| 88 | */ |
| 89 | static struct resource spitz_scoop2_resources[] = { |
| 90 | [0] = { |
| 91 | .start = 0x08800040, |
| 92 | .end = 0x08800fff, |
| 93 | .flags = IORESOURCE_MEM, |
| 94 | }, |
| 95 | }; |
| 96 | |
| 97 | static struct scoop_config spitz_scoop2_setup = { |
| 98 | .io_dir = SPITZ_SCP2_IO_DIR, |
| 99 | .io_out = SPITZ_SCP2_IO_OUT, |
| 100 | .suspend_clr = SPITZ_SCP2_SUS_CLR, |
| 101 | .suspend_set = SPITZ_SCP2_SUS_SET, |
| 102 | }; |
| 103 | |
| 104 | struct platform_device spitzscoop2_device = { |
| 105 | .name = "sharp-scoop", |
| 106 | .id = 1, |
| 107 | .dev = { |
| 108 | .platform_data = &spitz_scoop2_setup, |
| 109 | }, |
| 110 | .num_resources = ARRAY_SIZE(spitz_scoop2_resources), |
| 111 | .resource = spitz_scoop2_resources, |
| 112 | }; |
| 113 | |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 114 | #define SPITZ_PWR_SD 0x01 |
| 115 | #define SPITZ_PWR_CF 0x02 |
| 116 | |
| 117 | /* Power control is shared with between one of the CF slots and SD */ |
| 118 | static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr) |
| 119 | { |
| 120 | unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR); |
| 121 | |
| 122 | if (new_cpr & 0x0007) { |
| 123 | set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER); |
| 124 | if (!(cpr & 0x0002) && !(cpr & 0x0004)) |
| 125 | mdelay(5); |
| 126 | if (device == SPITZ_PWR_CF) |
| 127 | cpr |= 0x0002; |
| 128 | if (device == SPITZ_PWR_SD) |
| 129 | cpr |= 0x0004; |
| 130 | write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr); |
| 131 | } else { |
| 132 | if (device == SPITZ_PWR_CF) |
| 133 | cpr &= ~0x0002; |
| 134 | if (device == SPITZ_PWR_SD) |
| 135 | cpr &= ~0x0004; |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 136 | if (!(cpr & 0x0002) && !(cpr & 0x0004)) { |
Richard Purdie | 945b957 | 2006-01-05 20:44:57 +0000 | [diff] [blame] | 137 | write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000); |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 138 | mdelay(1); |
| 139 | reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER); |
Richard Purdie | 945b957 | 2006-01-05 20:44:57 +0000 | [diff] [blame] | 140 | } else { |
| 141 | write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr); |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | static void spitz_pcmcia_init(void) |
| 147 | { |
| 148 | /* Setup default state of GPIO outputs |
| 149 | before we enable them as outputs. */ |
| 150 | GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) | |
| 151 | GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) | |
| 152 | GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO54_nPCE_2); |
| 153 | GPSR(GPIO85_nPCE_1) = GPIO_bit(GPIO85_nPCE_1); |
| 154 | |
| 155 | pxa_gpio_mode(GPIO48_nPOE_MD); |
| 156 | pxa_gpio_mode(GPIO49_nPWE_MD); |
| 157 | pxa_gpio_mode(GPIO50_nPIOR_MD); |
| 158 | pxa_gpio_mode(GPIO51_nPIOW_MD); |
| 159 | pxa_gpio_mode(GPIO55_nPREG_MD); |
| 160 | pxa_gpio_mode(GPIO56_nPWAIT_MD); |
| 161 | pxa_gpio_mode(GPIO57_nIOIS16_MD); |
| 162 | pxa_gpio_mode(GPIO85_nPCE_1_MD); |
| 163 | pxa_gpio_mode(GPIO54_nPCE_2_MD); |
| 164 | pxa_gpio_mode(GPIO104_pSKTSEL_MD); |
| 165 | } |
| 166 | |
| 167 | static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr) |
| 168 | { |
| 169 | /* Only need to override behaviour for slot 0 */ |
| 170 | if (nr == 0) |
| 171 | spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr); |
| 172 | else |
| 173 | write_scoop_reg(scoop, SCOOP_CPR, cpr); |
| 174 | } |
| 175 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 176 | static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = { |
| 177 | { |
| 178 | .dev = &spitzscoop_device.dev, |
| 179 | .irq = SPITZ_IRQ_GPIO_CF_IRQ, |
| 180 | .cd_irq = SPITZ_IRQ_GPIO_CF_CD, |
| 181 | .cd_irq_str = "PCMCIA0 CD", |
| 182 | },{ |
| 183 | .dev = &spitzscoop2_device.dev, |
| 184 | .irq = SPITZ_IRQ_GPIO_CF2_IRQ, |
| 185 | .cd_irq = -1, |
| 186 | }, |
| 187 | }; |
| 188 | |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 189 | static struct scoop_pcmcia_config spitz_pcmcia_config = { |
| 190 | .devs = &spitz_pcmcia_scoop[0], |
| 191 | .num_devs = 2, |
| 192 | .pcmcia_init = spitz_pcmcia_init, |
| 193 | .power_ctrl = spitz_pcmcia_pwr, |
| 194 | }; |
| 195 | |
| 196 | EXPORT_SYMBOL(spitzscoop_device); |
| 197 | EXPORT_SYMBOL(spitzscoop2_device); |
| 198 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 199 | |
| 200 | /* |
| 201 | * Spitz SSP Device |
| 202 | * |
| 203 | * Set the parent as the scoop device because a lot of SSP devices |
| 204 | * also use scoop functions and this makes the power up/down order |
| 205 | * work correctly. |
| 206 | */ |
| 207 | struct platform_device spitzssp_device = { |
| 208 | .name = "corgi-ssp", |
| 209 | .dev = { |
| 210 | .parent = &spitzscoop_device.dev, |
| 211 | }, |
| 212 | .id = -1, |
| 213 | }; |
| 214 | |
| 215 | struct corgissp_machinfo spitz_ssp_machinfo = { |
| 216 | .port = 2, |
| 217 | .cs_lcdcon = SPITZ_GPIO_LCDCON_CS, |
| 218 | .cs_ads7846 = SPITZ_GPIO_ADS7846_CS, |
| 219 | .cs_max1111 = SPITZ_GPIO_MAX1111_CS, |
| 220 | .clk_lcdcon = 520, |
| 221 | .clk_ads7846 = 14, |
| 222 | .clk_max1111 = 56, |
| 223 | }; |
| 224 | |
| 225 | |
| 226 | /* |
| 227 | * Spitz Backlight Device |
| 228 | */ |
Richard Purdie | c3f8f65 | 2007-09-03 00:27:00 +0100 | [diff] [blame] | 229 | static void spitz_bl_kick_battery(void) |
| 230 | { |
| 231 | void (*kick_batt)(void); |
| 232 | |
| 233 | kick_batt = symbol_get(sharpsl_battery_kick); |
| 234 | if (kick_batt) { |
| 235 | kick_batt(); |
| 236 | symbol_put(sharpsl_battery_kick); |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | static struct generic_bl_info spitz_bl_machinfo = { |
| 241 | .name = "corgi-bl", |
Richard Purdie | 2c0f5fb | 2006-03-31 02:31:51 -0800 | [diff] [blame] | 242 | .default_intensity = 0x1f, |
| 243 | .limit_mask = 0x0b, |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 244 | .max_intensity = 0x2f, |
Richard Purdie | c3f8f65 | 2007-09-03 00:27:00 +0100 | [diff] [blame] | 245 | .kick_battery = spitz_bl_kick_battery, |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 246 | }; |
| 247 | |
| 248 | static struct platform_device spitzbl_device = { |
Richard Purdie | c3f8f65 | 2007-09-03 00:27:00 +0100 | [diff] [blame] | 249 | .name = "generic-bl", |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 250 | .dev = { |
| 251 | .platform_data = &spitz_bl_machinfo, |
| 252 | }, |
| 253 | .id = -1, |
| 254 | }; |
| 255 | |
| 256 | |
| 257 | /* |
| 258 | * Spitz Keyboard Device |
| 259 | */ |
| 260 | static struct platform_device spitzkbd_device = { |
| 261 | .name = "spitz-keyboard", |
| 262 | .id = -1, |
| 263 | }; |
| 264 | |
| 265 | |
| 266 | /* |
Richard Purdie | 3179108 | 2006-03-31 02:31:09 -0800 | [diff] [blame] | 267 | * Spitz LEDs |
| 268 | */ |
| 269 | static struct platform_device spitzled_device = { |
| 270 | .name = "spitz-led", |
| 271 | .id = -1, |
| 272 | }; |
| 273 | |
| 274 | /* |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 275 | * Spitz Touch Screen Device |
| 276 | */ |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 277 | |
| 278 | static unsigned long (*get_hsync_invperiod)(struct device *dev); |
| 279 | |
| 280 | static void inline sharpsl_wait_sync(int gpio) |
| 281 | { |
| 282 | while((GPLR(gpio) & GPIO_bit(gpio)) == 0); |
| 283 | while((GPLR(gpio) & GPIO_bit(gpio)) != 0); |
| 284 | } |
| 285 | |
| 286 | static struct device *spitz_pxafb_dev; |
| 287 | |
| 288 | static int is_pxafb_device(struct device * dev, void * data) |
| 289 | { |
| 290 | struct platform_device *pdev = container_of(dev, struct platform_device, dev); |
| 291 | |
| 292 | return (strncmp(pdev->name, "pxa2xx-fb", 9) == 0); |
| 293 | } |
| 294 | |
| 295 | static unsigned long spitz_get_hsync_invperiod(void) |
| 296 | { |
| 297 | #ifdef CONFIG_FB_PXA |
| 298 | if (!spitz_pxafb_dev) { |
| 299 | spitz_pxafb_dev = bus_find_device(&platform_bus_type, NULL, NULL, is_pxafb_device); |
| 300 | if (!spitz_pxafb_dev) |
| 301 | return 0; |
| 302 | } |
| 303 | if (!get_hsync_invperiod) |
| 304 | get_hsync_invperiod = symbol_get(pxafb_get_hsync_time); |
| 305 | if (!get_hsync_invperiod) |
| 306 | #endif |
| 307 | return 0; |
| 308 | |
| 309 | return get_hsync_invperiod(spitz_pxafb_dev); |
| 310 | } |
| 311 | |
| 312 | static void spitz_put_hsync(void) |
| 313 | { |
| 314 | put_device(spitz_pxafb_dev); |
| 315 | if (get_hsync_invperiod) |
| 316 | symbol_put(pxafb_get_hsync_time); |
| 317 | spitz_pxafb_dev = NULL; |
| 318 | get_hsync_invperiod = NULL; |
| 319 | } |
| 320 | |
| 321 | static void spitz_wait_hsync(void) |
| 322 | { |
| 323 | sharpsl_wait_sync(SPITZ_GPIO_HSYNC); |
| 324 | } |
| 325 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 326 | static struct resource spitzts_resources[] = { |
| 327 | [0] = { |
| 328 | .start = SPITZ_IRQ_GPIO_TP_INT, |
| 329 | .end = SPITZ_IRQ_GPIO_TP_INT, |
| 330 | .flags = IORESOURCE_IRQ, |
| 331 | }, |
| 332 | }; |
| 333 | |
| 334 | static struct corgits_machinfo spitz_ts_machinfo = { |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 335 | .get_hsync_invperiod = spitz_get_hsync_invperiod, |
| 336 | .put_hsync = spitz_put_hsync, |
| 337 | .wait_hsync = spitz_wait_hsync, |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 338 | }; |
| 339 | |
| 340 | static struct platform_device spitzts_device = { |
| 341 | .name = "corgi-ts", |
| 342 | .dev = { |
| 343 | .parent = &spitzssp_device.dev, |
| 344 | .platform_data = &spitz_ts_machinfo, |
| 345 | }, |
| 346 | .id = -1, |
| 347 | .num_resources = ARRAY_SIZE(spitzts_resources), |
| 348 | .resource = spitzts_resources, |
| 349 | }; |
| 350 | |
| 351 | |
| 352 | /* |
| 353 | * MMC/SD Device |
| 354 | * |
| 355 | * The card detect interrupt isn't debounced so we delay it by 250ms |
| 356 | * to give the card a chance to fully insert/eject. |
| 357 | */ |
| 358 | |
| 359 | static struct pxamci_platform_data spitz_mci_platform_data; |
| 360 | |
David Howells | 40220c1 | 2006-10-09 12:19:47 +0100 | [diff] [blame] | 361 | static int spitz_mci_init(struct device *dev, irq_handler_t spitz_detect_int, void *data) |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 362 | { |
| 363 | int err; |
| 364 | |
| 365 | /* setup GPIO for PXA27x MMC controller */ |
| 366 | pxa_gpio_mode(GPIO32_MMCCLK_MD); |
| 367 | pxa_gpio_mode(GPIO112_MMCCMD_MD); |
| 368 | pxa_gpio_mode(GPIO92_MMCDAT0_MD); |
| 369 | pxa_gpio_mode(GPIO109_MMCDAT1_MD); |
| 370 | pxa_gpio_mode(GPIO110_MMCDAT2_MD); |
| 371 | pxa_gpio_mode(GPIO111_MMCDAT3_MD); |
| 372 | pxa_gpio_mode(SPITZ_GPIO_nSD_DETECT | GPIO_IN); |
| 373 | pxa_gpio_mode(SPITZ_GPIO_nSD_WP | GPIO_IN); |
| 374 | |
| 375 | spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250); |
| 376 | |
Russell King | 9ded96f | 2006-01-08 01:02:07 -0800 | [diff] [blame] | 377 | err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int, |
Thomas Gleixner | 52e405e | 2006-07-03 02:20:05 +0200 | [diff] [blame] | 378 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
Russell King | 9ded96f | 2006-01-08 01:02:07 -0800 | [diff] [blame] | 379 | "MMC card detect", data); |
Russell King | 2687bd3 | 2008-01-23 14:05:58 +0000 | [diff] [blame] | 380 | if (err) |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 381 | printk(KERN_ERR "spitz_mci_init: MMC/SD: can't request MMC card detect IRQ\n"); |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 382 | |
Russell King | 2687bd3 | 2008-01-23 14:05:58 +0000 | [diff] [blame] | 383 | return err; |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 384 | } |
| 385 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 386 | static void spitz_mci_setpower(struct device *dev, unsigned int vdd) |
| 387 | { |
| 388 | struct pxamci_platform_data* p_d = dev->platform_data; |
| 389 | |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 390 | if (( 1 << vdd) & p_d->ocr_mask) |
| 391 | spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004); |
| 392 | else |
| 393 | spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000); |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | static int spitz_mci_get_ro(struct device *dev) |
| 397 | { |
| 398 | return GPLR(SPITZ_GPIO_nSD_WP) & GPIO_bit(SPITZ_GPIO_nSD_WP); |
| 399 | } |
| 400 | |
| 401 | static void spitz_mci_exit(struct device *dev, void *data) |
| 402 | { |
| 403 | free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data); |
| 404 | } |
| 405 | |
| 406 | static struct pxamci_platform_data spitz_mci_platform_data = { |
| 407 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
| 408 | .init = spitz_mci_init, |
| 409 | .get_ro = spitz_mci_get_ro, |
| 410 | .setpower = spitz_mci_setpower, |
| 411 | .exit = spitz_mci_exit, |
| 412 | }; |
| 413 | |
| 414 | |
| 415 | /* |
Richard Purdie | 3125c68 | 2006-01-05 20:44:52 +0000 | [diff] [blame] | 416 | * USB Host (OHCI) |
| 417 | */ |
| 418 | static int spitz_ohci_init(struct device *dev) |
| 419 | { |
| 420 | /* Only Port 2 is connected */ |
| 421 | pxa_gpio_mode(SPITZ_GPIO_USB_CONNECT | GPIO_IN); |
| 422 | pxa_gpio_mode(SPITZ_GPIO_USB_HOST | GPIO_OUT); |
| 423 | pxa_gpio_mode(SPITZ_GPIO_USB_DEVICE | GPIO_IN); |
| 424 | |
| 425 | /* Setup USB Port 2 Output Control Register */ |
| 426 | UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE; |
| 427 | |
| 428 | GPSR(SPITZ_GPIO_USB_HOST) = GPIO_bit(SPITZ_GPIO_USB_HOST); |
| 429 | |
| 430 | UHCHR = (UHCHR) & |
| 431 | ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE); |
| 432 | |
| 433 | UHCRHDA |= UHCRHDA_NOCP; |
| 434 | |
| 435 | return 0; |
| 436 | } |
| 437 | |
| 438 | static struct pxaohci_platform_data spitz_ohci_platform_data = { |
| 439 | .port_mode = PMM_NPS_MODE, |
| 440 | .init = spitz_ohci_init, |
Richard Purdie | 0c27c5d | 2006-06-08 22:44:07 +0100 | [diff] [blame] | 441 | .power_budget = 150, |
Richard Purdie | 3125c68 | 2006-01-05 20:44:52 +0000 | [diff] [blame] | 442 | }; |
| 443 | |
| 444 | |
| 445 | /* |
Richard Purdie | dc07845 | 2005-10-30 14:50:25 +0000 | [diff] [blame] | 446 | * Irda |
| 447 | */ |
| 448 | static void spitz_irda_transceiver_mode(struct device *dev, int mode) |
| 449 | { |
| 450 | if (mode & IR_OFF) |
| 451 | set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON); |
| 452 | else |
| 453 | reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON); |
| 454 | } |
| 455 | |
Richard Purdie | 94cabd0 | 2005-11-12 18:53:48 +0000 | [diff] [blame] | 456 | #ifdef CONFIG_MACH_AKITA |
| 457 | static void akita_irda_transceiver_mode(struct device *dev, int mode) |
| 458 | { |
| 459 | if (mode & IR_OFF) |
| 460 | akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON); |
| 461 | else |
| 462 | akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON); |
| 463 | } |
| 464 | #endif |
| 465 | |
Richard Purdie | dc07845 | 2005-10-30 14:50:25 +0000 | [diff] [blame] | 466 | static struct pxaficp_platform_data spitz_ficp_platform_data = { |
| 467 | .transceiver_cap = IR_SIRMODE | IR_OFF, |
| 468 | .transceiver_mode = spitz_irda_transceiver_mode, |
| 469 | }; |
| 470 | |
| 471 | |
| 472 | /* |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 473 | * Spitz PXA Framebuffer |
| 474 | */ |
Richard Purdie | d14b272 | 2006-09-20 22:54:21 +0100 | [diff] [blame] | 475 | |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 476 | static void spitz_lcd_power(int on, struct fb_var_screeninfo *var) |
| 477 | { |
| 478 | if (on) |
| 479 | corgi_lcdtg_hw_init(var->xres); |
| 480 | else |
| 481 | corgi_lcdtg_suspend(); |
| 482 | } |
| 483 | |
Richard Purdie | d14b272 | 2006-09-20 22:54:21 +0100 | [diff] [blame] | 484 | static struct pxafb_mode_info spitz_pxafb_modes[] = { |
| 485 | { |
| 486 | .pixclock = 19231, |
| 487 | .xres = 480, |
| 488 | .yres = 640, |
| 489 | .bpp = 16, |
| 490 | .hsync_len = 40, |
| 491 | .left_margin = 46, |
| 492 | .right_margin = 125, |
| 493 | .vsync_len = 3, |
| 494 | .upper_margin = 1, |
| 495 | .lower_margin = 0, |
| 496 | .sync = 0, |
| 497 | },{ |
| 498 | .pixclock = 134617, |
| 499 | .xres = 240, |
| 500 | .yres = 320, |
| 501 | .bpp = 16, |
| 502 | .hsync_len = 20, |
| 503 | .left_margin = 20, |
| 504 | .right_margin = 46, |
| 505 | .vsync_len = 2, |
| 506 | .upper_margin = 1, |
| 507 | .lower_margin = 0, |
| 508 | .sync = 0, |
| 509 | }, |
| 510 | }; |
| 511 | |
| 512 | static struct pxafb_mach_info spitz_pxafb_info = { |
| 513 | .modes = &spitz_pxafb_modes[0], |
| 514 | .num_modes = 2, |
| 515 | .fixed_modes = 1, |
| 516 | .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act | LCCR0_LDDALT | LCCR0_OUC | LCCR0_CMDIM | LCCR0_RDSTM, |
| 517 | .lccr3 = LCCR3_PixRsEdg | LCCR3_OutEnH, |
| 518 | .pxafb_lcd_power = spitz_lcd_power, |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 519 | }; |
| 520 | |
| 521 | |
| 522 | static struct platform_device *devices[] __initdata = { |
| 523 | &spitzscoop_device, |
| 524 | &spitzssp_device, |
| 525 | &spitzkbd_device, |
| 526 | &spitzts_device, |
| 527 | &spitzbl_device, |
Richard Purdie | 3179108 | 2006-03-31 02:31:09 -0800 | [diff] [blame] | 528 | &spitzled_device, |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 529 | }; |
| 530 | |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 531 | static void spitz_poweroff(void) |
| 532 | { |
Dmitry Baryshkov | 86159a9 | 2008-05-22 16:21:48 +0100 | [diff] [blame^] | 533 | arm_machine_restart('g'); |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | static void spitz_restart(char mode) |
| 537 | { |
| 538 | /* Bootloader magic for a reboot */ |
| 539 | if((MSC0 & 0xffff0000) == 0x7ff00000) |
| 540 | MSC0 = (MSC0 & 0xffff) | 0x7ee00000; |
| 541 | |
| 542 | spitz_poweroff(); |
| 543 | } |
| 544 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 545 | static void __init common_init(void) |
| 546 | { |
Dmitry Baryshkov | 86159a9 | 2008-05-22 16:21:48 +0100 | [diff] [blame^] | 547 | init_gpio_reset(SPITZ_GPIO_ON_RESET); |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 548 | pm_power_off = spitz_poweroff; |
| 549 | arm_pm_restart = spitz_restart; |
| 550 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 551 | PMCR = 0x00; |
| 552 | |
| 553 | /* setup sleep mode values */ |
| 554 | PWER = 0x00000002; |
| 555 | PFER = 0x00000000; |
| 556 | PRER = 0x00000002; |
| 557 | PGSR0 = 0x0158C000; |
| 558 | PGSR1 = 0x00FF0080; |
| 559 | PGSR2 = 0x0001C004; |
| 560 | |
| 561 | /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */ |
| 562 | PCFR |= PCFR_OPDE; |
| 563 | |
| 564 | corgi_ssp_set_machinfo(&spitz_ssp_machinfo); |
| 565 | |
| 566 | pxa_gpio_mode(SPITZ_GPIO_HSYNC | GPIO_IN); |
| 567 | |
| 568 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 569 | pxa_set_mci_info(&spitz_mci_platform_data); |
Richard Purdie | 3125c68 | 2006-01-05 20:44:52 +0000 | [diff] [blame] | 570 | pxa_set_ohci_info(&spitz_ohci_platform_data); |
Richard Purdie | dc07845 | 2005-10-30 14:50:25 +0000 | [diff] [blame] | 571 | pxa_set_ficp_info(&spitz_ficp_platform_data); |
Richard Purdie | cb38c56 | 2005-10-14 16:07:25 +0100 | [diff] [blame] | 572 | set_pxa_fb_parent(&spitzssp_device.dev); |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 573 | set_pxa_fb_info(&spitz_pxafb_info); |
| 574 | } |
| 575 | |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 576 | #if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI) |
| 577 | static void spitz_bl_set_intensity(int intensity) |
| 578 | { |
| 579 | if (intensity > 0x10) |
| 580 | intensity += 0x10; |
| 581 | |
| 582 | /* Bits 0-4 are accessed via the SSP interface */ |
| 583 | corgi_ssp_blduty_set(intensity & 0x1f); |
| 584 | |
| 585 | /* Bit 5 is via SCOOP */ |
| 586 | if (intensity & 0x0020) |
| 587 | reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT); |
| 588 | else |
| 589 | set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT); |
| 590 | |
| 591 | if (intensity) |
| 592 | set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON); |
| 593 | else |
| 594 | reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON); |
| 595 | } |
| 596 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 597 | static void __init spitz_init(void) |
| 598 | { |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 599 | platform_scoop_config = &spitz_pcmcia_config; |
| 600 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 601 | spitz_bl_machinfo.set_bl_intensity = spitz_bl_set_intensity; |
| 602 | |
| 603 | common_init(); |
| 604 | |
| 605 | platform_device_register(&spitzscoop2_device); |
| 606 | } |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 607 | #endif |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 608 | |
Richard Purdie | 94cabd0 | 2005-11-12 18:53:48 +0000 | [diff] [blame] | 609 | #ifdef CONFIG_MACH_AKITA |
| 610 | /* |
| 611 | * Akita IO Expander |
| 612 | */ |
| 613 | struct platform_device akitaioexp_device = { |
| 614 | .name = "akita-ioexp", |
| 615 | .id = -1, |
| 616 | }; |
| 617 | |
Richard Purdie | bd8f103 | 2006-03-26 21:40:27 +0100 | [diff] [blame] | 618 | EXPORT_SYMBOL_GPL(akitaioexp_device); |
| 619 | |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 620 | static void akita_bl_set_intensity(int intensity) |
| 621 | { |
| 622 | if (intensity > 0x10) |
| 623 | intensity += 0x10; |
| 624 | |
| 625 | /* Bits 0-4 are accessed via the SSP interface */ |
| 626 | corgi_ssp_blduty_set(intensity & 0x1f); |
| 627 | |
| 628 | /* Bit 5 is via IO-Expander */ |
| 629 | if (intensity & 0x0020) |
| 630 | akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT); |
| 631 | else |
| 632 | akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT); |
| 633 | |
| 634 | if (intensity) |
| 635 | akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON); |
| 636 | else |
| 637 | akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON); |
| 638 | } |
| 639 | |
Richard Purdie | 94cabd0 | 2005-11-12 18:53:48 +0000 | [diff] [blame] | 640 | static void __init akita_init(void) |
| 641 | { |
| 642 | spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode; |
| 643 | |
| 644 | /* We just pretend the second element of the array doesn't exist */ |
| 645 | spitz_pcmcia_config.num_devs = 1; |
| 646 | platform_scoop_config = &spitz_pcmcia_config; |
| 647 | spitz_bl_machinfo.set_bl_intensity = akita_bl_set_intensity; |
| 648 | |
| 649 | platform_device_register(&akitaioexp_device); |
| 650 | |
| 651 | spitzscoop_device.dev.parent = &akitaioexp_device.dev; |
| 652 | common_init(); |
| 653 | } |
| 654 | #endif |
| 655 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 656 | static void __init fixup_spitz(struct machine_desc *desc, |
| 657 | struct tag *tags, char **cmdline, struct meminfo *mi) |
| 658 | { |
| 659 | sharpsl_save_param(); |
| 660 | mi->nr_banks = 1; |
| 661 | mi->bank[0].start = 0xa0000000; |
| 662 | mi->bank[0].node = 0; |
| 663 | mi->bank[0].size = (64*1024*1024); |
| 664 | } |
| 665 | |
| 666 | #ifdef CONFIG_MACH_SPITZ |
| 667 | MACHINE_START(SPITZ, "SHARP Spitz") |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 668 | .phys_io = 0x40000000, |
| 669 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
| 670 | .fixup = fixup_spitz, |
| 671 | .map_io = pxa_map_io, |
Eric Miao | cd49104 | 2007-06-22 04:14:09 +0100 | [diff] [blame] | 672 | .init_irq = pxa27x_init_irq, |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 673 | .init_machine = spitz_init, |
| 674 | .timer = &pxa_timer, |
| 675 | MACHINE_END |
| 676 | #endif |
| 677 | |
| 678 | #ifdef CONFIG_MACH_BORZOI |
| 679 | MACHINE_START(BORZOI, "SHARP Borzoi") |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 680 | .phys_io = 0x40000000, |
| 681 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
| 682 | .fixup = fixup_spitz, |
| 683 | .map_io = pxa_map_io, |
Eric Miao | cd49104 | 2007-06-22 04:14:09 +0100 | [diff] [blame] | 684 | .init_irq = pxa27x_init_irq, |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 685 | .init_machine = spitz_init, |
| 686 | .timer = &pxa_timer, |
| 687 | MACHINE_END |
| 688 | #endif |
Richard Purdie | 94cabd0 | 2005-11-12 18:53:48 +0000 | [diff] [blame] | 689 | |
| 690 | #ifdef CONFIG_MACH_AKITA |
| 691 | MACHINE_START(AKITA, "SHARP Akita") |
Richard Purdie | 94cabd0 | 2005-11-12 18:53:48 +0000 | [diff] [blame] | 692 | .phys_io = 0x40000000, |
| 693 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
| 694 | .fixup = fixup_spitz, |
| 695 | .map_io = pxa_map_io, |
Eric Miao | cd49104 | 2007-06-22 04:14:09 +0100 | [diff] [blame] | 696 | .init_irq = pxa27x_init_irq, |
Richard Purdie | 94cabd0 | 2005-11-12 18:53:48 +0000 | [diff] [blame] | 697 | .init_machine = akita_init, |
| 698 | .timer = &pxa_timer, |
| 699 | MACHINE_END |
| 700 | #endif |