Add an option ED_NO_MIIBUS, which causes the `ed' driver to be

built without support for miibus PHYs. Most ed cards don't need
miibus support, so it's useful to be able to avoid the bloat of
all the mii devices for small fixed-purpose kernels.
This commit is contained in:
Ian Dowse 2001-09-29 22:32:03 +00:00
parent 2bb3ce0c47
commit 9b04180c2c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=84151
6 changed files with 43 additions and 0 deletions

View File

@ -1795,6 +1795,7 @@ hint.cx.0.port="0x240"
hint.cx.0.irq="15"
hint.cx.0.drq="7"
device ed
#options ED_NO_MIIBUS # Disable ed miibus support
hint.ed.0.at="isa"
hint.ed.0.port="0x280"
hint.ed.0.irq="5"

View File

@ -523,3 +523,6 @@ NDEVFSOVERFLOW opt_devfs.h
# various 'device presence' options.
DEV_MCA opt_mca.h
DEV_BPF opt_bpf.h
# ed driver
ED_NO_MIIBUS opt_ed.h

View File

@ -37,6 +37,8 @@
*
*/
#include "opt_ed.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sockio.h>
@ -58,8 +60,10 @@
#include <net/if_mib.h>
#include <net/if_media.h>
#ifndef ED_NO_MIIBUS
#include <dev/mii/mii.h>
#include <dev/mii/miivar.h>
#endif
#include <net/bpf.h>
#include "opt_bdg.h"
@ -79,7 +83,9 @@ static int ed_ioctl __P((struct ifnet *, u_long, caddr_t));
static void ed_start __P((struct ifnet *));
static void ed_reset __P((struct ifnet *));
static void ed_watchdog __P((struct ifnet *));
#ifndef ED_NO_MIIBUS
static void ed_tick __P((void *));
#endif
static void ds_getmcaf __P((struct ed_softc *, u_int32_t *));
@ -1702,8 +1708,10 @@ ed_stop(sc)
{
int n = 5000;
#ifndef ED_NO_MIIBUS
untimeout(ed_tick, sc, sc->tick_ch);
callout_handle_init(&sc->tick_ch);
#endif
if (sc->gone)
return;
/*
@ -1738,6 +1746,7 @@ ed_watchdog(ifp)
ed_reset(ifp);
}
#ifndef ED_NO_MIIBUS
static void
ed_tick(arg)
void *arg;
@ -1758,6 +1767,7 @@ ed_tick(arg)
sc->tick_ch = timeout(ed_tick, sc, hz);
splx(s);
}
#endif
/*
* Initialize device.
@ -1900,11 +1910,13 @@ ed_init(xsc)
}
}
#ifndef ED_NO_MIIBUS
if (sc->miibus != NULL) {
struct mii_data *mii;
mii = device_get_softc(sc->miibus);
mii_mediachg(mii);
}
#endif
/*
* Set 'running' flag, and clear output active flag.
*/
@ -1916,8 +1928,10 @@ ed_init(xsc)
*/
ed_start(ifp);
#ifndef ED_NO_MIIBUS
untimeout(ed_tick, sc, sc->tick_ch);
sc->tick_ch = timeout(ed_tick, sc, hz);
#endif
(void) splx(s);
}
@ -2529,8 +2543,10 @@ ed_ioctl(ifp, command, data)
caddr_t data;
{
struct ed_softc *sc = ifp->if_softc;
#ifndef ED_NO_MIIBUS
struct ifreq *ifr = (struct ifreq *)data;
struct mii_data *mii;
#endif
int s, error = 0;
if (sc == NULL || sc->gone) {
@ -2593,6 +2609,7 @@ ed_ioctl(ifp, command, data)
error = 0;
break;
#ifndef ED_NO_MIIBUS
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
if (sc->miibus == NULL) {
@ -2602,6 +2619,7 @@ ed_ioctl(ifp, command, data)
mii = device_get_softc(sc->miibus);
error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command);
break;
#endif
default:
error = EINVAL;
@ -3222,6 +3240,7 @@ ed_hpp_write_mbufs(struct ed_softc *sc, struct mbuf *m, int dst)
return (total_len);
}
#ifndef ED_NO_MIIBUS
/*
* MII bus support routines.
*/
@ -3325,6 +3344,7 @@ ed_child_detached(dev, child)
if (child == sc->miibus)
sc->miibus = NULL;
}
#endif
static void
ed_setrcr(sc)

View File

@ -27,6 +27,8 @@
* $FreeBSD$
*/
#include "opt_ed.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/socket.h>
@ -50,14 +52,18 @@
#include <dev/ed/if_edvar.h>
#include <dev/pccard/pccardvar.h>
#include <dev/pccard/pccarddevs.h>
#ifndef ED_NO_MIIBUS
#include <dev/mii/mii.h>
#include <dev/mii/miivar.h>
#endif
#include "card_if.h"
#ifndef ED_NO_MIIBUS
/* "device miibus" required. See GENERIC if you get errors here. */
#include "miibus_if.h"
MODULE_DEPEND(ed, miibus, 1, 1, 1);
#endif
/*
* PC-Card (PCMCIA) specific code.
@ -72,10 +78,12 @@ static int ed_pccard_ax88190(device_t dev);
static void ax88190_geteprom(struct ed_softc *);
static int ed_pccard_memwrite(device_t dev, off_t offset, u_char byte);
#ifndef ED_NO_MIIBUS
static void ed_pccard_dlink_mii_reset(struct ed_softc *sc);
static u_int ed_pccard_dlink_mii_readbits(struct ed_softc *sc, int nbits);
static void ed_pccard_dlink_mii_writebits(struct ed_softc *sc, u_int val,
int nbits);
#endif
/*
* ed_pccard_detach - unload the driver and clear the table.
@ -561,6 +569,7 @@ ed_pccard_attach(device_t dev)
}
error = ed_attach(sc, device_get_unit(dev), flags);
#ifndef ED_NO_MIIBUS
if (error == 0 && sc->vendor == ED_VENDOR_LINKSYS) {
/* Probe for an MII bus, but ignore errors. */
ed_pccard_dlink_mii_reset(sc);
@ -569,6 +578,7 @@ ed_pccard_attach(device_t dev)
mii_phy_probe(dev, &sc->miibus, ed_ifmedia_upd,
ed_ifmedia_sts);
}
#endif
return (error);
}
@ -712,6 +722,7 @@ ed_pccard_ax88190(device_t dev)
return (error);
}
#ifndef ED_NO_MIIBUS
/* MII bit-twiddling routines for cards using Dlink chipset */
#define DLINK_MIISET(sc, x) ed_asic_outb(sc, ED_DLINK_MIIBUS, \
ed_asic_inb(sc, ED_DLINK_MIIBUS) | (x))
@ -779,6 +790,7 @@ ed_pccard_dlink_mii_readbits(sc, nbits)
return val;
}
#endif
static device_method_t ed_pccard_methods[] = {
/* Device interface */
@ -786,12 +798,14 @@ static device_method_t ed_pccard_methods[] = {
DEVMETHOD(device_attach, pccard_compat_attach),
DEVMETHOD(device_detach, ed_pccard_detach),
#ifndef ED_NO_MIIBUS
/* Bus interface */
DEVMETHOD(bus_child_detached, ed_child_detached),
/* MII interface */
DEVMETHOD(miibus_readreg, ed_miibus_readreg),
DEVMETHOD(miibus_writereg, ed_miibus_writereg),
#endif
/* Card interface */
DEVMETHOD(card_compat_match, ed_pccard_match),
@ -807,4 +821,6 @@ static driver_t ed_pccard_driver = {
};
DRIVER_MODULE(if_ed, pccard, ed_pccard_driver, ed_devclass, 0, 0);
#ifndef ED_NO_MIIBUS
DRIVER_MODULE(miibus, ed, miibus_driver, miibus_devclass, 0, 0);
#endif

View File

@ -209,11 +209,13 @@ void ed_pio_readmem __P((struct ed_softc *, int, unsigned char *,
unsigned short));
void ed_pio_writemem __P((struct ed_softc *, char *,
unsigned short, unsigned short));
#ifndef ED_NO_MIIBUS
int ed_miibus_readreg __P((device_t, int, int));
void ed_miibus_writereg __P((device_t, int, int, int));
int ed_ifmedia_upd __P((struct ifnet *));
void ed_ifmedia_sts __P((struct ifnet *, struct ifmediareq *));
void ed_child_detached __P((device_t, device_t));
#endif
driver_intr_t edintr;

View File

@ -1795,6 +1795,7 @@ hint.cx.0.port="0x240"
hint.cx.0.irq="15"
hint.cx.0.drq="7"
device ed
#options ED_NO_MIIBUS # Disable ed miibus support
hint.ed.0.at="isa"
hint.ed.0.port="0x280"
hint.ed.0.irq="5"