Merge branch 'rio.b19' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/bird
[linux-2.6] / arch / arm / mach-ixp23xx / roadrunner.c
1 /*
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
17 #include <linux/config.h>
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/spinlock.h>
21 #include <linux/sched.h>
22 #include <linux/interrupt.h>
23 #include <linux/serial.h>
24 #include <linux/tty.h>
25 #include <linux/bitops.h>
26 #include <linux/ioport.h>
27 #include <linux/serial.h>
28 #include <linux/serial_8250.h>
29 #include <linux/serial_core.h>
30 #include <linux/device.h>
31 #include <linux/mm.h>
32 #include <linux/pci.h>
33 #include <linux/mtd/physmap.h>
34
35 #include <asm/types.h>
36 #include <asm/setup.h>
37 #include <asm/memory.h>
38 #include <asm/hardware.h>
39 #include <asm/mach-types.h>
40 #include <asm/irq.h>
41 #include <asm/system.h>
42 #include <asm/tlbflush.h>
43 #include <asm/pgtable.h>
44
45 #include <asm/mach/map.h>
46 #include <asm/mach/irq.h>
47 #include <asm/mach/arch.h>
48 #include <asm/mach/irq.h>
49 #include <asm/mach/pci.h>
50
51 /*
52  * Interrupt mapping
53  */
54 #define INTA            IRQ_ROADRUNNER_PCI_INTA
55 #define INTB            IRQ_ROADRUNNER_PCI_INTB
56 #define INTC            IRQ_ROADRUNNER_PCI_INTC
57 #define INTD            IRQ_ROADRUNNER_PCI_INTD
58
59 #define INTC_PIN        IXP23XX_GPIO_PIN_11
60 #define INTD_PIN        IXP23XX_GPIO_PIN_12
61
62 static int __init roadrunner_map_irq(struct pci_dev *dev, u8 idsel, u8 pin)
63 {
64         static int pci_card_slot_irq[] = {INTB, INTC, INTD, INTA};
65         static int pmc_card_slot_irq[] = {INTA, INTB, INTC, INTD};
66         static int usb_irq[] = {INTB, INTC, INTD, -1};
67         static int mini_pci_1_irq[] = {INTB, INTC, -1, -1};
68         static int mini_pci_2_irq[] = {INTC, INTD, -1, -1};
69
70         switch(dev->bus->number) {
71                 case 0:
72                         switch(dev->devfn) {
73                         case 0x0: // PCI-PCI bridge
74                                 break;
75                         case 0x8: // PCI Card Slot
76                                 return pci_card_slot_irq[pin - 1];
77                         case 0x10: // PMC Slot
78                                 return pmc_card_slot_irq[pin - 1];
79                         case 0x18: // PMC Slot Secondary Agent
80                                 break;
81                         case 0x20: // IXP Processor
82                                 break;
83                         default:
84                                 return NO_IRQ;
85                         }
86                         break;
87
88                 case 1:
89                         switch(dev->devfn) {
90                         case 0x0: // IDE Controller
91                                 return (pin == 1) ? INTC : -1;
92                         case 0x8: // USB fun 0
93                         case 0x9: // USB fun 1
94                         case 0xa: // USB fun 2
95                                 return usb_irq[pin - 1];
96                         case 0x10: // Mini PCI 1
97                                 return mini_pci_1_irq[pin-1];
98                         case 0x18: // Mini PCI 2
99                                 return mini_pci_2_irq[pin-1];
100                         case 0x20: // MEM slot
101                                 return (pin == 1) ? INTA : -1;
102                         default:
103                                 return NO_IRQ;
104                         }
105                         break;
106
107                 default:
108                         return NO_IRQ;
109         }
110
111         return NO_IRQ;
112 }
113
114 static void roadrunner_pci_preinit(void)
115 {
116         set_irq_type(IRQ_ROADRUNNER_PCI_INTC, IRQT_LOW);
117         set_irq_type(IRQ_ROADRUNNER_PCI_INTD, IRQT_LOW);
118
119         ixp23xx_pci_preinit();
120 }
121
122 static struct hw_pci roadrunner_pci __initdata = {
123         .nr_controllers = 1,
124         .preinit        = roadrunner_pci_preinit,
125         .setup          = ixp23xx_pci_setup,
126         .scan           = ixp23xx_pci_scan_bus,
127         .map_irq        = roadrunner_map_irq,
128 };
129
130 static int __init roadrunner_pci_init(void)
131 {
132         if (machine_is_roadrunner())
133                 pci_common_init(&roadrunner_pci);
134
135         return 0;
136 };
137
138 subsys_initcall(roadrunner_pci_init);
139
140 static void __init roadrunner_init(void)
141 {
142         physmap_configure(0x90000000, 0x04000000, 2, NULL);
143
144         /*
145          * Mark flash as writeable
146          */
147         IXP23XX_EXP_CS0[0] |= IXP23XX_FLASH_WRITABLE;
148         IXP23XX_EXP_CS0[1] |= IXP23XX_FLASH_WRITABLE;
149         IXP23XX_EXP_CS0[2] |= IXP23XX_FLASH_WRITABLE;
150         IXP23XX_EXP_CS0[3] |= IXP23XX_FLASH_WRITABLE;
151
152         ixp23xx_sys_init();
153 }
154
155 MACHINE_START(ROADRUNNER, "ADI Engineering RoadRunner Development Platform")
156         /* Maintainer: Deepak Saxena */
157         .phys_io        = IXP23XX_PERIPHERAL_PHYS,
158         .io_pg_offst    = ((IXP23XX_PERIPHERAL_VIRT >> 18)) & 0xfffc,
159         .map_io         = ixp23xx_map_io,
160         .init_irq       = ixp23xx_init_irq,
161         .timer          = &ixp23xx_timer,
162         .boot_params    = 0x00000100,
163         .init_machine   = roadrunner_init,
164 MACHINE_END