This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / arch / arm / mach-ixp2000 / ixdp2800.c
1 /*
2  * arch/arm/mach-ixp2000/ixdp2800.c
3  *
4  * IXDP2800 platform support
5  *
6  * Original Author: Jeffrey Daly <jeffrey.daly@intel.com>
7  * Maintainer: Deepak Saxena <dsaxena@plexity.net>
8  *
9  * Copyright (C) 2002 Intel Corp.
10  * Copyright (C) 2003-2004 MontaVista Software, Inc.
11  *
12  *  This program is free software; you can redistribute  it and/or modify it
13  *  under  the terms of  the GNU General  Public License as published by the
14  *  Free Software Foundation;  either version 2 of the  License, or (at your
15  *  option) any later version.
16  */
17 #include <linux/config.h>
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/mm.h>
21 #include <linux/sched.h>
22 #include <linux/interrupt.h>
23 #include <linux/device.h>
24 #include <linux/bitops.h>
25 #include <linux/pci.h>
26 #include <linux/interrupt.h>
27 #include <linux/mm.h>
28 #include <linux/init.h>
29 #include <linux/ioport.h>
30 #include <linux/slab.h>
31 #include <linux/delay.h>
32
33 #include <asm/io.h>
34 #include <asm/irq.h>
35 #include <asm/pgtable.h>
36 #include <asm/page.h>
37 #include <asm/system.h>
38 #include <asm/hardware.h>
39 #include <asm/mach-types.h>
40
41 #include <asm/mach/pci.h>
42 #include <asm/mach/map.h>
43 #include <asm/mach/irq.h>
44 #include <asm/mach/time.h>
45 #include <asm/mach/flash.h>
46 #include <asm/mach/arch.h>
47
48
49 void ixdp2400_init_irq(void)
50 {
51         ixdp2x00_init_irq(IXDP2800_CPLD_INT_STAT, IXDP2800_CPLD_INT_MASK, IXDP2400_NR_IRQS);
52 }
53
54 /*************************************************************************
55  * IXDP2800 timer tick
56  *************************************************************************/
57
58 static void __init ixdp2800_init_time(void)
59 {
60         ixp2000_init_time(50000000);
61 }
62
63 /*************************************************************************
64  * IXDP2800 PCI
65  *************************************************************************/
66 void __init ixdp2800_pci_preinit(void)
67 {
68         printk("ixdp2x00_pci_preinit called\n");
69
70         *IXP2000_PCI_ADDR_EXT =  0x0000e000;
71
72         *IXP2000_PCI_DRAM_BASE_ADDR_MASK = (0x40000000 - 1) & ~0xfffff;
73         *IXP2000_PCI_SRAM_BASE_ADDR_MASK = (0x2000000 - 1) & ~0x3ffff;
74
75         ixp2000_pci_preinit();
76 }
77
78 int ixdp2800_pci_setup(int nr, struct pci_sys_data *sys)
79 {
80         sys->mem_offset = 0x00000000;
81
82         ixp2000_pci_setup(nr, sys);
83
84         return 1;
85 }
86
87 static int __init ixdp2800_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
88 {
89         if (ixdp2x00_master_npu()) {
90
91                 /*
92                  * Root bus devices.  Slave NPU is only one with interrupt.
93                  * Everything else, we just return -1 which is invalid.
94                  */
95                 if(!dev->bus->self) {
96                         if(dev->devfn == IXDP2X00_SLAVE_NPU_DEVFN )
97                                 return IRQ_IXDP2800_INGRESS_NPU;
98
99                         return -1;
100                 }
101
102                 /*
103                  * Bridge behind the PMC slot.
104                  */
105                 if(dev->bus->self->devfn == IXDP2X00_PMC_DEVFN &&
106                         dev->bus->parent->self->devfn == IXDP2X00_P2P_DEVFN &&
107                         !dev->bus->parent->self->bus->parent)
108                                   return IRQ_IXDP2800_PMC;
109
110                 /*
111                  * Device behind the first bridge
112                  */
113                 if(dev->bus->self->devfn == IXDP2X00_P2P_DEVFN) {
114                         switch(PCI_SLOT(dev->devfn)) {
115                                 case IXDP2X00_PMC_DEVFN:
116                                         return IRQ_IXDP2800_PMC;        
117                         
118                                 case IXDP2800_MASTER_ENET_DEVFN:
119                                         return IRQ_IXDP2800_EGRESS_ENET;
120
121                                 case IXDP2800_SWITCH_FABRIC_DEVFN:
122                                         return IRQ_IXDP2800_FABRIC;
123                         }
124                 }
125
126                 return -1;
127         } else return IRQ_IXP2000_PCIB; /* Slave NIC interrupt */
128 }
129
130 static void ixdp2800_pci_postinit(void)
131 {
132         struct pci_dev *dev;
133
134         if (ixdp2x00_master_npu()) {
135                 dev = pci_find_slot(1, IXDP2800_SLAVE_ENET_DEVFN);
136                 pci_remove_bus_device(dev);
137         } else {
138                 dev = pci_find_slot(1, IXDP2800_MASTER_ENET_DEVFN);
139                 pci_remove_bus_device(dev);
140
141                 ixdp2x00_slave_pci_postinit();
142         }
143 }
144
145 struct hw_pci ixdp2800_pci __initdata = {
146         .nr_controllers = 1,
147         .setup          = ixdp2800_pci_setup,
148         .preinit        = ixdp2800_pci_preinit,
149         .postinit       = ixdp2800_pci_postinit,
150         .scan           = ixp2000_pci_scan_bus,
151         .map_irq        = ixdp2800_pci_map_irq,
152 };
153
154 int __init ixdp2800_pci_init(void)
155 {
156         if (machine_is_ixdp2800())
157                 pci_common_init(&ixdp2800_pci);
158
159         return 0;
160 }
161
162 subsys_initcall(ixdp2800_pci_init);
163
164 void ixdp2800_init_irq(void)
165 {
166         ixdp2x00_init_irq(IXDP2800_CPLD_INT_STAT, IXDP2800_CPLD_INT_MASK, IXDP2800_NR_IRQS);
167 }
168
169 MACHINE_START(IXDP2800, "Intel IXDP2800 Development Platform")
170         MAINTAINER("MontaVista Software, Inc.")
171         BOOT_MEM(0x00000000, IXP2000_UART_PHYS_BASE, IXP2000_UART_VIRT_BASE)
172         BOOT_PARAMS(0x00000100)
173         MAPIO(ixdp2x00_map_io)
174         INITIRQ(ixdp2800_init_irq)
175         INITTIME(ixdp2800_init_time)
176         INIT_MACHINE(ixdp2x00_init_machine)
177 MACHINE_END
178