source: rtems/c/src/lib/libbsp/powerpc/shared/pci/detect_raven_bridge.c @ 674b9497

4.104.114.84.95
Last change on this file since 674b9497 was 674b9497, checked in by Joel Sherrill <joel.sherrill@…>, on 07/18/03 at 17:05:48

2003-07-18 Till Straumann <strauman@…>

PR 415/bsps

  • pci/detect_raven_bridge.c, startup/bspstart.c: This patch reverts enabling MCP interrupts for the motorola_powerpc BSPs. REASON: pci config space scanning (as e.g. done by the DEC Ethernet driver) would raise machine check exceptions.
  • Property mode set to 100644
File size: 4.4 KB
Line 
1/*
2 *  $Id$
3 */
4
5#include <libcpu/io.h>
6#include <libcpu/spr.h>
7
8#include <bsp.h>
9#include <bsp/pci.h>
10#include <bsp/consoleIo.h>
11#include <bsp/residual.h>
12#include <bsp/openpic.h>
13
14#include <rtems/bspIo.h>
15
16#define RAVEN_MPIC_IOSPACE_ENABLE       0x1
17#define RAVEN_MPIC_MEMSPACE_ENABLE      0x2
18#define RAVEN_MASTER_ENABLE             0x4
19#define RAVEN_PARITY_CHECK_ENABLE       0x40
20#define RAVEN_SYSTEM_ERROR_ENABLE       0x100
21#define RAVEN_CLEAR_EVENTS_MASK         0xf9000000
22
23#define RAVEN_MPIC_MEREN                ((volatile unsigned *)0xfeff0020)
24#define RAVEN_MPIC_MERST                ((volatile unsigned *)0xfeff0024)
25/* enable machine check on all conditions */
26#define MEREN_VAL                               0x2f00
27
28#define pci BSP_pci_configuration
29
30extern const pci_config_access_functions pci_direct_functions;
31extern const pci_config_access_functions pci_indirect_functions;
32
33unsigned long
34_BSP_clear_hostbridge_errors(int enableMCP, int quiet)
35{
36unsigned merst;
37
38                merst = in_be32(RAVEN_MPIC_MERST);
39                /* write back value to clear status */
40                out_be32(RAVEN_MPIC_MERST, merst);
41
42                if (enableMCP) {
43                        if (!quiet)
44                                printk("Enabling MCP generation on hostbridge errors\n");
45                        out_be32(RAVEN_MPIC_MEREN, MEREN_VAL);
46                } else {
47                        out_be32(RAVEN_MPIC_MEREN, 0);
48                        if ( !quiet && enableMCP ) {
49                                printk("leaving MCP interrupt disabled\n");
50                        }
51                }
52                return (merst & 0xffff);
53}
54
55void detect_host_bridge()
56{
57  PPC_DEVICE *hostbridge;
58  unsigned int id0;
59  unsigned int tmp;
60 
61  /*
62   * This code assumes that the host bridge is located at
63   * bus 0, dev 0, func 0 AND that the old pre PCI 2.1
64   * standart devices detection mecahnism that was used on PC
65   * (still used in BSD source code) works.
66   */
67  hostbridge=residual_find_device(&residualCopy, PROCESSORDEVICE, NULL,
68                                  BridgeController,
69                                  PCIBridge, -1, 0);
70  if (hostbridge) {
71    if (hostbridge->DeviceId.Interface==PCIBridgeIndirect) {
72      pci.pci_functions=&pci_indirect_functions;
73      /* Should be extracted from residual data,
74       * indeed MPC106 in CHRP mode is different,
75       * but we should not use residual data in
76       * this case anyway.
77       */
78      pci.pci_config_addr = ((volatile unsigned char *)
79                              (ptr_mem_map->io_base+0xcf8));
80      pci.pci_config_data = ptr_mem_map->io_base+0xcfc;
81    } else if(hostbridge->DeviceId.Interface==PCIBridgeDirect) {
82      pci.pci_functions=&pci_direct_functions;
83      pci.pci_config_data=(unsigned char *) 0x80800000;
84    } else {
85    }
86  } else {
87    /* Let us try by experimentation at our own risk! */
88    pci.pci_functions = &pci_direct_functions;
89    /* On all direct bridges I know the host bridge itself
90     * appears as device 0 function 0.
91                 */
92    pci_read_config_dword(0, 0, 0, PCI_VENDOR_ID, &id0);
93    if (id0==~0U) {
94      pci.pci_functions = &pci_indirect_functions;
95      pci.pci_config_addr = ((volatile unsigned char*)
96                              (ptr_mem_map->io_base+0xcf8));
97      pci.pci_config_data = ((volatile unsigned char*)ptr_mem_map->io_base+0xcfc);
98    }
99    /* Here we should check that the host bridge is actually
100     * present, but if it not, we are in such a desperate
101     * situation, that we probably can't even tell it.
102     */
103  }
104  pci_read_config_dword(0, 0, 0, 0, &id0);
105  if(id0 == PCI_VENDOR_ID_MOTOROLA +
106     (PCI_DEVICE_ID_MOTOROLA_RAVEN<<16)) {
107    /*
108     * We have a Raven bridge. We will get information about its settings
109     */
110    pci_read_config_dword(0, 0, 0, PCI_COMMAND, &id0);
111#ifdef SHOW_RAVEN_SETTING   
112    printk("RAVEN PCI command register = %x\n",id0);
113#endif   
114    id0 |= RAVEN_CLEAR_EVENTS_MASK;
115    pci_write_config_dword(0, 0, 0, PCI_COMMAND, id0);
116    pci_read_config_dword(0, 0, 0, PCI_COMMAND, &id0);
117#ifdef SHOW_RAVEN_SETTING   
118    printk("After error clearing RAVEN PCI command register = %x\n",id0);
119#endif   
120   
121    if (id0 & RAVEN_MPIC_IOSPACE_ENABLE) {
122      pci_read_config_dword(0, 0, 0,PCI_BASE_ADDRESS_0, &tmp);
123#ifdef SHOW_RAVEN_SETTING   
124      printk("Raven MPIC is accessed via IO Space Access at address : %x\n",(tmp & ~0x1));
125#endif   
126    }
127    if (id0 & RAVEN_MPIC_MEMSPACE_ENABLE) {
128      pci_read_config_dword(0, 0, 0,PCI_BASE_ADDRESS_1, &tmp);
129#ifdef SHOW_RAVEN_SETTING   
130      printk("Raven MPIC is accessed via memory Space Access at address : %x\n", tmp);
131#endif   
132      OpenPIC=(volatile struct OpenPIC *) (tmp + PREP_ISA_MEM_BASE);
133      printk("OpenPIC found at %x.\n",
134             OpenPIC);
135    }
136  }
137  if (OpenPIC == (volatile struct OpenPIC *)0) {
138    BSP_panic("OpenPic Not found\n");
139  }
140
141}
Note: See TracBrowser for help on using the repository browser.