ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / 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/kernel.h>
15 #include <linux/init.h>
16 #include <linux/device.h>
17 #include <linux/major.h>
18 #include <linux/fs.h>
19 #include <linux/interrupt.h>
20
21 #include <asm/setup.h>
22 #include <asm/memory.h>
23 #include <asm/mach-types.h>
24 #include <asm/hardware.h>
25 #include <asm/irq.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/udc.h>
32 #include <asm/hardware/sa1111.h>
33
34 #include "generic.h"
35
36
37 static unsigned long lubbock_irq_enabled;
38
39 static void lubbock_mask_irq(unsigned int irq)
40 {
41         int lubbock_irq = (irq - LUBBOCK_IRQ(0));
42         LUB_IRQ_MASK_EN = (lubbock_irq_enabled &= ~(1 << lubbock_irq));
43 }
44
45 static void lubbock_unmask_irq(unsigned int irq)
46 {
47         int lubbock_irq = (irq - LUBBOCK_IRQ(0));
48         /* the irq can be acknowledged only if deasserted, so it's done here */
49         LUB_IRQ_SET_CLR &= ~(1 << lubbock_irq);
50         LUB_IRQ_MASK_EN = (lubbock_irq_enabled |= (1 << lubbock_irq));
51 }
52
53 static struct irqchip lubbock_irq_chip = {
54         .ack            = lubbock_mask_irq,
55         .mask           = lubbock_mask_irq,
56         .unmask         = lubbock_unmask_irq,
57 };
58
59 static void lubbock_irq_handler(unsigned int irq, struct irqdesc *desc,
60                                 struct pt_regs *regs)
61 {
62         unsigned long pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
63         do {
64                 GEDR(0) = GPIO_bit(0);  /* clear our parent irq */
65                 if (likely(pending)) {
66                         irq = LUBBOCK_IRQ(0) + __ffs(pending);
67                         desc = irq_desc + irq;
68                         desc->handle(irq, desc, regs);
69                 }
70                 pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
71         } while (pending);
72 }
73
74 static void __init lubbock_init_irq(void)
75 {
76         int irq;
77
78         pxa_init_irq();
79
80         /* setup extra lubbock irqs */
81         for (irq = LUBBOCK_IRQ(0); irq <= LUBBOCK_LAST_IRQ; irq++) {
82                 set_irq_chip(irq, &lubbock_irq_chip);
83                 set_irq_handler(irq, do_level_IRQ);
84                 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
85         }
86
87         set_irq_chained_handler(IRQ_GPIO(0), lubbock_irq_handler);
88         set_irq_type(IRQ_GPIO(0), IRQT_FALLING);
89 }
90
91 static int lubbock_udc_is_connected(void)
92 {
93         return (LUB_MISC_RD & (1 << 9)) == 0;
94 }
95
96 static struct pxa2xx_udc_mach_info udc_info __initdata = {
97         .udc_is_connected       = lubbock_udc_is_connected,
98         // no D+ pullup; lubbock can't connect/disconnect in software
99 };
100
101 static struct resource sa1111_resources[] = {
102         [0] = {
103                 .start  = 0x10000000,
104                 .end    = 0x10001fff,
105                 .flags  = IORESOURCE_MEM,
106         },
107         [1] = {
108                 .start  = LUBBOCK_SA1111_IRQ,
109                 .end    = LUBBOCK_SA1111_IRQ,
110                 .flags  = IORESOURCE_IRQ,
111         },
112 };
113
114 static struct platform_device sa1111_device = {
115         .name           = "sa1111",
116         .id             = 0,
117         .num_resources  = ARRAY_SIZE(sa1111_resources),
118         .resource       = sa1111_resources,
119 };
120
121 static struct resource smc91x_resources[] = {
122         [0] = {
123                 .start  = 0x0c000000,
124                 .end    = 0x0c0fffff,
125                 .flags  = IORESOURCE_MEM,
126         },
127         [1] = {
128                 .start  = LUBBOCK_ETH_IRQ,
129                 .end    = LUBBOCK_ETH_IRQ,
130                 .flags  = IORESOURCE_IRQ,
131         },
132         [2] = {
133                 .start  = 0x0e000000,
134                 .end    = 0x0e0fffff,
135                 .flags  = IORESOURCE_MEM,
136         },
137 };
138
139 static struct platform_device smc91x_device = {
140         .name           = "smc91x",
141         .id             = 0,
142         .num_resources  = ARRAY_SIZE(smc91x_resources),
143         .resource       = smc91x_resources,
144 };
145
146 static struct platform_device *devices[] __initdata = {
147         &sa1111_device,
148         &smc91x_device,
149 };
150
151 static void __init lubbock_init(void)
152 {
153         pxa_set_udc_info(&udc_info);
154         (void) platform_add_devices(devices, ARRAY_SIZE(devices));
155 }
156
157 static struct map_desc lubbock_io_desc[] __initdata = {
158   { LUBBOCK_FPGA_VIRT, LUBBOCK_FPGA_PHYS, 0x00100000, MT_DEVICE }, /* CPLD */
159 };
160
161 static void __init lubbock_map_io(void)
162 {
163         pxa_map_io();
164         iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc));
165
166         /* This enables the BTUART */
167         pxa_gpio_mode(GPIO42_BTRXD_MD);
168         pxa_gpio_mode(GPIO43_BTTXD_MD);
169         pxa_gpio_mode(GPIO44_BTCTS_MD);
170         pxa_gpio_mode(GPIO45_BTRTS_MD);
171
172         /* This is for the SMC chip select */
173         pxa_gpio_mode(GPIO79_nCS_3_MD);
174
175         /* setup sleep mode values */
176         PWER  = 0x00000002;
177         PFER  = 0x00000000;
178         PRER  = 0x00000002;
179         PGSR0 = 0x00008000;
180         PGSR1 = 0x003F0202;
181         PGSR2 = 0x0001C000;
182         PCFR |= PCFR_OPDE;
183 }
184
185 MACHINE_START(LUBBOCK, "Intel DBPXA250 Development Platform (aka Lubbock)")
186         MAINTAINER("MontaVista Software Inc.")
187         BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000))
188         MAPIO(lubbock_map_io)
189         INITIRQ(lubbock_init_irq)
190         INIT_MACHINE(lubbock_init)
191 MACHINE_END