[ARM] 3615/1: ixp23xx: use platform devices for physmap flash
[linux-2.6.git] / 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 struct physmap_flash_data roadrunner_flash_data = {
141         .width          = 2,
142 };
143
144 static struct resource roadrunner_flash_resource = {
145         .start          = 0x90000000,
146         .end            = 0x94000000,
147         .flags          = IORESOURCE_MEM,
148 };
149
150 static struct platform_device roadrunner_flash = {
151         .name           = "physmap-flash",
152         .id             = 0,
153         .dev            = {
154                 .platform_data  = &roadrunner_flash_data,
155         },
156         .num_resources  = 1,
157         .resource       = &roadrunner_flash_resource,
158 };
159
160 static void __init roadrunner_init(void)
161 {
162         platform_device_register(&roadrunner_flash);
163
164         /*
165          * Mark flash as writeable
166          */
167         IXP23XX_EXP_CS0[0] |= IXP23XX_FLASH_WRITABLE;
168         IXP23XX_EXP_CS0[1] |= IXP23XX_FLASH_WRITABLE;
169         IXP23XX_EXP_CS0[2] |= IXP23XX_FLASH_WRITABLE;
170         IXP23XX_EXP_CS0[3] |= IXP23XX_FLASH_WRITABLE;
171
172         ixp23xx_sys_init();
173 }
174
175 MACHINE_START(ROADRUNNER, "ADI Engineering RoadRunner Development Platform")
176         /* Maintainer: Deepak Saxena */
177         .phys_io        = IXP23XX_PERIPHERAL_PHYS,
178         .io_pg_offst    = ((IXP23XX_PERIPHERAL_VIRT >> 18)) & 0xfffc,
179         .map_io         = ixp23xx_map_io,
180         .init_irq       = ixp23xx_init_irq,
181         .timer          = &ixp23xx_timer,
182         .boot_params    = 0x00000100,
183         .init_machine   = roadrunner_init,
184 MACHINE_END