Path: blob/master/arch/arm/mach-ixp2000/ixdp2800.c
10817 views
/*1* arch/arm/mach-ixp2000/ixdp2800.c2*3* IXDP2800 platform support4*5* Original Author: Jeffrey Daly <[email protected]>6* Maintainer: Deepak Saxena <[email protected]>7*8* Copyright (C) 2002 Intel Corp.9* Copyright (C) 2003-2004 MontaVista Software, Inc.10*11* This program is free software; you can redistribute it and/or modify it12* under the terms of the GNU General Public License as published by the13* Free Software Foundation; either version 2 of the License, or (at your14* option) any later version.15*/16#include <linux/kernel.h>17#include <linux/init.h>18#include <linux/mm.h>19#include <linux/sched.h>20#include <linux/interrupt.h>21#include <linux/device.h>22#include <linux/bitops.h>23#include <linux/pci.h>24#include <linux/ioport.h>25#include <linux/delay.h>26#include <linux/io.h>2728#include <asm/irq.h>29#include <asm/pgtable.h>30#include <asm/page.h>31#include <asm/system.h>32#include <mach/hardware.h>33#include <asm/mach-types.h>3435#include <asm/mach/pci.h>36#include <asm/mach/map.h>37#include <asm/mach/irq.h>38#include <asm/mach/time.h>39#include <asm/mach/flash.h>40#include <asm/mach/arch.h>4142/*************************************************************************43* IXDP2800 timer tick44*************************************************************************/4546static void __init ixdp2800_timer_init(void)47{48ixp2000_init_time(50000000);49}5051static struct sys_timer ixdp2800_timer = {52.init = ixdp2800_timer_init,53.offset = ixp2000_gettimeoffset,54};5556/*************************************************************************57* IXDP2800 PCI58*************************************************************************/59static void __init ixdp2800_slave_disable_pci_master(void)60{61*IXP2000_PCI_CMDSTAT &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);62}6364static void __init ixdp2800_master_wait_for_slave(void)65{66volatile u32 *addr;6768printk(KERN_INFO "IXDP2800: waiting for slave NPU to configure "69"its BAR sizes\n");7071addr = ixp2000_pci_config_addr(0, IXDP2X00_SLAVE_NPU_DEVFN,72PCI_BASE_ADDRESS_1);73do {74*addr = 0xffffffff;75cpu_relax();76} while (*addr != 0xfe000008);7778addr = ixp2000_pci_config_addr(0, IXDP2X00_SLAVE_NPU_DEVFN,79PCI_BASE_ADDRESS_2);80do {81*addr = 0xffffffff;82cpu_relax();83} while (*addr != 0xc0000008);8485/*86* Configure the slave's SDRAM BAR by hand.87*/88*addr = 0x40000008;89}9091static void __init ixdp2800_slave_wait_for_master_enable(void)92{93printk(KERN_INFO "IXDP2800: waiting for master NPU to enable us\n");9495while ((*IXP2000_PCI_CMDSTAT & PCI_COMMAND_MASTER) == 0)96cpu_relax();97}9899void __init ixdp2800_pci_preinit(void)100{101printk("ixdp2x00_pci_preinit called\n");102103*IXP2000_PCI_ADDR_EXT = 0x0001e000;104105if (!ixdp2x00_master_npu())106ixdp2800_slave_disable_pci_master();107108*IXP2000_PCI_SRAM_BASE_ADDR_MASK = (0x2000000 - 1) & ~0x3ffff;109*IXP2000_PCI_DRAM_BASE_ADDR_MASK = (0x40000000 - 1) & ~0xfffff;110111ixp2000_pci_preinit();112113if (ixdp2x00_master_npu()) {114/*115* Wait until the slave set its SRAM/SDRAM BAR sizes116* correctly before we proceed to scan and enumerate117* the bus.118*/119ixdp2800_master_wait_for_slave();120121/*122* We configure the SDRAM BARs by hand because they123* are 1G and fall outside of the regular allocated124* PCI address space.125*/126*IXP2000_PCI_SDRAM_BAR = 0x00000008;127} else {128/*129* Wait for the master to complete scanning the bus130* and assigning resources before we proceed to scan131* the bus ourselves. Set pci=firmware to honor the132* master's resource assignment.133*/134ixdp2800_slave_wait_for_master_enable();135pcibios_setup("firmware");136}137}138139/*140* We assign the SDRAM BARs for the two IXP2800 CPUs by hand, outside141* of the regular PCI window, because there's only 512M of outbound PCI142* memory window on each IXP, while we need 1G for each of the BARs.143*/144static void __devinit ixp2800_pci_fixup(struct pci_dev *dev)145{146if (machine_is_ixdp2800()) {147dev->resource[2].start = 0;148dev->resource[2].end = 0;149dev->resource[2].flags = 0;150}151}152DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IXP2800, ixp2800_pci_fixup);153154static int __init ixdp2800_pci_setup(int nr, struct pci_sys_data *sys)155{156sys->mem_offset = 0x00000000;157158ixp2000_pci_setup(nr, sys);159160return 1;161}162163static int __init ixdp2800_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)164{165if (ixdp2x00_master_npu()) {166167/*168* Root bus devices. Slave NPU is only one with interrupt.169* Everything else, we just return -1 which is invalid.170*/171if(!dev->bus->self) {172if(dev->devfn == IXDP2X00_SLAVE_NPU_DEVFN )173return IRQ_IXDP2800_INGRESS_NPU;174175return -1;176}177178/*179* Bridge behind the PMC slot.180*/181if(dev->bus->self->devfn == IXDP2X00_PMC_DEVFN &&182dev->bus->parent->self->devfn == IXDP2X00_P2P_DEVFN &&183!dev->bus->parent->self->bus->parent)184return IRQ_IXDP2800_PMC;185186/*187* Device behind the first bridge188*/189if(dev->bus->self->devfn == IXDP2X00_P2P_DEVFN) {190switch(dev->devfn) {191case IXDP2X00_PMC_DEVFN:192return IRQ_IXDP2800_PMC;193194case IXDP2800_MASTER_ENET_DEVFN:195return IRQ_IXDP2800_EGRESS_ENET;196197case IXDP2800_SWITCH_FABRIC_DEVFN:198return IRQ_IXDP2800_FABRIC;199}200}201202return -1;203} else return IRQ_IXP2000_PCIB; /* Slave NIC interrupt */204}205206static void __init ixdp2800_master_enable_slave(void)207{208volatile u32 *addr;209210printk(KERN_INFO "IXDP2800: enabling slave NPU\n");211212addr = (volatile u32 *)ixp2000_pci_config_addr(0,213IXDP2X00_SLAVE_NPU_DEVFN,214PCI_COMMAND);215216*addr |= PCI_COMMAND_MASTER;217}218219static void __init ixdp2800_master_wait_for_slave_bus_scan(void)220{221volatile u32 *addr;222223printk(KERN_INFO "IXDP2800: waiting for slave to finish bus scan\n");224225addr = (volatile u32 *)ixp2000_pci_config_addr(0,226IXDP2X00_SLAVE_NPU_DEVFN,227PCI_COMMAND);228while ((*addr & PCI_COMMAND_MEMORY) == 0)229cpu_relax();230}231232static void __init ixdp2800_slave_signal_bus_scan_completion(void)233{234printk(KERN_INFO "IXDP2800: bus scan done, signaling master\n");235*IXP2000_PCI_CMDSTAT |= PCI_COMMAND_MEMORY;236}237238static void __init ixdp2800_pci_postinit(void)239{240if (!ixdp2x00_master_npu()) {241ixdp2x00_slave_pci_postinit();242ixdp2800_slave_signal_bus_scan_completion();243}244}245246struct __initdata hw_pci ixdp2800_pci __initdata = {247.nr_controllers = 1,248.setup = ixdp2800_pci_setup,249.preinit = ixdp2800_pci_preinit,250.postinit = ixdp2800_pci_postinit,251.scan = ixp2000_pci_scan_bus,252.map_irq = ixdp2800_pci_map_irq,253};254255int __init ixdp2800_pci_init(void)256{257if (machine_is_ixdp2800()) {258struct pci_dev *dev;259260pci_common_init(&ixdp2800_pci);261if (ixdp2x00_master_npu()) {262dev = pci_get_bus_and_slot(1, IXDP2800_SLAVE_ENET_DEVFN);263pci_remove_bus_device(dev);264pci_dev_put(dev);265266ixdp2800_master_enable_slave();267ixdp2800_master_wait_for_slave_bus_scan();268} else {269dev = pci_get_bus_and_slot(1, IXDP2800_MASTER_ENET_DEVFN);270pci_remove_bus_device(dev);271pci_dev_put(dev);272}273}274275return 0;276}277278subsys_initcall(ixdp2800_pci_init);279280void __init ixdp2800_init_irq(void)281{282ixdp2x00_init_irq(IXDP2800_CPLD_INT_STAT, IXDP2800_CPLD_INT_MASK, IXDP2800_NR_IRQS);283}284285MACHINE_START(IXDP2800, "Intel IXDP2800 Development Platform")286/* Maintainer: MontaVista Software, Inc. */287.boot_params = 0x00000100,288.map_io = ixdp2x00_map_io,289.init_irq = ixdp2800_init_irq,290.timer = &ixdp2800_timer,291.init_machine = ixdp2x00_init_machine,292MACHINE_END293294295296