Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Support for Sharp SL-C7xx PDAs |
| 3 | * Models: SL-C700 (Corgi), SL-C750 (Shepherd), SL-C760 (Husky) |
| 4 | * |
| 5 | * Copyright (c) 2004-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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [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> |
Richard Purdie | c3f8f65 | 2007-09-03 00:27:00 +0100 | [diff] [blame] | 23 | #include <linux/backlight.h> |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 24 | #include <video/w100fb.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -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/irda.h> |
| 42 | #include <mach/mmc.h> |
| 43 | #include <mach/udc.h> |
| 44 | #include <mach/corgi.h> |
| 45 | #include <mach/sharpsl.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
| 47 | #include <asm/mach/sharpsl_param.h> |
| 48 | #include <asm/hardware/scoop.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | #include "generic.h" |
Russell King | 46c41e6 | 2007-05-15 15:39:36 +0100 | [diff] [blame] | 51 | #include "devices.h" |
Richard Purdie | 50a5de4 | 2005-09-13 01:25:30 -0700 | [diff] [blame] | 52 | #include "sharpsl.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
| 54 | |
| 55 | /* |
| 56 | * Corgi SCOOP Device |
| 57 | */ |
| 58 | static struct resource corgi_scoop_resources[] = { |
| 59 | [0] = { |
| 60 | .start = 0x10800000, |
| 61 | .end = 0x10800fff, |
| 62 | .flags = IORESOURCE_MEM, |
| 63 | }, |
| 64 | }; |
| 65 | |
| 66 | static struct scoop_config corgi_scoop_setup = { |
| 67 | .io_dir = CORGI_SCOOP_IO_DIR, |
| 68 | .io_out = CORGI_SCOOP_IO_OUT, |
| 69 | }; |
| 70 | |
| 71 | struct platform_device corgiscoop_device = { |
| 72 | .name = "sharp-scoop", |
| 73 | .id = -1, |
| 74 | .dev = { |
| 75 | .platform_data = &corgi_scoop_setup, |
| 76 | }, |
| 77 | .num_resources = ARRAY_SIZE(corgi_scoop_resources), |
| 78 | .resource = corgi_scoop_resources, |
| 79 | }; |
| 80 | |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 81 | static void corgi_pcmcia_init(void) |
| 82 | { |
| 83 | /* Setup default state of GPIO outputs |
| 84 | before we enable them as outputs. */ |
| 85 | GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) | |
| 86 | GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) | |
| 87 | GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) | |
| 88 | GPIO_bit(GPIO53_nPCE_2); |
| 89 | |
| 90 | pxa_gpio_mode(GPIO48_nPOE_MD); |
| 91 | pxa_gpio_mode(GPIO49_nPWE_MD); |
| 92 | pxa_gpio_mode(GPIO50_nPIOR_MD); |
| 93 | pxa_gpio_mode(GPIO51_nPIOW_MD); |
| 94 | pxa_gpio_mode(GPIO55_nPREG_MD); |
| 95 | pxa_gpio_mode(GPIO56_nPWAIT_MD); |
| 96 | pxa_gpio_mode(GPIO57_nIOIS16_MD); |
| 97 | pxa_gpio_mode(GPIO52_nPCE_1_MD); |
| 98 | pxa_gpio_mode(GPIO53_nPCE_2_MD); |
| 99 | pxa_gpio_mode(GPIO54_pSKTSEL_MD); |
| 100 | } |
| 101 | |
| 102 | static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = { |
| 103 | { |
| 104 | .dev = &corgiscoop_device.dev, |
| 105 | .irq = CORGI_IRQ_GPIO_CF_IRQ, |
| 106 | .cd_irq = CORGI_IRQ_GPIO_CF_CD, |
| 107 | .cd_irq_str = "PCMCIA0 CD", |
| 108 | }, |
| 109 | }; |
| 110 | |
| 111 | static struct scoop_pcmcia_config corgi_pcmcia_config = { |
| 112 | .devs = &corgi_pcmcia_scoop[0], |
| 113 | .num_devs = 1, |
| 114 | .pcmcia_init = corgi_pcmcia_init, |
| 115 | }; |
| 116 | |
| 117 | EXPORT_SYMBOL(corgiscoop_device); |
| 118 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | |
| 120 | /* |
| 121 | * Corgi SSP Device |
| 122 | * |
| 123 | * Set the parent as the scoop device because a lot of SSP devices |
| 124 | * also use scoop functions and this makes the power up/down order |
| 125 | * work correctly. |
| 126 | */ |
Richard Purdie | 41b1bce | 2005-09-06 15:19:05 -0700 | [diff] [blame] | 127 | struct platform_device corgissp_device = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | .name = "corgi-ssp", |
| 129 | .dev = { |
| 130 | .parent = &corgiscoop_device.dev, |
| 131 | }, |
| 132 | .id = -1, |
| 133 | }; |
| 134 | |
Richard Purdie | 50a5de4 | 2005-09-13 01:25:30 -0700 | [diff] [blame] | 135 | struct corgissp_machinfo corgi_ssp_machinfo = { |
| 136 | .port = 1, |
| 137 | .cs_lcdcon = CORGI_GPIO_LCDCON_CS, |
| 138 | .cs_ads7846 = CORGI_GPIO_ADS7846_CS, |
| 139 | .cs_max1111 = CORGI_GPIO_MAX1111_CS, |
| 140 | .clk_lcdcon = 76, |
| 141 | .clk_ads7846 = 2, |
| 142 | .clk_max1111 = 8, |
| 143 | }; |
| 144 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
| 146 | /* |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 147 | * LCD/Framebuffer |
| 148 | */ |
| 149 | static void w100_lcdtg_suspend(struct w100fb_par *par) |
| 150 | { |
| 151 | corgi_lcdtg_suspend(); |
| 152 | } |
| 153 | |
| 154 | static void w100_lcdtg_init(struct w100fb_par *par) |
| 155 | { |
| 156 | corgi_lcdtg_hw_init(par->xres); |
| 157 | } |
| 158 | |
| 159 | |
| 160 | static struct w100_tg_info corgi_lcdtg_info = { |
| 161 | .change = w100_lcdtg_init, |
| 162 | .suspend = w100_lcdtg_suspend, |
| 163 | .resume = w100_lcdtg_init, |
| 164 | }; |
| 165 | |
| 166 | static struct w100_mem_info corgi_fb_mem = { |
| 167 | .ext_cntl = 0x00040003, |
| 168 | .sdram_mode_reg = 0x00650021, |
| 169 | .ext_timing_cntl = 0x10002a4a, |
| 170 | .io_cntl = 0x7ff87012, |
| 171 | .size = 0x1fffff, |
| 172 | }; |
| 173 | |
| 174 | static struct w100_gen_regs corgi_fb_regs = { |
| 175 | .lcd_format = 0x00000003, |
| 176 | .lcdd_cntl1 = 0x01CC0000, |
| 177 | .lcdd_cntl2 = 0x0003FFFF, |
| 178 | .genlcd_cntl1 = 0x00FFFF0D, |
| 179 | .genlcd_cntl2 = 0x003F3003, |
| 180 | .genlcd_cntl3 = 0x000102aa, |
| 181 | }; |
| 182 | |
| 183 | static struct w100_gpio_regs corgi_fb_gpio = { |
| 184 | .init_data1 = 0x000000bf, |
| 185 | .init_data2 = 0x00000000, |
| 186 | .gpio_dir1 = 0x00000000, |
| 187 | .gpio_oe1 = 0x03c0feff, |
| 188 | .gpio_dir2 = 0x00000000, |
| 189 | .gpio_oe2 = 0x00000000, |
| 190 | }; |
| 191 | |
| 192 | static struct w100_mode corgi_fb_modes[] = { |
| 193 | { |
| 194 | .xres = 480, |
| 195 | .yres = 640, |
| 196 | .left_margin = 0x56, |
| 197 | .right_margin = 0x55, |
| 198 | .upper_margin = 0x03, |
| 199 | .lower_margin = 0x00, |
| 200 | .crtc_ss = 0x82360056, |
| 201 | .crtc_ls = 0xA0280000, |
| 202 | .crtc_gs = 0x80280028, |
| 203 | .crtc_vpos_gs = 0x02830002, |
| 204 | .crtc_rev = 0x00400008, |
| 205 | .crtc_dclk = 0xA0000000, |
| 206 | .crtc_gclk = 0x8015010F, |
| 207 | .crtc_goe = 0x80100110, |
| 208 | .crtc_ps1_active = 0x41060010, |
| 209 | .pll_freq = 75, |
| 210 | .fast_pll_freq = 100, |
| 211 | .sysclk_src = CLK_SRC_PLL, |
| 212 | .sysclk_divider = 0, |
| 213 | .pixclk_src = CLK_SRC_PLL, |
| 214 | .pixclk_divider = 2, |
| 215 | .pixclk_divider_rotated = 6, |
| 216 | },{ |
| 217 | .xres = 240, |
| 218 | .yres = 320, |
| 219 | .left_margin = 0x27, |
| 220 | .right_margin = 0x2e, |
| 221 | .upper_margin = 0x01, |
| 222 | .lower_margin = 0x00, |
| 223 | .crtc_ss = 0x81170027, |
| 224 | .crtc_ls = 0xA0140000, |
| 225 | .crtc_gs = 0xC0140014, |
| 226 | .crtc_vpos_gs = 0x00010141, |
| 227 | .crtc_rev = 0x00400008, |
| 228 | .crtc_dclk = 0xA0000000, |
| 229 | .crtc_gclk = 0x8015010F, |
| 230 | .crtc_goe = 0x80100110, |
| 231 | .crtc_ps1_active = 0x41060010, |
| 232 | .pll_freq = 0, |
| 233 | .fast_pll_freq = 0, |
| 234 | .sysclk_src = CLK_SRC_XTAL, |
| 235 | .sysclk_divider = 0, |
| 236 | .pixclk_src = CLK_SRC_XTAL, |
| 237 | .pixclk_divider = 1, |
| 238 | .pixclk_divider_rotated = 1, |
| 239 | }, |
| 240 | |
| 241 | }; |
| 242 | |
| 243 | static struct w100fb_mach_info corgi_fb_info = { |
| 244 | .tg = &corgi_lcdtg_info, |
| 245 | .init_mode = INIT_MODE_ROTATED, |
| 246 | .mem = &corgi_fb_mem, |
| 247 | .regs = &corgi_fb_regs, |
| 248 | .modelist = &corgi_fb_modes[0], |
| 249 | .num_modes = 2, |
| 250 | .gpio = &corgi_fb_gpio, |
| 251 | .xtal_freq = 12500000, |
| 252 | .xtal_dbl = 0, |
| 253 | }; |
| 254 | |
| 255 | static struct resource corgi_fb_resources[] = { |
| 256 | [0] = { |
| 257 | .start = 0x08000000, |
| 258 | .end = 0x08ffffff, |
| 259 | .flags = IORESOURCE_MEM, |
| 260 | }, |
| 261 | }; |
| 262 | |
| 263 | static struct platform_device corgifb_device = { |
| 264 | .name = "w100fb", |
| 265 | .id = -1, |
| 266 | .num_resources = ARRAY_SIZE(corgi_fb_resources), |
| 267 | .resource = corgi_fb_resources, |
| 268 | .dev = { |
| 269 | .platform_data = &corgi_fb_info, |
| 270 | .parent = &corgissp_device.dev, |
| 271 | }, |
| 272 | |
| 273 | }; |
| 274 | |
| 275 | |
| 276 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | * Corgi Backlight Device |
| 278 | */ |
Richard Purdie | c3f8f65 | 2007-09-03 00:27:00 +0100 | [diff] [blame] | 279 | static void corgi_bl_kick_battery(void) |
| 280 | { |
| 281 | void (*kick_batt)(void); |
| 282 | |
| 283 | kick_batt = symbol_get(sharpsl_battery_kick); |
| 284 | if (kick_batt) { |
| 285 | kick_batt(); |
| 286 | symbol_put(sharpsl_battery_kick); |
| 287 | } |
| 288 | } |
| 289 | |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 290 | static void corgi_bl_set_intensity(int intensity) |
| 291 | { |
| 292 | if (intensity > 0x10) |
| 293 | intensity += 0x10; |
| 294 | |
| 295 | /* Bits 0-4 are accessed via the SSP interface */ |
| 296 | corgi_ssp_blduty_set(intensity & 0x1f); |
| 297 | |
| 298 | /* Bit 5 is via SCOOP */ |
| 299 | if (intensity & 0x0020) |
| 300 | set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT); |
| 301 | else |
| 302 | reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT); |
| 303 | } |
| 304 | |
Richard Purdie | c3f8f65 | 2007-09-03 00:27:00 +0100 | [diff] [blame] | 305 | static struct generic_bl_info corgi_bl_machinfo = { |
| 306 | .name = "corgi-bl", |
Richard Purdie | 1351e6e | 2005-09-13 01:25:33 -0700 | [diff] [blame] | 307 | .max_intensity = 0x2f, |
Richard Purdie | 2c0f5fb | 2006-03-31 02:31:51 -0800 | [diff] [blame] | 308 | .default_intensity = 0x1f, |
| 309 | .limit_mask = 0x0b, |
Richard Purdie | 1351e6e | 2005-09-13 01:25:33 -0700 | [diff] [blame] | 310 | .set_bl_intensity = corgi_bl_set_intensity, |
Richard Purdie | c3f8f65 | 2007-09-03 00:27:00 +0100 | [diff] [blame] | 311 | .kick_battery = corgi_bl_kick_battery, |
Richard Purdie | 1351e6e | 2005-09-13 01:25:33 -0700 | [diff] [blame] | 312 | }; |
| 313 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | static struct platform_device corgibl_device = { |
Richard Purdie | c3f8f65 | 2007-09-03 00:27:00 +0100 | [diff] [blame] | 315 | .name = "generic-bl", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | .dev = { |
| 317 | .parent = &corgifb_device.dev, |
Richard Purdie | 1351e6e | 2005-09-13 01:25:33 -0700 | [diff] [blame] | 318 | .platform_data = &corgi_bl_machinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | }, |
| 320 | .id = -1, |
| 321 | }; |
| 322 | |
| 323 | |
| 324 | /* |
Richard Purdie | f7ceff3 | 2005-09-06 15:19:07 -0700 | [diff] [blame] | 325 | * Corgi Keyboard Device |
| 326 | */ |
| 327 | static struct platform_device corgikbd_device = { |
| 328 | .name = "corgi-keyboard", |
| 329 | .id = -1, |
| 330 | }; |
| 331 | |
| 332 | |
| 333 | /* |
Richard Purdie | 3179108 | 2006-03-31 02:31:09 -0800 | [diff] [blame] | 334 | * Corgi LEDs |
| 335 | */ |
| 336 | static struct platform_device corgiled_device = { |
| 337 | .name = "corgi-led", |
| 338 | .id = -1, |
| 339 | }; |
| 340 | |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 341 | |
Richard Purdie | 3179108 | 2006-03-31 02:31:09 -0800 | [diff] [blame] | 342 | /* |
Richard Purdie | f7ceff3 | 2005-09-06 15:19:07 -0700 | [diff] [blame] | 343 | * Corgi Touch Screen Device |
| 344 | */ |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 345 | static unsigned long (*get_hsync_invperiod)(struct device *dev); |
| 346 | |
| 347 | static void inline sharpsl_wait_sync(int gpio) |
| 348 | { |
| 349 | while((GPLR(gpio) & GPIO_bit(gpio)) == 0); |
| 350 | while((GPLR(gpio) & GPIO_bit(gpio)) != 0); |
| 351 | } |
| 352 | |
| 353 | static unsigned long corgi_get_hsync_invperiod(void) |
| 354 | { |
| 355 | if (!get_hsync_invperiod) |
| 356 | get_hsync_invperiod = symbol_get(w100fb_get_hsynclen); |
| 357 | if (!get_hsync_invperiod) |
| 358 | return 0; |
| 359 | |
| 360 | return get_hsync_invperiod(&corgifb_device.dev); |
| 361 | } |
| 362 | |
| 363 | static void corgi_put_hsync(void) |
| 364 | { |
| 365 | if (get_hsync_invperiod) |
| 366 | symbol_put(w100fb_get_hsynclen); |
| 367 | get_hsync_invperiod = NULL; |
| 368 | } |
| 369 | |
| 370 | static void corgi_wait_hsync(void) |
| 371 | { |
| 372 | sharpsl_wait_sync(CORGI_GPIO_HSYNC); |
| 373 | } |
| 374 | |
Richard Purdie | 513b6e1 | 2005-09-13 01:25:33 -0700 | [diff] [blame] | 375 | static struct resource corgits_resources[] = { |
| 376 | [0] = { |
| 377 | .start = CORGI_IRQ_GPIO_TP_INT, |
| 378 | .end = CORGI_IRQ_GPIO_TP_INT, |
| 379 | .flags = IORESOURCE_IRQ, |
| 380 | }, |
| 381 | }; |
| 382 | |
| 383 | static struct corgits_machinfo corgi_ts_machinfo = { |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 384 | .get_hsync_invperiod = corgi_get_hsync_invperiod, |
| 385 | .put_hsync = corgi_put_hsync, |
| 386 | .wait_hsync = corgi_wait_hsync, |
Richard Purdie | 513b6e1 | 2005-09-13 01:25:33 -0700 | [diff] [blame] | 387 | }; |
| 388 | |
Richard Purdie | f7ceff3 | 2005-09-06 15:19:07 -0700 | [diff] [blame] | 389 | static struct platform_device corgits_device = { |
| 390 | .name = "corgi-ts", |
| 391 | .dev = { |
| 392 | .parent = &corgissp_device.dev, |
Richard Purdie | 513b6e1 | 2005-09-13 01:25:33 -0700 | [diff] [blame] | 393 | .platform_data = &corgi_ts_machinfo, |
Richard Purdie | f7ceff3 | 2005-09-06 15:19:07 -0700 | [diff] [blame] | 394 | }, |
| 395 | .id = -1, |
Richard Purdie | 513b6e1 | 2005-09-13 01:25:33 -0700 | [diff] [blame] | 396 | .num_resources = ARRAY_SIZE(corgits_resources), |
| 397 | .resource = corgits_resources, |
Richard Purdie | f7ceff3 | 2005-09-06 15:19:07 -0700 | [diff] [blame] | 398 | }; |
| 399 | |
| 400 | |
| 401 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | * MMC/SD Device |
| 403 | * |
Richard Purdie | aa6c2e7 | 2005-09-09 18:54:03 +0100 | [diff] [blame] | 404 | * The card detect interrupt isn't debounced so we delay it by 250ms |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | * to give the card a chance to fully insert/eject. |
| 406 | */ |
Richard Purdie | aa6c2e7 | 2005-09-09 18:54:03 +0100 | [diff] [blame] | 407 | static struct pxamci_platform_data corgi_mci_platform_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | |
David Howells | 40220c1 | 2006-10-09 12:19:47 +0100 | [diff] [blame] | 409 | static int corgi_mci_init(struct device *dev, irq_handler_t corgi_detect_int, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | { |
| 411 | int err; |
| 412 | |
| 413 | /* setup GPIO for PXA25x MMC controller */ |
| 414 | pxa_gpio_mode(GPIO6_MMCCLK_MD); |
| 415 | pxa_gpio_mode(GPIO8_MMCCS0_MD); |
| 416 | pxa_gpio_mode(CORGI_GPIO_nSD_DETECT | GPIO_IN); |
| 417 | pxa_gpio_mode(CORGI_GPIO_SD_PWR | GPIO_OUT); |
| 418 | |
Richard Purdie | aa6c2e7 | 2005-09-09 18:54:03 +0100 | [diff] [blame] | 419 | corgi_mci_platform_data.detect_delay = msecs_to_jiffies(250); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | |
Russell King | 9ded96f | 2006-01-08 01:02:07 -0800 | [diff] [blame] | 421 | err = request_irq(CORGI_IRQ_GPIO_nSD_DETECT, corgi_detect_int, |
Thomas Gleixner | 52e405e | 2006-07-03 02:20:05 +0200 | [diff] [blame] | 422 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
Russell King | 9ded96f | 2006-01-08 01:02:07 -0800 | [diff] [blame] | 423 | "MMC card detect", data); |
Russell King | 2687bd3 | 2008-01-23 14:05:58 +0000 | [diff] [blame] | 424 | if (err) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | printk(KERN_ERR "corgi_mci_init: MMC/SD: can't request MMC card detect IRQ\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | |
Russell King | 2687bd3 | 2008-01-23 14:05:58 +0000 | [diff] [blame] | 427 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | static void corgi_mci_setpower(struct device *dev, unsigned int vdd) |
| 431 | { |
| 432 | struct pxamci_platform_data* p_d = dev->platform_data; |
| 433 | |
Richard Purdie | fdce05b | 2005-09-15 14:53:21 +0100 | [diff] [blame] | 434 | if (( 1 << vdd) & p_d->ocr_mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | GPSR1 = GPIO_bit(CORGI_GPIO_SD_PWR); |
Richard Purdie | fdce05b | 2005-09-15 14:53:21 +0100 | [diff] [blame] | 436 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | GPCR1 = GPIO_bit(CORGI_GPIO_SD_PWR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | } |
| 439 | |
Richard Purdie | 3870ee8 | 2005-09-06 15:19:07 -0700 | [diff] [blame] | 440 | static int corgi_mci_get_ro(struct device *dev) |
| 441 | { |
| 442 | return GPLR(CORGI_GPIO_nSD_WP) & GPIO_bit(CORGI_GPIO_nSD_WP); |
| 443 | } |
| 444 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | static void corgi_mci_exit(struct device *dev, void *data) |
| 446 | { |
| 447 | free_irq(CORGI_IRQ_GPIO_nSD_DETECT, data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | static struct pxamci_platform_data corgi_mci_platform_data = { |
| 451 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
| 452 | .init = corgi_mci_init, |
Richard Purdie | 3870ee8 | 2005-09-06 15:19:07 -0700 | [diff] [blame] | 453 | .get_ro = corgi_mci_get_ro, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | .setpower = corgi_mci_setpower, |
| 455 | .exit = corgi_mci_exit, |
| 456 | }; |
| 457 | |
| 458 | |
Richard Purdie | ca1140b | 2005-10-30 14:38:53 +0000 | [diff] [blame] | 459 | /* |
| 460 | * Irda |
| 461 | */ |
| 462 | static void corgi_irda_transceiver_mode(struct device *dev, int mode) |
| 463 | { |
| 464 | if (mode & IR_OFF) |
| 465 | GPSR(CORGI_GPIO_IR_ON) = GPIO_bit(CORGI_GPIO_IR_ON); |
| 466 | else |
| 467 | GPCR(CORGI_GPIO_IR_ON) = GPIO_bit(CORGI_GPIO_IR_ON); |
Dmitry Baryshkov | 0fc3ff3 | 2008-07-02 13:54:46 +0100 | [diff] [blame] | 468 | pxa2xx_transceiver_mode(dev, mode); |
Richard Purdie | ca1140b | 2005-10-30 14:38:53 +0000 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | static struct pxaficp_platform_data corgi_ficp_platform_data = { |
| 472 | .transceiver_cap = IR_SIRMODE | IR_OFF, |
| 473 | .transceiver_mode = corgi_irda_transceiver_mode, |
| 474 | }; |
| 475 | |
Richard Purdie | f7ceff3 | 2005-09-06 15:19:07 -0700 | [diff] [blame] | 476 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | /* |
| 478 | * USB Device Controller |
| 479 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | static struct pxa2xx_udc_mach_info udc_info __initdata = { |
| 481 | /* no connect GPIO; corgi can't tell connection status */ |
David Brownell | b2bbb20 | 2006-06-29 12:25:39 -0700 | [diff] [blame] | 482 | .gpio_pullup = CORGI_GPIO_USB_PULLUP, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | }; |
| 484 | |
| 485 | |
| 486 | static struct platform_device *devices[] __initdata = { |
| 487 | &corgiscoop_device, |
| 488 | &corgissp_device, |
| 489 | &corgifb_device, |
Richard Purdie | f7ceff3 | 2005-09-06 15:19:07 -0700 | [diff] [blame] | 490 | &corgikbd_device, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | &corgibl_device, |
Richard Purdie | f7ceff3 | 2005-09-06 15:19:07 -0700 | [diff] [blame] | 492 | &corgits_device, |
Richard Purdie | 3179108 | 2006-03-31 02:31:09 -0800 | [diff] [blame] | 493 | &corgiled_device, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | }; |
| 495 | |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 496 | static void corgi_poweroff(void) |
| 497 | { |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 498 | if (!machine_is_corgi()) |
| 499 | /* Green LED off tells the bootloader to halt */ |
| 500 | reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN); |
| 501 | arm_machine_restart('h'); |
| 502 | } |
| 503 | |
| 504 | static void corgi_restart(char mode) |
| 505 | { |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 506 | if (!machine_is_corgi()) |
| 507 | /* Green LED on tells the bootloader to reboot */ |
| 508 | set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN); |
| 509 | arm_machine_restart('h'); |
| 510 | } |
| 511 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | static void __init corgi_init(void) |
| 513 | { |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 514 | pm_power_off = corgi_poweroff; |
| 515 | arm_pm_restart = corgi_restart; |
| 516 | |
Richard Purdie | fdce05b | 2005-09-15 14:53:21 +0100 | [diff] [blame] | 517 | /* setup sleep mode values */ |
| 518 | PWER = 0x00000002; |
| 519 | PFER = 0x00000000; |
| 520 | PRER = 0x00000002; |
| 521 | PGSR0 = 0x0158C000; |
| 522 | PGSR1 = 0x00FF0080; |
| 523 | PGSR2 = 0x0001C004; |
| 524 | /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */ |
| 525 | PCFR |= PCFR_OPDE; |
| 526 | |
Richard Purdie | 50a5de4 | 2005-09-13 01:25:30 -0700 | [diff] [blame] | 527 | corgi_ssp_set_machinfo(&corgi_ssp_machinfo); |
| 528 | |
Richard Purdie | ca1140b | 2005-10-30 14:38:53 +0000 | [diff] [blame] | 529 | pxa_gpio_mode(CORGI_GPIO_IR_ON | GPIO_OUT); |
Richard Purdie | 513b6e1 | 2005-09-13 01:25:33 -0700 | [diff] [blame] | 530 | pxa_gpio_mode(CORGI_GPIO_HSYNC | GPIO_IN); |
Richard Purdie | ca1140b | 2005-10-30 14:38:53 +0000 | [diff] [blame] | 531 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | pxa_set_udc_info(&udc_info); |
| 533 | pxa_set_mci_info(&corgi_mci_platform_data); |
Richard Purdie | ca1140b | 2005-10-30 14:38:53 +0000 | [diff] [blame] | 534 | pxa_set_ficp_info(&corgi_ficp_platform_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 536 | platform_scoop_config = &corgi_pcmcia_config; |
Richard Purdie | 0ce7625 | 2005-09-05 20:49:54 +0100 | [diff] [blame] | 537 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 539 | } |
| 540 | |
| 541 | static void __init fixup_corgi(struct machine_desc *desc, |
| 542 | struct tag *tags, char **cmdline, struct meminfo *mi) |
| 543 | { |
| 544 | sharpsl_save_param(); |
| 545 | mi->nr_banks=1; |
| 546 | mi->bank[0].start = 0xa0000000; |
| 547 | mi->bank[0].node = 0; |
| 548 | if (machine_is_corgi()) |
| 549 | mi->bank[0].size = (32*1024*1024); |
| 550 | else |
| 551 | mi->bank[0].size = (64*1024*1024); |
| 552 | } |
| 553 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | #ifdef CONFIG_MACH_CORGI |
| 555 | MACHINE_START(CORGI, "SHARP Corgi") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 556 | .phys_io = 0x40000000, |
Russell King | 68070bd | 2005-07-04 10:44:34 +0100 | [diff] [blame] | 557 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 558 | .fixup = fixup_corgi, |
Richard Purdie | fdce05b | 2005-09-15 14:53:21 +0100 | [diff] [blame] | 559 | .map_io = pxa_map_io, |
Eric Miao | cd49104 | 2007-06-22 04:14:09 +0100 | [diff] [blame] | 560 | .init_irq = pxa25x_init_irq, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 561 | .init_machine = corgi_init, |
| 562 | .timer = &pxa_timer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | MACHINE_END |
| 564 | #endif |
| 565 | |
| 566 | #ifdef CONFIG_MACH_SHEPHERD |
| 567 | MACHINE_START(SHEPHERD, "SHARP Shepherd") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 568 | .phys_io = 0x40000000, |
Russell King | 68070bd | 2005-07-04 10:44:34 +0100 | [diff] [blame] | 569 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 570 | .fixup = fixup_corgi, |
Richard Purdie | fdce05b | 2005-09-15 14:53:21 +0100 | [diff] [blame] | 571 | .map_io = pxa_map_io, |
Eric Miao | cd49104 | 2007-06-22 04:14:09 +0100 | [diff] [blame] | 572 | .init_irq = pxa25x_init_irq, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 573 | .init_machine = corgi_init, |
| 574 | .timer = &pxa_timer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | MACHINE_END |
| 576 | #endif |
| 577 | |
| 578 | #ifdef CONFIG_MACH_HUSKY |
| 579 | MACHINE_START(HUSKY, "SHARP Husky") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 580 | .phys_io = 0x40000000, |
Russell King | 68070bd | 2005-07-04 10:44:34 +0100 | [diff] [blame] | 581 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 582 | .fixup = fixup_corgi, |
Richard Purdie | fdce05b | 2005-09-15 14:53:21 +0100 | [diff] [blame] | 583 | .map_io = pxa_map_io, |
Eric Miao | cd49104 | 2007-06-22 04:14:09 +0100 | [diff] [blame] | 584 | .init_irq = pxa25x_init_irq, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 585 | .init_machine = corgi_init, |
| 586 | .timer = &pxa_timer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | MACHINE_END |
| 588 | #endif |
| 589 | |