blob: 8f4dcbba90250e7b5c3d8b9e95c13cc09d111767 [file] [log] [blame]
Lennert Buytenhekc4713072006-03-28 21:18:54 +01001/*
2 * arch/arm/mach-ixp23xx/roadrunner.c
3 *
4 * RoadRunner board-specific routines
5 *
6 * Author: Deepak Saxena <dsaxena@plexity.net>
7 *
8 * Copyright 2005 (c) MontaVista Software, Inc.
9 *
10 * Based on 2.4 code Copyright 2005 (c) ADI Engineering Corporation
11 *
12 * This file is licensed under the terms of the GNU General Public
13 * License version 2. This program is licensed "as is" without any
14 * warranty of any kind, whether express or implied.
15 */
16
Lennert Buytenhekc4713072006-03-28 21:18:54 +010017#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/spinlock.h>
20#include <linux/sched.h>
21#include <linux/interrupt.h>
22#include <linux/serial.h>
23#include <linux/tty.h>
24#include <linux/bitops.h>
25#include <linux/ioport.h>
Lennert Buytenhekc4713072006-03-28 21:18:54 +010026#include <linux/serial_8250.h>
27#include <linux/serial_core.h>
28#include <linux/device.h>
29#include <linux/mm.h>
30#include <linux/pci.h>
31#include <linux/mtd/physmap.h>
32
33#include <asm/types.h>
34#include <asm/setup.h>
35#include <asm/memory.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010036#include <mach/hardware.h>
Lennert Buytenhekc4713072006-03-28 21:18:54 +010037#include <asm/mach-types.h>
38#include <asm/irq.h>
39#include <asm/system.h>
40#include <asm/tlbflush.h>
41#include <asm/pgtable.h>
42
43#include <asm/mach/map.h>
44#include <asm/mach/irq.h>
45#include <asm/mach/arch.h>
Lennert Buytenhekc4713072006-03-28 21:18:54 +010046#include <asm/mach/pci.h>
47
48/*
49 * Interrupt mapping
50 */
51#define INTA IRQ_ROADRUNNER_PCI_INTA
52#define INTB IRQ_ROADRUNNER_PCI_INTB
53#define INTC IRQ_ROADRUNNER_PCI_INTC
54#define INTD IRQ_ROADRUNNER_PCI_INTD
55
56#define INTC_PIN IXP23XX_GPIO_PIN_11
57#define INTD_PIN IXP23XX_GPIO_PIN_12
58
Ralf Baechled5341942011-06-10 15:30:21 +010059static int __init roadrunner_map_irq(const struct pci_dev *dev, u8 idsel,
60 u8 pin)
Lennert Buytenhekc4713072006-03-28 21:18:54 +010061{
62 static int pci_card_slot_irq[] = {INTB, INTC, INTD, INTA};
63 static int pmc_card_slot_irq[] = {INTA, INTB, INTC, INTD};
64 static int usb_irq[] = {INTB, INTC, INTD, -1};
65 static int mini_pci_1_irq[] = {INTB, INTC, -1, -1};
66 static int mini_pci_2_irq[] = {INTC, INTD, -1, -1};
67
68 switch(dev->bus->number) {
69 case 0:
70 switch(dev->devfn) {
71 case 0x0: // PCI-PCI bridge
72 break;
73 case 0x8: // PCI Card Slot
74 return pci_card_slot_irq[pin - 1];
75 case 0x10: // PMC Slot
76 return pmc_card_slot_irq[pin - 1];
77 case 0x18: // PMC Slot Secondary Agent
78 break;
79 case 0x20: // IXP Processor
80 break;
81 default:
82 return NO_IRQ;
83 }
84 break;
85
86 case 1:
87 switch(dev->devfn) {
88 case 0x0: // IDE Controller
89 return (pin == 1) ? INTC : -1;
90 case 0x8: // USB fun 0
91 case 0x9: // USB fun 1
92 case 0xa: // USB fun 2
93 return usb_irq[pin - 1];
94 case 0x10: // Mini PCI 1
95 return mini_pci_1_irq[pin-1];
96 case 0x18: // Mini PCI 2
97 return mini_pci_2_irq[pin-1];
98 case 0x20: // MEM slot
99 return (pin == 1) ? INTA : -1;
100 default:
101 return NO_IRQ;
102 }
103 break;
104
105 default:
106 return NO_IRQ;
107 }
108
109 return NO_IRQ;
110}
111
Russell Kingcdea4602007-05-30 17:48:45 +0100112static void __init roadrunner_pci_preinit(void)
Lennert Buytenhekc4713072006-03-28 21:18:54 +0100113{
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100114 irq_set_irq_type(IRQ_ROADRUNNER_PCI_INTC, IRQ_TYPE_LEVEL_LOW);
115 irq_set_irq_type(IRQ_ROADRUNNER_PCI_INTD, IRQ_TYPE_LEVEL_LOW);
Lennert Buytenhekc4713072006-03-28 21:18:54 +0100116
117 ixp23xx_pci_preinit();
118}
119
120static struct hw_pci roadrunner_pci __initdata = {
121 .nr_controllers = 1,
122 .preinit = roadrunner_pci_preinit,
123 .setup = ixp23xx_pci_setup,
124 .scan = ixp23xx_pci_scan_bus,
125 .map_irq = roadrunner_map_irq,
126};
127
128static int __init roadrunner_pci_init(void)
129{
130 if (machine_is_roadrunner())
131 pci_common_init(&roadrunner_pci);
132
133 return 0;
134};
135
136subsys_initcall(roadrunner_pci_init);
137
Lennert Buytenhek84b61f62006-06-22 10:30:52 +0100138static struct physmap_flash_data roadrunner_flash_data = {
139 .width = 2,
140};
141
142static struct resource roadrunner_flash_resource = {
143 .start = 0x90000000,
Lennert Buytenhek562ca1e2006-06-27 22:56:17 +0100144 .end = 0x93ffffff,
Lennert Buytenhek84b61f62006-06-22 10:30:52 +0100145 .flags = IORESOURCE_MEM,
146};
147
148static struct platform_device roadrunner_flash = {
149 .name = "physmap-flash",
150 .id = 0,
151 .dev = {
152 .platform_data = &roadrunner_flash_data,
153 },
154 .num_resources = 1,
155 .resource = &roadrunner_flash_resource,
156};
157
Lennert Buytenhekc4713072006-03-28 21:18:54 +0100158static void __init roadrunner_init(void)
159{
Lennert Buytenhek84b61f62006-06-22 10:30:52 +0100160 platform_device_register(&roadrunner_flash);
Lennert Buytenhekc4713072006-03-28 21:18:54 +0100161
162 /*
163 * Mark flash as writeable
164 */
165 IXP23XX_EXP_CS0[0] |= IXP23XX_FLASH_WRITABLE;
166 IXP23XX_EXP_CS0[1] |= IXP23XX_FLASH_WRITABLE;
167 IXP23XX_EXP_CS0[2] |= IXP23XX_FLASH_WRITABLE;
168 IXP23XX_EXP_CS0[3] |= IXP23XX_FLASH_WRITABLE;
169
170 ixp23xx_sys_init();
171}
172
173MACHINE_START(ROADRUNNER, "ADI Engineering RoadRunner Development Platform")
174 /* Maintainer: Deepak Saxena */
Lennert Buytenhekc4713072006-03-28 21:18:54 +0100175 .map_io = ixp23xx_map_io,
176 .init_irq = ixp23xx_init_irq,
177 .timer = &ixp23xx_timer,
Nicolas Pitre36f7a1e2011-07-05 22:38:13 -0400178 .atag_offset = 0x100,
Lennert Buytenhekc4713072006-03-28 21:18:54 +0100179 .init_machine = roadrunner_init,
180MACHINE_END