PageRenderTime 26ms CodeModel.GetById 15ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

/arch/arm/mach-ixp2000/ixdp2800.c

https://bitbucket.org/evzijst/gittest
C | 180 lines | 116 code | 32 blank | 32 comment | 13 complexity | 8076a2095dac7ad533b20ab9ec6d915f MD5 | raw file
  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/ioport.h>
 27#include <linux/slab.h>
 28#include <linux/delay.h>
 29
 30#include <asm/io.h>
 31#include <asm/irq.h>
 32#include <asm/pgtable.h>
 33#include <asm/page.h>
 34#include <asm/system.h>
 35#include <asm/hardware.h>
 36#include <asm/mach-types.h>
 37
 38#include <asm/mach/pci.h>
 39#include <asm/mach/map.h>
 40#include <asm/mach/irq.h>
 41#include <asm/mach/time.h>
 42#include <asm/mach/flash.h>
 43#include <asm/mach/arch.h>
 44
 45
 46void ixdp2400_init_irq(void)
 47{
 48	ixdp2x00_init_irq(IXDP2800_CPLD_INT_STAT, IXDP2800_CPLD_INT_MASK, IXDP2400_NR_IRQS);
 49}
 50
 51/*************************************************************************
 52 * IXDP2800 timer tick
 53 *************************************************************************/
 54
 55static void __init ixdp2800_timer_init(void)
 56{
 57	ixp2000_init_time(50000000);
 58}
 59
 60static struct sys_timer ixdp2800_timer = {
 61	.init		= ixdp2800_timer_init,
 62	.offset		= ixp2000_gettimeoffset,
 63};
 64
 65/*************************************************************************
 66 * IXDP2800 PCI
 67 *************************************************************************/
 68void __init ixdp2800_pci_preinit(void)
 69{
 70	printk("ixdp2x00_pci_preinit called\n");
 71
 72	*IXP2000_PCI_ADDR_EXT =  0x0000e000;
 73
 74	*IXP2000_PCI_DRAM_BASE_ADDR_MASK = (0x40000000 - 1) & ~0xfffff;
 75	*IXP2000_PCI_SRAM_BASE_ADDR_MASK = (0x2000000 - 1) & ~0x3ffff;
 76
 77	ixp2000_pci_preinit();
 78}
 79
 80int ixdp2800_pci_setup(int nr, struct pci_sys_data *sys)
 81{
 82	sys->mem_offset = 0x00000000;
 83
 84	ixp2000_pci_setup(nr, sys);
 85
 86	return 1;
 87}
 88
 89static int __init ixdp2800_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 90{
 91	if (ixdp2x00_master_npu()) {
 92
 93		/*
 94		 * Root bus devices.  Slave NPU is only one with interrupt.
 95		 * Everything else, we just return -1 which is invalid.
 96		 */
 97		if(!dev->bus->self) {
 98			if(dev->devfn == IXDP2X00_SLAVE_NPU_DEVFN )
 99				return IRQ_IXDP2800_INGRESS_NPU;
100
101			return -1;
102		}
103
104		/*
105		 * Bridge behind the PMC slot.
106		 */
107		if(dev->bus->self->devfn == IXDP2X00_PMC_DEVFN &&
108			dev->bus->parent->self->devfn == IXDP2X00_P2P_DEVFN &&
109			!dev->bus->parent->self->bus->parent)
110				  return IRQ_IXDP2800_PMC;
111
112		/*
113		 * Device behind the first bridge
114		 */
115		if(dev->bus->self->devfn == IXDP2X00_P2P_DEVFN) {
116			switch(dev->devfn) {
117				case IXDP2X00_PMC_DEVFN:
118					return IRQ_IXDP2800_PMC;	
119			
120				case IXDP2800_MASTER_ENET_DEVFN:
121					return IRQ_IXDP2800_EGRESS_ENET;
122
123				case IXDP2800_SWITCH_FABRIC_DEVFN:
124					return IRQ_IXDP2800_FABRIC;
125			}
126		}
127
128		return -1;
129	} else return IRQ_IXP2000_PCIB; /* Slave NIC interrupt */
130}
131
132static void ixdp2800_pci_postinit(void)
133{
134	struct pci_dev *dev;
135
136	if (ixdp2x00_master_npu()) {
137		dev = pci_find_slot(1, IXDP2800_SLAVE_ENET_DEVFN);
138		pci_remove_bus_device(dev);
139	} else {
140		dev = pci_find_slot(1, IXDP2800_MASTER_ENET_DEVFN);
141		pci_remove_bus_device(dev);
142
143		ixdp2x00_slave_pci_postinit();
144	}
145}
146
147struct hw_pci ixdp2800_pci __initdata = {
148	.nr_controllers	= 1,
149	.setup		= ixdp2800_pci_setup,
150	.preinit	= ixdp2800_pci_preinit,
151	.postinit	= ixdp2800_pci_postinit,
152	.scan		= ixp2000_pci_scan_bus,
153	.map_irq	= ixdp2800_pci_map_irq,
154};
155
156int __init ixdp2800_pci_init(void)
157{
158	if (machine_is_ixdp2800())
159		pci_common_init(&ixdp2800_pci);
160
161	return 0;
162}
163
164subsys_initcall(ixdp2800_pci_init);
165
166void ixdp2800_init_irq(void)
167{
168	ixdp2x00_init_irq(IXDP2800_CPLD_INT_STAT, IXDP2800_CPLD_INT_MASK, IXDP2800_NR_IRQS);
169}
170
171MACHINE_START(IXDP2800, "Intel IXDP2800 Development Platform")
172	MAINTAINER("MontaVista Software, Inc.")
173	BOOT_MEM(0x00000000, IXP2000_UART_PHYS_BASE, IXP2000_UART_VIRT_BASE)
174	BOOT_PARAMS(0x00000100)
175	MAPIO(ixdp2x00_map_io)
176	INITIRQ(ixdp2800_init_irq)
177	.timer		= &ixdp2800_timer,
178	INIT_MACHINE(ixdp2x00_init_machine)
179MACHINE_END
180