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