This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / arch / arm / mach-ixp2000 / ixdp2400.c
1 /*
2  * arch/arm/mach-ixp2000/ixdp2400.c
3  *
4  * IXDP2400 platform support
5  *
6  * Original Author: Naeem Afzal <naeem.m.afzal@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  * IXDP2400 timer tick
50  *************************************************************************/
51 static void __init ixdp2400_init_time(void)
52 {
53         int numerator, denominator;
54         int denom_array[] = {2, 4, 8, 16, 1, 2, 4, 8};
55
56         numerator = (*(IXDP2400_CPLD_SYS_CLK_M) & 0xFF) *2;
57         denominator = denom_array[(*(IXDP2400_CPLD_SYS_CLK_N) & 0x7)];
58
59         ixp2000_init_time(((3125000 * numerator) / (denominator)) / 2);
60 }
61
62 /*************************************************************************
63  * IXDP2400 PCI
64  *************************************************************************/
65 void __init ixdp2400_pci_preinit(void)
66 {
67         ixp2000_reg_write(IXP2000_PCI_ADDR_EXT, 0x00100000);
68         ixp2000_pci_preinit();
69 }
70
71 int ixdp2400_pci_setup(int nr, struct pci_sys_data *sys)
72 {
73         sys->mem_offset = 0xe0000000;
74
75         ixp2000_pci_setup(nr, sys);
76
77         return 1;
78 }
79
80 static int __init ixdp2400_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
81 {
82         if (ixdp2x00_master_npu()) {
83
84                 /*
85                  * Root bus devices.  Slave NPU is only one with interrupt.
86                  * Everything else, we just return -1 b/c nothing else
87                  * on the root bus has interrupts.
88                  */
89                 if(!dev->bus->self) {
90                         if(dev->devfn == IXDP2X00_SLAVE_NPU_DEVFN )
91                                 return IRQ_IXDP2400_INGRESS_NPU;
92
93                         return -1;
94                 }
95
96                 /*
97                  * Bridge behind the PMC slot.
98                  * NOTE: Only INTA from the PMC slot is routed. VERY BAD.
99                  */
100                 if(dev->bus->self->devfn == IXDP2X00_PMC_DEVFN &&
101                         dev->bus->parent->self->devfn == IXDP2X00_P2P_DEVFN &&
102                         !dev->bus->parent->self->bus->parent)
103                                   return IRQ_IXDP2400_PMC;
104
105                 /*
106                  * Device behind the first bridge
107                  */
108                 if(dev->bus->self->devfn == IXDP2X00_P2P_DEVFN) {
109                         switch(dev->devfn) {
110                                 case IXDP2400_MASTER_ENET_DEVFN:        
111                                         return IRQ_IXDP2400_ENET;       
112                         
113                                 case IXDP2400_MEDIA_DEVFN:
114                                         return IRQ_IXDP2400_MEDIA_PCI;
115
116                                 case IXDP2400_SWITCH_FABRIC_DEVFN:
117                                         return IRQ_IXDP2400_SF_PCI;
118
119                                 case IXDP2X00_PMC_DEVFN:
120                                         return IRQ_IXDP2400_PMC;
121                         }
122                 }
123
124                 return -1;
125         } else return IRQ_IXP2000_PCIB; /* Slave NIC interrupt */
126 }
127
128
129 static void ixdp2400_pci_postinit(void)
130 {
131         struct pci_dev *dev;
132
133         if (ixdp2x00_master_npu()) {
134                 dev = pci_find_slot(1, IXDP2400_SLAVE_ENET_DEVFN);
135                 pci_remove_bus_device(dev);
136         } else {
137                 dev = pci_find_slot(1, IXDP2400_MASTER_ENET_DEVFN);
138                 pci_remove_bus_device(dev);
139
140                 ixdp2x00_slave_pci_postinit();
141         }
142 }
143
144 static struct hw_pci ixdp2400_pci __initdata = {
145         .nr_controllers = 1,
146         .setup          = ixdp2400_pci_setup,
147         .preinit        = ixdp2400_pci_preinit,
148         .postinit       = ixdp2400_pci_postinit,
149         .scan           = ixp2000_pci_scan_bus,
150         .map_irq        = ixdp2400_pci_map_irq,
151 };
152
153 int __init ixdp2400_pci_init(void)
154 {
155         if (machine_is_ixdp2400())
156                 pci_common_init(&ixdp2400_pci);
157
158         return 0;
159 }
160
161 subsys_initcall(ixdp2400_pci_init);
162
163 void ixdp2400_init_irq(void)
164 {
165         ixdp2x00_init_irq(IXDP2400_CPLD_INT_STAT, IXDP2400_CPLD_INT_MASK, IXDP2400_NR_IRQS);
166 }
167
168 MACHINE_START(IXDP2400, "Intel IXDP2400 Development Platform")
169         MAINTAINER("MontaVista Software, Inc.")
170         BOOT_MEM(0x00000000, IXP2000_UART_PHYS_BASE, IXP2000_UART_VIRT_BASE)
171         BOOT_PARAMS(0x00000100)
172         MAPIO(ixdp2x00_map_io)
173         INITIRQ(ixdp2400_init_irq)
174         INITTIME(ixdp2400_init_time)
175         INIT_MACHINE(ixdp2x00_init_machine)
176 MACHINE_END
177