diff options
author | David S. Miller <davem@davemloft.net> | 2008-09-10 07:13:10 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-09-11 02:14:46 -0400 |
commit | 87395fc6781ff269bad7f972b8abf2312a8ccdf6 (patch) | |
tree | 8b47f5a0b948cb3aac1f19f1d63d90e9be478909 /arch/sparc64/kernel/pci_psycho.c | |
parent | e6e003720fd7123482f77dcec19e930d272937fe (diff) |
sparc64: Kill hand-crafted I/O accessors in PCI controller drivers.
Use existing upa_{read,write}q() interfaces instead.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64/kernel/pci_psycho.c')
-rw-r--r-- | arch/sparc64/kernel/pci_psycho.c | 69 |
1 files changed, 25 insertions, 44 deletions
diff --git a/arch/sparc64/kernel/pci_psycho.c b/arch/sparc64/kernel/pci_psycho.c index bac9c1ba40e0..897334680657 100644 --- a/arch/sparc64/kernel/pci_psycho.c +++ b/arch/sparc64/kernel/pci_psycho.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <asm/irq.h> | 17 | #include <asm/irq.h> |
18 | #include <asm/starfire.h> | 18 | #include <asm/starfire.h> |
19 | #include <asm/prom.h> | 19 | #include <asm/prom.h> |
20 | #include <asm/upa.h> | ||
20 | 21 | ||
21 | #include "pci_impl.h" | 22 | #include "pci_impl.h" |
22 | #include "iommu_common.h" | 23 | #include "iommu_common.h" |
@@ -25,25 +26,6 @@ | |||
25 | #define DRIVER_NAME "psycho" | 26 | #define DRIVER_NAME "psycho" |
26 | #define PFX DRIVER_NAME ": " | 27 | #define PFX DRIVER_NAME ": " |
27 | 28 | ||
28 | /* All PSYCHO registers are 64-bits. The following accessor | ||
29 | * routines are how they are accessed. The REG parameter | ||
30 | * is a physical address. | ||
31 | */ | ||
32 | #define psycho_read(__reg) \ | ||
33 | ({ u64 __ret; \ | ||
34 | __asm__ __volatile__("ldxa [%1] %2, %0" \ | ||
35 | : "=r" (__ret) \ | ||
36 | : "r" (__reg), "i" (ASI_PHYS_BYPASS_EC_E) \ | ||
37 | : "memory"); \ | ||
38 | __ret; \ | ||
39 | }) | ||
40 | #define psycho_write(__reg, __val) \ | ||
41 | __asm__ __volatile__("stxa %0, [%1] %2" \ | ||
42 | : /* no outputs */ \ | ||
43 | : "r" (__val), "r" (__reg), \ | ||
44 | "i" (ASI_PHYS_BYPASS_EC_E) \ | ||
45 | : "memory") | ||
46 | |||
47 | /* Misc. PSYCHO PCI controller register offsets and definitions. */ | 29 | /* Misc. PSYCHO PCI controller register offsets and definitions. */ |
48 | #define PSYCHO_CONTROL 0x0010UL | 30 | #define PSYCHO_CONTROL 0x0010UL |
49 | #define PSYCHO_CONTROL_IMPL 0xf000000000000000UL /* Implementation of this PSYCHO*/ | 31 | #define PSYCHO_CONTROL_IMPL 0xf000000000000000UL /* Implementation of this PSYCHO*/ |
@@ -182,8 +164,8 @@ static irqreturn_t psycho_ue_intr(int irq, void *dev_id) | |||
182 | int reported; | 164 | int reported; |
183 | 165 | ||
184 | /* Latch uncorrectable error status. */ | 166 | /* Latch uncorrectable error status. */ |
185 | afar = psycho_read(afar_reg); | 167 | afar = upa_readq(afar_reg); |
186 | afsr = psycho_read(afsr_reg); | 168 | afsr = upa_readq(afsr_reg); |
187 | 169 | ||
188 | /* Clear the primary/secondary error status bits. */ | 170 | /* Clear the primary/secondary error status bits. */ |
189 | error_bits = afsr & | 171 | error_bits = afsr & |
@@ -191,7 +173,7 @@ static irqreturn_t psycho_ue_intr(int irq, void *dev_id) | |||
191 | PSYCHO_UEAFSR_SPIO | PSYCHO_UEAFSR_SDRD | PSYCHO_UEAFSR_SDWR); | 173 | PSYCHO_UEAFSR_SPIO | PSYCHO_UEAFSR_SDRD | PSYCHO_UEAFSR_SDWR); |
192 | if (!error_bits) | 174 | if (!error_bits) |
193 | return IRQ_NONE; | 175 | return IRQ_NONE; |
194 | psycho_write(afsr_reg, error_bits); | 176 | upa_writeq(error_bits, afsr_reg); |
195 | 177 | ||
196 | /* Log the error. */ | 178 | /* Log the error. */ |
197 | printk("%s: Uncorrectable Error, primary error type[%s]\n", | 179 | printk("%s: Uncorrectable Error, primary error type[%s]\n", |
@@ -261,8 +243,8 @@ static irqreturn_t psycho_ce_intr(int irq, void *dev_id) | |||
261 | int reported; | 243 | int reported; |
262 | 244 | ||
263 | /* Latch error status. */ | 245 | /* Latch error status. */ |
264 | afar = psycho_read(afar_reg); | 246 | afar = upa_readq(afar_reg); |
265 | afsr = psycho_read(afsr_reg); | 247 | afsr = upa_readq(afsr_reg); |
266 | 248 | ||
267 | /* Clear primary/secondary error status bits. */ | 249 | /* Clear primary/secondary error status bits. */ |
268 | error_bits = afsr & | 250 | error_bits = afsr & |
@@ -270,7 +252,7 @@ static irqreturn_t psycho_ce_intr(int irq, void *dev_id) | |||
270 | PSYCHO_CEAFSR_SPIO | PSYCHO_CEAFSR_SDRD | PSYCHO_CEAFSR_SDWR); | 252 | PSYCHO_CEAFSR_SPIO | PSYCHO_CEAFSR_SDRD | PSYCHO_CEAFSR_SDWR); |
271 | if (!error_bits) | 253 | if (!error_bits) |
272 | return IRQ_NONE; | 254 | return IRQ_NONE; |
273 | psycho_write(afsr_reg, error_bits); | 255 | upa_writeq(error_bits, afsr_reg); |
274 | 256 | ||
275 | /* Log the error. */ | 257 | /* Log the error. */ |
276 | printk("%s: Correctable Error, primary error type[%s]\n", | 258 | printk("%s: Correctable Error, primary error type[%s]\n", |
@@ -373,27 +355,26 @@ static void psycho_register_error_handlers(struct pci_pbm_info *pbm) | |||
373 | "err=%d\n", pbm->name, err); | 355 | "err=%d\n", pbm->name, err); |
374 | 356 | ||
375 | /* Enable UE and CE interrupts for controller. */ | 357 | /* Enable UE and CE interrupts for controller. */ |
376 | psycho_write(base + PSYCHO_ECC_CTRL, | 358 | upa_writeq((PSYCHO_ECCCTRL_EE | |
377 | (PSYCHO_ECCCTRL_EE | | 359 | PSYCHO_ECCCTRL_UE | |
378 | PSYCHO_ECCCTRL_UE | | 360 | PSYCHO_ECCCTRL_CE), base + PSYCHO_ECC_CTRL); |
379 | PSYCHO_ECCCTRL_CE)); | ||
380 | 361 | ||
381 | /* Enable PCI Error interrupts and clear error | 362 | /* Enable PCI Error interrupts and clear error |
382 | * bits for each PBM. | 363 | * bits for each PBM. |
383 | */ | 364 | */ |
384 | tmp = psycho_read(base + PSYCHO_PCIA_CTRL); | 365 | tmp = upa_readq(base + PSYCHO_PCIA_CTRL); |
385 | tmp |= (PSYCHO_PCICTRL_SERR | | 366 | tmp |= (PSYCHO_PCICTRL_SERR | |
386 | PSYCHO_PCICTRL_SBH_ERR | | 367 | PSYCHO_PCICTRL_SBH_ERR | |
387 | PSYCHO_PCICTRL_EEN); | 368 | PSYCHO_PCICTRL_EEN); |
388 | tmp &= ~(PSYCHO_PCICTRL_SBH_INT); | 369 | tmp &= ~(PSYCHO_PCICTRL_SBH_INT); |
389 | psycho_write(base + PSYCHO_PCIA_CTRL, tmp); | 370 | upa_writeq(tmp, base + PSYCHO_PCIA_CTRL); |
390 | 371 | ||
391 | tmp = psycho_read(base + PSYCHO_PCIB_CTRL); | 372 | tmp = upa_readq(base + PSYCHO_PCIB_CTRL); |
392 | tmp |= (PSYCHO_PCICTRL_SERR | | 373 | tmp |= (PSYCHO_PCICTRL_SERR | |
393 | PSYCHO_PCICTRL_SBH_ERR | | 374 | PSYCHO_PCICTRL_SBH_ERR | |
394 | PSYCHO_PCICTRL_EEN); | 375 | PSYCHO_PCICTRL_EEN); |
395 | tmp &= ~(PSYCHO_PCICTRL_SBH_INT); | 376 | tmp &= ~(PSYCHO_PCICTRL_SBH_INT); |
396 | psycho_write(base + PSYCHO_PCIB_CTRL, tmp); | 377 | upa_writeq(tmp, base + PSYCHO_PCIB_CTRL); |
397 | } | 378 | } |
398 | 379 | ||
399 | /* PSYCHO boot time probing and initialization. */ | 380 | /* PSYCHO boot time probing and initialization. */ |
@@ -443,28 +424,28 @@ static void psycho_controller_hwinit(struct pci_pbm_info *pbm) | |||
443 | { | 424 | { |
444 | u64 tmp; | 425 | u64 tmp; |
445 | 426 | ||
446 | psycho_write(pbm->controller_regs + PSYCHO_IRQ_RETRY, 5); | 427 | upa_writeq(5, pbm->controller_regs + PSYCHO_IRQ_RETRY); |
447 | 428 | ||
448 | /* Enable arbiter for all PCI slots. */ | 429 | /* Enable arbiter for all PCI slots. */ |
449 | tmp = psycho_read(pbm->controller_regs + PSYCHO_PCIA_CTRL); | 430 | tmp = upa_readq(pbm->controller_regs + PSYCHO_PCIA_CTRL); |
450 | tmp |= PSYCHO_PCICTRL_AEN; | 431 | tmp |= PSYCHO_PCICTRL_AEN; |
451 | psycho_write(pbm->controller_regs + PSYCHO_PCIA_CTRL, tmp); | 432 | upa_writeq(tmp, pbm->controller_regs + PSYCHO_PCIA_CTRL); |
452 | 433 | ||
453 | tmp = psycho_read(pbm->controller_regs + PSYCHO_PCIB_CTRL); | 434 | tmp = upa_readq(pbm->controller_regs + PSYCHO_PCIB_CTRL); |
454 | tmp |= PSYCHO_PCICTRL_AEN; | 435 | tmp |= PSYCHO_PCICTRL_AEN; |
455 | psycho_write(pbm->controller_regs + PSYCHO_PCIB_CTRL, tmp); | 436 | upa_writeq(tmp, pbm->controller_regs + PSYCHO_PCIB_CTRL); |
456 | 437 | ||
457 | /* Disable DMA write / PIO read synchronization on | 438 | /* Disable DMA write / PIO read synchronization on |
458 | * both PCI bus segments. | 439 | * both PCI bus segments. |
459 | * [ U2P Erratum 1243770, STP2223BGA data sheet ] | 440 | * [ U2P Erratum 1243770, STP2223BGA data sheet ] |
460 | */ | 441 | */ |
461 | tmp = psycho_read(pbm->controller_regs + PSYCHO_PCIA_DIAG); | 442 | tmp = upa_readq(pbm->controller_regs + PSYCHO_PCIA_DIAG); |
462 | tmp |= PSYCHO_PCIDIAG_DDWSYNC; | 443 | tmp |= PSYCHO_PCIDIAG_DDWSYNC; |
463 | psycho_write(pbm->controller_regs + PSYCHO_PCIA_DIAG, tmp); | 444 | upa_writeq(tmp, pbm->controller_regs + PSYCHO_PCIA_DIAG); |
464 | 445 | ||
465 | tmp = psycho_read(pbm->controller_regs + PSYCHO_PCIB_DIAG); | 446 | tmp = upa_readq(pbm->controller_regs + PSYCHO_PCIB_DIAG); |
466 | tmp |= PSYCHO_PCIDIAG_DDWSYNC; | 447 | tmp |= PSYCHO_PCIDIAG_DDWSYNC; |
467 | psycho_write(pbm->controller_regs + PSYCHO_PCIB_DIAG, tmp); | 448 | upa_writeq(tmp, pbm->controller_regs + PSYCHO_PCIB_DIAG); |
468 | } | 449 | } |
469 | 450 | ||
470 | static void psycho_pbm_strbuf_init(struct pci_pbm_info *pbm, | 451 | static void psycho_pbm_strbuf_init(struct pci_pbm_info *pbm, |
@@ -509,7 +490,7 @@ static void psycho_pbm_strbuf_init(struct pci_pbm_info *pbm, | |||
509 | */ | 490 | */ |
510 | #undef PSYCHO_STRBUF_RERUN_ENABLE | 491 | #undef PSYCHO_STRBUF_RERUN_ENABLE |
511 | #undef PSYCHO_STRBUF_RERUN_DISABLE | 492 | #undef PSYCHO_STRBUF_RERUN_DISABLE |
512 | control = psycho_read(pbm->stc.strbuf_control); | 493 | control = upa_readq(pbm->stc.strbuf_control); |
513 | control |= PSYCHO_STRBUF_CTRL_ENAB; | 494 | control |= PSYCHO_STRBUF_CTRL_ENAB; |
514 | control &= ~(PSYCHO_STRBUF_CTRL_LENAB | PSYCHO_STRBUF_CTRL_LPTR); | 495 | control &= ~(PSYCHO_STRBUF_CTRL_LENAB | PSYCHO_STRBUF_CTRL_LPTR); |
515 | #ifdef PSYCHO_STRBUF_RERUN_ENABLE | 496 | #ifdef PSYCHO_STRBUF_RERUN_ENABLE |
@@ -519,7 +500,7 @@ static void psycho_pbm_strbuf_init(struct pci_pbm_info *pbm, | |||
519 | control |= PSYCHO_STRBUF_CTRL_RRDIS; | 500 | control |= PSYCHO_STRBUF_CTRL_RRDIS; |
520 | #endif | 501 | #endif |
521 | #endif | 502 | #endif |
522 | psycho_write(pbm->stc.strbuf_control, control); | 503 | upa_writeq(control, pbm->stc.strbuf_control); |
523 | 504 | ||
524 | pbm->stc.strbuf_enabled = 1; | 505 | pbm->stc.strbuf_enabled = 1; |
525 | } | 506 | } |