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