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