modified to fit usb driver requirements

This commit is contained in:
Markus Fröschle
2013-11-03 03:40:22 +00:00
parent 7c25bc1124
commit 22cbc5a23d
3 changed files with 45 additions and 22 deletions

View File

@@ -21,6 +21,8 @@
* Author: Markus Fröschle * Author: Markus Fröschle
*/ */
#include <stdint.h>
#define PCI_MEMORY_OFFSET (0x80000000) #define PCI_MEMORY_OFFSET (0x80000000)
#define PCI_MEMORY_SIZE (0x40000000) /* 1 GByte PCI memory window */ #define PCI_MEMORY_SIZE (0x40000000) /* 1 GByte PCI memory window */
#define PCI_IO_OFFSET (0xD0000000) #define PCI_IO_OFFSET (0xD0000000)
@@ -197,4 +199,7 @@ extern void init_eport(void);
extern void init_xlbus_arbiter(void); extern void init_xlbus_arbiter(void);
extern void init_pci(void); extern void init_pci(void);
extern int pci_find_device(uint16_t device_id, uint16_t vendor_id, int index);
#endif /* _PCI_H_ */ #endif /* _PCI_H_ */

View File

@@ -1522,11 +1522,7 @@ static int hc_reset(ohci_t *ohci)
long handle; long handle;
do do
{ {
#ifdef PCI_XBIOS handle = pci_find_device(0x0, 0xffff, index++)
handle = find_pci_device(0x0000FFFFL, index++);
#else
handle = Find_pci_device(0x0000FFFFL, index++);
#endif
if (handle >= 0) if (handle >= 0)
{ {
unsigned long id = 0; unsigned long id = 0;

View File

@@ -101,14 +101,6 @@ uint32_t pci_read_config_longword(uint16_t bus, uint16_t slot, uint16_t function
wait(1000); wait(1000);
value = * (volatile uint32_t *) PCI_IO_OFFSET; /* access device */ value = * (volatile uint32_t *) PCI_IO_OFFSET; /* access device */
#ifdef _NOT_USED_
/* finish config cycle */
MCF_PCI_PCICAR = MCF_PCI_PCICAR_DEVNUM(10) |
MCF_PCI_PCICAR_FUNCNUM(function) |
MCF_PCI_PCICAR_DWORD(0);
#endif /* _NOT_USED_ */
swpl(value); swpl(value);
//xprintf("PCISCR after config cycle: %lx\r\n", MCF_PCI_PCISCR); //xprintf("PCISCR after config cycle: %lx\r\n", MCF_PCI_PCISCR);
@@ -157,16 +149,46 @@ void pci_write_config_longword(uint16_t bus, uint16_t slot, uint16_t function, u
wait(1000); wait(1000);
swpl(value); swpl(value);
* (volatile uint32_t *) PCI_IO_OFFSET = value; /* access device */ * (volatile uint32_t *) PCI_IO_OFFSET = value; /* access device */
#ifdef _NOT_USED_
/* finish config cycle */
MCF_PCI_PCICAR = MCF_PCI_PCICAR_DEVNUM(10) |
MCF_PCI_PCICAR_FUNCNUM(function) |
MCF_PCI_PCICAR_DWORD(0);
#endif /* _NOT_USED_ */
} }
int pci_find_device(uint16_t device_id, uint16_t vendor_id, int index)
{
uint16_t bus;
uint16_t slot;
uint16_t function;
uint16_t pos = 0;
int handle;
for (bus = 0; bus < 1; bus++)
{
for (slot = 0; slot < 32; slot++)
{
for (function = 0; function < 8; function++)
{
uint32_t value;
value = pci_read_config_longword(bus, slot, function, 0);
handle = bus << 16 | slot << 8 | function;
if (value != 0xffffffff) /* we have a device at this position */
{
if (vendor_id == 0xffff) /* ignore vendor id */
{
return handle;
}
else if (PCI_VENDOR_ID(value) == vendor_id && PCI_DEVICE_ID(value) == device_id)
{
if (pos == index)
return handle;
pos++;
}
}
}
}
}
return PCI_DEVICE_NOT_FOUND;
}
static uint32_t mem_address = PCI_MEMORY_OFFSET; static uint32_t mem_address = PCI_MEMORY_OFFSET;
static uint32_t io_address = PCI_IO_OFFSET; static uint32_t io_address = PCI_IO_OFFSET;