blob: 09101271298e0fa54ee93956555db25983da33d1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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/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/*************************************************************************
46 * IXDP2400 timer tick
47 *************************************************************************/
48static void __init ixdp2400_timer_init(void)
49{
50 int numerator, denominator;
51 int denom_array[] = {2, 4, 8, 16, 1, 2, 4, 8};
52
53 numerator = (*(IXDP2400_CPLD_SYS_CLK_M) & 0xFF) *2;
54 denominator = denom_array[(*(IXDP2400_CPLD_SYS_CLK_N) & 0x7)];
55
56 ixp2000_init_time(((3125000 * numerator) / (denominator)) / 2);
57}
58
59static struct sys_timer ixdp2400_timer = {
60 .init = ixdp2400_timer_init,
61 .offset = ixp2000_gettimeoffset,
62};
63
64/*************************************************************************
65 * IXDP2400 PCI
66 *************************************************************************/
67void __init ixdp2400_pci_preinit(void)
68{
69 ixp2000_reg_write(IXP2000_PCI_ADDR_EXT, 0x00100000);
70 ixp2000_pci_preinit();
Lennert Buytenhekf8e5b282006-02-08 21:09:04 +000071 pcibios_setup("firmware");
Linus Torvalds1da177e2005-04-16 15:20:36 -070072}
73
74int ixdp2400_pci_setup(int nr, struct pci_sys_data *sys)
75{
76 sys->mem_offset = 0xe0000000;
77
78 ixp2000_pci_setup(nr, sys);
79
80 return 1;
81}
82
83static int __init ixdp2400_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
84{
85 if (ixdp2x00_master_npu()) {
86
87 /*
88 * Root bus devices. Slave NPU is only one with interrupt.
89 * Everything else, we just return -1 b/c nothing else
90 * on the root bus has interrupts.
91 */
92 if(!dev->bus->self) {
93 if(dev->devfn == IXDP2X00_SLAVE_NPU_DEVFN )
94 return IRQ_IXDP2400_INGRESS_NPU;
95
96 return -1;
97 }
98
99 /*
100 * Bridge behind the PMC slot.
101 * NOTE: Only INTA from the PMC slot is routed. VERY BAD.
102 */
103 if(dev->bus->self->devfn == IXDP2X00_PMC_DEVFN &&
104 dev->bus->parent->self->devfn == IXDP2X00_P2P_DEVFN &&
105 !dev->bus->parent->self->bus->parent)
106 return IRQ_IXDP2400_PMC;
107
108 /*
109 * Device behind the first bridge
110 */
111 if(dev->bus->self->devfn == IXDP2X00_P2P_DEVFN) {
112 switch(dev->devfn) {
113 case IXDP2400_MASTER_ENET_DEVFN:
114 return IRQ_IXDP2400_ENET;
115
116 case IXDP2400_MEDIA_DEVFN:
117 return IRQ_IXDP2400_MEDIA_PCI;
118
119 case IXDP2400_SWITCH_FABRIC_DEVFN:
120 return IRQ_IXDP2400_SF_PCI;
121
122 case IXDP2X00_PMC_DEVFN:
123 return IRQ_IXDP2400_PMC;
124 }
125 }
126
127 return -1;
128 } else return IRQ_IXP2000_PCIB; /* Slave NIC interrupt */
129}
130
131
132static void ixdp2400_pci_postinit(void)
133{
134 struct pci_dev *dev;
135
136 if (ixdp2x00_master_npu()) {
137 dev = pci_find_slot(1, IXDP2400_SLAVE_ENET_DEVFN);
138 pci_remove_bus_device(dev);
139 } else {
140 dev = pci_find_slot(1, IXDP2400_MASTER_ENET_DEVFN);
141 pci_remove_bus_device(dev);
142
143 ixdp2x00_slave_pci_postinit();
144 }
145}
146
147static struct hw_pci ixdp2400_pci __initdata = {
148 .nr_controllers = 1,
149 .setup = ixdp2400_pci_setup,
150 .preinit = ixdp2400_pci_preinit,
151 .postinit = ixdp2400_pci_postinit,
152 .scan = ixp2000_pci_scan_bus,
153 .map_irq = ixdp2400_pci_map_irq,
154};
155
156int __init ixdp2400_pci_init(void)
157{
158 if (machine_is_ixdp2400())
159 pci_common_init(&ixdp2400_pci);
160
161 return 0;
162}
163
164subsys_initcall(ixdp2400_pci_init);
165
166void ixdp2400_init_irq(void)
167{
168 ixdp2x00_init_irq(IXDP2400_CPLD_INT_STAT, IXDP2400_CPLD_INT_MASK, IXDP2400_NR_IRQS);
169}
170
171MACHINE_START(IXDP2400, "Intel IXDP2400 Development Platform")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100172 /* Maintainer: MontaVista Software, Inc. */
Russell Kinge9dea0c2005-07-03 17:38:58 +0100173 .phys_io = IXP2000_UART_PHYS_BASE,
174 .io_pg_offst = ((IXP2000_UART_VIRT_BASE) >> 18) & 0xfffc,
175 .boot_params = 0x00000100,
176 .map_io = ixdp2x00_map_io,
177 .init_irq = ixdp2400_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 .timer = &ixdp2400_timer,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100179 .init_machine = ixdp2x00_init_machine,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180MACHINE_END
181