patch-2_6_7-vs1_9_1_12
[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 <asm/arch/mainstone.h>
34
35 #include "generic.h"
36
37
38 static unsigned long mainstone_irq_enabled;
39
40 static void mainstone_mask_irq(unsigned int irq)
41 {
42         int mainstone_irq = (irq - MAINSTONE_IRQ(0));
43         MST_INTMSKENA = (mainstone_irq_enabled &= ~(1 << mainstone_irq));
44 }
45
46 static void mainstone_unmask_irq(unsigned int irq)
47 {
48         int mainstone_irq = (irq - MAINSTONE_IRQ(0));
49         /* the irq can be acknowledged only if deasserted, so it's done here */
50         MST_INTSETCLR &= ~(1 << mainstone_irq);
51         MST_INTMSKENA = (mainstone_irq_enabled |= (1 << mainstone_irq));
52 }
53
54 static struct irqchip mainstone_irq_chip = {
55         .ack            = mainstone_mask_irq,
56         .mask           = mainstone_mask_irq,
57         .unmask         = mainstone_unmask_irq,
58 };
59
60
61 static void mainstone_irq_handler(unsigned int irq, struct irqdesc *desc,
62                                   struct pt_regs *regs)
63 {
64         unsigned long pending = MST_INTSETCLR & mainstone_irq_enabled;
65         do {
66                 GEDR(0) = GPIO_bit(0);  /* clear useless edge notification */
67                 if (likely(pending)) {
68                         irq = MAINSTONE_IRQ(0) + __ffs(pending);
69                         desc = irq_desc + irq;
70                         desc->handle(irq, desc, regs);
71                 }
72                 pending = MST_INTSETCLR & mainstone_irq_enabled;
73         } while (pending);
74 }
75
76 static void __init mainstone_init_irq(void)
77 {
78         int irq;
79
80         pxa_init_irq();
81
82         /* setup extra Mainstone irqs */
83         for(irq = MAINSTONE_IRQ(0); irq <= MAINSTONE_IRQ(15); irq++) {
84                 set_irq_chip(irq, &mainstone_irq_chip);
85                 set_irq_handler(irq, do_level_IRQ);
86                 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
87         }
88         set_irq_flags(MAINSTONE_IRQ(8), 0);
89         set_irq_flags(MAINSTONE_IRQ(12), 0);
90
91         MST_INTMSKENA = 0;
92         MST_INTSETCLR = 0;
93
94         set_irq_chained_handler(IRQ_GPIO(0), mainstone_irq_handler);
95         set_irq_type(IRQ_GPIO(0), IRQT_FALLING);
96 }
97
98
99 static struct resource smc91x_resources[] = {
100         [0] = {
101                 .start  = (MST_ETH_PHYS + 0x300),
102                 .end    = (MST_ETH_PHYS + 0xfffff),
103                 .flags  = IORESOURCE_MEM,
104         },
105         [1] = {
106                 .start  = MAINSTONE_IRQ(3),
107                 .end    = MAINSTONE_IRQ(3),
108                 .flags  = IORESOURCE_IRQ,
109         }
110 };
111
112 static struct platform_device smc91x_device = {
113         .name           = "smc91x",
114         .id             = 0,
115         .num_resources  = ARRAY_SIZE(smc91x_resources),
116         .resource       = smc91x_resources,
117 };
118
119 static void __init mainstone_init(void)
120 {
121         platform_add_device(&smc91x_device);
122 }
123
124
125 static struct map_desc mainstone_io_desc[] __initdata = {
126   { MST_FPGA_VIRT, MST_FPGA_PHYS, 0x00100000, MT_DEVICE }, /* CPLD */
127 };
128
129 static void __init mainstone_map_io(void)
130 {
131         pxa_map_io();
132         iotable_init(mainstone_io_desc, ARRAY_SIZE(mainstone_io_desc));
133 }
134
135 MACHINE_START(MAINSTONE, "Intel HCDDBBVA0 Development Platform (aka Mainstone)")
136         MAINTAINER("MontaVista Software Inc.")
137         BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000))
138         MAPIO(mainstone_map_io)
139         INITIRQ(mainstone_init_irq)
140         INIT_MACHINE(mainstone_init)
141 MACHINE_END