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