forked from Imagelibrary/rtems
pci.h cleanup - Consolidate common defines to cpukit pci.h
+ libbsp/sparc/shared/include/pci.h was largely a copy of an older version of the cpukit pci.h. Removed much of the contents and included <rtems/pci.h>. + sparc/*/pci*.c - Move to <rtems/pci.h> required updating to use uint32_t for dword accesses. + Rename PCI_MULTI_FUNCTION to PCI_HEADER_TYPE_MULTI_FUNCTION + Define PCI_HEADER_TYPE_MULTI_FUNCTION in cpukit pci.h and remove PCI_MULTI_FUNCTION definitions in C files. + Move PCI_INVALID_VENDORDEVICEID definitions from various C files to cpukit pci.h
This commit is contained in:
@@ -220,8 +220,6 @@ pcib_find_by_class(int classCode, int idx, int *sig)
|
||||
return PCIB_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
#define PCI_MULTI_FUNCTION 0x80
|
||||
|
||||
static uint8_t ucBusCount = 0xff;
|
||||
|
||||
unsigned char
|
||||
|
||||
@@ -37,9 +37,6 @@
|
||||
#define PCI_CONFIG_DATA 0xcfc
|
||||
#endif
|
||||
|
||||
#define PCI_INVALID_VENDORDEVICEID 0xffffffff
|
||||
#define PCI_MULTI_FUNCTION 0x80
|
||||
|
||||
/* define a shortcut */
|
||||
#define pci BSP_pci_configuration
|
||||
|
||||
@@ -727,7 +724,7 @@ void FixupPCI( const struct _int_map *bspmap, int (*swizzler)(int,int) )
|
||||
|
||||
/* got a device */
|
||||
pci_read_config_byte(pbus, pslot, 0, PCI_HEADER_TYPE, &cvalue);
|
||||
nfuns = cvalue & PCI_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1;
|
||||
nfuns = cvalue & PCI_HEADER_TYPE_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1;
|
||||
for (pfun=0; pfun< nfuns; pfun++) {
|
||||
|
||||
pci_read_config_word(pbus, pslot, pfun, PCI_DEVICE_ID, &devid);
|
||||
@@ -1032,7 +1029,7 @@ int pci_initialize(void)
|
||||
}
|
||||
|
||||
pci_read_config_byte(0, slot, 0, PCI_HEADER_TYPE, &ucHeader);
|
||||
if (ucHeader & PCI_MULTI_FUNCTION) {
|
||||
if (ucHeader & PCI_HEADER_TYPE_MULTI_FUNCTION) {
|
||||
ucNumFuncs = PCI_MAX_FUNCTIONS;
|
||||
} else {
|
||||
ucNumFuncs=1;
|
||||
|
||||
@@ -62,8 +62,6 @@
|
||||
*
|
||||
* ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
|
||||
*/
|
||||
#define PCI_INVALID_VENDORDEVICEID 0xffffffff
|
||||
#define PCI_MULTI_FUNCTION 0x80
|
||||
|
||||
#define PCI_DEBUG
|
||||
|
||||
@@ -245,7 +243,7 @@ BSP_PciScanHandle BSP_pciScan(
|
||||
d
|
||||
);
|
||||
#endif
|
||||
hd = (hd & PCI_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1);
|
||||
hd = (hd & PCI_HEADER_TYPE_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1);
|
||||
}
|
||||
|
||||
(void)pci_read_config_dword(bus,dev,fun,PCI_VENDOR_ID,&d);
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
* List all PCI Devices
|
||||
*/
|
||||
|
||||
#define PCI_INVALID_VENDORDEVICEID 0xffffffff
|
||||
#define PCI_MULTI_FUNCTION 0x80
|
||||
|
||||
#define PCI_DEBUG
|
||||
|
||||
#include <inttypes.h>
|
||||
@@ -92,7 +89,7 @@ void pci_list_devices( void )
|
||||
|
||||
if ( 0 == fun ) {
|
||||
pci_read_config_byte(bus,dev,0, PCI_HEADER_TYPE, &hd);
|
||||
hd = (hd & PCI_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1);
|
||||
hd = (hd & PCI_HEADER_TYPE_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1);
|
||||
}
|
||||
|
||||
(void)pci_read_config_dword(bus,dev,fun,PCI_VENDOR_ID,&d);
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
|
||||
#define PCI_DEBUG 0
|
||||
|
||||
#define PCI_INVALID_VENDORDEVICEID 0xffffffff
|
||||
#define PCI_MULTI_FUNCTION 0x80
|
||||
#define HOSTBRIDGET_ERROR 0xf0000000
|
||||
|
||||
unsigned long _BSP_clear_hostbridge_errors(int enableMCP, int quiet)
|
||||
|
||||
@@ -54,8 +54,6 @@
|
||||
#define PCI1_CONFIG_DATA 0xc7c
|
||||
#endif
|
||||
|
||||
#define PCI_INVALID_VENDORDEVICEID 0xffffffff
|
||||
#define PCI_MULTI_FUNCTION 0x80
|
||||
#define HOSTBRIDGET_ERROR 0xf0000000
|
||||
|
||||
#define GT64x60_PCI_CONFIG_ADDR GT64x60_REG_BASE + PCI_CONFIG_ADDR
|
||||
@@ -367,7 +365,7 @@ int pci_initialize(void)
|
||||
0,
|
||||
PCI_CACHE_LINE_SIZE,
|
||||
&ulHeader);
|
||||
if ((ulHeader>>16)&PCI_MULTI_FUNCTION)
|
||||
if ((ulHeader>>16)&PCI_HEADER_TYPE_MULTI_FUNCTION)
|
||||
ucNumFuncs=PCI_MAX_FUNCTIONS;
|
||||
else
|
||||
ucNumFuncs=1;
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#define PCI_INVALID_VENDORDEVICEID 0xffffffff
|
||||
#define PCI_MULTI_FUNCTION 0x80
|
||||
|
||||
|
||||
#include <bsp/pci.h>
|
||||
#include <rtems/bspIo.h>
|
||||
#include <bsp.h>
|
||||
@@ -42,7 +38,7 @@ int pci_find_device( unsigned short vendorid, unsigned short deviceid,
|
||||
for (bus=0; bus<BSP_MAX_PCI_BUS; bus++) {
|
||||
for (dev=0; dev<PCI_MAX_DEVICES; dev++) {
|
||||
pci_read_config_byte(bus, dev, 0, PCI_HEADER_TYPE, &hd);
|
||||
hd = (hd & PCI_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1);
|
||||
hd = (hd & PCI_HEADER_TYPE_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1);
|
||||
for (fun=0; fun<hd; fun++) {
|
||||
/*
|
||||
* The last devfn id/slot is special; must skip it
|
||||
|
||||
@@ -34,9 +34,6 @@
|
||||
#define PCI_CONFIG_DATA 0xcfc
|
||||
#endif
|
||||
|
||||
#define PCI_INVALID_VENDORDEVICEID 0xffffffff
|
||||
#define PCI_MULTI_FUNCTION 0x80
|
||||
|
||||
/* define a shortcut */
|
||||
#define pci BSP_pci_configuration
|
||||
|
||||
@@ -411,7 +408,7 @@ void FixupPCI( const struct _int_map *bspmap, int (*swizzler)(int,int) )
|
||||
|
||||
/* got a device */
|
||||
pci_read_config_byte(pbus, pslot, 0, PCI_HEADER_TYPE, &cvalue);
|
||||
nfuns = cvalue & PCI_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1;
|
||||
nfuns = cvalue & PCI_HEADER_TYPE_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1;
|
||||
|
||||
for (pfun=0; pfun< nfuns; pfun++) {
|
||||
pci_read_config_word(pbus, pslot, pfun, PCI_DEVICE_ID, &devid);
|
||||
@@ -604,7 +601,7 @@ int pci_initialize(void)
|
||||
continue;
|
||||
}
|
||||
pci_read_config_byte(0, ucSlotNumber, 0, PCI_HEADER_TYPE, &ucHeader);
|
||||
if (ucHeader&PCI_MULTI_FUNCTION) {
|
||||
if (ucHeader&PCI_HEADER_TYPE_MULTI_FUNCTION) {
|
||||
ucNumFuncs=PCI_MAX_FUNCTIONS;
|
||||
} else {
|
||||
ucNumFuncs=1;
|
||||
|
||||
@@ -46,8 +46,6 @@
|
||||
*
|
||||
* ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
|
||||
*/
|
||||
#define PCI_INVALID_VENDORDEVICEID 0xffffffff
|
||||
#define PCI_MULTI_FUNCTION 0x80
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <bsp/pci.h>
|
||||
@@ -188,7 +186,7 @@ BSP_pciScan(
|
||||
|
||||
if ( 0 == fun ) {
|
||||
pci_read_config_byte(bus,dev,0, PCI_HEADER_TYPE, &hd);
|
||||
hd = (hd & PCI_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1);
|
||||
hd = (hd & PCI_HEADER_TYPE_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1);
|
||||
}
|
||||
|
||||
(void)pci_read_config_dword(bus,dev,fun,PCI_VENDOR_ID,&d);
|
||||
|
||||
@@ -44,9 +44,6 @@
|
||||
#define PCI_CONFIG_DATA 0xcfc
|
||||
#endif
|
||||
|
||||
#define PCI_INVALID_VENDORDEVICEID 0xffffffff
|
||||
#define PCI_MULTI_FUNCTION 0x80
|
||||
|
||||
/* define a shortcut */
|
||||
#define pci BSP_pci_configuration
|
||||
|
||||
@@ -442,7 +439,7 @@ void pci_allocate_resources(void) {
|
||||
|
||||
pci_read_config_byte(0, slot, 0, PCI_HEADER_TYPE, &header);
|
||||
|
||||
if(header & PCI_MULTI_FUNCTION) {
|
||||
if(header & PCI_HEADER_TYPE_MULTI_FUNCTION) {
|
||||
numfuncs = PCI_MAX_FUNCTIONS;
|
||||
}
|
||||
else {
|
||||
@@ -535,7 +532,7 @@ done:
|
||||
|
||||
pci_read_config_byte(0, slot, 0, PCI_HEADER_TYPE, &header);
|
||||
|
||||
if(header & PCI_MULTI_FUNCTION) {
|
||||
if(header & PCI_HEADER_TYPE_MULTI_FUNCTION) {
|
||||
numfuncs = PCI_MAX_FUNCTIONS;
|
||||
}
|
||||
else {
|
||||
@@ -617,7 +614,7 @@ int init_pci(void)
|
||||
0,
|
||||
PCI_HEADER_TYPE,
|
||||
&ucHeader);
|
||||
if(ucHeader&PCI_MULTI_FUNCTION) {
|
||||
if(ucHeader&PCI_HEADER_TYPE_MULTI_FUNCTION) {
|
||||
ucNumFuncs=PCI_MAX_FUNCTIONS;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -57,9 +57,6 @@
|
||||
#define PCI_CONFIG_DATA 0xcfc
|
||||
#endif
|
||||
|
||||
#define PCI_INVALID_VENDORDEVICEID 0xffffffff
|
||||
#define PCI_MULTI_FUNCTION 0x80
|
||||
|
||||
/* define a shortcut */
|
||||
#define pci BSP_pci_configuration
|
||||
|
||||
@@ -103,7 +100,7 @@ BSP_pci_read_config_dword(
|
||||
unsigned char slot,
|
||||
unsigned char function,
|
||||
unsigned char offset,
|
||||
unsigned int *val
|
||||
uint32_t *val
|
||||
)
|
||||
{
|
||||
volatile unsigned int *pci_conf;
|
||||
@@ -136,7 +133,7 @@ BSP_pci_read_config_dword(
|
||||
|
||||
static int
|
||||
BSP_pci_read_config_word(unsigned char bus, unsigned char slot, unsigned char function, unsigned char offset, unsigned short *val) {
|
||||
unsigned int v;
|
||||
uint32_t v;
|
||||
|
||||
if (offset & 1) return PCIBIOS_BAD_REGISTER_NUMBER;
|
||||
|
||||
@@ -149,7 +146,7 @@ BSP_pci_read_config_word(unsigned char bus, unsigned char slot, unsigned char fu
|
||||
|
||||
static int
|
||||
BSP_pci_read_config_byte(unsigned char bus, unsigned char slot, unsigned char function, unsigned char offset, unsigned char *val) {
|
||||
unsigned int v;
|
||||
uint32_t v;
|
||||
|
||||
pci_read_config_dword(bus, slot, function, offset&~3, &v);
|
||||
|
||||
@@ -160,7 +157,7 @@ BSP_pci_read_config_byte(unsigned char bus, unsigned char slot, unsigned char fu
|
||||
|
||||
|
||||
static int
|
||||
BSP_pci_write_config_dword(unsigned char bus, unsigned char slot, unsigned char function, unsigned char offset, unsigned int val) {
|
||||
BSP_pci_write_config_dword(unsigned char bus, unsigned char slot, unsigned char function, unsigned char offset, uint32_t val) {
|
||||
|
||||
volatile unsigned int *pci_conf;
|
||||
unsigned int value;
|
||||
@@ -187,7 +184,7 @@ BSP_pci_write_config_dword(unsigned char bus, unsigned char slot, unsigned char
|
||||
|
||||
static int
|
||||
BSP_pci_write_config_word(unsigned char bus, unsigned char slot, unsigned char function, unsigned char offset, unsigned short val) {
|
||||
unsigned int v;
|
||||
uint32_t v;
|
||||
|
||||
if (offset & 1) return PCIBIOS_BAD_REGISTER_NUMBER;
|
||||
|
||||
@@ -201,7 +198,7 @@ BSP_pci_write_config_word(unsigned char bus, unsigned char slot, unsigned char f
|
||||
|
||||
static int
|
||||
BSP_pci_write_config_byte(unsigned char bus, unsigned char slot, unsigned char function, unsigned char offset, unsigned char val) {
|
||||
unsigned int v;
|
||||
uint32_t v;
|
||||
|
||||
pci_read_config_dword(bus, slot, function, offset&~3, &v);
|
||||
|
||||
@@ -231,7 +228,10 @@ rtems_pci_config_t BSP_pci_configuration = {
|
||||
int init_grpci(void) {
|
||||
|
||||
volatile unsigned int *page0 = (unsigned volatile int *) PCI_MEM_START;
|
||||
unsigned int data, addr;
|
||||
uint32_t data;
|
||||
#ifndef BT_ENABLED
|
||||
uint32_t addr;
|
||||
#endif
|
||||
|
||||
#ifndef BT_ENABLED
|
||||
pci_write_config_dword(0,0,0,0x10, 0xffffffff);
|
||||
@@ -301,7 +301,7 @@ int dma_from_pci(unsigned int ahb_addr, unsigned int pci_addr, unsigned int len)
|
||||
|
||||
|
||||
void pci_mem_enable(unsigned char bus, unsigned char slot, unsigned char function) {
|
||||
unsigned int data;
|
||||
uint32_t data;
|
||||
|
||||
pci_read_config_dword(0, slot, function, PCI_COMMAND, &data);
|
||||
pci_write_config_dword(0, slot, function, PCI_COMMAND, data | PCI_COMMAND_MEMORY);
|
||||
@@ -309,7 +309,7 @@ void pci_mem_enable(unsigned char bus, unsigned char slot, unsigned char functio
|
||||
}
|
||||
|
||||
void pci_master_enable(unsigned char bus, unsigned char slot, unsigned char function) {
|
||||
unsigned int data;
|
||||
uint32_t data;
|
||||
|
||||
pci_read_config_dword(0, slot, function, PCI_COMMAND, &data);
|
||||
pci_write_config_dword(0, slot, function, PCI_COMMAND, data | PCI_COMMAND_MASTER);
|
||||
@@ -337,7 +337,8 @@ static inline void swap_res(struct pci_res **p1, struct pci_res **p2) {
|
||||
*/
|
||||
void pci_allocate_resources(void) {
|
||||
|
||||
unsigned int slot, numfuncs, func, id, pos, size, tmp, i, swapped, addr, dev, fn;
|
||||
unsigned int slot, numfuncs, func, pos, i, swapped, addr, dev, fn;
|
||||
uint32_t id, tmp, size;
|
||||
unsigned char header;
|
||||
struct pci_res **res;
|
||||
|
||||
@@ -362,7 +363,7 @@ void pci_allocate_resources(void) {
|
||||
|
||||
pci_read_config_byte(0, slot, 0, PCI_HEADER_TYPE, &header);
|
||||
|
||||
if(header & PCI_MULTI_FUNCTION) {
|
||||
if(header & PCI_HEADER_TYPE_MULTI_FUNCTION) {
|
||||
numfuncs = PCI_MAX_FUNCTIONS;
|
||||
}
|
||||
else {
|
||||
@@ -453,7 +454,7 @@ done:
|
||||
|
||||
pci_read_config_byte(0, slot, 0, PCI_HEADER_TYPE, &header);
|
||||
|
||||
if(header & PCI_MULTI_FUNCTION) {
|
||||
if(header & PCI_HEADER_TYPE_MULTI_FUNCTION) {
|
||||
numfuncs = PCI_MAX_FUNCTIONS;
|
||||
}
|
||||
else {
|
||||
@@ -503,7 +504,7 @@ int init_pci(void)
|
||||
unsigned char ucSlotNumber, ucFnNumber, ucNumFuncs;
|
||||
unsigned char ucHeader;
|
||||
unsigned char ucMaxSubordinate;
|
||||
unsigned int ulClass, ulDeviceID;
|
||||
uint32_t ulClass, ulDeviceID;
|
||||
|
||||
DBG("Initializing PCI\n");
|
||||
if ( init_grpci() ) {
|
||||
@@ -531,7 +532,7 @@ int init_pci(void)
|
||||
0,
|
||||
PCI_HEADER_TYPE,
|
||||
&ucHeader);
|
||||
if(ucHeader&PCI_MULTI_FUNCTION) {
|
||||
if(ucHeader&PCI_HEADER_TYPE_MULTI_FUNCTION) {
|
||||
ucNumFuncs=PCI_MAX_FUNCTIONS;
|
||||
}
|
||||
else {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,13 +2,8 @@
|
||||
|
||||
/* find a particular PCI device
|
||||
* (we assume, the firmware configured the PCI bus[es] for us)
|
||||
*
|
||||
* pcifinddevice.c,v 1.1.4.2 2003/07/18 15:48:54 joel Exp
|
||||
*/
|
||||
|
||||
#define PCI_INVALID_VENDORDEVICEID 0xffffffff
|
||||
#define PCI_MULTI_FUNCTION 0x80
|
||||
|
||||
#include <pci.h>
|
||||
#include <rtems/bspIo.h>
|
||||
|
||||
@@ -16,7 +11,7 @@ int
|
||||
BSP_pciFindDevice( unsigned short vendorid, unsigned short deviceid,
|
||||
int instance, int *pbus, int *pdev, int *pfun )
|
||||
{
|
||||
unsigned int d;
|
||||
uint32_t d;
|
||||
unsigned short s;
|
||||
unsigned char bus,dev,fun,hd;
|
||||
|
||||
@@ -24,7 +19,7 @@ BSP_pciFindDevice( unsigned short vendorid, unsigned short deviceid,
|
||||
for (dev=0; dev<PCI_MAX_DEVICES; dev++) {
|
||||
|
||||
pci_read_config_byte(bus,dev,0, PCI_HEADER_TYPE, &hd);
|
||||
hd = (hd & PCI_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1);
|
||||
hd = (hd & PCI_HEADER_TYPE_MULTI_FUNCTION ? PCI_MAX_FUNCTIONS : 1);
|
||||
|
||||
for (fun=0; fun<hd; fun++) {
|
||||
/*
|
||||
|
||||
@@ -99,7 +99,6 @@
|
||||
#define DEC_DEBUG
|
||||
|
||||
/* note: the 21143 isn't really a DEC, it's an Intel chip */
|
||||
#define PCI_INVALID_VENDORDEVICEID 0xffffffff
|
||||
#define PCI_VENDOR_ID_DEC 0x1011
|
||||
#define PCI_DEVICE_ID_DEC_21140 0x0009
|
||||
#define PCI_DEVICE_ID_DEC_21143 0x0019
|
||||
|
||||
@@ -33,6 +33,8 @@ extern "C" {
|
||||
#define PCI_VENDOR_ID 0x00 /* 16 bits */
|
||||
#define PCI_DEVICE_ID 0x02 /* 16 bits */
|
||||
|
||||
#define PCI_INVALID_VENDORDEVICEID 0xffffffff
|
||||
|
||||
#define PCI_COMMAND 0x04 /* 16 bits */
|
||||
#define PCI_COMMAND_IO 0x0001 /* Enable response in I/O space */
|
||||
#define PCI_COMMAND_MEMORY 0x0002 /* Enable response in Memory space */
|
||||
@@ -67,10 +69,11 @@ extern "C" {
|
||||
#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */
|
||||
#define PCI_LATENCY_TIMER 0x0d /* 8 bits */
|
||||
|
||||
#define PCI_HEADER_TYPE 0x0e /* 8 bits */
|
||||
#define PCI_HEADER_TYPE_NORMAL 0
|
||||
#define PCI_HEADER_TYPE_BRIDGE 1
|
||||
#define PCI_HEADER_TYPE_CARDBUS 2
|
||||
#define PCI_HEADER_TYPE 0x0e /* 8 bits */
|
||||
#define PCI_HEADER_TYPE_NORMAL 0x00
|
||||
#define PCI_HEADER_TYPE_BRIDGE 0x01
|
||||
#define PCI_HEADER_TYPE_CARDBUS 0x02
|
||||
#define PCI_HEADER_TYPE_MULTI_FUNCTION 0x80
|
||||
|
||||
#define PCI_BIST 0x0f /* 8 bits */
|
||||
#define PCI_BIST_CODE_MASK 0x0f /* Return result */
|
||||
@@ -375,6 +378,7 @@ extern "C" {
|
||||
#define PCI_DEVICE_ID_DEC_FDDI 0x000F
|
||||
#define PCI_DEVICE_ID_DEC_TULIP_PLUS 0x0014
|
||||
#define PCI_DEVICE_ID_DEC_21142 0x0019
|
||||
#define PCI_DEVICE_ID_DEC_21143 0x0019
|
||||
#define PCI_DEVICE_ID_DEC_21052 0x0021
|
||||
#define PCI_DEVICE_ID_DEC_21150 0x0022
|
||||
#define PCI_DEVICE_ID_DEC_21152 0x0024
|
||||
|
||||
Reference in New Issue
Block a user