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