fixed offsets in PCI config space access
This commit is contained in:
@@ -31,6 +31,47 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "wait.h"
|
#include "wait.h"
|
||||||
|
|
||||||
|
uint16_t pci_read_config_byte(uint16_t bus, uint16_t slot, uint16_t function, uint16_t offset)
|
||||||
|
{
|
||||||
|
uint8_t value;
|
||||||
|
|
||||||
|
|
||||||
|
/* clear PCI status/command register */
|
||||||
|
MCF_PCI_PCISCR = MCF_PCI_PCISCR_PE | /* clear parity error bit */
|
||||||
|
MCF_PCI_PCISCR_SE | /* clear system error */
|
||||||
|
MCF_PCI_PCISCR_MA | /* clear master abort */
|
||||||
|
MCF_PCI_PCISCR_TR | /* clear target abort */
|
||||||
|
MCF_PCI_PCISCR_TS | /* clear target abort signalling (as target) */
|
||||||
|
MCF_PCI_PCISCR_DP; /* clear parity error */
|
||||||
|
|
||||||
|
//(void) MCF_PCI_PCISCR;
|
||||||
|
wait(1000);
|
||||||
|
|
||||||
|
/* initiate PCI configuration access to device */
|
||||||
|
|
||||||
|
MCF_PCI_PCICAR = MCF_PCI_PCICAR_E | /* enable configuration access special cycle */
|
||||||
|
MCF_PCI_PCICAR_DEVNUM(slot) | /* device number, devices 0 - 9 are reserved */
|
||||||
|
MCF_PCI_PCICAR_FUNCNUM(function) | /* function number */
|
||||||
|
MCF_PCI_PCICAR_DWORD(offset * 2);
|
||||||
|
|
||||||
|
wait(1000);
|
||||||
|
|
||||||
|
value = * (volatile uint16_t *) PCI_IO_OFFSET; /* access device */
|
||||||
|
|
||||||
|
#ifdef _NOT_USED_
|
||||||
|
/* finish config cycle */
|
||||||
|
|
||||||
|
MCF_PCI_PCICAR = MCF_PCI_PCICAR_E |
|
||||||
|
MCF_PCI_PCICAR_BUSNUM(bus) |
|
||||||
|
MCF_PCI_PCICAR_DEVNUM(slot) |
|
||||||
|
MCF_PCI_PCICAR_FUNCNUM(function) |
|
||||||
|
MCF_PCI_PCICAR_DWORD(0);
|
||||||
|
#endif /* _NOT_USED_ */
|
||||||
|
|
||||||
|
swpw(value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t pci_read_config_word(uint16_t bus, uint16_t slot, uint16_t function, uint16_t offset)
|
uint16_t pci_read_config_word(uint16_t bus, uint16_t slot, uint16_t function, uint16_t offset)
|
||||||
{
|
{
|
||||||
uint16_t value;
|
uint16_t value;
|
||||||
@@ -97,7 +138,7 @@ uint32_t pci_read_config_longword(uint16_t bus, uint16_t slot, uint16_t function
|
|||||||
MCF_PCI_PCICAR_BUSNUM(bus) |
|
MCF_PCI_PCICAR_BUSNUM(bus) |
|
||||||
MCF_PCI_PCICAR_DEVNUM(slot) | /* device number, devices 0 - 9 are reserved */
|
MCF_PCI_PCICAR_DEVNUM(slot) | /* device number, devices 0 - 9 are reserved */
|
||||||
MCF_PCI_PCICAR_FUNCNUM(function) | /* function number */
|
MCF_PCI_PCICAR_FUNCNUM(function) | /* function number */
|
||||||
MCF_PCI_PCICAR_DWORD(offset);
|
MCF_PCI_PCICAR_DWORD(offset / 2);
|
||||||
|
|
||||||
wait(1000);
|
wait(1000);
|
||||||
value = * (volatile uint32_t *) PCI_IO_OFFSET; /* access device */
|
value = * (volatile uint32_t *) PCI_IO_OFFSET; /* access device */
|
||||||
@@ -138,8 +179,8 @@ void pci_scan(void)
|
|||||||
xprintf("[%02x] [%02x] [%02x]: %08x\r\n", bus, slot, function, value);
|
xprintf("[%02x] [%02x] [%02x]: %08x\r\n", bus, slot, function, value);
|
||||||
for (i = 0; i < 0x40; i += 2)
|
for (i = 0; i < 0x40; i += 2)
|
||||||
{
|
{
|
||||||
value = pci_read_config_word(bus, slot, function, i);
|
value = pci_read_config_longword(bus, slot, function, i);
|
||||||
xprintf("register %02x value= %04x\r\n", i, value);
|
xprintf("register %02x value= %08x\r\n", i, value);
|
||||||
}
|
}
|
||||||
/* test for multi-function device to avoid ghost device detects */
|
/* test for multi-function device to avoid ghost device detects */
|
||||||
value = pci_read_config_longword(bus, slot, function, 0x0c);
|
value = pci_read_config_longword(bus, slot, function, 0x0c);
|
||||||
|
|||||||
Reference in New Issue
Block a user