]> git.ipfire.org Git - thirdparty/kernel/stable.git/blob - arch/arm/mach-ixp2000/enp2611.c
Linux-2.6.12-rc2
[thirdparty/kernel/stable.git] / arch / arm / mach-ixp2000 / enp2611.c
1 /*
2 * arch/arm/mach-ixp2000/enp2611.c
3 *
4 * Radisys ENP-2611 support.
5 *
6 * Created 2004 by Lennert Buytenhek from the ixdp2x01 code. The
7 * original version carries the following notices:
8 *
9 * Original Author: Andrzej Mialkowski <andrzej.mialkowski@intel.com>
10 * Maintainer: Deepak Saxena <dsaxena@plexity.net>
11 *
12 * Copyright (C) 2002-2003 Intel Corp.
13 * Copyright (C) 2003-2004 MontaVista Software, Inc.
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2 of the License, or (at your
18 * option) any later version.
19 */
20
21 #include <linux/config.h>
22 #include <linux/kernel.h>
23 #include <linux/init.h>
24 #include <linux/mm.h>
25 #include <linux/sched.h>
26 #include <linux/interrupt.h>
27 #include <linux/bitops.h>
28 #include <linux/pci.h>
29 #include <linux/ioport.h>
30 #include <linux/slab.h>
31 #include <linux/delay.h>
32 #include <linux/serial.h>
33 #include <linux/tty.h>
34 #include <linux/serial_core.h>
35 #include <linux/device.h>
36
37 #include <asm/io.h>
38 #include <asm/irq.h>
39 #include <asm/pgtable.h>
40 #include <asm/page.h>
41 #include <asm/system.h>
42 #include <asm/hardware.h>
43 #include <asm/mach-types.h>
44
45 #include <asm/mach/pci.h>
46 #include <asm/mach/map.h>
47 #include <asm/mach/irq.h>
48 #include <asm/mach/time.h>
49 #include <asm/mach/arch.h>
50 #include <asm/mach/flash.h>
51
52 /*************************************************************************
53 * ENP-2611 timer tick configuration
54 *************************************************************************/
55 static void __init enp2611_timer_init(void)
56 {
57 ixp2000_init_time(50 * 1000 * 1000);
58 }
59
60 static struct sys_timer enp2611_timer = {
61 .init = enp2611_timer_init,
62 .offset = ixp2000_gettimeoffset,
63 };
64
65
66 /*************************************************************************
67 * ENP-2611 PCI
68 *************************************************************************/
69 static int enp2611_pci_setup(int nr, struct pci_sys_data *sys)
70 {
71 sys->mem_offset = 0xe0000000;
72 ixp2000_pci_setup(nr, sys);
73 return 1;
74 }
75
76 static void __init enp2611_pci_preinit(void)
77 {
78 ixp2000_reg_write(IXP2000_PCI_ADDR_EXT, 0x00100000);
79 ixp2000_pci_preinit();
80 }
81
82 static inline int enp2611_pci_valid_device(struct pci_bus *bus,
83 unsigned int devfn)
84 {
85 /* The 82559 ethernet controller appears at both PCI:1:0:0 and
86 * PCI:1:2:0, so let's pretend the second one isn't there.
87 */
88 if (bus->number == 0x01 && devfn == 0x10)
89 return 0;
90
91 return 1;
92 }
93
94 static int enp2611_pci_read_config(struct pci_bus *bus, unsigned int devfn,
95 int where, int size, u32 *value)
96 {
97 if (enp2611_pci_valid_device(bus, devfn))
98 return ixp2000_pci_read_config(bus, devfn, where, size, value);
99
100 return PCIBIOS_DEVICE_NOT_FOUND;
101 }
102
103 static int enp2611_pci_write_config(struct pci_bus *bus, unsigned int devfn,
104 int where, int size, u32 value)
105 {
106 if (enp2611_pci_valid_device(bus, devfn))
107 return ixp2000_pci_write_config(bus, devfn, where, size, value);
108
109 return PCIBIOS_DEVICE_NOT_FOUND;
110 }
111
112 static struct pci_ops enp2611_pci_ops = {
113 .read = enp2611_pci_read_config,
114 .write = enp2611_pci_write_config
115 };
116
117 static struct pci_bus * __init enp2611_pci_scan_bus(int nr,
118 struct pci_sys_data *sys)
119 {
120 return pci_scan_bus(sys->busnr, &enp2611_pci_ops, sys);
121 }
122
123 static int __init enp2611_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
124 {
125 int irq;
126
127 if (dev->bus->number == 0 && PCI_SLOT(dev->devfn) == 0) {
128 /* IXP2400. */
129 irq = IRQ_IXP2000_PCIA;
130 } else if (dev->bus->number == 0 && PCI_SLOT(dev->devfn) == 1) {
131 /* 21555 non-transparent bridge. */
132 irq = IRQ_IXP2000_PCIB;
133 } else if (dev->bus->number == 0 && PCI_SLOT(dev->devfn) == 4) {
134 /* PCI2050B transparent bridge. */
135 irq = -1;
136 } else if (dev->bus->number == 1 && PCI_SLOT(dev->devfn) == 0) {
137 /* 82559 ethernet. */
138 irq = IRQ_IXP2000_PCIA;
139 } else if (dev->bus->number == 1 && PCI_SLOT(dev->devfn) == 1) {
140 /* SPI-3 option board. */
141 irq = IRQ_IXP2000_PCIB;
142 } else {
143 printk(KERN_ERR "enp2611_pci_map_irq() called for unknown "
144 "device PCI:%d:%d:%d\n", dev->bus->number,
145 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
146 irq = -1;
147 }
148
149 return irq;
150 }
151
152 struct hw_pci enp2611_pci __initdata = {
153 .nr_controllers = 1,
154 .setup = enp2611_pci_setup,
155 .preinit = enp2611_pci_preinit,
156 .scan = enp2611_pci_scan_bus,
157 .map_irq = enp2611_pci_map_irq,
158 };
159
160 int __init enp2611_pci_init(void)
161 {
162 if (machine_is_enp2611())
163 pci_common_init(&enp2611_pci);
164
165 return 0;
166 }
167
168 subsys_initcall(enp2611_pci_init);
169
170
171 /*************************************************************************
172 * ENP-2611 Machine Intialization
173 *************************************************************************/
174 static struct flash_platform_data enp2611_flash_platform_data = {
175 .map_name = "cfi_probe",
176 .width = 1,
177 };
178
179 static struct ixp2000_flash_data enp2611_flash_data = {
180 .platform_data = &enp2611_flash_platform_data,
181 .nr_banks = 1
182 };
183
184 static struct resource enp2611_flash_resource = {
185 .start = 0xc4000000,
186 .end = 0xc4000000 + 0x00ffffff,
187 .flags = IORESOURCE_MEM,
188 };
189
190 static struct platform_device enp2611_flash = {
191 .name = "IXP2000-Flash",
192 .id = 0,
193 .dev = {
194 .platform_data = &enp2611_flash_data,
195 },
196 .num_resources = 1,
197 .resource = &enp2611_flash_resource,
198 };
199
200 static struct platform_device *enp2611_devices[] __initdata = {
201 &enp2611_flash
202 };
203
204 static void __init enp2611_init_machine(void)
205 {
206 platform_add_devices(enp2611_devices, ARRAY_SIZE(enp2611_devices));
207 }
208
209
210 MACHINE_START(ENP2611, "Radisys ENP-2611 PCI network processor board")
211 MAINTAINER("Lennert Buytenhek <buytenh@wantstofly.org>")
212 BOOT_MEM(0x00000000, IXP2000_UART_PHYS_BASE, IXP2000_UART_VIRT_BASE)
213 BOOT_PARAMS(0x00000100)
214 MAPIO(ixp2000_map_io)
215 INITIRQ(ixp2000_init_irq)
216 .timer = &enp2611_timer,
217 INIT_MACHINE(enp2611_init_machine)
218 MACHINE_END
219
220