From bb9e843a12e03d0b04c236f5f70400d859e7581e Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 14 Mar 2005 21:45:03 +0000 Subject: 2005-03-14 Joel Sherrill * 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. --- c/src/libchip/network/dec21140.c | 77 +++++++++++----------------------------- c/src/libchip/network/elnk.c | 7 ++-- c/src/libchip/network/if_fxp.c | 9 +++-- 3 files changed, 28 insertions(+), 65 deletions(-) (limited to 'c/src/libchip') diff --git a/c/src/libchip/network/dec21140.c b/c/src/libchip/network/dec21140.c index 69fc0cbf1c..90695f30e7 100644 --- a/c/src/libchip/network/dec21140.c +++ b/c/src/libchip/network/dec21140.c @@ -588,7 +588,7 @@ dec21140Enet_initialize_hardware (struct dec21140_softc *sc) * Build setup frame */ 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. */ for (i = 1; i < 16; i++) { *setup_frm++ = eaddrs[0]; @@ -1012,13 +1012,11 @@ rtems_dec21140_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach) unsigned char cvalue; #if defined(__i386__) int signature; - int value; - char interrupt; - int diag; - unsigned int deviceId; + unsigned int value; + unsigned char interrupt; #endif -#if defined(__PPC__) int pbus, pdev, pfun; +#if defined(__PPC__) int tmp; unsigned int lvalue; #endif @@ -1039,74 +1037,43 @@ rtems_dec21140_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach) } if (pci_initialize() != PCIB_ERR_SUCCESS) - rtems_panic("Unable to initialize PCI"); - - -#if defined(__i386__) - /* - * First, find a DEC board - */ + rtems_panic("dec2114x: Unable to initialize PCI"); - /* - * 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 */ - if( BSP_pciFindDevice( PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21140, - unitNumber-1, &pbus, &pdev, &pfun) == -1 ) - { - if( BSP_pciFindDevice( PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21143, - unitNumber-1, &pbus, &pdev, &pfun) != -1 ) - { + if ( pci_find_device(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21140, + unitNumber-1, &pbus, &pdev, &pfun) == -1 ) { + if ( pci_find_device(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21143, + unitNumber-1, &pbus, &pdev, &pfun) != -1 ) { - pci_write_config_dword(pbus, - pdev, - pfun, - 0x40, - PCI_DEVICE_ID_DEC_21143 ); + /* the 21143 chip must be enabled before it can be accessed */ +#if defined(__i386__) + signature = PCIB_DEVSIG_MAKE( pbus, pdev, pfun ); + pcib_conf_write32( signature, 0x40, 0 ); +#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 ); return 0; } } #ifdef DEC_DEBUG - else - { + else { printk("dec21140 : found device '%s', bus 0x%02x, dev 0x%02x, func 0x%02x\n", config->name, pbus, pdev, pfun); } #endif +#if defined(__i386__) + signature = PCIB_DEVSIG_MAKE( pbus, pdev, pfun ); #endif - if ((unitNumber < 1) || (unitNumber > NDECDRIVER)) { 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__) - /* 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); sc->port = value & ~IO_MASK; diff --git a/c/src/libchip/network/elnk.c b/c/src/libchip/network/elnk.c index 970f98a9c1..4624cf8d04 100644 --- a/c/src/libchip/network/elnk.c +++ b/c/src/libchip/network/elnk.c @@ -3139,8 +3139,8 @@ rtems_elnk_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach) int pbus, pdev, pfun; #if defined(__i386__) int signature; - int value; - char interrupt; + unsigned int value; + unsigned char interrupt; #endif #if defined(__PPC__) 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(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].pdev, &sysboards[numFound].pfun)==0; unum++) diff --git a/c/src/libchip/network/if_fxp.c b/c/src/libchip/network/if_fxp.c index a08ab3e25d..f7bf7b0402 100644 --- a/c/src/libchip/network/if_fxp.c +++ b/c/src/libchip/network/if_fxp.c @@ -459,13 +459,12 @@ rtems_fxp_attach(struct rtems_bsdnet_ifconfig *config, int attaching) /* * find device on pci bus */ - { int j; + { int j; int pbus, pdev, pfun; for (j=0; fxp_ident_table[j].devid; j++ ) { - i = pcib_find_by_devid( 0x8086, - fxp_ident_table[j].devid, - unitNumber-1, - &(sc->pci_signature)); + i = pci_find_device( 0x8086, fxp_ident_table[j].devid, + unitNumber-1, &pbus, &pdev, &pfun ); + sc->pci_signature = PCIB_DEVSIG_MAKE( pbus, pdev, pfun ); DBGLVL_PRINTK(2,"fxp_attach: find_devid returned %d " "and pci signature 0x%x\n", i,sc->pci_signature); -- cgit v1.2.3