2 * arch/arm/mach-ixp2000/ixdp2800.c
4 * IXDP2800 platform support
6 * Original Author: Jeffrey Daly <jeffrey.daly@intel.com>
7 * Maintainer: Deepak Saxena <dsaxena@plexity.net>
9 * Copyright (C) 2002 Intel Corp.
10 * Copyright (C) 2003-2004 MontaVista Software, Inc.
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.
17 #include <linux/kernel.h>
18 #include <linux/init.h>
20 #include <linux/sched.h>
21 #include <linux/interrupt.h>
22 #include <linux/device.h>
23 #include <linux/bitops.h>
24 #include <linux/pci.h>
25 #include <linux/ioport.h>
26 #include <linux/delay.h>
30 #include <asm/pgtable.h>
32 #include <asm/system.h>
33 #include <mach/hardware.h>
34 #include <asm/mach-types.h>
36 #include <asm/mach/pci.h>
37 #include <asm/mach/map.h>
38 #include <asm/mach/irq.h>
39 #include <asm/mach/time.h>
40 #include <asm/mach/flash.h>
41 #include <asm/mach/arch.h>
43 /*************************************************************************
45 *************************************************************************/
47 static void __init
ixdp2800_timer_init(void)
49 ixp2000_init_time(50000000);
52 static struct sys_timer ixdp2800_timer
= {
53 .init
= ixdp2800_timer_init
,
54 .offset
= ixp2000_gettimeoffset
,
57 /*************************************************************************
59 *************************************************************************/
60 static void __init
ixdp2800_slave_disable_pci_master(void)
62 *IXP2000_PCI_CMDSTAT
&= ~(PCI_COMMAND_MASTER
| PCI_COMMAND_MEMORY
);
65 static void __init
ixdp2800_master_wait_for_slave(void)
69 printk(KERN_INFO
"IXDP2800: waiting for slave NPU to configure "
72 addr
= ixp2000_pci_config_addr(0, IXDP2X00_SLAVE_NPU_DEVFN
,
77 } while (*addr
!= 0xfe000008);
79 addr
= ixp2000_pci_config_addr(0, IXDP2X00_SLAVE_NPU_DEVFN
,
84 } while (*addr
!= 0xc0000008);
87 * Configure the slave's SDRAM BAR by hand.
92 static void __init
ixdp2800_slave_wait_for_master_enable(void)
94 printk(KERN_INFO
"IXDP2800: waiting for master NPU to enable us\n");
96 while ((*IXP2000_PCI_CMDSTAT
& PCI_COMMAND_MASTER
) == 0)
100 void __init
ixdp2800_pci_preinit(void)
102 printk("ixdp2x00_pci_preinit called\n");
104 *IXP2000_PCI_ADDR_EXT
= 0x0001e000;
106 if (!ixdp2x00_master_npu())
107 ixdp2800_slave_disable_pci_master();
109 *IXP2000_PCI_SRAM_BASE_ADDR_MASK
= (0x2000000 - 1) & ~0x3ffff;
110 *IXP2000_PCI_DRAM_BASE_ADDR_MASK
= (0x40000000 - 1) & ~0xfffff;
112 ixp2000_pci_preinit();
114 if (ixdp2x00_master_npu()) {
116 * Wait until the slave set its SRAM/SDRAM BAR sizes
117 * correctly before we proceed to scan and enumerate
120 ixdp2800_master_wait_for_slave();
123 * We configure the SDRAM BARs by hand because they
124 * are 1G and fall outside of the regular allocated
127 *IXP2000_PCI_SDRAM_BAR
= 0x00000008;
130 * Wait for the master to complete scanning the bus
131 * and assigning resources before we proceed to scan
132 * the bus ourselves. Set pci=firmware to honor the
133 * master's resource assignment.
135 ixdp2800_slave_wait_for_master_enable();
136 pcibios_setup("firmware");
141 * We assign the SDRAM BARs for the two IXP2800 CPUs by hand, outside
142 * of the regular PCI window, because there's only 512M of outbound PCI
143 * memory window on each IXP, while we need 1G for each of the BARs.
145 static void __devinit
ixp2800_pci_fixup(struct pci_dev
*dev
)
147 if (machine_is_ixdp2800()) {
148 dev
->resource
[2].start
= 0;
149 dev
->resource
[2].end
= 0;
150 dev
->resource
[2].flags
= 0;
153 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL
, PCI_DEVICE_ID_INTEL_IXP2800
, ixp2800_pci_fixup
);
155 static int __init
ixdp2800_pci_setup(int nr
, struct pci_sys_data
*sys
)
157 sys
->mem_offset
= 0x00000000;
159 ixp2000_pci_setup(nr
, sys
);
164 static int __init
ixdp2800_pci_map_irq(struct pci_dev
*dev
, u8 slot
, u8 pin
)
166 if (ixdp2x00_master_npu()) {
169 * Root bus devices. Slave NPU is only one with interrupt.
170 * Everything else, we just return -1 which is invalid.
172 if(!dev
->bus
->self
) {
173 if(dev
->devfn
== IXDP2X00_SLAVE_NPU_DEVFN
)
174 return IRQ_IXDP2800_INGRESS_NPU
;
180 * Bridge behind the PMC slot.
182 if(dev
->bus
->self
->devfn
== IXDP2X00_PMC_DEVFN
&&
183 dev
->bus
->parent
->self
->devfn
== IXDP2X00_P2P_DEVFN
&&
184 !dev
->bus
->parent
->self
->bus
->parent
)
185 return IRQ_IXDP2800_PMC
;
188 * Device behind the first bridge
190 if(dev
->bus
->self
->devfn
== IXDP2X00_P2P_DEVFN
) {
192 case IXDP2X00_PMC_DEVFN
:
193 return IRQ_IXDP2800_PMC
;
195 case IXDP2800_MASTER_ENET_DEVFN
:
196 return IRQ_IXDP2800_EGRESS_ENET
;
198 case IXDP2800_SWITCH_FABRIC_DEVFN
:
199 return IRQ_IXDP2800_FABRIC
;
204 } else return IRQ_IXP2000_PCIB
; /* Slave NIC interrupt */
207 static void __init
ixdp2800_master_enable_slave(void)
211 printk(KERN_INFO
"IXDP2800: enabling slave NPU\n");
213 addr
= (volatile u32
*)ixp2000_pci_config_addr(0,
214 IXDP2X00_SLAVE_NPU_DEVFN
,
217 *addr
|= PCI_COMMAND_MASTER
;
220 static void __init
ixdp2800_master_wait_for_slave_bus_scan(void)
224 printk(KERN_INFO
"IXDP2800: waiting for slave to finish bus scan\n");
226 addr
= (volatile u32
*)ixp2000_pci_config_addr(0,
227 IXDP2X00_SLAVE_NPU_DEVFN
,
229 while ((*addr
& PCI_COMMAND_MEMORY
) == 0)
233 static void __init
ixdp2800_slave_signal_bus_scan_completion(void)
235 printk(KERN_INFO
"IXDP2800: bus scan done, signaling master\n");
236 *IXP2000_PCI_CMDSTAT
|= PCI_COMMAND_MEMORY
;
239 static void __init
ixdp2800_pci_postinit(void)
241 if (!ixdp2x00_master_npu()) {
242 ixdp2x00_slave_pci_postinit();
243 ixdp2800_slave_signal_bus_scan_completion();
247 struct __initdata hw_pci ixdp2800_pci __initdata
= {
249 .setup
= ixdp2800_pci_setup
,
250 .preinit
= ixdp2800_pci_preinit
,
251 .postinit
= ixdp2800_pci_postinit
,
252 .scan
= ixp2000_pci_scan_bus
,
253 .map_irq
= ixdp2800_pci_map_irq
,
256 int __init
ixdp2800_pci_init(void)
258 if (machine_is_ixdp2800()) {
261 pci_common_init(&ixdp2800_pci
);
262 if (ixdp2x00_master_npu()) {
263 dev
= pci_get_bus_and_slot(1, IXDP2800_SLAVE_ENET_DEVFN
);
264 pci_remove_bus_device(dev
);
267 ixdp2800_master_enable_slave();
268 ixdp2800_master_wait_for_slave_bus_scan();
270 dev
= pci_get_bus_and_slot(1, IXDP2800_MASTER_ENET_DEVFN
);
271 pci_remove_bus_device(dev
);
279 subsys_initcall(ixdp2800_pci_init
);
281 void __init
ixdp2800_init_irq(void)
283 ixdp2x00_init_irq(IXDP2800_CPLD_INT_STAT
, IXDP2800_CPLD_INT_MASK
, IXDP2800_NR_IRQS
);
286 MACHINE_START(IXDP2800
, "Intel IXDP2800 Development Platform")
287 /* Maintainer: MontaVista Software, Inc. */
288 .boot_params
= 0x00000100,
289 .map_io
= ixdp2x00_map_io
,
290 .init_irq
= ixdp2800_init_irq
,
291 .timer
= &ixdp2800_timer
,
292 .init_machine
= ixdp2x00_init_machine
,