1 | /* |
---|
2 | * detect_host_bridge.c |
---|
3 | * |
---|
4 | * This code is inspired by detect_grackle_bridge.c of SVGM BSP |
---|
5 | * written by Till Straumann |
---|
6 | * Copyright (C) 2001, 2003 Till Straumann <strauman@slac.stanford.edu> |
---|
7 | * |
---|
8 | * Copyright (C) 2004 S. Kate Feng, <feng1@bnl.gov> |
---|
9 | * wrote it to support the MVME5500 board. |
---|
10 | * |
---|
11 | */ |
---|
12 | #include <libcpu/io.h> |
---|
13 | #include <rtems/bspIo.h> /* printk */ |
---|
14 | |
---|
15 | #include <bsp/pci.h> |
---|
16 | #include <bsp/gtreg.h> |
---|
17 | #include <bsp/gtpcireg.h> |
---|
18 | |
---|
19 | #include <stdio.h> |
---|
20 | #include <string.h> |
---|
21 | |
---|
22 | #define PCI_DEBUG 0 |
---|
23 | |
---|
24 | #define HOSTBRIDGET_ERROR 0xf0000000 |
---|
25 | |
---|
26 | unsigned long _BSP_clear_hostbridge_errors(int enableMCP, int quiet) |
---|
27 | { |
---|
28 | uint32_t pcidata, pcidata1; |
---|
29 | int PciLocal, busNumber=0; |
---|
30 | |
---|
31 | /* On the mvme5500 board, the GT64260B system controller had the MCP |
---|
32 | * signal pulled up high. Thus, the MCP signal is not used as it is |
---|
33 | * on other boards such as mvme2307. |
---|
34 | */ |
---|
35 | if (enableMCP) return(-1); |
---|
36 | for (PciLocal=0; PciLocal<1; PciLocal++ ) { |
---|
37 | pci_read_config_dword(busNumber, |
---|
38 | 0, |
---|
39 | 0, |
---|
40 | PCI_COMMAND, |
---|
41 | &pcidata); |
---|
42 | |
---|
43 | if (!quiet) |
---|
44 | printk("Before _BSP_clear_hostbridge_errors(): 0x%x, cause 0x%x\n", |
---|
45 | pcidata, inl(0x1d58)); |
---|
46 | |
---|
47 | outl(0,0x1d58); |
---|
48 | |
---|
49 | /* Clear the error on the host bridge */ |
---|
50 | pcidata1= pcidata; |
---|
51 | pcidata1 |= PCI_STATUS_CLRERR_MASK; |
---|
52 | pcidata1 |= 0x140; |
---|
53 | pci_write_config_dword(busNumber, |
---|
54 | 0, |
---|
55 | 0, |
---|
56 | PCI_COMMAND, |
---|
57 | pcidata1); |
---|
58 | |
---|
59 | pci_read_config_dword(busNumber, |
---|
60 | 0, |
---|
61 | 0, |
---|
62 | PCI_COMMAND, |
---|
63 | &pcidata1); |
---|
64 | |
---|
65 | if (!quiet) printk("After _BSP_clear_hostbridge_errors(): sts 0x%x\n", |
---|
66 | pcidata1); |
---|
67 | if (pcidata1 & HOSTBRIDGET_ERROR) printk("BSP_clear_hostbridge_errors(): unable to clear pending hostbridge errors\n"); |
---|
68 | busNumber += BSP_MAX_PCI_BUS_ON_PCI0; |
---|
69 | } |
---|
70 | return(pcidata & HOSTBRIDGET_ERROR); |
---|
71 | } |
---|