blob: 915ad49e3b8fdf0d918523f8ee35b2c0ef4549a9 [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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/mm.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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/delay.h>
Russell Kingfced80c2008-09-06 12:10:45 +010027#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <asm/irq.h>
30#include <asm/pgtable.h>
31#include <asm/page.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010032#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include <asm/mach-types.h>
34
35#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>
41
42/*************************************************************************
43 * IXDP2400 timer tick
44 *************************************************************************/
45static void __init ixdp2400_timer_init(void)
46{
47 int numerator, denominator;
48 int denom_array[] = {2, 4, 8, 16, 1, 2, 4, 8};
49
50 numerator = (*(IXDP2400_CPLD_SYS_CLK_M) & 0xFF) *2;
51 denominator = denom_array[(*(IXDP2400_CPLD_SYS_CLK_N) & 0x7)];
52
53 ixp2000_init_time(((3125000 * numerator) / (denominator)) / 2);
54}
55
56static struct sys_timer ixdp2400_timer = {
57 .init = ixdp2400_timer_init,
58 .offset = ixp2000_gettimeoffset,
59};
60
61/*************************************************************************
62 * IXDP2400 PCI
63 *************************************************************************/
64void __init ixdp2400_pci_preinit(void)
65{
66 ixp2000_reg_write(IXP2000_PCI_ADDR_EXT, 0x00100000);
67 ixp2000_pci_preinit();
Lennert Buytenhekf8e5b282006-02-08 21:09:04 +000068 pcibios_setup("firmware");
Linus Torvalds1da177e2005-04-16 15:20:36 -070069}
70
71int 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
Ralf Baechled5341942011-06-10 15:30:21 +010080static int __init ixdp2400_pci_map_irq(const struct pci_dev *dev, u8 slot,
81 u8 pin)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082{
83 if (ixdp2x00_master_npu()) {
84
85 /*
86 * Root bus devices. Slave NPU is only one with interrupt.
87 * Everything else, we just return -1 b/c nothing else
88 * on the root bus has interrupts.
89 */
90 if(!dev->bus->self) {
91 if(dev->devfn == IXDP2X00_SLAVE_NPU_DEVFN )
92 return IRQ_IXDP2400_INGRESS_NPU;
93
94 return -1;
95 }
96
97 /*
98 * Bridge behind the PMC slot.
99 * NOTE: Only INTA from the PMC slot is routed. VERY BAD.
100 */
101 if(dev->bus->self->devfn == IXDP2X00_PMC_DEVFN &&
102 dev->bus->parent->self->devfn == IXDP2X00_P2P_DEVFN &&
103 !dev->bus->parent->self->bus->parent)
104 return IRQ_IXDP2400_PMC;
105
106 /*
107 * Device behind the first bridge
108 */
109 if(dev->bus->self->devfn == IXDP2X00_P2P_DEVFN) {
110 switch(dev->devfn) {
111 case IXDP2400_MASTER_ENET_DEVFN:
112 return IRQ_IXDP2400_ENET;
113
114 case IXDP2400_MEDIA_DEVFN:
115 return IRQ_IXDP2400_MEDIA_PCI;
116
117 case IXDP2400_SWITCH_FABRIC_DEVFN:
118 return IRQ_IXDP2400_SF_PCI;
119
120 case IXDP2X00_PMC_DEVFN:
121 return IRQ_IXDP2400_PMC;
122 }
123 }
124
125 return -1;
126 } else return IRQ_IXP2000_PCIB; /* Slave NIC interrupt */
127}
128
129
130static void ixdp2400_pci_postinit(void)
131{
132 struct pci_dev *dev;
133
134 if (ixdp2x00_master_npu()) {
Alan Cox7281c242006-10-16 16:49:50 +0100135 dev = pci_get_bus_and_slot(1, IXDP2400_SLAVE_ENET_DEVFN);
Yinghai Lu210647a2012-02-25 13:54:20 -0800136 pci_stop_and_remove_bus_device(dev);
Russell Kingcf610ca2006-10-20 20:16:24 +0100137 pci_dev_put(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 } else {
Alan Cox7281c242006-10-16 16:49:50 +0100139 dev = pci_get_bus_and_slot(1, IXDP2400_MASTER_ENET_DEVFN);
Yinghai Lu210647a2012-02-25 13:54:20 -0800140 pci_stop_and_remove_bus_device(dev);
Russell Kingcf610ca2006-10-20 20:16:24 +0100141 pci_dev_put(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
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
Russell Kingcdea4602007-05-30 17:48:45 +0100166void __init ixdp2400_init_irq(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167{
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. */
Nicolas Pitreade59312011-07-05 22:38:13 -0400173 .atag_offset = 0x100,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100174 .map_io = ixdp2x00_map_io,
175 .init_irq = ixdp2400_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 .timer = &ixdp2400_timer,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100177 .init_machine = ixdp2x00_init_machine,
Russell King1139b922011-11-05 11:46:04 +0000178 .restart = ixp2000_restart,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179MACHINE_END
180