Ignore:
Timestamp:
05/14/02 17:10:17 (21 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
6a4df9f9
Parents:
3ce2907
Message:

2001-05-14 Till Straumann <strauman@…>

  • bootloader/misc.c, console/Makefile.am, console/console.c, console/consoleIo.h, console/inch.c, console/polled_io.c, console/uart.c, console/uart.h, include/bsp.h, irq/Makefile.am, irq/irq.c, irq/irq.h, irq/irq_init.c, openpic/openpic.c, openpic/openpic.h, pci/Makefile.am, pci/pci.c, pci/pci.h, residual/Makefile.am, start/start.S, startup/bspstart.c, vectors/vectors.S, vectors/vectors.h, vectors/vectors_init.c: Per PR216, "libbsp/powerpc/shared" BSP has been modified considerably with the goal to make it more flexible and reusable by other BSPs. The main strategies were:
    • eliminate hardcoded base addresses; devices use offsets and a BSP defined base address.
    • separate functionality into different files (e.g. reboot from inch.c to reboot.c) which can be overridden by a 'derived' BSP.
    • separate initialization code into separate files (e.g. PCI bridge detection/initialization was separated from the more generic PCI access routines), also to make it easier for 'derived' BSPs to substitute their own initialization code.

There are also a couple of enhancements and fixes:

  • IRQ handling code now has a hook for attaching a VME bridge.
  • OpenPIC is now explicitely initialized (polarities, senses). Eliminated the implicit assumption on the presence of an ISA PIC.
  • UART and console driver now supports more than 1 port. The current maximum of 2 can easily be extended by enlarging a table (it would even be easier if the ISR API was not broken by design).
  • fixed polled_io.c so it correctly supports console on COM2
  • fixed TLB invalidation code (start.S).
  • exception handler prints a stack backtrace.
  • added BSP_pciFindDevice() to scan the pci bus for a particular vendor/device/instance.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/shared/pci/pci.c

    r3ce2907 r69ed59f  
    1515 *
    1616 *  $Id$
     17 *
     18 *  Till Straumann, <strauman@slac.stanford.edu>, 1/2002
     19 *   - separated bridge detection code out of this file
    1720 */
    1821
    19 #include <bsp/consoleIo.h>
    2022#include <libcpu/io.h>
    2123#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
    2627#define PCI_CONFIG_ADDR                 0xcf8
     28#endif
     29#ifndef PCI_CONFIG_DATA
    2730#define PCI_CONFIG_DATA                 0xcfc
     31#endif
     32
    2833#define PCI_INVALID_VENDORDEVICEID      0xffffffff
    2934#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
    3738
    3839/*
     
    107108}
    108109
    109 static const pci_config_access_functions indirect_functions = {
     110const pci_config_access_functions pci_indirect_functions = {
    110111        indirect_pci_read_config_byte,
    111112        indirect_pci_read_config_word,
     
    116117};
    117118
    118 pci_config pci = {(volatile unsigned char*)PCI_CONFIG_ADDR,
     119pci_config BSP_pci_configuration = {(volatile unsigned char*)PCI_CONFIG_ADDR,
    119120                         (volatile unsigned char*)PCI_CONFIG_DATA,
    120                          &indirect_functions};
     121                         &pci_indirect_functions};
    121122
    122123static int
     
    206207}
    207208
    208 static const pci_config_access_functions direct_functions = {
     209const pci_config_access_functions pci_direct_functions = {
    209210        direct_pci_read_config_byte,
    210211        direct_pci_read_config_word,
     
    216217
    217218
    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 at
    226    * bus 0, dev 0, func 0 AND that the old pre PCI 2.1
    227    * standart devices detection mecahnism that was used on PC
    228    * (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 in
    239        * 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 itself
    253      * 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 actually
    263      * present, but if it not, we are in such a desperate
    264      * 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 settings
    272      */
    273     pci_read_config_dword(0, 0, 0, PCI_COMMAND, &id0);
    274 #ifdef SHOW_RAVEN_SETTING   
    275     printk("RAVEN PCI command register = %x\n",id0);
    276 #endif   
    277     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_SETTING   
    281     printk("After error clearing RAVEN PCI command register = %x\n",id0);
    282 #endif   
    283    
    284     if (id0 & RAVEN_MPIC_IOSPACE_ENABLE) {
    285       pci_read_config_dword(0, 0, 0,PCI_BASE_ADDRESS_0, &tmp);
    286 #ifdef SHOW_RAVEN_SETTING   
    287       printk("Raven MPIC is accessed via IO Space Access at address : %x\n",(tmp & ~0x1));
    288 #endif   
    289     }
    290     if (id0 & RAVEN_MPIC_MEMSPACE_ENABLE) {
    291       pci_read_config_dword(0, 0, 0,PCI_BASE_ADDRESS_1, &tmp);
    292 #ifdef SHOW_RAVEN_SETTING   
    293       printk("Raven MPIC is accessed via memory Space Access at address : %x\n", tmp);
    294 #endif   
    295       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 
    306219/*
    307220 * This routine determines the maximum bus number in the system
     
    309222void InitializePCI()
    310223{
     224  extern void detect_host_bridge();
    311225  unsigned char ucSlotNumber, ucFnNumber, ucNumFuncs;
    312226  unsigned char ucHeader;
Note: See TracChangeset for help on using the changeset viewer.