📄 i21555.c
字号:
/* i21555.c - Intel 21555 PCI-PCI Non-Transparent Bridge Chip Driver */
/* Copyright 2004 Orion Technologies, Inc. */
/*
modification history
--------------------
01a,16mar04,csd written
*/
/*
DESCRIPTION
This library provides support routines for the Intel 21555 PCI Bridge chip.
INCLUDE FILES: i21555.h
SEE ALSO:
*/
/* includes */
#include "vxWorks.h"
#include "config.h"
#include "cpc7510.h"
#include "gtPci.h"
#include "i21555.h"
#include "drv/pci/pciConfigLib.h"
#ifdef INCLUDE_I21555
LOCAL PCI_LOC i21555_localDev =
{
bus: 1,
device: 1,
function: 0
};
/**********************************************************************************************
*
* i21555_DownstreamConfigEnable - Enable Downstream Configuration cycles
*
* This function sets the Downstream Configuration Control bit in the local
* 21555 Configuration CSR register.
*
*
* RETURNS: NA.
*
* SEE ALSO:
*/
void i21555_DownstreamConfigEnable(void)
{
int old_interface = 0;
PCI_LOC *i21555_dev = &i21555_localDev;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
pciConfigOutByte(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_CONFIG_CSR, BIT1);
setCurrentPciInterface(old_interface);
}
/**********************************************************************************************
*
* i21555_DownstreamReadConfigLong - Read Downstream 32-bit configuration registers
*
* This function uses the local 21555 to read a 32-bit configuration register
* of a device on the secondary side of the bridge (downstream).
*
*
* RETURNS: The data read from the configuration register.
*
* SEE ALSO:
*/
UINT32 i21555_DownstreamReadConfigLong(PCI_LOC *downstream_dev, UINT32 regOffset)
{
UINT32 AddrReg;
UINT32 data;
UINT8 configOwned = 0;
int old_interface = 0;
PCI_LOC *i21555_dev = &i21555_localDev;
if(downstream_dev == NULL || downstream_dev->device > PCI_MAX_DEVICES) /* illegal device Number */
return PCI_ERROR_CODE;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
AddrReg = ((1 << downstream_dev->device) | (downstream_dev->function << 8) |
(regOffset & PCI_REG_OFFSET_MASK));
/* get ownership of the downstream config registers */
while(configOwned != 1)
{
pciConfigInByte(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_OWN, &configOwned);
}
/* write the device address to the downstream config address register */
pciConfigOutLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_ADDR, AddrReg);
/* read the data from the downstream config data register */
pciConfigInLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_DATA, &data);
setCurrentPciInterface(old_interface);
return data;
}
/**********************************************************************************************
*
* i21555_DownstreamOverBridgeReadConfigLong - Read 32-bit configuration registers
*
* This function uses the local 21555 to read a downstream 32-bit configuration register
* over a PCI-PCI Bridge.
*
*
* RETURNS: The data read from the configuration register.
*
* SEE ALSO:
*/
UINT32 i21555_DownstreamOverBridgeReadConfigLong(PCI_LOC *downstream_dev, UINT32 regOffset)
{
UINT32 AddrReg;
UINT32 data;
UINT8 configOwned = 0;
int old_interface = 0;
PCI_LOC *i21555_dev = &i21555_localDev;
if(downstream_dev == NULL || downstream_dev->device > PCI_MAX_DEVICES) /* illegal device Number */
return PCI_ERROR_CODE;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
AddrReg = ((0x80000001) | (downstream_dev->bus << 16) | (downstream_dev->device << 11) |
(downstream_dev->function << 8) | (regOffset & PCI_REG_OFFSET_MASK));
/* get ownership of the downstream config registers */
while(configOwned != 1)
{
pciConfigInByte(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_OWN, &configOwned);
}
/* write the device address to the downstream config address register */
pciConfigOutLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_ADDR, AddrReg);
/* read the data from the downstream config data register */
pciConfigInLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_DATA, &data);
setCurrentPciInterface(old_interface);
return data;
}
/**********************************************************************************************
*
* i21555_DownstreamWriteConfigLong - Write to a Downstream 32-bit configuration register
*
* This function uses the local 21555 to write to a 32-bit configuration register
* of a device on the secondary side of the bridge (downstream).
*
*
* RETURNS: NA.
*
* SEE ALSO:
*/
void i21555_DownstreamWriteConfigLong(PCI_LOC *downstream_dev, UINT32 regOffset, UINT32 data)
{
UINT32 AddrReg;
UINT8 configOwned = 0;
int old_interface = 0;
PCI_LOC *i21555_dev = &i21555_localDev;
if(downstream_dev == NULL || downstream_dev->device > PCI_MAX_DEVICES) /* illegal device Number */
return;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
AddrReg = ((1 << downstream_dev->device) | (downstream_dev->function << 8) |
(regOffset & PCI_REG_OFFSET_MASK));
/* get ownership of the downstream config registers */
while(configOwned != 1)
{
pciConfigInByte(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_OWN, &configOwned);
}
/* write the device address to the downstream config address register */
pciConfigOutLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_ADDR, AddrReg);
/* write the data to the downstream config data register */
pciConfigOutLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_DATA, data);
setCurrentPciInterface(old_interface);
}
/**********************************************************************************************
*
* i21555_DownstreamWriteConfigWord - Write to a Downstream 16-bit configuration register
*
* This function uses the local 21555 to write to a 16-bit configuration register
* of a device on the secondary side of the bridge (downstream).
*
*
* RETURNS: NA.
*
* SEE ALSO:
*/
void i21555_DownstreamWriteConfigWord(PCI_LOC *downstream_dev, UINT32 regOffset, UINT16 data)
{
UINT32 AddrReg;
UINT8 configOwned = 0;
int old_interface = 0;
PCI_LOC *i21555_dev = &i21555_localDev;
if(downstream_dev == NULL || downstream_dev->device > PCI_MAX_DEVICES) /* illegal device Number */
return;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
AddrReg = ((1 << downstream_dev->device) | (downstream_dev->function << 8) |
(regOffset & PCI_REG_OFFSET_MASK));
/* get ownership of the downstream config registers */
while(configOwned != 1)
{
pciConfigInByte(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_OWN, &configOwned);
}
/* write the device address to the downstream config address register */
pciConfigOutLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_ADDR, AddrReg);
/* write the data to the downstream config data register */
pciConfigOutWord(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_DATA | (regOffset & 2), data);
setCurrentPciInterface(old_interface);
}
/**********************************************************************************************
*
* i21555_DownstreamWriteConfigByte - Write to a Downstream 8-bit configuration register
*
* This function uses the local 21555 to write to a 8-bit configuration register
* of a device on the secondary side of the bridge (downstream).
*
*
* RETURNS: NA.
*
* SEE ALSO:
*/
void i21555_DownstreamWriteConfigByte(PCI_LOC *downstream_dev, UINT32 regOffset, UINT8 data)
{
UINT32 AddrReg;
UINT8 configOwned = 0;
int old_interface = 0;
PCI_LOC *i21555_dev = &i21555_localDev;
if(downstream_dev == NULL || downstream_dev->device > PCI_MAX_DEVICES) /* illegal device Number */
return;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
AddrReg = ((1 << downstream_dev->device) | (downstream_dev->function << 8) |
(regOffset & PCI_REG_OFFSET_MASK));
/* get ownership of the downstream config registers */
while(configOwned != 1)
{
pciConfigInByte(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_OWN, &configOwned);
}
/* write the device address to the downstream config address register */
pciConfigOutLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_ADDR, AddrReg);
/* write the data to the downstream config data register */
pciConfigOutByte(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_DATA | (regOffset & 3), data);
setCurrentPciInterface(old_interface);
}
/**********************************************************************************************
*
* i21555_DownstreamOverBridgeWriteConfigLong - Write to a 32-bit configuration register
*
* This function uses the local 21555 to write to a downstream 32-bit configuration register
* over a PCI-PCI Bridge.
*
*
* RETURNS: NA.
*
* SEE ALSO:
*/
void i21555_DownstreamOverBridgeWriteConfigLong(PCI_LOC *downstream_dev, UINT32 regOffset, UINT32 data)
{
UINT32 AddrReg;
UINT8 configOwned = 0;
int old_interface = 0;
PCI_LOC *i21555_dev = &i21555_localDev;
if(downstream_dev == NULL || downstream_dev->device > PCI_MAX_DEVICES) /* illegal device Number */
return;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
AddrReg = ((0x80000001) | (downstream_dev->bus << 16) | (downstream_dev->device << 11) |
(downstream_dev->function << 8) | (regOffset & PCI_REG_OFFSET_MASK));
/* get ownership of the downstream config registers */
while(configOwned != 1)
{
pciConfigInByte(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_OWN, &configOwned);
}
/* write the device address to the downstream config address register */
pciConfigOutLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_ADDR, AddrReg);
/* write the data to the downstream config data register */
pciConfigOutLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_DATA, data);
setCurrentPciInterface(old_interface);
}
/**********************************************************************************************
*
* i21555_DownstreamOverBridgeWriteConfigWord - Write to a 16-bit configuration register
*
* This function uses the local 21555 to write to a downstream 16-bit configuration register
* over a PCI-PCI Bridge.
*
*
* RETURNS: NA.
*
* SEE ALSO:
*/
void i21555_DownstreamOverBridgeWriteConfigWord(PCI_LOC *downstream_dev, UINT32 regOffset, UINT16 data)
{
UINT32 AddrReg;
UINT8 configOwned = 0;
int old_interface = 0;
PCI_LOC *i21555_dev = &i21555_localDev;
if(downstream_dev == NULL || downstream_dev->device > PCI_MAX_DEVICES) /* illegal device Number */
return;
old_interface = setCurrentPciInterface(PCI_LOCAL_INTERFACE);
AddrReg = ((0x80000001) | (downstream_dev->bus << 16) | (downstream_dev->device << 11) |
(downstream_dev->function << 8) | (regOffset & PCI_REG_OFFSET_MASK));
/* get ownership of the downstream config registers */
while(configOwned != 1)
{
pciConfigInByte(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_OWN, &configOwned);
}
/* write the device address to the downstream config address register */
pciConfigOutLong(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_ADDR, AddrReg);
/* write the data to the downstream config data register */
pciConfigOutWord(i21555_dev->bus, i21555_dev->device, i21555_dev->function,
I21555_CONFIG_DS_CONFIG_DATA | (regOffset & 2), data);
setCurrentPciInterface(old_interface);
}
/**********************************************************************************************
*
* i21555_DownstreamOverBridgeWriteConfigByte - Write to a 8-bit configuration register
*
* This function uses the local 21555 to write to a downstream 8-bit configuration register
* over a PCI-PCI Bridge.
*
*
* RETURNS: NA.
*
* SEE ALSO:
*/
void i21555_DownstreamOverBridgeWriteConfigByte(PCI_LOC *downstream_dev, UINT32 regOffset, UINT8 data)
{
UINT32 AddrReg;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -