This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.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 Mialwoski <andrzej.mialwoski@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/interrupt.h>
30 #include <linux/mm.h>
31 #include <linux/init.h>
32 #include <linux/ioport.h>
33 #include <linux/slab.h>
34 #include <linux/delay.h>
35 #include <linux/serial.h>
36 #include <linux/tty.h>
37 #include <linux/serial_core.h>
38 #include <linux/device.h>
39
40 #include <asm/io.h>
41 #include <asm/irq.h>
42 #include <asm/pgtable.h>
43 #include <asm/page.h>
44 #include <asm/system.h>
45 #include <asm/hardware.h>
46 #include <asm/mach-types.h>
47
48 #include <asm/mach/pci.h>
49 #include <asm/mach/map.h>
50 #include <asm/mach/irq.h>
51 #include <asm/mach/time.h>
52 #include <asm/mach/arch.h>
53 #include <asm/mach/flash.h>
54
55 /*************************************************************************
56  * ENP-2611 timer tick configuration
57  *************************************************************************/
58 static void __init enp2611_init_time(void)
59 {
60         ixp2000_init_time(50 * 1000 * 1000);
61 }
62
63
64 /*************************************************************************
65  * ENP-2611 PCI
66  *************************************************************************/
67 static int enp2611_pci_setup(int nr, struct pci_sys_data *sys)
68 {
69         sys->mem_offset = 0xe0000000;
70         ixp2000_pci_setup(nr, sys);
71         return 1;
72 }
73
74 static void __init enp2611_pci_preinit(void)
75 {
76         ixp2000_reg_write(IXP2000_PCI_ADDR_EXT, 0x00100000);
77         ixp2000_pci_preinit();
78 }
79
80 static inline int enp2611_pci_valid_device(struct pci_bus *bus,
81                                                 unsigned int devfn)
82 {
83         /* The 82559 ethernet controller appears at both PCI:1:0:0 and
84          * PCI:1:2:0, so let's pretend the second one isn't there.
85          */
86         if (bus->number == 0x01 && devfn == 0x10)
87                 return 0;
88
89         return 1;
90 }
91
92 static int enp2611_pci_read_config(struct pci_bus *bus, unsigned int devfn,
93                                         int where, int size, u32 *value)
94 {
95         if (enp2611_pci_valid_device(bus, devfn))
96                 return ixp2000_pci_read_config(bus, devfn, where, size, value);
97
98         return PCIBIOS_DEVICE_NOT_FOUND;
99 }
100
101 static int enp2611_pci_write_config(struct pci_bus *bus, unsigned int devfn,
102                                         int where, int size, u32 value)
103 {
104         if (enp2611_pci_valid_device(bus, devfn))
105                 return ixp2000_pci_write_config(bus, devfn, where, size, value);
106
107         return PCIBIOS_DEVICE_NOT_FOUND;
108 }
109
110 static struct pci_ops enp2611_pci_ops = {
111         .read   = enp2611_pci_read_config,
112         .write  = enp2611_pci_write_config
113 };
114
115 static struct pci_bus * __init enp2611_pci_scan_bus(int nr,
116                                                 struct pci_sys_data *sys)
117 {
118         return pci_scan_bus(sys->busnr, &enp2611_pci_ops, sys);
119 }
120
121 static int __init enp2611_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
122 {
123         int irq;
124
125         if (dev->bus->number == 0x00 && PCI_SLOT(dev->devfn) == 0x01) {
126                 /* 21555 non-transparent bridge.  */
127                 irq = IRQ_IXP2000_PCIB;
128         } else if (dev->bus->number == 0x01 && PCI_SLOT(dev->devfn) == 0x00) {
129                 /* 82559 ethernet.  */
130                 irq = IRQ_IXP2000_PCIA;
131         } else {
132                 printk(KERN_INFO "enp2611_pci_map_irq for unknown device\n");
133                 irq = IRQ_IXP2000_PCI;
134         }
135
136         printk(KERN_INFO "Assigned IRQ %d to PCI:%d:%d:%d\n", irq,
137                 dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
138
139         return irq;
140 }
141
142 struct hw_pci enp2611_pci __initdata = {
143         .nr_controllers = 1,
144         .setup          = enp2611_pci_setup,
145         .preinit        = enp2611_pci_preinit,
146         .scan           = enp2611_pci_scan_bus,
147         .map_irq        = enp2611_pci_map_irq,
148 };
149
150 int __init enp2611_pci_init(void)
151 {
152         pci_common_init(&enp2611_pci);
153         return 0;
154 }
155
156 subsys_initcall(enp2611_pci_init);
157
158
159 /*************************************************************************
160  * ENP-2611 Machine Intialization
161  *************************************************************************/
162 static struct flash_platform_data enp2611_flash_platform_data = {
163         .map_name       = "cfi_probe",
164         .width          = 1,
165 };
166
167 static struct ixp2000_flash_data enp2611_flash_data = {
168         .platform_data  = &enp2611_flash_platform_data,
169         .nr_banks       = 1
170 };
171
172 static struct resource enp2611_flash_resource = {
173         .start          = 0xc4000000,
174         .end            = 0xc4000000 + 0x00ffffff,
175         .flags          = IORESOURCE_MEM,
176 };
177
178 static struct platform_device enp2611_flash = {
179         .name           = "IXP2000-Flash",
180         .id             = 0,
181         .dev            = {
182                 .platform_data = &enp2611_flash_data,
183         },
184         .num_resources  = 1,
185         .resource       = &enp2611_flash_resource,
186 };
187
188 static struct platform_device *enp2611_devices[] __initdata = {
189         &enp2611_flash
190 };
191
192 static void __init enp2611_init_machine(void)
193 {
194         platform_add_devices(enp2611_devices, ARRAY_SIZE(enp2611_devices));
195 }
196
197
198 #ifdef CONFIG_ARCH_ENP2611
199 MACHINE_START(ENP2611, "Radisys ENP-2611 PCI network processor board")
200         MAINTAINER("Lennert Buytenhek <buytenh@wantstofly.org>")
201         BOOT_MEM(0x00000000, IXP2000_UART_PHYS_BASE, IXP2000_UART_VIRT_BASE)
202         BOOT_PARAMS(0x00000100)
203         MAPIO(ixp2000_map_io)
204         INITIRQ(ixp2000_init_irq)
205         INITTIME(enp2611_init_time)
206         INIT_MACHINE(enp2611_init_machine)
207 MACHINE_END
208 #endif
209
210