1 | #include <libcpu/io.h> |
---|
2 | #include <libcpu/spr.h> |
---|
3 | |
---|
4 | #include <bsp.h> |
---|
5 | #include <bsp/pci.h> |
---|
6 | |
---|
7 | #include <rtems/bspIo.h> |
---|
8 | |
---|
9 | #define PCI_ERR_BITS 0xf900 |
---|
10 | #define PCI_STATUS_OK(x) (!((x)&PCI_ERR_BITS)) |
---|
11 | |
---|
12 | /* For now, just clear errors in the PCI status reg. |
---|
13 | * |
---|
14 | * Returns: (for diagnostic purposes) |
---|
15 | * original settings (i.e. before applying the clearing |
---|
16 | * sequence) or the error bits or 0 if there were no errors. |
---|
17 | * |
---|
18 | */ |
---|
19 | |
---|
20 | unsigned short |
---|
21 | (*_BSP_clear_vmebridge_errors)(int) = 0; |
---|
22 | |
---|
23 | unsigned long |
---|
24 | _BSP_clear_hostbridge_errors(int enableMCP, int quiet) |
---|
25 | { |
---|
26 | unsigned long rval; |
---|
27 | unsigned short pcistat; |
---|
28 | int count; |
---|
29 | |
---|
30 | if (enableMCP) |
---|
31 | return -1; /* exceptions not supported / MCP not wired */ |
---|
32 | |
---|
33 | /* read error status for info return */ |
---|
34 | pci_read_config_word(0,0,0,PCI_STATUS,&pcistat); |
---|
35 | rval = pcistat; |
---|
36 | |
---|
37 | count=10; |
---|
38 | do { |
---|
39 | /* clear error reporting registers */ |
---|
40 | |
---|
41 | /* clear PCI status register */ |
---|
42 | pci_write_config_word(0,0,0,PCI_STATUS, PCI_ERR_BITS); |
---|
43 | |
---|
44 | /* read new status */ |
---|
45 | pci_read_config_word(0,0,0,PCI_STATUS, &pcistat); |
---|
46 | |
---|
47 | } while ( ! PCI_STATUS_OK(pcistat) && count-- ); |
---|
48 | |
---|
49 | if ( !PCI_STATUS_OK(rval) && !quiet) { |
---|
50 | printk("Cleared PCI errors: pci_stat was 0x%04lx\n", rval); |
---|
51 | } |
---|
52 | if ( !PCI_STATUS_OK(pcistat) ) { |
---|
53 | printk("Unable to clear PCI errors: still 0x%04x after 10 attempts\n", pcistat); |
---|
54 | } |
---|
55 | |
---|
56 | rval &= PCI_ERR_BITS; |
---|
57 | |
---|
58 | /* Some VME bridges (Tsi148) don't propagate VME bus errors to PCI status reg. */ |
---|
59 | if ( _BSP_clear_vmebridge_errors ) |
---|
60 | rval |= _BSP_clear_vmebridge_errors(quiet)<<16; |
---|
61 | |
---|
62 | return rval; |
---|
63 | } |
---|