2005-03-14 Joel Sherrill <joel@OARcorp.com>

* libchip/network/dec21140.c, libchip/network/elnk.c,
	libchip/network/if_fxp.c: Continue PCI API unification. All use
	pci_find_device(). Network drivers manufacture a signature since all
	calls have not been converted yet.
This commit is contained in:
Joel Sherrill
2005-03-14 21:45:03 +00:00
parent fb77bc8af0
commit bb9e843a12
4 changed files with 35 additions and 65 deletions

View File

@@ -1,3 +1,10 @@
2005-03-14 Joel Sherrill <joel@OARcorp.com>
* libchip/network/dec21140.c, libchip/network/elnk.c,
libchip/network/if_fxp.c: Continue PCI API unification. All use
pci_find_device(). Network drivers manufacture a signature since all
calls have not been converted yet.
2005-03-04 Joel Sherrill <joel@OARcorp.com> 2005-03-04 Joel Sherrill <joel@OARcorp.com>
* libchip/network/dec21140.c, libchip/network/if_fxp.c: Make PCI * libchip/network/dec21140.c, libchip/network/if_fxp.c: Make PCI

View File

@@ -588,7 +588,7 @@ dec21140Enet_initialize_hardware (struct dec21140_softc *sc)
* Build setup frame * Build setup frame
*/ */
setup_frm = (volatile unsigned char *)(bus_to_phys(rmd->buf1)); setup_frm = (volatile unsigned char *)(bus_to_phys(rmd->buf1));
eaddrs = (char *)(sc->arpcom.ac_enaddr); eaddrs = (unsigned char *)(sc->arpcom.ac_enaddr);
/* Fill the buffer with our physical address. */ /* Fill the buffer with our physical address. */
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
*setup_frm++ = eaddrs[0]; *setup_frm++ = eaddrs[0];
@@ -1012,13 +1012,11 @@ rtems_dec21140_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach)
unsigned char cvalue; unsigned char cvalue;
#if defined(__i386__) #if defined(__i386__)
int signature; int signature;
int value; unsigned int value;
char interrupt; unsigned char interrupt;
int diag;
unsigned int deviceId;
#endif #endif
#if defined(__PPC__)
int pbus, pdev, pfun; int pbus, pdev, pfun;
#if defined(__PPC__)
int tmp; int tmp;
unsigned int lvalue; unsigned int lvalue;
#endif #endif
@@ -1039,74 +1037,43 @@ rtems_dec21140_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach)
} }
if (pci_initialize() != PCIB_ERR_SUCCESS) if (pci_initialize() != PCIB_ERR_SUCCESS)
rtems_panic("Unable to initialize PCI"); rtems_panic("dec2114x: Unable to initialize PCI");
#if defined(__i386__)
/*
* First, find a DEC board
*/
/*
* Try to find the network card on the PCI bus. Probe for a DEC 21140
* card first. If not found probe the bus for a DEC/Intel 21143 card.
*/
deviceId = PCI_DEVICE_ID_DEC_21140;
diag = pcib_find_by_devid( PCI_VENDOR_ID_DEC, deviceId, unitNumber-1, &signature);
if ( diag == PCIB_ERR_SUCCESS)
printk( "DEC 21140 PCI network card found\n" );
else
{
deviceId = PCI_DEVICE_ID_DEC_21143;
diag = pcib_find_by_devid( PCI_VENDOR_ID_DEC, deviceId, unitNumber-1, &signature);
if ( diag == PCIB_ERR_SUCCESS)
printk( "DEC/Intel 21143 PCI network card found\n" );
else
{
printk("No DEC/Intel 21140/3 PCI network card found !!\n");
return 0;
}
}
#endif
#if defined(__PPC__)
/* /*
* Find the board * Find the board
*/ */
if( BSP_pciFindDevice( PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21140, if ( pci_find_device(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21140,
unitNumber-1, &pbus, &pdev, &pfun) == -1 ) unitNumber-1, &pbus, &pdev, &pfun) == -1 ) {
{ if ( pci_find_device(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21143,
if( BSP_pciFindDevice( PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21143, unitNumber-1, &pbus, &pdev, &pfun) != -1 ) {
unitNumber-1, &pbus, &pdev, &pfun) != -1 )
{
pci_write_config_dword(pbus, /* the 21143 chip must be enabled before it can be accessed */
pdev, #if defined(__i386__)
pfun, signature = PCIB_DEVSIG_MAKE( pbus, pdev, pfun );
0x40, pcib_conf_write32( signature, 0x40, 0 );
PCI_DEVICE_ID_DEC_21143 ); #else
pci_write_config_dword(pbus, pdev, pfun, 0x40, PCI_DEVICE_ID_DEC_21143);
#endif
} } else {
else
{
printk("dec2114x : device '%s' not found on PCI bus\n", config->name ); printk("dec2114x : device '%s' not found on PCI bus\n", config->name );
return 0; return 0;
} }
} }
#ifdef DEC_DEBUG #ifdef DEC_DEBUG
else else {
{
printk("dec21140 : found device '%s', bus 0x%02x, dev 0x%02x, func 0x%02x\n", printk("dec21140 : found device '%s', bus 0x%02x, dev 0x%02x, func 0x%02x\n",
config->name, pbus, pdev, pfun); config->name, pbus, pdev, pfun);
} }
#endif #endif
#if defined(__i386__)
signature = PCIB_DEVSIG_MAKE( pbus, pdev, pfun );
#endif #endif
if ((unitNumber < 1) || (unitNumber > NDECDRIVER)) if ((unitNumber < 1) || (unitNumber > NDECDRIVER))
{ {
printk("dec2114x : unit %i is invalid, must be (1 <= n <= %d)\n", unitNumber); printk("dec2114x : unit %i is invalid, must be (1 <= n <= %d)\n", unitNumber);
@@ -1139,10 +1106,6 @@ rtems_dec21140_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach)
*/ */
#if defined(__i386__) #if defined(__i386__)
/* the 21143 chip must be enabled before it can be accessed */
if ( deviceId == PCI_DEVICE_ID_DEC_21143 )
pcib_conf_write32( signature, 0x40, 0 );
pcib_conf_read32(signature, 16, &value); pcib_conf_read32(signature, 16, &value);
sc->port = value & ~IO_MASK; sc->port = value & ~IO_MASK;

View File

@@ -3139,8 +3139,8 @@ rtems_elnk_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach)
int pbus, pdev, pfun; int pbus, pdev, pfun;
#if defined(__i386__) #if defined(__i386__)
int signature; int signature;
int value; unsigned int value;
char interrupt; unsigned char interrupt;
#endif #endif
#if defined(__PPC__) #if defined(__PPC__)
unsigned int lvalue; unsigned int lvalue;
@@ -3179,7 +3179,8 @@ rtems_elnk_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach)
*/ */
for( i=0; !done && xl_devs[i].xl_vid; i++) for( i=0; !done && xl_devs[i].xl_vid; i++)
{ {
for(unum= 1; !done && BSP_pciFindDevice( xl_devs[i].xl_vid, xl_devs[i].xl_did, unum-1, for(unum= 1; !done &&
pci_find_device( xl_devs[i].xl_vid, xl_devs[i].xl_did, unum-1,
&sysboards[numFound].pbus, &sysboards[numFound].pbus,
&sysboards[numFound].pdev, &sysboards[numFound].pdev,
&sysboards[numFound].pfun)==0; unum++) &sysboards[numFound].pfun)==0; unum++)

View File

@@ -459,13 +459,12 @@ rtems_fxp_attach(struct rtems_bsdnet_ifconfig *config, int attaching)
/* /*
* find device on pci bus * find device on pci bus
*/ */
{ int j; { int j; int pbus, pdev, pfun;
for (j=0; fxp_ident_table[j].devid; j++ ) { for (j=0; fxp_ident_table[j].devid; j++ ) {
i = pcib_find_by_devid( 0x8086, i = pci_find_device( 0x8086, fxp_ident_table[j].devid,
fxp_ident_table[j].devid, unitNumber-1, &pbus, &pdev, &pfun );
unitNumber-1, sc->pci_signature = PCIB_DEVSIG_MAKE( pbus, pdev, pfun );
&(sc->pci_signature));
DBGLVL_PRINTK(2,"fxp_attach: find_devid returned %d " DBGLVL_PRINTK(2,"fxp_attach: find_devid returned %d "
"and pci signature 0x%x\n", "and pci signature 0x%x\n",
i,sc->pci_signature); i,sc->pci_signature);