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/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>
26 #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>
36 #include <mach/hardware.h>
37 #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>
46 #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 
roadrunner_map_irq(const struct pci_dev * dev,u8 idsel,u8 pin)59 static int __init roadrunner_map_irq(const struct pci_dev *dev, u8 idsel,
60 	u8 pin)
61 {
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 
roadrunner_pci_preinit(void)112 static void __init roadrunner_pci_preinit(void)
113 {
114 	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);
116 
117 	ixp23xx_pci_preinit();
118 }
119 
120 static 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 
roadrunner_pci_init(void)128 static int __init roadrunner_pci_init(void)
129 {
130 	if (machine_is_roadrunner())
131 		pci_common_init(&roadrunner_pci);
132 
133 	return 0;
134 };
135 
136 subsys_initcall(roadrunner_pci_init);
137 
138 static struct physmap_flash_data roadrunner_flash_data = {
139 	.width		= 2,
140 };
141 
142 static struct resource roadrunner_flash_resource = {
143 	.start		= 0x90000000,
144 	.end		= 0x93ffffff,
145 	.flags		= IORESOURCE_MEM,
146 };
147 
148 static 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 
roadrunner_init(void)158 static void __init roadrunner_init(void)
159 {
160 	platform_device_register(&roadrunner_flash);
161 
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 
173 MACHINE_START(ROADRUNNER, "ADI Engineering RoadRunner Development Platform")
174 	/* Maintainer: Deepak Saxena */
175 	.map_io		= ixp23xx_map_io,
176 	.init_irq	= ixp23xx_init_irq,
177 	.timer		= &ixp23xx_timer,
178 	.atag_offset	= 0x100,
179 	.init_machine	= roadrunner_init,
180 	.restart	= ixp23xx_restart,
181 MACHINE_END
182