Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:50

0001 /**
0002  *  @file
0003  */
0004 
0005 /*
0006  *  COPYRIGHT (c) 1989-2012.
0007  *  On-Line Applications Research Corporation (OAR).
0008  *
0009  *  The license and distribution terms for this file may be
0010  *  found in the file LICENSE in this distribution or at
0011  *  http://www.rtems.org/license/LICENSE.
0012  */
0013 
0014 /*
0015  *
0016  *  PCI defines and function prototypes
0017  *  Copyright 1994, Drew Eckhardt
0018  *  Copyright 1997, 1998 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
0019  *
0020  *  For more information, please consult the following manuals (look at
0021  *  http://www.pcisig.com/ for how to get them):
0022  *
0023  *  PCI BIOS Specification
0024  *  PCI Local Bus Specification
0025  *  PCI to PCI Bridge Specification
0026  *  PCI System Design Guide
0027  */
0028 
0029 #ifndef BSP_PCI_H
0030 #define BSP_PCI_H
0031 
0032 #include <rtems/pci.h>
0033 #include <bsp.h>
0034 #include <stdio.h>
0035 
0036 struct _pin_routes
0037 {
0038       int pin, int_name[4];
0039 };
0040 struct _int_map
0041 {
0042       int bus, slot, opts;
0043       struct _pin_routes pin_route[5];
0044 };
0045 struct pcibridge
0046 {
0047   int bus;
0048   int slot;
0049 };
0050 
0051 /* If there's a conflict between a name in the routing table and
0052  * what's already set on the device, reprogram the device setting
0053  * to reflect int_name[0] for the routing table entry
0054  */
0055 #define PCI_FIXUP_OPT_OVERRIDE_NAME (1<<0)
0056 
0057 void FixupPCI( const struct _int_map *, int (*swizzler)(int,int) );
0058 
0059 /* FIXME: This probably belongs into rtems/pci.h */
0060 extern unsigned char pci_bus_count(void);
0061 
0062 int indirect_pci_read_config_byte(
0063   unsigned char bus,
0064   unsigned char slot,
0065   unsigned char function,
0066   unsigned char offset,
0067   uint8_t       *val
0068 );
0069 
0070 int indirect_pci_read_config_word(
0071   unsigned char bus,
0072   unsigned char slot,
0073   unsigned char function,
0074   unsigned char offset,
0075   uint16_t      *val
0076 );
0077 
0078 int indirect_pci_read_config_dword(
0079   unsigned char bus,
0080   unsigned char slot,
0081   unsigned char function,
0082   unsigned char offset,
0083   uint32_t *val
0084 );
0085 
0086 int indirect_pci_write_config_byte(
0087   unsigned char bus,
0088   unsigned char slot,
0089   unsigned char function,
0090   unsigned char offset,
0091   uint8_t       val
0092 );
0093 
0094 int indirect_pci_write_config_word(
0095   unsigned char bus,
0096   unsigned char slot,
0097   unsigned char function,
0098   unsigned char offset,
0099   uint16_t      val
0100 );
0101 
0102 int indirect_pci_write_config_dword(
0103   unsigned char bus,
0104   unsigned char slot,
0105   unsigned char function,
0106   unsigned char offset,
0107   uint32_t      val
0108 );
0109 
0110 /* Can these be moved to the rtems pci.h? */
0111 int FindPCIbridge( int mybus, struct pcibridge *pb );
0112 
0113 extern const pci_config_access_functions pci_indirect_functions;
0114 
0115 void     pci_out_le32( uint32_t base, uint32_t addr, uint32_t val);
0116 void     pci_out_32( uint32_t base, uint32_t addr, uint32_t val);
0117 uint8_t  pci_in_8    ( uint32_t base, uint32_t addr );
0118 int16_t  pci_in_le16 ( uint32_t base, uint32_t addr );
0119 uint32_t pci_in_le32 ( uint32_t base, uint32_t addr );
0120 int16_t  pci_in_16 ( uint32_t base, uint32_t addr );
0121 uint32_t pci_in_32 ( uint32_t base, uint32_t addr );
0122 void     pci_out_8   ( uint32_t base, uint32_t addr, uint8_t val );
0123 void     pci_out_le16( uint32_t base, uint32_t addr, uint16_t val );
0124 void     pci_out_16( uint32_t base, uint32_t addr, uint16_t val );
0125 void     pci_out_32  ( uint32_t base, uint32_t addr, uint32_t val);
0126 
0127 #define out_32(_addr, _val)   pci_out_32(BSP_PCI_BASE_ADDRESS, _addr, _val)
0128 #define out_le32(_addr, _val) pci_out_le32(BSP_PCI_BASE_ADDRESS, _addr, _val)
0129 #define out_32(_addr, _val)   pci_out_32(BSP_PCI_BASE_ADDRESS, _addr, _val)
0130 #define in_8(_addr)           pci_in_8( BSP_PCI_BASE_ADDRESS, _addr )
0131 #define in_le16(_addr)        pci_in_le16( BSP_PCI_BASE_ADDRESS, _addr )
0132 #define in_le32(_addr)        pci_in_le32( BSP_PCI_BASE_ADDRESS, _addr )
0133 #define in_16(_addr)          pci_in_16( BSP_PCI_BASE_ADDRESS, _addr )
0134 #define in_32(_addr)          pci_in_32( BSP_PCI_BASE_ADDRESS, _addr )
0135 #define out_8(_addr,_val)     pci_out_8( BSP_PCI_BASE_ADDRESS, _addr, _val )
0136 #define out_le16(_addr,_val)  pci_out_le16( BSP_PCI_BASE_ADDRESS, _addr, _val )
0137 #define out_16(_addr,_val)    pci_out_16( BSP_PCI_BASE_ADDRESS, _addr, _val )
0138 
0139 #endif /* BSP_PCI_H */