Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-pxa/poodle.c |
| 3 | * |
| 4 | * Support for the SHARP Poodle Board. |
| 5 | * |
| 6 | * Based on: |
| 7 | * linux/arch/arm/mach-pxa/lubbock.c Author: Nicolas Pitre |
| 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 | * Change Log |
| 14 | * 12-Dec-2002 Sharp Corporation for Poodle |
| 15 | * John Lenz <lenz@cs.wisc.edu> updates to 2.6 |
| 16 | */ |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/init.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 19 | #include <linux/platform_device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <linux/fb.h> |
| 21 | |
| 22 | #include <asm/hardware.h> |
| 23 | #include <asm/mach-types.h> |
| 24 | #include <asm/irq.h> |
| 25 | #include <asm/setup.h> |
| 26 | |
| 27 | #include <asm/mach/arch.h> |
| 28 | #include <asm/mach/map.h> |
| 29 | #include <asm/mach/irq.h> |
| 30 | |
| 31 | #include <asm/arch/pxa-regs.h> |
Richard Purdie | 13b9d47 | 2005-09-15 14:53:22 +0100 | [diff] [blame] | 32 | #include <asm/arch/mmc.h> |
| 33 | #include <asm/arch/udc.h> |
Richard Purdie | 8e4b871 | 2005-10-30 14:38:52 +0000 | [diff] [blame] | 34 | #include <asm/arch/irda.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <asm/arch/poodle.h> |
| 36 | #include <asm/arch/pxafb.h> |
| 37 | |
| 38 | #include <asm/hardware/scoop.h> |
| 39 | #include <asm/hardware/locomo.h> |
| 40 | #include <asm/mach/sharpsl_param.h> |
| 41 | |
| 42 | #include "generic.h" |
| 43 | |
| 44 | static struct resource poodle_scoop_resources[] = { |
| 45 | [0] = { |
| 46 | .start = 0x10800000, |
| 47 | .end = 0x10800fff, |
| 48 | .flags = IORESOURCE_MEM, |
| 49 | }, |
| 50 | }; |
| 51 | |
| 52 | static struct scoop_config poodle_scoop_setup = { |
| 53 | .io_dir = POODLE_SCOOP_IO_DIR, |
| 54 | .io_out = POODLE_SCOOP_IO_OUT, |
| 55 | }; |
| 56 | |
| 57 | struct platform_device poodle_scoop_device = { |
| 58 | .name = "sharp-scoop", |
| 59 | .id = -1, |
| 60 | .dev = { |
| 61 | .platform_data = &poodle_scoop_setup, |
| 62 | }, |
| 63 | .num_resources = ARRAY_SIZE(poodle_scoop_resources), |
| 64 | .resource = poodle_scoop_resources, |
| 65 | }; |
| 66 | |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 67 | static void poodle_pcmcia_init(void) |
| 68 | { |
| 69 | /* Setup default state of GPIO outputs |
| 70 | before we enable them as outputs. */ |
| 71 | GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) | |
| 72 | GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) | |
| 73 | GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) | |
| 74 | GPIO_bit(GPIO53_nPCE_2); |
| 75 | |
| 76 | pxa_gpio_mode(GPIO48_nPOE_MD); |
| 77 | pxa_gpio_mode(GPIO49_nPWE_MD); |
| 78 | pxa_gpio_mode(GPIO50_nPIOR_MD); |
| 79 | pxa_gpio_mode(GPIO51_nPIOW_MD); |
| 80 | pxa_gpio_mode(GPIO55_nPREG_MD); |
| 81 | pxa_gpio_mode(GPIO56_nPWAIT_MD); |
| 82 | pxa_gpio_mode(GPIO57_nIOIS16_MD); |
| 83 | pxa_gpio_mode(GPIO52_nPCE_1_MD); |
| 84 | pxa_gpio_mode(GPIO53_nPCE_2_MD); |
| 85 | pxa_gpio_mode(GPIO54_pSKTSEL_MD); |
| 86 | } |
| 87 | |
Richard Purdie | 0ce7625 | 2005-09-05 20:49:54 +0100 | [diff] [blame] | 88 | static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = { |
| 89 | { |
| 90 | .dev = &poodle_scoop_device.dev, |
| 91 | .irq = POODLE_IRQ_GPIO_CF_IRQ, |
| 92 | .cd_irq = POODLE_IRQ_GPIO_CF_CD, |
| 93 | .cd_irq_str = "PCMCIA0 CD", |
| 94 | }, |
| 95 | }; |
| 96 | |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 97 | static struct scoop_pcmcia_config poodle_pcmcia_config = { |
| 98 | .devs = &poodle_pcmcia_scoop[0], |
| 99 | .num_devs = 1, |
| 100 | .pcmcia_init = poodle_pcmcia_init, |
| 101 | }; |
| 102 | |
| 103 | EXPORT_SYMBOL(poodle_scoop_device); |
| 104 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | |
| 106 | /* LoCoMo device */ |
| 107 | static struct resource locomo_resources[] = { |
| 108 | [0] = { |
| 109 | .start = 0x10000000, |
| 110 | .end = 0x10001fff, |
| 111 | .flags = IORESOURCE_MEM, |
| 112 | }, |
| 113 | [1] = { |
| 114 | .start = IRQ_GPIO(10), |
| 115 | .end = IRQ_GPIO(10), |
| 116 | .flags = IORESOURCE_IRQ, |
| 117 | }, |
| 118 | }; |
| 119 | |
| 120 | static struct platform_device locomo_device = { |
| 121 | .name = "locomo", |
| 122 | .id = 0, |
| 123 | .num_resources = ARRAY_SIZE(locomo_resources), |
| 124 | .resource = locomo_resources, |
| 125 | }; |
| 126 | |
Richard Purdie | 13b9d47 | 2005-09-15 14:53:22 +0100 | [diff] [blame] | 127 | |
| 128 | /* |
| 129 | * MMC/SD Device |
| 130 | * |
| 131 | * The card detect interrupt isn't debounced so we delay it by 250ms |
| 132 | * to give the card a chance to fully insert/eject. |
| 133 | */ |
| 134 | static struct pxamci_platform_data poodle_mci_platform_data; |
| 135 | |
| 136 | static int poodle_mci_init(struct device *dev, irqreturn_t (*poodle_detect_int)(int, void *, struct pt_regs *), void *data) |
| 137 | { |
| 138 | int err; |
| 139 | |
| 140 | /* setup GPIO for PXA25x MMC controller */ |
| 141 | pxa_gpio_mode(GPIO6_MMCCLK_MD); |
| 142 | pxa_gpio_mode(GPIO8_MMCCS0_MD); |
| 143 | pxa_gpio_mode(POODLE_GPIO_nSD_DETECT | GPIO_IN); |
| 144 | pxa_gpio_mode(POODLE_GPIO_SD_PWR | GPIO_OUT); |
| 145 | |
| 146 | poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250); |
| 147 | |
Russell King | 9ded96f | 2006-01-08 01:02:07 -0800 | [diff] [blame] | 148 | err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int, |
| 149 | SA_INTERRUPT | SA_TRIGGER_RISING | SA_TRIGGER_FALLING, |
| 150 | "MMC card detect", data); |
Richard Purdie | 13b9d47 | 2005-09-15 14:53:22 +0100 | [diff] [blame] | 151 | if (err) { |
| 152 | printk(KERN_ERR "poodle_mci_init: MMC/SD: can't request MMC card detect IRQ\n"); |
| 153 | return -1; |
| 154 | } |
| 155 | |
Richard Purdie | 13b9d47 | 2005-09-15 14:53:22 +0100 | [diff] [blame] | 156 | return 0; |
| 157 | } |
| 158 | |
| 159 | static void poodle_mci_setpower(struct device *dev, unsigned int vdd) |
| 160 | { |
| 161 | struct pxamci_platform_data* p_d = dev->platform_data; |
| 162 | |
| 163 | if (( 1 << vdd) & p_d->ocr_mask) |
| 164 | GPSR1 = GPIO_bit(POODLE_GPIO_SD_PWR); |
| 165 | else |
| 166 | GPCR1 = GPIO_bit(POODLE_GPIO_SD_PWR); |
| 167 | } |
| 168 | |
| 169 | static void poodle_mci_exit(struct device *dev, void *data) |
| 170 | { |
| 171 | free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data); |
| 172 | } |
| 173 | |
| 174 | static struct pxamci_platform_data poodle_mci_platform_data = { |
| 175 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
| 176 | .init = poodle_mci_init, |
| 177 | .setpower = poodle_mci_setpower, |
| 178 | .exit = poodle_mci_exit, |
| 179 | }; |
| 180 | |
| 181 | |
| 182 | /* |
Richard Purdie | 8e4b871 | 2005-10-30 14:38:52 +0000 | [diff] [blame] | 183 | * Irda |
| 184 | */ |
| 185 | static void poodle_irda_transceiver_mode(struct device *dev, int mode) |
| 186 | { |
| 187 | if (mode & IR_OFF) { |
| 188 | GPSR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON); |
| 189 | } else { |
| 190 | GPCR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON); |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | static struct pxaficp_platform_data poodle_ficp_platform_data = { |
| 195 | .transceiver_cap = IR_SIRMODE | IR_OFF, |
| 196 | .transceiver_mode = poodle_irda_transceiver_mode, |
| 197 | }; |
| 198 | |
| 199 | |
| 200 | /* |
Richard Purdie | 13b9d47 | 2005-09-15 14:53:22 +0100 | [diff] [blame] | 201 | * USB Device Controller |
| 202 | */ |
| 203 | static void poodle_udc_command(int cmd) |
| 204 | { |
| 205 | switch(cmd) { |
| 206 | case PXA2XX_UDC_CMD_CONNECT: |
| 207 | GPSR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP); |
| 208 | break; |
| 209 | case PXA2XX_UDC_CMD_DISCONNECT: |
| 210 | GPCR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP); |
| 211 | break; |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | static struct pxa2xx_udc_mach_info udc_info __initdata = { |
| 216 | /* no connect GPIO; poodle can't tell connection status */ |
| 217 | .udc_command = poodle_udc_command, |
| 218 | }; |
| 219 | |
| 220 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | /* PXAFB device */ |
| 222 | static struct pxafb_mach_info poodle_fb_info __initdata = { |
| 223 | .pixclock = 144700, |
| 224 | |
| 225 | .xres = 320, |
| 226 | .yres = 240, |
| 227 | .bpp = 16, |
| 228 | |
| 229 | .hsync_len = 7, |
| 230 | .left_margin = 11, |
| 231 | .right_margin = 30, |
| 232 | |
| 233 | .vsync_len = 2, |
| 234 | .upper_margin = 2, |
| 235 | .lower_margin = 0, |
| 236 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 237 | |
| 238 | .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color, |
| 239 | .lccr3 = 0, |
| 240 | |
| 241 | .pxafb_backlight_power = NULL, |
| 242 | .pxafb_lcd_power = NULL, |
| 243 | }; |
| 244 | |
| 245 | static struct platform_device *devices[] __initdata = { |
| 246 | &locomo_device, |
| 247 | &poodle_scoop_device, |
| 248 | }; |
| 249 | |
| 250 | static void __init poodle_init(void) |
| 251 | { |
| 252 | int ret = 0; |
| 253 | |
Richard Purdie | f29d245 | 2005-09-15 14:53:22 +0100 | [diff] [blame] | 254 | /* setup sleep mode values */ |
| 255 | PWER = 0x00000002; |
| 256 | PFER = 0x00000000; |
| 257 | PRER = 0x00000002; |
| 258 | PGSR0 = 0x00008000; |
| 259 | PGSR1 = 0x003F0202; |
| 260 | PGSR2 = 0x0001C000; |
| 261 | PCFR |= PCFR_OPDE; |
| 262 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | /* cpu initialize */ |
| 264 | /* Pgsr Register */ |
| 265 | PGSR0 = 0x0146dd80; |
| 266 | PGSR1 = 0x03bf0890; |
| 267 | PGSR2 = 0x0001c000; |
| 268 | |
| 269 | /* Alternate Register */ |
| 270 | GAFR0_L = 0x01001000; |
| 271 | GAFR0_U = 0x591a8010; |
| 272 | GAFR1_L = 0x900a8451; |
| 273 | GAFR1_U = 0xaaa5aaaa; |
| 274 | GAFR2_L = 0x8aaaaaaa; |
| 275 | GAFR2_U = 0x00000002; |
| 276 | |
| 277 | /* Direction Register */ |
| 278 | GPDR0 = 0xd3f0904c; |
| 279 | GPDR1 = 0xfcffb7d3; |
| 280 | GPDR2 = 0x0001ffff; |
| 281 | |
| 282 | /* Output Register */ |
| 283 | GPCR0 = 0x00000000; |
| 284 | GPCR1 = 0x00000000; |
| 285 | GPCR2 = 0x00000000; |
| 286 | |
| 287 | GPSR0 = 0x00400000; |
| 288 | GPSR1 = 0x00000000; |
| 289 | GPSR2 = 0x00000000; |
| 290 | |
| 291 | set_pxa_fb_info(&poodle_fb_info); |
Richard Purdie | 13b9d47 | 2005-09-15 14:53:22 +0100 | [diff] [blame] | 292 | pxa_gpio_mode(POODLE_GPIO_USB_PULLUP | GPIO_OUT); |
Richard Purdie | 8e4b871 | 2005-10-30 14:38:52 +0000 | [diff] [blame] | 293 | pxa_gpio_mode(POODLE_GPIO_IR_ON | GPIO_OUT); |
Richard Purdie | 13b9d47 | 2005-09-15 14:53:22 +0100 | [diff] [blame] | 294 | pxa_set_udc_info(&udc_info); |
| 295 | pxa_set_mci_info(&poodle_mci_platform_data); |
Richard Purdie | 8e4b871 | 2005-10-30 14:38:52 +0000 | [diff] [blame] | 296 | pxa_set_ficp_info(&poodle_ficp_platform_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 298 | platform_scoop_config = &poodle_pcmcia_config; |
Richard Purdie | 0ce7625 | 2005-09-05 20:49:54 +0100 | [diff] [blame] | 299 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | ret = platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 301 | if (ret) { |
| 302 | printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n"); |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | static void __init fixup_poodle(struct machine_desc *desc, |
| 307 | struct tag *tags, char **cmdline, struct meminfo *mi) |
| 308 | { |
| 309 | sharpsl_save_param(); |
Richard Purdie | b2e6f75 | 2006-04-02 17:11:00 +0100 | [diff] [blame^] | 310 | mi->nr_banks=1; |
| 311 | mi->bank[0].start = 0xa0000000; |
| 312 | mi->bank[0].node = 0; |
| 313 | mi->bank[0].size = (32*1024*1024); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | } |
| 315 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | MACHINE_START(POODLE, "SHARP Poodle") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 317 | .phys_io = 0x40000000, |
Russell King | 68070bd | 2005-07-04 10:44:34 +0100 | [diff] [blame] | 318 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 319 | .fixup = fixup_poodle, |
Richard Purdie | f29d245 | 2005-09-15 14:53:22 +0100 | [diff] [blame] | 320 | .map_io = pxa_map_io, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 321 | .init_irq = pxa_init_irq, |
| 322 | .timer = &pxa_timer, |
| 323 | .init_machine = poodle_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | MACHINE_END |