blob: 52fac89e95b59c28701cfdbedfee0519820cf1af [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
Russell Kingd052d1b2005-10-29 19:07:23 +010035#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
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 *************************************************************************/
55static void __init enp2611_timer_init(void)
56{
57 ixp2000_init_time(50 * 1000 * 1000);
58}
59
60static struct sys_timer enp2611_timer = {
61 .init = enp2611_timer_init,
62 .offset = ixp2000_gettimeoffset,
63};
64
65
66/*************************************************************************
Lennert Buytenheka6f10632005-11-01 19:44:24 +000067 * ENP-2611 I/O
68 *************************************************************************/
69static struct map_desc enp2611_io_desc[] __initdata = {
70 {
71 .virtual = ENP2611_CALEB_VIRT_BASE,
Russell Kingca82d852005-11-03 10:06:35 +000072 .pfn = __phys_to_pfn(ENP2611_CALEB_PHYS_BASE),
Lennert Buytenheka6f10632005-11-01 19:44:24 +000073 .length = ENP2611_CALEB_SIZE,
Russell Kingca82d852005-11-03 10:06:35 +000074 .type = MT_IXP2000_DEVICE,
Lennert Buytenheka6f10632005-11-01 19:44:24 +000075 }, {
76 .virtual = ENP2611_PM3386_0_VIRT_BASE,
Russell Kingca82d852005-11-03 10:06:35 +000077 .pfn = __phys_to_pfn(ENP2611_PM3386_0_PHYS_BASE),
Lennert Buytenheka6f10632005-11-01 19:44:24 +000078 .length = ENP2611_PM3386_0_SIZE,
Russell Kingca82d852005-11-03 10:06:35 +000079 .type = MT_IXP2000_DEVICE,
Lennert Buytenheka6f10632005-11-01 19:44:24 +000080 }, {
81 .virtual = ENP2611_PM3386_1_VIRT_BASE,
Russell Kingca82d852005-11-03 10:06:35 +000082 .pfn = __phys_to_pfn(ENP2611_PM3386_1_PHYS_BASE),
Lennert Buytenheka6f10632005-11-01 19:44:24 +000083 .length = ENP2611_PM3386_1_SIZE,
Russell Kingca82d852005-11-03 10:06:35 +000084 .type = MT_IXP2000_DEVICE,
Lennert Buytenheka6f10632005-11-01 19:44:24 +000085 }
86};
87
88void __init enp2611_map_io(void)
89{
90 ixp2000_map_io();
91 iotable_init(enp2611_io_desc, ARRAY_SIZE(enp2611_io_desc));
92}
93
94
95/*************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 * ENP-2611 PCI
97 *************************************************************************/
98static int enp2611_pci_setup(int nr, struct pci_sys_data *sys)
99{
100 sys->mem_offset = 0xe0000000;
101 ixp2000_pci_setup(nr, sys);
102 return 1;
103}
104
105static void __init enp2611_pci_preinit(void)
106{
107 ixp2000_reg_write(IXP2000_PCI_ADDR_EXT, 0x00100000);
108 ixp2000_pci_preinit();
Lennert Buytenhekf8e5b282006-02-08 21:09:04 +0000109 pcibios_setup("firmware");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110}
111
112static inline int enp2611_pci_valid_device(struct pci_bus *bus,
113 unsigned int devfn)
114{
115 /* The 82559 ethernet controller appears at both PCI:1:0:0 and
116 * PCI:1:2:0, so let's pretend the second one isn't there.
117 */
118 if (bus->number == 0x01 && devfn == 0x10)
119 return 0;
120
121 return 1;
122}
123
124static int enp2611_pci_read_config(struct pci_bus *bus, unsigned int devfn,
125 int where, int size, u32 *value)
126{
127 if (enp2611_pci_valid_device(bus, devfn))
128 return ixp2000_pci_read_config(bus, devfn, where, size, value);
129
130 return PCIBIOS_DEVICE_NOT_FOUND;
131}
132
133static int enp2611_pci_write_config(struct pci_bus *bus, unsigned int devfn,
134 int where, int size, u32 value)
135{
136 if (enp2611_pci_valid_device(bus, devfn))
137 return ixp2000_pci_write_config(bus, devfn, where, size, value);
138
139 return PCIBIOS_DEVICE_NOT_FOUND;
140}
141
142static struct pci_ops enp2611_pci_ops = {
143 .read = enp2611_pci_read_config,
144 .write = enp2611_pci_write_config
145};
146
147static struct pci_bus * __init enp2611_pci_scan_bus(int nr,
148 struct pci_sys_data *sys)
149{
150 return pci_scan_bus(sys->busnr, &enp2611_pci_ops, sys);
151}
152
153static int __init enp2611_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
154{
155 int irq;
156
157 if (dev->bus->number == 0 && PCI_SLOT(dev->devfn) == 0) {
158 /* IXP2400. */
159 irq = IRQ_IXP2000_PCIA;
160 } else if (dev->bus->number == 0 && PCI_SLOT(dev->devfn) == 1) {
161 /* 21555 non-transparent bridge. */
162 irq = IRQ_IXP2000_PCIB;
163 } else if (dev->bus->number == 0 && PCI_SLOT(dev->devfn) == 4) {
164 /* PCI2050B transparent bridge. */
165 irq = -1;
166 } else if (dev->bus->number == 1 && PCI_SLOT(dev->devfn) == 0) {
167 /* 82559 ethernet. */
168 irq = IRQ_IXP2000_PCIA;
169 } else if (dev->bus->number == 1 && PCI_SLOT(dev->devfn) == 1) {
170 /* SPI-3 option board. */
171 irq = IRQ_IXP2000_PCIB;
172 } else {
173 printk(KERN_ERR "enp2611_pci_map_irq() called for unknown "
174 "device PCI:%d:%d:%d\n", dev->bus->number,
175 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
176 irq = -1;
177 }
178
179 return irq;
180}
181
182struct hw_pci enp2611_pci __initdata = {
183 .nr_controllers = 1,
184 .setup = enp2611_pci_setup,
185 .preinit = enp2611_pci_preinit,
186 .scan = enp2611_pci_scan_bus,
187 .map_irq = enp2611_pci_map_irq,
188};
189
190int __init enp2611_pci_init(void)
191{
192 if (machine_is_enp2611())
193 pci_common_init(&enp2611_pci);
194
195 return 0;
196}
197
198subsys_initcall(enp2611_pci_init);
199
200
201/*************************************************************************
202 * ENP-2611 Machine Intialization
203 *************************************************************************/
204static struct flash_platform_data enp2611_flash_platform_data = {
205 .map_name = "cfi_probe",
206 .width = 1,
207};
208
209static struct ixp2000_flash_data enp2611_flash_data = {
210 .platform_data = &enp2611_flash_platform_data,
211 .nr_banks = 1
212};
213
214static struct resource enp2611_flash_resource = {
215 .start = 0xc4000000,
216 .end = 0xc4000000 + 0x00ffffff,
217 .flags = IORESOURCE_MEM,
218};
219
220static struct platform_device enp2611_flash = {
221 .name = "IXP2000-Flash",
222 .id = 0,
223 .dev = {
224 .platform_data = &enp2611_flash_data,
225 },
226 .num_resources = 1,
227 .resource = &enp2611_flash_resource,
228};
229
Lennert Buytenhekea23d1a2005-06-25 16:58:21 +0100230static struct ixp2000_i2c_pins enp2611_i2c_gpio_pins = {
231 .sda_pin = ENP2611_GPIO_SDA,
232 .scl_pin = ENP2611_GPIO_SCL,
233};
234
235static struct platform_device enp2611_i2c_controller = {
236 .name = "IXP2000-I2C",
237 .id = 0,
238 .dev = {
239 .platform_data = &enp2611_i2c_gpio_pins
240 },
241 .num_resources = 0
242};
243
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244static struct platform_device *enp2611_devices[] __initdata = {
Lennert Buytenhekea23d1a2005-06-25 16:58:21 +0100245 &enp2611_flash,
246 &enp2611_i2c_controller
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247};
248
249static void __init enp2611_init_machine(void)
250{
251 platform_add_devices(enp2611_devices, ARRAY_SIZE(enp2611_devices));
Lennert Buytenhek28187f22005-07-10 19:44:53 +0100252 ixp2000_uart_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253}
254
255
256MACHINE_START(ENP2611, "Radisys ENP-2611 PCI network processor board")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100257 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
Russell Kinge9dea0c2005-07-03 17:38:58 +0100258 .phys_io = IXP2000_UART_PHYS_BASE,
259 .io_pg_offst = ((IXP2000_UART_VIRT_BASE) >> 18) & 0xfffc,
260 .boot_params = 0x00000100,
Lennert Buytenheka6f10632005-11-01 19:44:24 +0000261 .map_io = enp2611_map_io,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100262 .init_irq = ixp2000_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 .timer = &enp2611_timer,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100264 .init_machine = enp2611_init_machine,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265MACHINE_END
266
267