This commit was manufactured by cvs2svn to create branch 'fedora'.
[linux-2.6.git] / arch / arm / mach-pxa / mainstone.c
1 /*
2  *  linux/arch/arm/mach-pxa/mainstone.c
3  *
4  *  Support for the Intel HCDDBBVA0 Development Platform.
5  *  (go figure how they came up with such name...)
6  *
7  *  Author:     Nicolas Pitre
8  *  Created:    Nov 05, 2002
9  *  Copyright:  MontaVista Software Inc.
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License version 2 as
13  *  published by the Free Software Foundation.
14  */
15
16 #include <linux/init.h>
17 #include <linux/device.h>
18 #include <linux/interrupt.h>
19 #include <linux/sched.h>
20 #include <linux/bitops.h>
21
22 #include <asm/types.h>
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 "generic.h"
34
35
36 static unsigned long mainstone_irq_enabled;
37
38 static void mainstone_mask_irq(unsigned int irq)
39 {
40         int mainstone_irq = (irq - MAINSTONE_IRQ(0));
41         MST_INTMSKENA = (mainstone_irq_enabled &= ~(1 << mainstone_irq));
42 }
43
44 static void mainstone_unmask_irq(unsigned int irq)
45 {
46         int mainstone_irq = (irq - MAINSTONE_IRQ(0));
47         /* the irq can be acknowledged only if deasserted, so it's done here */
48         MST_INTSETCLR &= ~(1 << mainstone_irq);
49         MST_INTMSKENA = (mainstone_irq_enabled |= (1 << mainstone_irq));
50 }
51
52 static struct irqchip mainstone_irq_chip = {
53         .ack            = mainstone_mask_irq,
54         .mask           = mainstone_mask_irq,
55         .unmask         = mainstone_unmask_irq,
56 };
57
58
59 static void mainstone_irq_handler(unsigned int irq, struct irqdesc *desc,
60                                   struct pt_regs *regs)
61 {
62         unsigned long pending = MST_INTSETCLR & mainstone_irq_enabled;
63         do {
64                 GEDR(0) = GPIO_bit(0);  /* clear useless edge notification */
65                 if (likely(pending)) {
66                         irq = MAINSTONE_IRQ(0) + __ffs(pending);
67                         desc = irq_desc + irq;
68                         desc->handle(irq, desc, regs);
69                 }
70                 pending = MST_INTSETCLR & mainstone_irq_enabled;
71         } while (pending);
72 }
73
74 static void __init mainstone_init_irq(void)
75 {
76         int irq;
77
78         pxa_init_irq();
79
80         /* setup extra Mainstone irqs */
81         for(irq = MAINSTONE_IRQ(0); irq <= MAINSTONE_IRQ(15); irq++) {
82                 set_irq_chip(irq, &mainstone_irq_chip);
83                 set_irq_handler(irq, do_level_IRQ);
84                 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
85         }
86         set_irq_flags(MAINSTONE_IRQ(8), 0);
87         set_irq_flags(MAINSTONE_IRQ(12), 0);
88
89         MST_INTMSKENA = 0;
90         MST_INTSETCLR = 0;
91
92         set_irq_chained_handler(IRQ_GPIO(0), mainstone_irq_handler);
93         set_irq_type(IRQ_GPIO(0), IRQT_FALLING);
94 }
95
96
97 static struct resource smc91x_resources[] = {
98         [0] = {
99                 .start  = (MST_ETH_PHYS + 0x300),
100                 .end    = (MST_ETH_PHYS + 0xfffff),
101                 .flags  = IORESOURCE_MEM,
102         },
103         [1] = {
104                 .start  = MAINSTONE_IRQ(3),
105                 .end    = MAINSTONE_IRQ(3),
106                 .flags  = IORESOURCE_IRQ,
107         }
108 };
109
110 static struct platform_device smc91x_device = {
111         .name           = "smc91x",
112         .id             = 0,
113         .num_resources  = ARRAY_SIZE(smc91x_resources),
114         .resource       = smc91x_resources,
115 };
116
117 static void __init mainstone_init(void)
118 {
119         platform_add_device(&smc91x_device);
120 }
121
122
123 static struct map_desc mainstone_io_desc[] __initdata = {
124   { MST_FPGA_VIRT, MST_FPGA_PHYS, 0x00100000, MT_DEVICE }, /* CPLD */
125 };
126
127 static void __init mainstone_map_io(void)
128 {
129         pxa_map_io();
130         iotable_init(mainstone_io_desc, ARRAY_SIZE(mainstone_io_desc));
131 }
132
133 MACHINE_START(MAINSTONE, "Intel HCDDBBVA0 Development Platform (aka Mainstone)")
134         MAINTAINER("MontaVista Software Inc.")
135         BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000))
136         MAPIO(mainstone_map_io)
137         INITIRQ(mainstone_init_irq)
138         INIT_MACHINE(mainstone_init)
139 MACHINE_END