Changeset 69ed59f in rtems for c/src/lib/libbsp/powerpc/shared/pci/pci.c
- Timestamp:
- 05/14/02 17:10:17 (21 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 6a4df9f9
- Parents:
- 3ce2907
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/powerpc/shared/pci/pci.c
r3ce2907 r69ed59f 15 15 * 16 16 * $Id$ 17 * 18 * Till Straumann, <strauman@slac.stanford.edu>, 1/2002 19 * - separated bridge detection code out of this file 17 20 */ 18 21 19 #include <bsp/consoleIo.h>20 22 #include <libcpu/io.h> 21 23 #include <bsp/pci.h> 22 #include <bsp/residual.h> 23 #include <bsp/openpic.h> 24 #include <bsp.h> 25 24 25 /* allow for overriding these definitions */ 26 #ifndef PCI_CONFIG_ADDR 26 27 #define PCI_CONFIG_ADDR 0xcf8 28 #endif 29 #ifndef PCI_CONFIG_DATA 27 30 #define PCI_CONFIG_DATA 0xcfc 31 #endif 32 28 33 #define PCI_INVALID_VENDORDEVICEID 0xffffffff 29 34 #define PCI_MULTI_FUNCTION 0x80 30 #define RAVEN_MPIC_IOSPACE_ENABLE 0x1 31 #define RAVEN_MPIC_MEMSPACE_ENABLE 0x2 32 #define RAVEN_MASTER_ENABLE 0x4 33 #define RAVEN_PARITY_CHECK_ENABLE 0x40 34 #define RAVEN_SYSTEM_ERROR_ENABLE 0x100 35 #define RAVEN_CLEAR_EVENTS_MASK 0xf9000000 36 35 36 /* define a shortcut */ 37 #define pci BSP_pci_configuration 37 38 38 39 /* … … 107 108 } 108 109 109 static const pci_config_access_functionsindirect_functions = {110 const pci_config_access_functions pci_indirect_functions = { 110 111 indirect_pci_read_config_byte, 111 112 indirect_pci_read_config_word, … … 116 117 }; 117 118 118 pci_config pci= {(volatile unsigned char*)PCI_CONFIG_ADDR,119 pci_config BSP_pci_configuration = {(volatile unsigned char*)PCI_CONFIG_ADDR, 119 120 (volatile unsigned char*)PCI_CONFIG_DATA, 120 & indirect_functions};121 &pci_indirect_functions}; 121 122 122 123 static int … … 206 207 } 207 208 208 static const pci_config_access_functionsdirect_functions = {209 const pci_config_access_functions pci_direct_functions = { 209 210 direct_pci_read_config_byte, 210 211 direct_pci_read_config_word, … … 216 217 217 218 218 void detect_host_bridge()219 {220 PPC_DEVICE *hostbridge;221 unsigned int id0;222 unsigned int tmp;223 224 /*225 * This code assumes that the host bridge is located at226 * bus 0, dev 0, func 0 AND that the old pre PCI 2.1227 * standart devices detection mecahnism that was used on PC228 * (still used in BSD source code) works.229 */230 hostbridge=residual_find_device(&residualCopy, PROCESSORDEVICE, NULL,231 BridgeController,232 PCIBridge, -1, 0);233 if (hostbridge) {234 if (hostbridge->DeviceId.Interface==PCIBridgeIndirect) {235 pci.pci_functions=&indirect_functions;236 /* Should be extracted from residual data,237 * indeed MPC106 in CHRP mode is different,238 * but we should not use residual data in239 * this case anyway.240 */241 pci.pci_config_addr = ((volatile unsigned char *)242 (ptr_mem_map->io_base+0xcf8));243 pci.pci_config_data = ptr_mem_map->io_base+0xcfc;244 } else if(hostbridge->DeviceId.Interface==PCIBridgeDirect) {245 pci.pci_functions=&direct_functions;246 pci.pci_config_data=(unsigned char *) 0x80800000;247 } else {248 }249 } else {250 /* Let us try by experimentation at our own risk! */251 pci.pci_functions = &direct_functions;252 /* On all direct bridges I know the host bridge itself253 * appears as device 0 function 0.254 */255 pci_read_config_dword(0, 0, 0, PCI_VENDOR_ID, &id0);256 if (id0==~0U) {257 pci.pci_functions = &indirect_functions;258 pci.pci_config_addr = ((volatile unsigned char*)259 (ptr_mem_map->io_base+0xcf8));260 pci.pci_config_data = ((volatile unsigned char*)ptr_mem_map->io_base+0xcfc);261 }262 /* Here we should check that the host bridge is actually263 * present, but if it not, we are in such a desperate264 * situation, that we probably can't even tell it.265 */266 }267 pci_read_config_dword(0, 0, 0, 0, &id0);268 if(id0 == PCI_VENDOR_ID_MOTOROLA +269 (PCI_DEVICE_ID_MOTOROLA_RAVEN<<16)) {270 /*271 * We have a Raven bridge. We will get information about its settings272 */273 pci_read_config_dword(0, 0, 0, PCI_COMMAND, &id0);274 #ifdef SHOW_RAVEN_SETTING275 printk("RAVEN PCI command register = %x\n",id0);276 #endif277 id0 |= RAVEN_CLEAR_EVENTS_MASK;278 pci_write_config_dword(0, 0, 0, PCI_COMMAND, id0);279 pci_read_config_dword(0, 0, 0, PCI_COMMAND, &id0);280 #ifdef SHOW_RAVEN_SETTING281 printk("After error clearing RAVEN PCI command register = %x\n",id0);282 #endif283 284 if (id0 & RAVEN_MPIC_IOSPACE_ENABLE) {285 pci_read_config_dword(0, 0, 0,PCI_BASE_ADDRESS_0, &tmp);286 #ifdef SHOW_RAVEN_SETTING287 printk("Raven MPIC is accessed via IO Space Access at address : %x\n",(tmp & ~0x1));288 #endif289 }290 if (id0 & RAVEN_MPIC_MEMSPACE_ENABLE) {291 pci_read_config_dword(0, 0, 0,PCI_BASE_ADDRESS_1, &tmp);292 #ifdef SHOW_RAVEN_SETTING293 printk("Raven MPIC is accessed via memory Space Access at address : %x\n", tmp);294 #endif295 OpenPIC=(volatile struct OpenPIC *) (tmp + PREP_ISA_MEM_BASE);296 printk("OpenPIC found at %p.\n",297 OpenPIC);298 }299 }300 if (OpenPIC == (volatile struct OpenPIC *)0) {301 BSP_panic("OpenPic Not found\n");302 }303 304 }305 306 219 /* 307 220 * This routine determines the maximum bus number in the system … … 309 222 void InitializePCI() 310 223 { 224 extern void detect_host_bridge(); 311 225 unsigned char ucSlotNumber, ucFnNumber, ucNumFuncs; 312 226 unsigned char ucHeader;
Note: See TracChangeset
for help on using the changeset viewer.