Another step in merging our if_aue driver with NetBSD's.

This commit is contained in:
joe 2002-04-06 20:50:21 +00:00
parent a348167c48
commit 4f7e88806c
3 changed files with 19 additions and 20 deletions

View File

@ -405,12 +405,10 @@ aue_read_eeprom(struct aue_softc *sc, caddr_t dest, int off, int cnt, int swap)
Static int Static int
aue_miibus_readreg(device_ptr_t dev, int phy, int reg) aue_miibus_readreg(device_ptr_t dev, int phy, int reg)
{ {
struct aue_softc *sc; struct aue_softc *sc = USBGETSOFTC(dev);
int i; int i;
u_int16_t val = 0; u_int16_t val = 0;
sc = device_get_softc(dev);
/* /*
* The Am79C901 HomePNA PHY actually contains * The Am79C901 HomePNA PHY actually contains
* two transceivers: a 1Mbps HomePNA PHY and a * two transceivers: a 1Mbps HomePNA PHY and a
@ -451,14 +449,12 @@ aue_miibus_readreg(device_ptr_t dev, int phy, int reg)
Static int Static int
aue_miibus_writereg(device_ptr_t dev, int phy, int reg, int data) aue_miibus_writereg(device_ptr_t dev, int phy, int reg, int data)
{ {
struct aue_softc *sc; struct aue_softc *sc = USBGETSOFTC(dev);
int i; int i;
if (phy == 3) if (phy == 3)
return (0); return (0);
sc = device_get_softc(dev);
aue_csr_write_2(sc, AUE_PHY_DATA, data); aue_csr_write_2(sc, AUE_PHY_DATA, data);
aue_csr_write_1(sc, AUE_PHY_ADDR, phy); aue_csr_write_1(sc, AUE_PHY_ADDR, phy);
aue_csr_write_1(sc, AUE_PHY_CTL, reg | AUE_PHYCTL_WRITE); aue_csr_write_1(sc, AUE_PHY_CTL, reg | AUE_PHYCTL_WRITE);
@ -479,11 +475,8 @@ aue_miibus_writereg(device_ptr_t dev, int phy, int reg, int data)
Static void Static void
aue_miibus_statchg(device_ptr_t dev) aue_miibus_statchg(device_ptr_t dev)
{ {
struct aue_softc *sc; struct aue_softc *sc = USBGETSOFTC(dev);
struct mii_data *mii; struct mii_data *mii = GET_MII(sc);
sc = device_get_softc(dev);
mii = device_get_softc(sc->aue_miibus);
AUE_CLRBIT(sc, AUE_CTL0, AUE_CTL0_RX_ENB | AUE_CTL0_TX_ENB); AUE_CLRBIT(sc, AUE_CTL0, AUE_CTL0_RX_ENB | AUE_CTL0_TX_ENB);
if (IFM_SUBTYPE(mii->mii_media_active) == IFM_100_TX) { if (IFM_SUBTYPE(mii->mii_media_active) == IFM_100_TX) {
@ -1097,7 +1090,7 @@ aue_tick(void *xsc)
AUE_LOCK(sc); AUE_LOCK(sc);
ifp = &sc->arpcom.ac_if; ifp = &sc->arpcom.ac_if;
mii = device_get_softc(sc->aue_miibus); mii = GET_MII(sc);
if (mii == NULL) { if (mii == NULL) {
AUE_UNLOCK(sc); AUE_UNLOCK(sc);
return; return;
@ -1215,7 +1208,7 @@ aue_init(void *xsc)
{ {
struct aue_softc *sc = xsc; struct aue_softc *sc = xsc;
struct ifnet *ifp = &sc->arpcom.ac_if; struct ifnet *ifp = &sc->arpcom.ac_if;
struct mii_data *mii; struct mii_data *mii = GET_MII(sc);
struct aue_chain *c; struct aue_chain *c;
usbd_status err; usbd_status err;
int i; int i;
@ -1232,8 +1225,6 @@ aue_init(void *xsc)
*/ */
aue_reset(sc); aue_reset(sc);
mii = device_get_softc(sc->aue_miibus);
/* Set MAC address */ /* Set MAC address */
for (i = 0; i < ETHER_ADDR_LEN; i++) for (i = 0; i < ETHER_ADDR_LEN; i++)
aue_csr_write_1(sc, AUE_PAR0 + i, sc->arpcom.ac_enaddr[i]); aue_csr_write_1(sc, AUE_PAR0 + i, sc->arpcom.ac_enaddr[i]);
@ -1329,9 +1320,8 @@ Static int
aue_ifmedia_upd(struct ifnet *ifp) aue_ifmedia_upd(struct ifnet *ifp)
{ {
struct aue_softc *sc = ifp->if_softc; struct aue_softc *sc = ifp->if_softc;
struct mii_data *mii; struct mii_data *mii = GET_MII(sc);
mii = device_get_softc(sc->aue_miibus);
sc->aue_link = 0; sc->aue_link = 0;
if (mii->mii_instance) { if (mii->mii_instance) {
struct mii_softc *miisc; struct mii_softc *miisc;
@ -1350,9 +1340,8 @@ Static void
aue_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) aue_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
{ {
struct aue_softc *sc = ifp->if_softc; struct aue_softc *sc = ifp->if_softc;
struct mii_data *mii; struct mii_data *mii = GET_MII(sc);
mii = device_get_softc(sc->aue_miibus);
mii_pollstat(mii); mii_pollstat(mii);
ifmr->ifm_active = mii->mii_media_active; ifmr->ifm_active = mii->mii_media_active;
ifmr->ifm_status = mii->mii_media_status; ifmr->ifm_status = mii->mii_media_status;
@ -1402,7 +1391,7 @@ aue_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
break; break;
case SIOCGIFMEDIA: case SIOCGIFMEDIA:
case SIOCSIFMEDIA: case SIOCSIFMEDIA:
mii = device_get_softc(sc->aue_miibus); mii = GET_MII(sc);
error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command);
break; break;
default: default:

View File

@ -240,6 +240,13 @@ struct aue_cdata {
#define AUE_INC(x, y) (x) = (x + 1) % y #define AUE_INC(x, y) (x) = (x + 1) % y
struct aue_softc { struct aue_softc {
#if defined(__FreeBSD__)
#define GET_MII(sc) (device_get_softc((sc)->aue_miibus))
#elif defined(__NetBSD__)
#define GET_MII(sc) (&(sc)->aue_mii)
#elif defined(__OpenBSD__)
#define GET_MII(sc) (&(sc)->aue_mii)
#endif
struct arpcom arpcom; struct arpcom arpcom;
device_t aue_miibus; device_t aue_miibus;
usbd_device_handle aue_udev; usbd_device_handle aue_udev;

View File

@ -75,6 +75,7 @@ typedef struct device *device_ptr_t;
#define USBDEVUNIT(bdev) ((bdev).dv_unit) #define USBDEVUNIT(bdev) ((bdev).dv_unit)
#define USBDEVPTRNAME(bdevptr) ((bdevptr)->dv_xname) #define USBDEVPTRNAME(bdevptr) ((bdevptr)->dv_xname)
#define USBDEVUNIT(bdev) ((bdev).dv_unit) #define USBDEVUNIT(bdev) ((bdev).dv_unit)
#define USBGETSOFTC(d) ((void *)(d))
#define DECLARE_USB_DMA_T \ #define DECLARE_USB_DMA_T \
struct usb_dma_block; \ struct usb_dma_block; \
@ -206,6 +207,7 @@ typedef struct device *device_ptr_t;
#define USBDEVUNIT(bdev) ((bdev).dv_unit) #define USBDEVUNIT(bdev) ((bdev).dv_unit)
#define USBDEVPTRNAME(bdevptr) ((bdevptr)->dv_xname) #define USBDEVPTRNAME(bdevptr) ((bdevptr)->dv_xname)
#define USBDEVUNIT(bdev) ((bdev).dv_unit) #define USBDEVUNIT(bdev) ((bdev).dv_unit)
#define USBGETSOFTC(d) ((void *)(d))
#define DECLARE_USB_DMA_T \ #define DECLARE_USB_DMA_T \
struct usb_dma_block; \ struct usb_dma_block; \
@ -317,6 +319,7 @@ MALLOC_DECLARE(M_USBHC);
#define USBDEVUNIT(bdev) device_get_unit(bdev) #define USBDEVUNIT(bdev) device_get_unit(bdev)
#define USBDEVPTRNAME(bdev) device_get_nameunit(bdev) #define USBDEVPTRNAME(bdev) device_get_nameunit(bdev)
#define USBDEVUNIT(bdev) device_get_unit(bdev) #define USBDEVUNIT(bdev) device_get_unit(bdev)
#define USBGETSOFTC(bdev) (device_get_softc(bdev))
#define DECLARE_USB_DMA_T typedef char * usb_dma_t #define DECLARE_USB_DMA_T typedef char * usb_dma_t