1
2
3
4
5
6
7
8
9
10#include <linux/module.h>
11#include <linux/types.h>
12#include <linux/mm.h>
13#include <linux/ioport.h>
14#include <linux/list.h>
15#include <linux/init.h>
16#include <linux/io.h>
17#include <linux/spinlock.h>
18
19#include <asm/pgtable.h>
20#include <asm/page.h>
21#include <asm/irq.h>
22#include <asm/mach-types.h>
23#include <asm/setup.h>
24#include <asm/hardware/dec21285.h>
25
26#include <asm/mach/irq.h>
27#include <asm/mach/map.h>
28
29#include "common.h"
30
31unsigned int mem_fclk_21285 = 50000000;
32
33EXPORT_SYMBOL(mem_fclk_21285);
34
35static int __init early_fclk(char *arg)
36{
37 mem_fclk_21285 = simple_strtoul(arg, NULL, 0);
38 return 0;
39}
40
41early_param("mem_fclk_21285", early_fclk);
42
43static int __init parse_tag_memclk(const struct tag *tag)
44{
45 mem_fclk_21285 = tag->u.memclk.fmemclk;
46 return 0;
47}
48
49__tagtable(ATAG_MEMCLK, parse_tag_memclk);
50
51
52
53
54
55static const int fb_irq_mask[] = {
56 IRQ_MASK_UART_RX,
57 IRQ_MASK_UART_TX,
58 IRQ_MASK_TIMER1,
59 IRQ_MASK_TIMER2,
60 IRQ_MASK_TIMER3,
61 IRQ_MASK_IN0,
62 IRQ_MASK_IN1,
63 IRQ_MASK_IN2,
64 IRQ_MASK_IN3,
65 IRQ_MASK_DOORBELLHOST,
66 IRQ_MASK_DMA1,
67 IRQ_MASK_DMA2,
68 IRQ_MASK_PCI,
69 IRQ_MASK_SDRAMPARITY,
70 IRQ_MASK_I2OINPOST,
71 IRQ_MASK_PCI_ABORT,
72 IRQ_MASK_PCI_SERR,
73 IRQ_MASK_DISCARD_TIMER,
74 IRQ_MASK_PCI_DPERR,
75 IRQ_MASK_PCI_PERR,
76};
77
78static void fb_mask_irq(struct irq_data *d)
79{
80 *CSR_IRQ_DISABLE = fb_irq_mask[_DC21285_INR(d->irq)];
81}
82
83static void fb_unmask_irq(struct irq_data *d)
84{
85 *CSR_IRQ_ENABLE = fb_irq_mask[_DC21285_INR(d->irq)];
86}
87
88static struct irq_chip fb_chip = {
89 .irq_ack = fb_mask_irq,
90 .irq_mask = fb_mask_irq,
91 .irq_unmask = fb_unmask_irq,
92};
93
94static void __init __fb_init_irq(void)
95{
96 unsigned int irq;
97
98
99
100
101 *CSR_IRQ_DISABLE = -1;
102 *CSR_FIQ_DISABLE = -1;
103
104 for (irq = _DC21285_IRQ(0); irq < _DC21285_IRQ(20); irq++) {
105 set_irq_chip(irq, &fb_chip);
106 set_irq_handler(irq, handle_level_irq);
107 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
108 }
109}
110
111void __init footbridge_init_irq(void)
112{
113 __fb_init_irq();
114
115 if (!footbridge_cfn_mode())
116 return;
117
118 if (machine_is_ebsa285())
119
120
121
122
123
124 isa_init_irq(IRQ_PCI);
125
126 if (machine_is_cats())
127 isa_init_irq(IRQ_IN2);
128
129 if (machine_is_netwinder())
130 isa_init_irq(IRQ_IN3);
131}
132
133
134
135
136
137
138static struct map_desc fb_common_io_desc[] __initdata = {
139 {
140 .virtual = ARMCSR_BASE,
141 .pfn = __phys_to_pfn(DC21285_ARMCSR_BASE),
142 .length = ARMCSR_SIZE,
143 .type = MT_DEVICE,
144 }, {
145 .virtual = XBUS_BASE,
146 .pfn = __phys_to_pfn(0x40000000),
147 .length = XBUS_SIZE,
148 .type = MT_DEVICE,
149 }
150};
151
152
153
154
155
156static struct map_desc ebsa285_host_io_desc[] __initdata = {
157#if defined(CONFIG_ARCH_FOOTBRIDGE) && defined(CONFIG_FOOTBRIDGE_HOST)
158 {
159 .virtual = PCIMEM_BASE,
160 .pfn = __phys_to_pfn(DC21285_PCI_MEM),
161 .length = PCIMEM_SIZE,
162 .type = MT_DEVICE,
163 }, {
164 .virtual = PCICFG0_BASE,
165 .pfn = __phys_to_pfn(DC21285_PCI_TYPE_0_CONFIG),
166 .length = PCICFG0_SIZE,
167 .type = MT_DEVICE,
168 }, {
169 .virtual = PCICFG1_BASE,
170 .pfn = __phys_to_pfn(DC21285_PCI_TYPE_1_CONFIG),
171 .length = PCICFG1_SIZE,
172 .type = MT_DEVICE,
173 }, {
174 .virtual = PCIIACK_BASE,
175 .pfn = __phys_to_pfn(DC21285_PCI_IACK),
176 .length = PCIIACK_SIZE,
177 .type = MT_DEVICE,
178 }, {
179 .virtual = PCIO_BASE,
180 .pfn = __phys_to_pfn(DC21285_PCI_IO),
181 .length = PCIO_SIZE,
182 .type = MT_DEVICE,
183 },
184#endif
185};
186
187void __init footbridge_map_io(void)
188{
189
190
191
192
193 iotable_init(fb_common_io_desc, ARRAY_SIZE(fb_common_io_desc));
194
195
196
197
198
199 if (footbridge_cfn_mode())
200 iotable_init(ebsa285_host_io_desc, ARRAY_SIZE(ebsa285_host_io_desc));
201}
202
203#ifdef CONFIG_FOOTBRIDGE_ADDIN
204
205static inline unsigned long fb_bus_sdram_offset(void)
206{
207 return *CSR_PCISDRAMBASE & 0xfffffff0;
208}
209
210
211
212
213
214
215unsigned long __virt_to_bus(unsigned long res)
216{
217 WARN_ON(res < PAGE_OFFSET || res >= (unsigned long)high_memory);
218
219 return res + (fb_bus_sdram_offset() - PAGE_OFFSET);
220}
221EXPORT_SYMBOL(__virt_to_bus);
222
223unsigned long __bus_to_virt(unsigned long res)
224{
225 res = res - (fb_bus_sdram_offset() - PAGE_OFFSET);
226
227 WARN_ON(res < PAGE_OFFSET || res >= (unsigned long)high_memory);
228
229 return res;
230}
231EXPORT_SYMBOL(__bus_to_virt);
232
233unsigned long __pfn_to_bus(unsigned long pfn)
234{
235 return __pfn_to_phys(pfn) + (fb_bus_sdram_offset() - PHYS_OFFSET);
236}
237EXPORT_SYMBOL(__pfn_to_bus);
238
239unsigned long __bus_to_pfn(unsigned long bus)
240{
241 return __phys_to_pfn(bus - (fb_bus_sdram_offset() - PHYS_OFFSET));
242}
243EXPORT_SYMBOL(__bus_to_pfn);
244
245#endif
246