Changes from Daron Chabot

This commit is contained in:
Eric Norum
2006-02-23 21:05:16 +00:00
parent 0d0560a10e
commit 7f7298c468
3 changed files with 96 additions and 47 deletions

View File

@@ -1,6 +1,13 @@
2006-02-a32 Eric Norum <norume@aps.anl.gov>
* libchip/network/if_dc.c, if_dcreg.c: Changes from Daron Chabot:
"newer" PCI access calls
minor cleanups
comments
2006-01-12 Eric Norum <norume@aps.anl.gov> 2006-01-12 Eric Norum <norume@aps.anl.gov>
* libchip/network/smc91111.c: Fix illegial lvalue increments * libchip/network/smc91111.c: Fix illegal lvalue increments
2006-01-12 Ralf Corsepius <ralf.corsepius@rtems.org> 2006-01-12 Ralf Corsepius <ralf.corsepius@rtems.org>

View File

@@ -100,22 +100,28 @@
* from being compiled on systems which can't support this driver. * from being compiled on systems which can't support this driver.
*/ */
#if defined(DRIVER_SUPPORTED)
#undef DRIVER_SUPPORTED
#endif
#if defined(__i386__) #if defined(__i386__)
#define DRIVER_SUPPORTED #define DRIVER_SUPPORTED
#endif #endif
#if defined(__PPC__) && (defined(mpc604) || defined(mpc750) || defined(mpc603e)) #if defined(__PPC__) && (defined(mpc604) || defined(mpc750) || defined(mpc603e))
#define DRIVER_SUPPORTED #define DRIVER_SUPPORTED
#warning The if_dc driver is untested on the PPC platform !!!
#endif #endif
#undef DRIVER_SUPPORTED #if defined(DRIVER_SUPPORTED) /* this covers the file "globally"... */
#include <bsp.h>
#if defined(DRIVER_SUPPORTED)
#include <rtems.h> #include <rtems.h>
#include <rtems/error.h> #include <rtems/pci.h>
#include <rtems/rtems_bsdnet.h>
#include <rtems/error.h>
#include <errno.h>
#include <rtems/rtems_bsdnet.h>
#include <net/if_types.h> #include <net/if_types.h>
@@ -130,6 +136,9 @@
#include <sys/systm.h> #include <sys/systm.h>
#include <bsp.h> #include <bsp.h>
/* moved to cpukit/include/rtems in CVS current ! */
//#include "if_media.h"
//#include "pci.h"
#include <net/if_media.h> #include <net/if_media.h>
#include <rtems/pci.h> #include <rtems/pci.h>
/* /*
@@ -189,6 +198,8 @@
#define IRQ_EVENT RTEMS_EVENT_13 /* Ha ... */ #define IRQ_EVENT RTEMS_EVENT_13 /* Ha ... */
static struct dc_softc dc_softc_devs[NDRIVER]; static struct dc_softc dc_softc_devs[NDRIVER];
#define UNUSED
#if 0 #if 0
/* "controller miibus0" required. See GENERIC if you get errors here. */ /* "controller miibus0" required. See GENERIC if you get errors here. */
#include "miibus_if.h" #include "miibus_if.h"
@@ -283,7 +294,7 @@ static void dc_tx_underrun(struct dc_softc *);
static rtems_isr dc_intr(rtems_vector_number); static rtems_isr dc_intr(rtems_vector_number);
static void dc_daemon(void *); static void dc_daemon(void *);
static void dc_start(struct ifnet *); static void dc_start(struct ifnet *);
static int dc_ioctl(struct ifnet *, int, caddr_t); static int dc_ioctl(struct ifnet *, u_long, caddr_t);
static void dc_init(void *); static void dc_init(void *);
static void dc_stop(struct dc_softc *); static void dc_stop(struct dc_softc *);
static void dc_watchdog(struct ifnet *); static void dc_watchdog(struct ifnet *);
@@ -315,7 +326,9 @@ static void dc_miibus_mediainit __P((device_t));
static void dc_setcfg(struct dc_softc *, int); static void dc_setcfg(struct dc_softc *, int);
static u_int32_t dc_crc_le(struct dc_softc *, caddr_t); static u_int32_t dc_crc_le(struct dc_softc *, caddr_t);
#ifndef UNUSED
static u_int32_t dc_crc_be(caddr_t); static u_int32_t dc_crc_be(caddr_t);
#endif
static void dc_setfilt_21143(struct dc_softc *); static void dc_setfilt_21143(struct dc_softc *);
static void dc_setfilt_asix(struct dc_softc *); static void dc_setfilt_asix(struct dc_softc *);
static void dc_setfilt_admtek(struct dc_softc *); static void dc_setfilt_admtek(struct dc_softc *);
@@ -1129,6 +1142,7 @@ static u_int32_t dc_crc_le(sc, addr)
return (crc & ((1 << DC_BITS_512) - 1)); return (crc & ((1 << DC_BITS_512) - 1));
} }
#ifndef UNUSED
/* /*
* Calculate CRC of a multicast group address, return the lower 6 bits. * Calculate CRC of a multicast group address, return the lower 6 bits.
*/ */
@@ -1156,7 +1170,7 @@ static u_int32_t dc_crc_be(addr)
/* return the filter bit position */ /* return the filter bit position */
return((crc >> 26) & 0x0000003F); return((crc >> 26) & 0x0000003F);
} }
#endif
/* /*
* 21143-style RX filter setup routine. Filter programming is done by * 21143-style RX filter setup routine. Filter programming is done by
@@ -1597,12 +1611,15 @@ struct dc_type *dc_devtype( int unitnum )
t = dc_devs; t = dc_devs;
while(t->dc_name != NULL) { while(t->dc_name != NULL) {
rc = pcib_find_by_devid(t->dc_vid, t->dc_did, \ rc = pci_find_device(t->dc_vid, t->dc_did, \
(unitnum - 1), &t->dc_devsig); (unitnum - 1), &t->dc_bus, &t->dc_dev, &t->dc_fun);
if (rc == PCIB_ERR_SUCCESS) { if (rc == PCIB_ERR_SUCCESS) {
/* Check the PCI revision */ /* Check the PCI revision */
pcib_conf_read32(t->dc_devsig, DC_PCI_CFRV, &rev); //pcib_conf_read32(t->dc_devsig, DC_PCI_CFRV, &rev);
rev &= 0xFF; pci_read_config_dword(t->dc_bus,t->dc_dev,t->dc_fun,\
DC_PCI_CFRV, &rev);
rev &= 0xFF;
if (t->dc_did == DC_DEVICEID_98713 && if (t->dc_did == DC_DEVICEID_98713 &&
rev >= DC_REVISION_98713A) rev >= DC_REVISION_98713A)
t++; t++;
@@ -1885,7 +1902,7 @@ decISON(const rtems_irq_connect_data* irq)
int int
rtems_dc_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching) rtems_dc_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching)
{ {
/*int s, tmp = 0;*/ int rc;
u_char eaddr[ETHER_ADDR_LEN]; u_char eaddr[ETHER_ADDR_LEN];
char *unitName; char *unitName;
@@ -1894,12 +1911,10 @@ rtems_dc_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching)
u_int32_t command; u_int32_t command;
struct dc_softc *sc; struct dc_softc *sc;
struct ifnet *ifp; struct ifnet *ifp;
struct dc_type *t;
u_int32_t revision; u_int32_t revision;
int error = 0, mac_offset; int error = 0, mac_offset;
#if defined(__i386__) unsigned int value;
int sig;
int value;
#endif
/* /*
* Get the instance number for the board we're going to configure * Get the instance number for the board we're going to configure
@@ -1915,10 +1930,6 @@ rtems_dc_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching)
return 0; return 0;
} }
/*
* First, find a DEC board
*/
sc = &dc_softc_devs[unitNumber - 1]; sc = &dc_softc_devs[unitNumber - 1];
ifp = &sc->arpcom.ac_if; ifp = &sc->arpcom.ac_if;
@@ -1944,16 +1955,23 @@ rtems_dc_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching)
printk("Can't find any dec2114x NICs in PCI space.\n"); printk("Can't find any dec2114x NICs in PCI space.\n");
return 0; return 0;
} }
t = sc->dc_info;
/* /*
* Map control/status registers. * Map control/status registers.
*/ */
sig = sc->dc_info->dc_devsig; //sig = sc->dc_info->dc_devsig;
pcib_conf_read32(sig, PCI_COMMAND, &command); pci_read_config_dword(t->dc_bus,t->dc_dev,t->dc_fun,\
PCI_COMMAND, &command);
//pcib_conf_read32(sig, PCI_COMMAND, &command);
command |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); command |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
pcib_conf_write32(sig, PCI_COMMAND, command); pci_write_config_dword(t->dc_bus,t->dc_dev,t->dc_fun,\
pcib_conf_read32(sig, PCI_COMMAND, &command); PCI_COMMAND, command);
//pcib_conf_write32(sig, PCI_COMMAND, command);
pci_read_config_dword(t->dc_bus,t->dc_dev,t->dc_fun,\
PCI_COMMAND, &command);
//pcib_conf_read32(sig, PCI_COMMAND, &command);
#ifdef DC_USEIOSPACE #ifdef DC_USEIOSPACE
if (!(command & PCI_COMMAND_IO)) { if (!(command & PCI_COMMAND_IO)) {
@@ -1984,20 +2002,30 @@ rtems_dc_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching)
#endif #endif
/* sc->membase is the address of the card's CSRs !!! */ /* sc->membase is the address of the card's CSRs !!! */
pcib_conf_read32(sig, DC_PCI_CFBMA, &value); //pcib_conf_read32(sig, DC_PCI_CFBMA, &value);
pci_read_config_dword(t->dc_bus,t->dc_dev,t->dc_fun,\
DC_PCI_CFBMA, &value);
sc->membase = value; sc->membase = value;
/* Allocate interrupt */ /* Allocate interrupt */
memset(&sc->irqInfo, 0, sizeof(rtems_irq_connect_data)); memset(&sc->irqInfo, 0, sizeof(rtems_irq_connect_data));
pcib_conf_read32(sig, DC_PCI_CFIT, &value); //pcib_conf_read32(sig, DC_PCI_CFIT, &value);
pci_read_config_dword(t->dc_bus,t->dc_dev,t->dc_fun,\
DC_PCI_CFIT, &value);
sc->irqInfo.name = value & 0xFF; sc->irqInfo.name = value & 0xFF;
sc->irqInfo.hdl = (rtems_irq_hdl)dc_intr; sc->irqInfo.hdl = (rtems_irq_hdl)dc_intr;
sc->irqInfo.handle = (void *)sc; /* new parameter */
sc->irqInfo.on = nop; sc->irqInfo.on = nop;
sc->irqInfo.off = nop; sc->irqInfo.off = nop;
sc->irqInfo.isOn = decISON; sc->irqInfo.isOn = decISON;
if(!(BSP_install_rtems_irq_handler( &sc->irqInfo ))) { #ifdef BSP_SHARED_HANDLER_SUPPORT
rc = BSP_install_rtems_shared_irq_handler( &sc->irqInfo );
#else
rc = BSP_install_rtems_irq_handler( &sc->irqInfo );
#endif
if(!rc) {
rtems_panic("Can't install dec2114x irq handler.\n"); rtems_panic("Can't install dec2114x irq handler.\n");
} }
@@ -2029,7 +2057,9 @@ rtems_dc_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching)
/* Need this info to decide on a chip type. /* Need this info to decide on a chip type.
sc->dc_info = dc_devtype(dev); sc->dc_info = dc_devtype(dev);
*/ */
pcib_conf_read32(sig, DC_PCI_CFRV, &revision); //pcib_conf_read32(sig, DC_PCI_CFRV, &revision);
pci_read_config_dword(t->dc_bus,t->dc_dev,t->dc_fun,\
DC_PCI_CFRV, &revision);
revision &= 0x000000FF; revision &= 0x000000FF;
/* Get the eeprom width, but PNIC has diff eeprom */ /* Get the eeprom width, but PNIC has diff eeprom */
@@ -2052,10 +2082,14 @@ rtems_dc_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching)
sc->dc_flags |= DC_REDUCED_MII_POLL|DC_TX_STORENFWD; sc->dc_flags |= DC_REDUCED_MII_POLL|DC_TX_STORENFWD;
sc->dc_pmode = DC_PMODE_MII; sc->dc_pmode = DC_PMODE_MII;
/* Increase the latency timer value. */ /* Increase the latency timer value. */
pcib_conf_read32(sig, DC_PCI_CFLT, &command); //pcib_conf_read32(sig, DC_PCI_CFLT, &command);
pci_read_config_dword(t->dc_bus,t->dc_dev,t->dc_fun,\
DC_PCI_CFLT, &command);
command &= 0xFFFF00FF; command &= 0xFFFF00FF;
command |= 0x00008000; command |= 0x00008000;
pcib_conf_write32(sig, DC_PCI_CFLT, command); //pcib_conf_write32(sig, DC_PCI_CFLT, command);
pci_write_config_dword(t->dc_bus,t->dc_dev,t->dc_fun,\
DC_PCI_CFLT, command);
break; break;
case DC_DEVICEID_AL981: case DC_DEVICEID_AL981:
sc->dc_type = DC_TYPE_AL981; sc->dc_type = DC_TYPE_AL981;
@@ -2142,7 +2176,9 @@ rtems_dc_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching)
sc->dc_cachesize = 0; sc->dc_cachesize = 0;
} }
else { else {
pcib_conf_read32(sig, DC_PCI_CFLT, &value); //pcib_conf_read32(sig, DC_PCI_CFLT, &value);
pci_read_config_dword(t->dc_bus,t->dc_dev,t->dc_fun,\
DC_PCI_CFLT, &value);
sc->dc_cachesize = (u_int8_t)(value & 0xFF); sc->dc_cachesize = (u_int8_t)(value & 0xFF);
} }
@@ -2151,9 +2187,13 @@ rtems_dc_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching)
/* Take 21143 out of snooze mode */ /* Take 21143 out of snooze mode */
if (DC_IS_INTEL(sc)) { if (DC_IS_INTEL(sc)) {
pcib_conf_read32(sig, DC_PCI_CFDD, &command); //pcib_conf_read32(sig, DC_PCI_CFDD, &command);
pci_read_config_dword(t->dc_bus,t->dc_dev,t->dc_fun,\
DC_PCI_CFDD, &command);
command &= ~(DC_CFDD_SNOOZE_MODE|DC_CFDD_SLEEP_MODE); command &= ~(DC_CFDD_SNOOZE_MODE|DC_CFDD_SLEEP_MODE);
pcib_conf_write32(sig, DC_PCI_CFDD, command); //pcib_conf_write32(sig, DC_PCI_CFDD, command);
pci_write_config_dword(t->dc_bus,t->dc_dev,t->dc_fun,\
DC_PCI_CFDD, command);
} }
@@ -2241,7 +2281,7 @@ rtems_dc_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching)
ifp->if_unit = unitNumber; /*sc->dc_unit;*/ ifp->if_unit = unitNumber; /*sc->dc_unit;*/
ifp->if_name = unitName; /*sc->dc_name;*/ ifp->if_name = unitName; /*sc->dc_name;*/
ifp->if_mtu = ETHERMTU; ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;/* | IFF_MULTICAST;*/ ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX; /* | IFF_MULTICAST;*/
ifp->if_ioctl = dc_ioctl; ifp->if_ioctl = dc_ioctl;
ifp->if_output = ether_output; ifp->if_output = ether_output;
ifp->if_start = dc_start; ifp->if_start = dc_start;
@@ -2326,7 +2366,7 @@ rtems_dc_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching)
ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
*/ */
#ifdef SRM_MEDIA #ifdef SRM_MEDIA /* only defined if __alpha__ is defined... */
sc->dc_srm_media = 0; sc->dc_srm_media = 0;
/* Remember the SRM console media setting */ /* Remember the SRM console media setting */
@@ -3285,8 +3325,8 @@ static void dc_start(ifp)
struct ifnet *ifp; struct ifnet *ifp;
{ {
struct dc_softc *sc; struct dc_softc *sc;
struct mbuf *m_head = NULL; struct mbuf *m_head = NULL;
int idx; unsigned int idx;
sc = ifp->if_softc; sc = ifp->if_softc;
#if 0 #if 0
@@ -3581,7 +3621,7 @@ static void dc_ifmedia_sts(ifp, ifmr)
static int dc_ioctl(ifp, command, data) static int dc_ioctl(ifp, command, data)
struct ifnet *ifp; struct ifnet *ifp;
int command; u_long command;
caddr_t data; caddr_t data;
{ {
struct dc_softc *sc = ifp->if_softc; struct dc_softc *sc = ifp->if_softc;
@@ -3806,5 +3846,4 @@ static int dc_resume(dev)
} }
#endif #endif
#endif /* end if supported */
#endif /* end if supported */

View File

@@ -474,7 +474,10 @@ struct dc_type {
u_int16_t dc_vid; u_int16_t dc_vid;
u_int16_t dc_did; u_int16_t dc_did;
char *dc_name; char *dc_name;
int dc_devsig; int dc_devsig;
int dc_bus;
int dc_dev;
int dc_fun;
}; };
struct dc_mii_frame { struct dc_mii_frame {
@@ -678,7 +681,7 @@ struct dc_mii_frame {
struct dc_softc { struct dc_softc {
struct arpcom arpcom; /* interface info */ struct arpcom arpcom; /* interface info */
rtems_irq_connect_data irqInfo; rtems_irq_connect_data irqInfo;
volatile unsigned32 membase; volatile u_int32_t membase;
rtems_id daemontid; rtems_id daemontid;
#if 0 #if 0
bus_space_handle_t dc_bhandle; /* bus space handle */ bus_space_handle_t dc_bhandle; /* bus space handle */