Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-pxa/lubbock.c |
| 3 | * |
| 4 | * Support for the Intel DBPXA250 Development Platform. |
| 5 | * |
| 6 | * Author: Nicolas Pitre |
| 7 | * Created: Jun 15, 2001 |
| 8 | * Copyright: MontaVista Software Inc. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License version 2 as |
| 12 | * published by the Free Software Foundation. |
| 13 | */ |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/device.h> |
Nicolas Pitre | 22f11c4 | 2005-06-16 21:23:56 +0100 | [diff] [blame] | 18 | #include <linux/sysdev.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/major.h> |
| 20 | #include <linux/fb.h> |
| 21 | #include <linux/interrupt.h> |
| 22 | |
| 23 | #include <asm/setup.h> |
| 24 | #include <asm/memory.h> |
| 25 | #include <asm/mach-types.h> |
| 26 | #include <asm/hardware.h> |
| 27 | #include <asm/irq.h> |
| 28 | |
| 29 | #include <asm/mach/arch.h> |
| 30 | #include <asm/mach/map.h> |
| 31 | #include <asm/mach/irq.h> |
| 32 | |
| 33 | #include <asm/hardware/sa1111.h> |
| 34 | |
| 35 | #include <asm/arch/pxa-regs.h> |
| 36 | #include <asm/arch/lubbock.h> |
| 37 | #include <asm/arch/udc.h> |
| 38 | #include <asm/arch/pxafb.h> |
| 39 | #include <asm/arch/mmc.h> |
| 40 | |
| 41 | #include "generic.h" |
| 42 | |
| 43 | |
| 44 | #define LUB_MISC_WR __LUB_REG(LUBBOCK_FPGA_PHYS + 0x080) |
| 45 | |
| 46 | void lubbock_set_misc_wr(unsigned int mask, unsigned int set) |
| 47 | { |
| 48 | unsigned long flags; |
| 49 | |
| 50 | local_irq_save(flags); |
| 51 | LUB_MISC_WR = (LUB_MISC_WR & ~mask) | (set & mask); |
| 52 | local_irq_restore(flags); |
| 53 | } |
| 54 | EXPORT_SYMBOL(lubbock_set_misc_wr); |
| 55 | |
| 56 | static unsigned long lubbock_irq_enabled; |
| 57 | |
| 58 | static void lubbock_mask_irq(unsigned int irq) |
| 59 | { |
| 60 | int lubbock_irq = (irq - LUBBOCK_IRQ(0)); |
| 61 | LUB_IRQ_MASK_EN = (lubbock_irq_enabled &= ~(1 << lubbock_irq)); |
| 62 | } |
| 63 | |
| 64 | static void lubbock_unmask_irq(unsigned int irq) |
| 65 | { |
| 66 | int lubbock_irq = (irq - LUBBOCK_IRQ(0)); |
| 67 | /* the irq can be acknowledged only if deasserted, so it's done here */ |
| 68 | LUB_IRQ_SET_CLR &= ~(1 << lubbock_irq); |
| 69 | LUB_IRQ_MASK_EN = (lubbock_irq_enabled |= (1 << lubbock_irq)); |
| 70 | } |
| 71 | |
| 72 | static struct irqchip lubbock_irq_chip = { |
| 73 | .ack = lubbock_mask_irq, |
| 74 | .mask = lubbock_mask_irq, |
| 75 | .unmask = lubbock_unmask_irq, |
| 76 | }; |
| 77 | |
| 78 | static void lubbock_irq_handler(unsigned int irq, struct irqdesc *desc, |
| 79 | struct pt_regs *regs) |
| 80 | { |
| 81 | unsigned long pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled; |
| 82 | do { |
| 83 | GEDR(0) = GPIO_bit(0); /* clear our parent irq */ |
| 84 | if (likely(pending)) { |
| 85 | irq = LUBBOCK_IRQ(0) + __ffs(pending); |
| 86 | desc = irq_desc + irq; |
| 87 | desc->handle(irq, desc, regs); |
| 88 | } |
| 89 | pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled; |
| 90 | } while (pending); |
| 91 | } |
| 92 | |
| 93 | static void __init lubbock_init_irq(void) |
| 94 | { |
| 95 | int irq; |
| 96 | |
| 97 | pxa_init_irq(); |
| 98 | |
| 99 | /* setup extra lubbock irqs */ |
| 100 | for (irq = LUBBOCK_IRQ(0); irq <= LUBBOCK_LAST_IRQ; irq++) { |
| 101 | set_irq_chip(irq, &lubbock_irq_chip); |
| 102 | set_irq_handler(irq, do_level_IRQ); |
| 103 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); |
| 104 | } |
| 105 | |
| 106 | set_irq_chained_handler(IRQ_GPIO(0), lubbock_irq_handler); |
| 107 | set_irq_type(IRQ_GPIO(0), IRQT_FALLING); |
| 108 | } |
| 109 | |
Nicolas Pitre | 22f11c4 | 2005-06-16 21:23:56 +0100 | [diff] [blame] | 110 | #ifdef CONFIG_PM |
| 111 | |
| 112 | static int lubbock_irq_resume(struct sys_device *dev) |
| 113 | { |
| 114 | LUB_IRQ_MASK_EN = lubbock_irq_enabled; |
| 115 | return 0; |
| 116 | } |
| 117 | |
| 118 | static struct sysdev_class lubbock_irq_sysclass = { |
| 119 | set_kset_name("cpld_irq"), |
| 120 | .resume = lubbock_irq_resume, |
| 121 | }; |
| 122 | |
| 123 | static struct sys_device lubbock_irq_device = { |
| 124 | .cls = &lubbock_irq_sysclass, |
| 125 | }; |
| 126 | |
| 127 | static int __init lubbock_irq_device_init(void) |
| 128 | { |
| 129 | int ret = sysdev_class_register(&lubbock_irq_sysclass); |
| 130 | if (ret == 0) |
| 131 | ret = sysdev_register(&lubbock_irq_device); |
| 132 | return ret; |
| 133 | } |
| 134 | |
| 135 | device_initcall(lubbock_irq_device_init); |
| 136 | |
| 137 | #endif |
| 138 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | static int lubbock_udc_is_connected(void) |
| 140 | { |
| 141 | return (LUB_MISC_RD & (1 << 9)) == 0; |
| 142 | } |
| 143 | |
| 144 | static struct pxa2xx_udc_mach_info udc_info __initdata = { |
| 145 | .udc_is_connected = lubbock_udc_is_connected, |
| 146 | // no D+ pullup; lubbock can't connect/disconnect in software |
| 147 | }; |
| 148 | |
| 149 | static struct resource sa1111_resources[] = { |
| 150 | [0] = { |
| 151 | .start = 0x10000000, |
| 152 | .end = 0x10001fff, |
| 153 | .flags = IORESOURCE_MEM, |
| 154 | }, |
| 155 | [1] = { |
| 156 | .start = LUBBOCK_SA1111_IRQ, |
| 157 | .end = LUBBOCK_SA1111_IRQ, |
| 158 | .flags = IORESOURCE_IRQ, |
| 159 | }, |
| 160 | }; |
| 161 | |
| 162 | static struct platform_device sa1111_device = { |
| 163 | .name = "sa1111", |
| 164 | .id = -1, |
| 165 | .num_resources = ARRAY_SIZE(sa1111_resources), |
| 166 | .resource = sa1111_resources, |
| 167 | }; |
| 168 | |
| 169 | static struct resource smc91x_resources[] = { |
| 170 | [0] = { |
| 171 | .name = "smc91x-regs", |
| 172 | .start = 0x0c000000, |
| 173 | .end = 0x0c0fffff, |
| 174 | .flags = IORESOURCE_MEM, |
| 175 | }, |
| 176 | [1] = { |
| 177 | .start = LUBBOCK_ETH_IRQ, |
| 178 | .end = LUBBOCK_ETH_IRQ, |
| 179 | .flags = IORESOURCE_IRQ, |
| 180 | }, |
| 181 | [2] = { |
| 182 | .name = "smc91x-attrib", |
| 183 | .start = 0x0e000000, |
| 184 | .end = 0x0e0fffff, |
| 185 | .flags = IORESOURCE_MEM, |
| 186 | }, |
| 187 | }; |
| 188 | |
| 189 | static struct platform_device smc91x_device = { |
| 190 | .name = "smc91x", |
| 191 | .id = -1, |
| 192 | .num_resources = ARRAY_SIZE(smc91x_resources), |
| 193 | .resource = smc91x_resources, |
| 194 | }; |
| 195 | |
| 196 | static struct platform_device *devices[] __initdata = { |
| 197 | &sa1111_device, |
| 198 | &smc91x_device, |
| 199 | }; |
| 200 | |
| 201 | static struct pxafb_mach_info sharp_lm8v31 __initdata = { |
| 202 | .pixclock = 270000, |
| 203 | .xres = 640, |
| 204 | .yres = 480, |
| 205 | .bpp = 16, |
| 206 | .hsync_len = 1, |
| 207 | .left_margin = 3, |
| 208 | .right_margin = 3, |
| 209 | .vsync_len = 1, |
| 210 | .upper_margin = 0, |
| 211 | .lower_margin = 0, |
| 212 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
| 213 | .cmap_greyscale = 0, |
| 214 | .cmap_inverse = 0, |
| 215 | .cmap_static = 0, |
| 216 | .lccr0 = LCCR0_SDS, |
| 217 | .lccr3 = LCCR3_PCP | LCCR3_Acb(255), |
| 218 | }; |
| 219 | |
| 220 | static int lubbock_mci_init(struct device *dev, irqreturn_t (*lubbock_detect_int)(int, void *, struct pt_regs *), void *data) |
| 221 | { |
| 222 | /* setup GPIO for PXA25x MMC controller */ |
| 223 | pxa_gpio_mode(GPIO6_MMCCLK_MD); |
| 224 | pxa_gpio_mode(GPIO8_MMCCS0_MD); |
| 225 | |
| 226 | return 0; |
| 227 | } |
| 228 | |
| 229 | static struct pxamci_platform_data lubbock_mci_platform_data = { |
| 230 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
| 231 | .init = lubbock_mci_init, |
| 232 | }; |
| 233 | |
| 234 | static void __init lubbock_init(void) |
| 235 | { |
| 236 | pxa_set_udc_info(&udc_info); |
| 237 | set_pxa_fb_info(&sharp_lm8v31); |
| 238 | pxa_set_mci_info(&lubbock_mci_platform_data); |
| 239 | (void) platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 240 | } |
| 241 | |
| 242 | static struct map_desc lubbock_io_desc[] __initdata = { |
| 243 | { LUBBOCK_FPGA_VIRT, LUBBOCK_FPGA_PHYS, 0x00100000, MT_DEVICE }, /* CPLD */ |
| 244 | }; |
| 245 | |
| 246 | static void __init lubbock_map_io(void) |
| 247 | { |
| 248 | pxa_map_io(); |
| 249 | iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc)); |
| 250 | |
| 251 | /* This enables the BTUART */ |
| 252 | pxa_gpio_mode(GPIO42_BTRXD_MD); |
| 253 | pxa_gpio_mode(GPIO43_BTTXD_MD); |
| 254 | pxa_gpio_mode(GPIO44_BTCTS_MD); |
| 255 | pxa_gpio_mode(GPIO45_BTRTS_MD); |
| 256 | |
| 257 | /* This is for the SMC chip select */ |
| 258 | pxa_gpio_mode(GPIO79_nCS_3_MD); |
| 259 | |
| 260 | /* setup sleep mode values */ |
| 261 | PWER = 0x00000002; |
| 262 | PFER = 0x00000000; |
| 263 | PRER = 0x00000002; |
| 264 | PGSR0 = 0x00008000; |
| 265 | PGSR1 = 0x003F0202; |
| 266 | PGSR2 = 0x0001C000; |
| 267 | PCFR |= PCFR_OPDE; |
| 268 | } |
| 269 | |
| 270 | MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 271 | /* Maintainer: MontaVista Software Inc. */ |
| 272 | .phys_ram = 0xa0000000, |
| 273 | .phys_io = 0x40000000, |
Russell King | 68070bd | 2005-07-04 10:44:34 +0100 | [diff] [blame^] | 274 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 275 | .map_io = lubbock_map_io, |
| 276 | .init_irq = lubbock_init_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | .timer = &pxa_timer, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 278 | .init_machine = lubbock_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | MACHINE_END |