8 #include <linux/kernel.h>
9 #include <linux/types.h>
10 #include <linux/pci.h>
12 #include <linux/export.h>
13 #include <linux/slab.h>
17 #include <asm/iommu.h>
27 #define DRIVER_NAME "psycho"
28 #define PFX DRIVER_NAME ": "
31 #define PSYCHO_CONTROL 0x0010UL
32 #define PSYCHO_CONTROL_IMPL 0xf000000000000000UL
33 #define PSYCHO_CONTROL_VER 0x0f00000000000000UL
34 #define PSYCHO_CONTROL_MID 0x00f8000000000000UL
35 #define PSYCHO_CONTROL_IGN 0x0007c00000000000UL
36 #define PSYCHO_CONTROL_RESV 0x00003ffffffffff0UL
37 #define PSYCHO_CONTROL_APCKEN 0x0000000000000008UL
38 #define PSYCHO_CONTROL_APERR 0x0000000000000004UL
39 #define PSYCHO_CONTROL_IAP 0x0000000000000002UL
40 #define PSYCHO_CONTROL_MODE 0x0000000000000001UL
41 #define PSYCHO_PCIA_CTRL 0x2000UL
42 #define PSYCHO_PCIB_CTRL 0x4000UL
43 #define PSYCHO_PCICTRL_RESV1 0xfffffff000000000UL
44 #define PSYCHO_PCICTRL_SBH_ERR 0x0000000800000000UL
45 #define PSYCHO_PCICTRL_SERR 0x0000000400000000UL
46 #define PSYCHO_PCICTRL_SPEED 0x0000000200000000UL
47 #define PSYCHO_PCICTRL_RESV2 0x00000001ffc00000UL
48 #define PSYCHO_PCICTRL_ARB_PARK 0x0000000000200000UL
49 #define PSYCHO_PCICTRL_RESV3 0x00000000001ff800UL
50 #define PSYCHO_PCICTRL_SBH_INT 0x0000000000000400UL
51 #define PSYCHO_PCICTRL_WEN 0x0000000000000200UL
52 #define PSYCHO_PCICTRL_EEN 0x0000000000000100UL
53 #define PSYCHO_PCICTRL_RESV4 0x00000000000000c0UL
54 #define PSYCHO_PCICTRL_AEN 0x000000000000003fUL
66 #define PSYCHO_STRBUF_CONTROL_A 0x2800UL
67 #define PSYCHO_STRBUF_CONTROL_B 0x4800UL
68 #define PSYCHO_STRBUF_CTRL_LPTR 0x00000000000000f0UL
69 #define PSYCHO_STRBUF_CTRL_LENAB 0x0000000000000008UL
70 #define PSYCHO_STRBUF_CTRL_RRDIS 0x0000000000000004UL
71 #define PSYCHO_STRBUF_CTRL_DENAB 0x0000000000000002UL
72 #define PSYCHO_STRBUF_CTRL_ENAB 0x0000000000000001UL
73 #define PSYCHO_STRBUF_FLUSH_A 0x2808UL
74 #define PSYCHO_STRBUF_FLUSH_B 0x4808UL
75 #define PSYCHO_STRBUF_FSYNC_A 0x2810UL
76 #define PSYCHO_STRBUF_FSYNC_B 0x4810UL
77 #define PSYCHO_STC_DATA_A 0xb000UL
78 #define PSYCHO_STC_DATA_B 0xc000UL
79 #define PSYCHO_STC_ERR_A 0xb400UL
80 #define PSYCHO_STC_ERR_B 0xc400UL
81 #define PSYCHO_STC_TAG_A 0xb800UL
82 #define PSYCHO_STC_TAG_B 0xc800UL
83 #define PSYCHO_STC_LINE_A 0xb900UL
84 #define PSYCHO_STC_LINE_B 0xc900UL
89 #define PSYCHO_IOMMU_CONTROL 0x0200UL
90 #define PSYCHO_IOMMU_CTRL_RESV 0xfffffffff9000000UL
91 #define PSYCHO_IOMMU_CTRL_XLTESTAT 0x0000000006000000UL
92 #define PSYCHO_IOMMU_CTRL_XLTEERR 0x0000000001000000UL
93 #define PSYCHO_IOMMU_CTRL_LCKEN 0x0000000000800000UL
94 #define PSYCHO_IOMMU_CTRL_LCKPTR 0x0000000000780000UL
95 #define PSYCHO_IOMMU_CTRL_TSBSZ 0x0000000000070000UL
96 #define PSYCHO_IOMMU_TSBSZ_1K 0x0000000000000000UL
97 #define PSYCHO_IOMMU_TSBSZ_2K 0x0000000000010000UL
98 #define PSYCHO_IOMMU_TSBSZ_4K 0x0000000000020000UL
99 #define PSYCHO_IOMMU_TSBSZ_8K 0x0000000000030000UL
100 #define PSYCHO_IOMMU_TSBSZ_16K 0x0000000000040000UL
101 #define PSYCHO_IOMMU_TSBSZ_32K 0x0000000000050000UL
102 #define PSYCHO_IOMMU_TSBSZ_64K 0x0000000000060000UL
103 #define PSYCHO_IOMMU_TSBSZ_128K 0x0000000000070000UL
104 #define PSYCHO_IOMMU_CTRL_RESV2 0x000000000000fff8UL
105 #define PSYCHO_IOMMU_CTRL_TBWSZ 0x0000000000000004UL
106 #define PSYCHO_IOMMU_CTRL_DENAB 0x0000000000000002UL
107 #define PSYCHO_IOMMU_CTRL_ENAB 0x0000000000000001UL
108 #define PSYCHO_IOMMU_TSBBASE 0x0208UL
109 #define PSYCHO_IOMMU_FLUSH 0x0210UL
110 #define PSYCHO_IOMMU_TAG 0xa580UL
111 #define PSYCHO_IOMMU_DATA 0xa600UL
117 #define PSYCHO_UE_AFSR 0x0030UL
118 #define PSYCHO_UEAFSR_PPIO 0x8000000000000000UL
119 #define PSYCHO_UEAFSR_PDRD 0x4000000000000000UL
120 #define PSYCHO_UEAFSR_PDWR 0x2000000000000000UL
121 #define PSYCHO_UEAFSR_SPIO 0x1000000000000000UL
122 #define PSYCHO_UEAFSR_SDRD 0x0800000000000000UL
123 #define PSYCHO_UEAFSR_SDWR 0x0400000000000000UL
124 #define PSYCHO_UEAFSR_RESV1 0x03ff000000000000UL
125 #define PSYCHO_UEAFSR_BMSK 0x0000ffff00000000UL
126 #define PSYCHO_UEAFSR_DOFF 0x00000000e0000000UL
127 #define PSYCHO_UEAFSR_MID 0x000000001f000000UL
128 #define PSYCHO_UEAFSR_BLK 0x0000000000800000UL
129 #define PSYCHO_UEAFSR_RESV2 0x00000000007fffffUL
130 #define PSYCHO_UE_AFAR 0x0038UL
141 afar = upa_readq(afar_reg);
142 afsr = upa_readq(afsr_reg);
150 upa_writeq(error_bits, afsr_reg);
153 printk(
"%s: Uncorrectable Error, primary error type[%s]\n",
160 "DMA Write" :
"???")))));
161 printk(
"%s: bytemask[%04lx] dword_offset[%lx] UPA_MID[%02lx] was_block(%d)\n",
167 printk(
"%s: UE AFAR [%016lx]\n", pbm->
name, afar);
168 printk(
"%s: UE Secondary errors [", pbm->
name);
195 #define PSYCHO_CE_AFSR 0x0040UL
196 #define PSYCHO_CEAFSR_PPIO 0x8000000000000000UL
197 #define PSYCHO_CEAFSR_PDRD 0x4000000000000000UL
198 #define PSYCHO_CEAFSR_PDWR 0x2000000000000000UL
199 #define PSYCHO_CEAFSR_SPIO 0x1000000000000000UL
200 #define PSYCHO_CEAFSR_SDRD 0x0800000000000000UL
201 #define PSYCHO_CEAFSR_SDWR 0x0400000000000000UL
202 #define PSYCHO_CEAFSR_RESV1 0x0300000000000000UL
203 #define PSYCHO_CEAFSR_ESYND 0x00ff000000000000UL
204 #define PSYCHO_CEAFSR_BMSK 0x0000ffff00000000UL
205 #define PSYCHO_CEAFSR_DOFF 0x00000000e0000000UL
206 #define PSYCHO_CEAFSR_MID 0x000000001f000000UL
207 #define PSYCHO_CEAFSR_BLK 0x0000000000800000UL
208 #define PSYCHO_CEAFSR_RESV2 0x00000000007fffffUL
209 #define PSYCHO_CE_AFAR 0x0040UL
220 afar = upa_readq(afar_reg);
221 afsr = upa_readq(afsr_reg);
229 upa_writeq(error_bits, afsr_reg);
232 printk(
"%s: Correctable Error, primary error type[%s]\n",
239 "DMA Write" :
"???")))));
244 printk(
"%s: syndrome[%02lx] bytemask[%04lx] dword_offset[%lx] "
245 "UPA_MID[%02lx] was_block(%d)\n",
252 printk(
"%s: CE AFAR [%016lx]\n", pbm->
name, afar);
253 printk(
"%s: CE Secondary errors [", pbm->
name);
277 #define PSYCHO_PCI_AFSR_A 0x2010UL
278 #define PSYCHO_PCI_AFSR_B 0x4010UL
279 #define PSYCHO_PCI_AFAR_A 0x2018UL
280 #define PSYCHO_PCI_AFAR_B 0x4018UL
283 #define PSYCHO_ECC_CTRL 0x0020
284 #define PSYCHO_ECCCTRL_EE 0x8000000000000000UL
285 #define PSYCHO_ECCCTRL_UE 0x4000000000000000UL
286 #define PSYCHO_ECCCTRL_CE 0x2000000000000000UL
287 static void psycho_register_error_handlers(
struct pci_pbm_info *pbm)
323 "PSYCHO_PCIERR", pbm);
326 "err=%d\n", pbm->
name, err);
352 static void pbm_config_busmastering(
struct pci_pbm_info *pbm)
372 pbm_config_busmastering(pbm);
379 psycho_register_error_handlers(pbm);
382 #define PSYCHO_IRQ_RETRY 0x1a00UL
383 #define PSYCHO_PCIA_DIAG 0x2020UL
384 #define PSYCHO_PCIB_DIAG 0x4020UL
385 #define PSYCHO_PCIDIAG_RESV 0xffffffffffffff80UL
386 #define PSYCHO_PCIDIAG_DRETRY 0x0000000000000040UL
387 #define PSYCHO_PCIDIAG_DISYNC 0x0000000000000020UL
388 #define PSYCHO_PCIDIAG_DDWSYNC 0x0000000000000010UL
389 #define PSYCHO_PCIDIAG_IDDPAR 0x0000000000000008UL
390 #define PSYCHO_PCIDIAG_IPDPAR 0x0000000000000004UL
391 #define PSYCHO_PCIDIAG_IPAPAR 0x0000000000000002UL
392 #define PSYCHO_PCIDIAG_LPBACK 0x0000000000000001UL
394 static void psycho_controller_hwinit(
struct pci_pbm_info *pbm)
422 static void psycho_pbm_strbuf_init(
struct pci_pbm_info *pbm,
444 pbm->
stc.strbuf_ctxflush = 0;
445 pbm->
stc.strbuf_ctxmatch_base = 0;
447 pbm->
stc.strbuf_flushflag = (
volatile unsigned long *)
448 ((((
unsigned long)&pbm->
stc.__flushflag_buf[0])
451 pbm->
stc.strbuf_flushflag_pa = (
unsigned long)
452 __pa(pbm->
stc.strbuf_flushflag);
462 #undef PSYCHO_STRBUF_RERUN_ENABLE
463 #undef PSYCHO_STRBUF_RERUN_DISABLE
464 control = upa_readq(pbm->
stc.strbuf_control);
467 #ifdef PSYCHO_STRBUF_RERUN_ENABLE
470 #ifdef PSYCHO_STRBUF_RERUN_DISABLE
474 upa_writeq(control, pbm->
stc.strbuf_control);
476 pbm->
stc.strbuf_enabled = 1;
479 #define PSYCHO_IOSPACE_A 0x002000000UL
480 #define PSYCHO_IOSPACE_B 0x002010000UL
481 #define PSYCHO_IOSPACE_SIZE 0x00000ffffUL
482 #define PSYCHO_MEMSPACE_A 0x100000000UL
483 #define PSYCHO_MEMSPACE_B 0x180000000UL
484 #define PSYCHO_MEMSPACE_SIZE 0x07fffffffUL
490 psycho_pbm_strbuf_init(pbm, is_pbm_a);
491 psycho_scan_bus(pbm, &op->
dev);
499 if (pbm->
portid == upa_portid)
505 #define PSYCHO_CONFIGSPACE 0x001000000UL
525 pbm->
sibling = psycho_find_sibling(upa_portid);
529 iommu = kzalloc(
sizeof(
struct iommu),
GFP_KERNEL);
532 goto out_free_controller;
546 is_pbm_a = ((pr_regs[0].
phys_addr & 0x6000) == 0x2000);
561 psycho_controller_hwinit(pbm);
573 psycho_pbm_init(pbm, op, is_pbm_a);
599 .compatible =
"pci108e,8000",
608 .of_match_table = psycho_match,
610 .probe = psycho_probe,
613 static int __init psycho_init(
void)