Linux-2.6.12-rc2
[safe/jmp/linux-2.6] / arch / arm / mach-pxa / lubbock.c
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>
18 #include <linux/major.h>
19 #include <linux/fb.h>
20 #include <linux/interrupt.h>
21
22 #include <asm/setup.h>
23 #include <asm/memory.h>
24 #include <asm/mach-types.h>
25 #include <asm/hardware.h>
26 #include <asm/irq.h>
27
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/irq.h>
31
32 #include <asm/hardware/sa1111.h>
33
34 #include <asm/arch/pxa-regs.h>
35 #include <asm/arch/lubbock.h>
36 #include <asm/arch/udc.h>
37 #include <asm/arch/pxafb.h>
38 #include <asm/arch/mmc.h>
39
40 #include "generic.h"
41
42
43 #define LUB_MISC_WR             __LUB_REG(LUBBOCK_FPGA_PHYS + 0x080)
44
45 void lubbock_set_misc_wr(unsigned int mask, unsigned int set)
46 {
47         unsigned long flags;
48
49         local_irq_save(flags);
50         LUB_MISC_WR = (LUB_MISC_WR & ~mask) | (set & mask);
51         local_irq_restore(flags);
52 }
53 EXPORT_SYMBOL(lubbock_set_misc_wr);
54
55 static unsigned long lubbock_irq_enabled;
56
57 static void lubbock_mask_irq(unsigned int irq)
58 {
59         int lubbock_irq = (irq - LUBBOCK_IRQ(0));
60         LUB_IRQ_MASK_EN = (lubbock_irq_enabled &= ~(1 << lubbock_irq));
61 }
62
63 static void lubbock_unmask_irq(unsigned int irq)
64 {
65         int lubbock_irq = (irq - LUBBOCK_IRQ(0));
66         /* the irq can be acknowledged only if deasserted, so it's done here */
67         LUB_IRQ_SET_CLR &= ~(1 << lubbock_irq);
68         LUB_IRQ_MASK_EN = (lubbock_irq_enabled |= (1 << lubbock_irq));
69 }
70
71 static struct irqchip lubbock_irq_chip = {
72         .ack            = lubbock_mask_irq,
73         .mask           = lubbock_mask_irq,
74         .unmask         = lubbock_unmask_irq,
75 };
76
77 static void lubbock_irq_handler(unsigned int irq, struct irqdesc *desc,
78                                 struct pt_regs *regs)
79 {
80         unsigned long pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
81         do {
82                 GEDR(0) = GPIO_bit(0);  /* clear our parent irq */
83                 if (likely(pending)) {
84                         irq = LUBBOCK_IRQ(0) + __ffs(pending);
85                         desc = irq_desc + irq;
86                         desc->handle(irq, desc, regs);
87                 }
88                 pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
89         } while (pending);
90 }
91
92 static void __init lubbock_init_irq(void)
93 {
94         int irq;
95
96         pxa_init_irq();
97
98         /* setup extra lubbock irqs */
99         for (irq = LUBBOCK_IRQ(0); irq <= LUBBOCK_LAST_IRQ; irq++) {
100                 set_irq_chip(irq, &lubbock_irq_chip);
101                 set_irq_handler(irq, do_level_IRQ);
102                 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
103         }
104
105         set_irq_chained_handler(IRQ_GPIO(0), lubbock_irq_handler);
106         set_irq_type(IRQ_GPIO(0), IRQT_FALLING);
107 }
108
109 static int lubbock_udc_is_connected(void)
110 {
111         return (LUB_MISC_RD & (1 << 9)) == 0;
112 }
113
114 static struct pxa2xx_udc_mach_info udc_info __initdata = {
115         .udc_is_connected       = lubbock_udc_is_connected,
116         // no D+ pullup; lubbock can't connect/disconnect in software
117 };
118
119 static struct resource sa1111_resources[] = {
120         [0] = {
121                 .start  = 0x10000000,
122                 .end    = 0x10001fff,
123                 .flags  = IORESOURCE_MEM,
124         },
125         [1] = {
126                 .start  = LUBBOCK_SA1111_IRQ,
127                 .end    = LUBBOCK_SA1111_IRQ,
128                 .flags  = IORESOURCE_IRQ,
129         },
130 };
131
132 static struct platform_device sa1111_device = {
133         .name           = "sa1111",
134         .id             = -1,
135         .num_resources  = ARRAY_SIZE(sa1111_resources),
136         .resource       = sa1111_resources,
137 };
138
139 static struct resource smc91x_resources[] = {
140         [0] = {
141                 .name   = "smc91x-regs",
142                 .start  = 0x0c000000,
143                 .end    = 0x0c0fffff,
144                 .flags  = IORESOURCE_MEM,
145         },
146         [1] = {
147                 .start  = LUBBOCK_ETH_IRQ,
148                 .end    = LUBBOCK_ETH_IRQ,
149                 .flags  = IORESOURCE_IRQ,
150         },
151         [2] = {
152                 .name   = "smc91x-attrib",
153                 .start  = 0x0e000000,
154                 .end    = 0x0e0fffff,
155                 .flags  = IORESOURCE_MEM,
156         },
157 };
158
159 static struct platform_device smc91x_device = {
160         .name           = "smc91x",
161         .id             = -1,
162         .num_resources  = ARRAY_SIZE(smc91x_resources),
163         .resource       = smc91x_resources,
164 };
165
166 static struct platform_device *devices[] __initdata = {
167         &sa1111_device,
168         &smc91x_device,
169 };
170
171 static struct pxafb_mach_info sharp_lm8v31 __initdata = {
172         .pixclock       = 270000,
173         .xres           = 640,
174         .yres           = 480,
175         .bpp            = 16,
176         .hsync_len      = 1,
177         .left_margin    = 3,
178         .right_margin   = 3,
179         .vsync_len      = 1,
180         .upper_margin   = 0,
181         .lower_margin   = 0,
182         .sync           = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
183         .cmap_greyscale = 0,
184         .cmap_inverse   = 0,
185         .cmap_static    = 0,
186         .lccr0          = LCCR0_SDS,
187         .lccr3          = LCCR3_PCP | LCCR3_Acb(255),
188 };
189
190 static int lubbock_mci_init(struct device *dev, irqreturn_t (*lubbock_detect_int)(int, void *, struct pt_regs *), void *data)
191 {
192         /* setup GPIO for PXA25x MMC controller */
193         pxa_gpio_mode(GPIO6_MMCCLK_MD);
194         pxa_gpio_mode(GPIO8_MMCCS0_MD);
195
196         return 0;
197 }
198
199 static struct pxamci_platform_data lubbock_mci_platform_data = {
200         .ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34,
201         .init           = lubbock_mci_init,
202 };
203
204 static void __init lubbock_init(void)
205 {
206         pxa_set_udc_info(&udc_info);
207         set_pxa_fb_info(&sharp_lm8v31);
208         pxa_set_mci_info(&lubbock_mci_platform_data);
209         (void) platform_add_devices(devices, ARRAY_SIZE(devices));
210 }
211
212 static struct map_desc lubbock_io_desc[] __initdata = {
213   { LUBBOCK_FPGA_VIRT, LUBBOCK_FPGA_PHYS, 0x00100000, MT_DEVICE }, /* CPLD */
214 };
215
216 static void __init lubbock_map_io(void)
217 {
218         pxa_map_io();
219         iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc));
220
221         /* This enables the BTUART */
222         pxa_gpio_mode(GPIO42_BTRXD_MD);
223         pxa_gpio_mode(GPIO43_BTTXD_MD);
224         pxa_gpio_mode(GPIO44_BTCTS_MD);
225         pxa_gpio_mode(GPIO45_BTRTS_MD);
226
227         /* This is for the SMC chip select */
228         pxa_gpio_mode(GPIO79_nCS_3_MD);
229
230         /* setup sleep mode values */
231         PWER  = 0x00000002;
232         PFER  = 0x00000000;
233         PRER  = 0x00000002;
234         PGSR0 = 0x00008000;
235         PGSR1 = 0x003F0202;
236         PGSR2 = 0x0001C000;
237         PCFR |= PCFR_OPDE;
238 }
239
240 MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)")
241         MAINTAINER("MontaVista Software Inc.")
242         BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000))
243         MAPIO(lubbock_map_io)
244         INITIRQ(lubbock_init_irq)
245         .timer          = &pxa_timer,
246         INIT_MACHINE(lubbock_init)
247 MACHINE_END