aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/pci/pci-vr41xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/pci/pci-vr41xx.c')
-rw-r--r--arch/mips/pci/pci-vr41xx.c88
1 files changed, 52 insertions, 36 deletions
diff --git a/arch/mips/pci/pci-vr41xx.c b/arch/mips/pci/pci-vr41xx.c
index f3ccbf7fada4..91df4da7ddb9 100644
--- a/arch/mips/pci/pci-vr41xx.c
+++ b/arch/mips/pci/pci-vr41xx.c
@@ -3,8 +3,8 @@
3 * 3 *
4 * Copyright (C) 2001-2003 MontaVista Software Inc. 4 * Copyright (C) 2001-2003 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com> 5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com>
6 * Copyright (C) 2004 Yoichi Yuasa <yuasa@hh.iij4u.or.jp> 6 * Copyright (C) 2004-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
7 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org) 7 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
@@ -31,12 +31,18 @@
31 31
32#include <asm/cpu.h> 32#include <asm/cpu.h>
33#include <asm/io.h> 33#include <asm/io.h>
34#include <asm/vr41xx/pci.h>
34#include <asm/vr41xx/vr41xx.h> 35#include <asm/vr41xx/vr41xx.h>
35 36
36#include "pci-vr41xx.h" 37#include "pci-vr41xx.h"
37 38
38extern struct pci_ops vr41xx_pci_ops; 39extern struct pci_ops vr41xx_pci_ops;
39 40
41static void __iomem *pciu_base;
42
43#define pciu_read(offset) readl(pciu_base + (offset))
44#define pciu_write(offset, value) writel((value), pciu_base + (offset))
45
40static struct pci_master_address_conversion pci_master_memory1 = { 46static struct pci_master_address_conversion pci_master_memory1 = {
41 .bus_base_address = PCI_MASTER_MEM1_BUS_BASE_ADDRESS, 47 .bus_base_address = PCI_MASTER_MEM1_BUS_BASE_ADDRESS,
42 .address_mask = PCI_MASTER_MEM1_ADDRESS_MASK, 48 .address_mask = PCI_MASTER_MEM1_ADDRESS_MASK,
@@ -113,6 +119,15 @@ static int __init vr41xx_pciu_init(void)
113 119
114 setup = &vr41xx_pci_controller_unit_setup; 120 setup = &vr41xx_pci_controller_unit_setup;
115 121
122 if (request_mem_region(PCIU_BASE, PCIU_SIZE, "PCIU") == NULL)
123 return -EBUSY;
124
125 pciu_base = ioremap(PCIU_BASE, PCIU_SIZE);
126 if (pciu_base == NULL) {
127 release_mem_region(PCIU_BASE, PCIU_SIZE);
128 return -EBUSY;
129 }
130
116 /* Disable PCI interrupt */ 131 /* Disable PCI interrupt */
117 vr41xx_disable_pciint(); 132 vr41xx_disable_pciint();
118 133
@@ -129,14 +144,14 @@ static int __init vr41xx_pciu_init(void)
129 pci_clock_max = PCI_CLOCK_MAX; 144 pci_clock_max = PCI_CLOCK_MAX;
130 vtclock = vr41xx_get_vtclock_frequency(); 145 vtclock = vr41xx_get_vtclock_frequency();
131 if (vtclock < pci_clock_max) 146 if (vtclock < pci_clock_max)
132 writel(EQUAL_VTCLOCK, PCICLKSELREG); 147 pciu_write(PCICLKSELREG, EQUAL_VTCLOCK);
133 else if ((vtclock / 2) < pci_clock_max) 148 else if ((vtclock / 2) < pci_clock_max)
134 writel(HALF_VTCLOCK, PCICLKSELREG); 149 pciu_write(PCICLKSELREG, HALF_VTCLOCK);
135 else if (current_cpu_data.processor_id >= PRID_VR4131_REV2_1 && 150 else if (current_cpu_data.processor_id >= PRID_VR4131_REV2_1 &&
136 (vtclock / 3) < pci_clock_max) 151 (vtclock / 3) < pci_clock_max)
137 writel(ONE_THIRD_VTCLOCK, PCICLKSELREG); 152 pciu_write(PCICLKSELREG, ONE_THIRD_VTCLOCK);
138 else if ((vtclock / 4) < pci_clock_max) 153 else if ((vtclock / 4) < pci_clock_max)
139 writel(QUARTER_VTCLOCK, PCICLKSELREG); 154 pciu_write(PCICLKSELREG, QUARTER_VTCLOCK);
140 else { 155 else {
141 printk(KERN_ERR "PCI Clock is over 33MHz.\n"); 156 printk(KERN_ERR "PCI Clock is over 33MHz.\n");
142 return -EINVAL; 157 return -EINVAL;
@@ -151,11 +166,11 @@ static int __init vr41xx_pciu_init(void)
151 MASTER_MSK(master->address_mask) | 166 MASTER_MSK(master->address_mask) |
152 WINEN | 167 WINEN |
153 PCIA(master->pci_base_address); 168 PCIA(master->pci_base_address);
154 writel(val, PCIMMAW1REG); 169 pciu_write(PCIMMAW1REG, val);
155 } else { 170 } else {
156 val = readl(PCIMMAW1REG); 171 val = pciu_read(PCIMMAW1REG);
157 val &= ~WINEN; 172 val &= ~WINEN;
158 writel(val, PCIMMAW1REG); 173 pciu_write(PCIMMAW1REG, val);
159 } 174 }
160 175
161 if (setup->master_memory2 != NULL) { 176 if (setup->master_memory2 != NULL) {
@@ -164,11 +179,11 @@ static int __init vr41xx_pciu_init(void)
164 MASTER_MSK(master->address_mask) | 179 MASTER_MSK(master->address_mask) |
165 WINEN | 180 WINEN |
166 PCIA(master->pci_base_address); 181 PCIA(master->pci_base_address);
167 writel(val, PCIMMAW2REG); 182 pciu_write(PCIMMAW2REG, val);
168 } else { 183 } else {
169 val = readl(PCIMMAW2REG); 184 val = pciu_read(PCIMMAW2REG);
170 val &= ~WINEN; 185 val &= ~WINEN;
171 writel(val, PCIMMAW2REG); 186 pciu_write(PCIMMAW2REG, val);
172 } 187 }
173 188
174 if (setup->target_memory1 != NULL) { 189 if (setup->target_memory1 != NULL) {
@@ -176,11 +191,11 @@ static int __init vr41xx_pciu_init(void)
176 val = TARGET_MSK(target->address_mask) | 191 val = TARGET_MSK(target->address_mask) |
177 WINEN | 192 WINEN |
178 ITA(target->bus_base_address); 193 ITA(target->bus_base_address);
179 writel(val, PCITAW1REG); 194 pciu_write(PCITAW1REG, val);
180 } else { 195 } else {
181 val = readl(PCITAW1REG); 196 val = pciu_read(PCITAW1REG);
182 val &= ~WINEN; 197 val &= ~WINEN;
183 writel(val, PCITAW1REG); 198 pciu_write(PCITAW1REG, val);
184 } 199 }
185 200
186 if (setup->target_memory2 != NULL) { 201 if (setup->target_memory2 != NULL) {
@@ -188,11 +203,11 @@ static int __init vr41xx_pciu_init(void)
188 val = TARGET_MSK(target->address_mask) | 203 val = TARGET_MSK(target->address_mask) |
189 WINEN | 204 WINEN |
190 ITA(target->bus_base_address); 205 ITA(target->bus_base_address);
191 writel(val, PCITAW2REG); 206 pciu_write(PCITAW2REG, val);
192 } else { 207 } else {
193 val = readl(PCITAW2REG); 208 val = pciu_read(PCITAW2REG);
194 val &= ~WINEN; 209 val &= ~WINEN;
195 writel(val, PCITAW2REG); 210 pciu_write(PCITAW2REG, val);
196 } 211 }
197 212
198 if (setup->master_io != NULL) { 213 if (setup->master_io != NULL) {
@@ -201,50 +216,50 @@ static int __init vr41xx_pciu_init(void)
201 MASTER_MSK(master->address_mask) | 216 MASTER_MSK(master->address_mask) |
202 WINEN | 217 WINEN |
203 PCIIA(master->pci_base_address); 218 PCIIA(master->pci_base_address);
204 writel(val, PCIMIOAWREG); 219 pciu_write(PCIMIOAWREG, val);
205 } else { 220 } else {
206 val = readl(PCIMIOAWREG); 221 val = pciu_read(PCIMIOAWREG);
207 val &= ~WINEN; 222 val &= ~WINEN;
208 writel(val, PCIMIOAWREG); 223 pciu_write(PCIMIOAWREG, val);
209 } 224 }
210 225
211 if (setup->exclusive_access == CANNOT_LOCK_FROM_DEVICE) 226 if (setup->exclusive_access == CANNOT_LOCK_FROM_DEVICE)
212 writel(UNLOCK, PCIEXACCREG); 227 pciu_write(PCIEXACCREG, UNLOCK);
213 else 228 else
214 writel(0, PCIEXACCREG); 229 pciu_write(PCIEXACCREG, 0);
215 230
216 if (current_cpu_data.cputype == CPU_VR4122) 231 if (current_cpu_data.cputype == CPU_VR4122)
217 writel(TRDYV(setup->wait_time_limit_from_irdy_to_trdy), PCITRDYVREG); 232 pciu_write(PCITRDYVREG, TRDYV(setup->wait_time_limit_from_irdy_to_trdy));
218 233
219 writel(MLTIM(setup->master_latency_timer), LATTIMEREG); 234 pciu_write(LATTIMEREG, MLTIM(setup->master_latency_timer));
220 235
221 if (setup->mailbox != NULL) { 236 if (setup->mailbox != NULL) {
222 mailbox = setup->mailbox; 237 mailbox = setup->mailbox;
223 val = MBADD(mailbox->base_address) | TYPE_32BITSPACE | 238 val = MBADD(mailbox->base_address) | TYPE_32BITSPACE |
224 MSI_MEMORY | PREF_APPROVAL; 239 MSI_MEMORY | PREF_APPROVAL;
225 writel(val, MAILBAREG); 240 pciu_write(MAILBAREG, val);
226 } 241 }
227 242
228 if (setup->target_window1) { 243 if (setup->target_window1) {
229 window = setup->target_window1; 244 window = setup->target_window1;
230 val = PMBA(window->base_address) | TYPE_32BITSPACE | 245 val = PMBA(window->base_address) | TYPE_32BITSPACE |
231 MSI_MEMORY | PREF_APPROVAL; 246 MSI_MEMORY | PREF_APPROVAL;
232 writel(val, PCIMBA1REG); 247 pciu_write(PCIMBA1REG, val);
233 } 248 }
234 249
235 if (setup->target_window2) { 250 if (setup->target_window2) {
236 window = setup->target_window2; 251 window = setup->target_window2;
237 val = PMBA(window->base_address) | TYPE_32BITSPACE | 252 val = PMBA(window->base_address) | TYPE_32BITSPACE |
238 MSI_MEMORY | PREF_APPROVAL; 253 MSI_MEMORY | PREF_APPROVAL;
239 writel(val, PCIMBA2REG); 254 pciu_write(PCIMBA2REG, val);
240 } 255 }
241 256
242 val = readl(RETVALREG); 257 val = pciu_read(RETVALREG);
243 val &= ~RTYVAL_MASK; 258 val &= ~RTYVAL_MASK;
244 val |= RTYVAL(setup->retry_limit); 259 val |= RTYVAL(setup->retry_limit);
245 writel(val, RETVALREG); 260 pciu_write(RETVALREG, val);
246 261
247 val = readl(PCIAPCNTREG); 262 val = pciu_read(PCIAPCNTREG);
248 val &= ~(TKYGNT | PAPC); 263 val &= ~(TKYGNT | PAPC);
249 264
250 switch (setup->arbiter_priority_control) { 265 switch (setup->arbiter_priority_control) {
@@ -262,15 +277,16 @@ static int __init vr41xx_pciu_init(void)
262 if (setup->take_away_gnt_mode == PCI_TAKE_AWAY_GNT_ENABLE) 277 if (setup->take_away_gnt_mode == PCI_TAKE_AWAY_GNT_ENABLE)
263 val |= TKYGNT_ENABLE; 278 val |= TKYGNT_ENABLE;
264 279
265 writel(val, PCIAPCNTREG); 280 pciu_write(PCIAPCNTREG, val);
266 281
267 writel(PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | 282 pciu_write(COMMANDREG, PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
268 PCI_COMMAND_PARITY | PCI_COMMAND_SERR, COMMANDREG); 283 PCI_COMMAND_MASTER | PCI_COMMAND_PARITY |
284 PCI_COMMAND_SERR);
269 285
270 /* Clear bus error */ 286 /* Clear bus error */
271 readl(BUSERRADREG); 287 pciu_read(BUSERRADREG);
272 288
273 writel(BLOODY_CONFIG_DONE, PCIENREG); 289 pciu_write(PCIENREG, PCIU_CONFIG_DONE);
274 290
275 if (setup->mem_resource != NULL) 291 if (setup->mem_resource != NULL)
276 vr41xx_pci_controller.mem_resource = setup->mem_resource; 292 vr41xx_pci_controller.mem_resource = setup->mem_resource;