1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-17 15:27:36 +00:00

Initial ifmedia support. Once I figure out autoselection I'll put the

rest of the code in (so changing media actually works.)

Add a few more register definitions for use with this and other new code.

Print a few details in the probe message; this should be useful in
bug reports and such but should not add to the clutter.
This commit is contained in:
Matthew N. Dodd 2000-03-13 12:23:32 +00:00
parent cfb21bbb7d
commit c7a9e0529c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=57987
2 changed files with 113 additions and 15 deletions

View File

@ -55,14 +55,15 @@
#include <machine/resource.h>
#include <sys/rman.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <net/if_media.h>
#include <net/ethernet.h>
#include <net/bpf.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <net/bpf.h>
#include <machine/clock.h>
#include <isa/isavar.h>
@ -82,15 +83,12 @@ static int exintr_count = 0;
# define DODEBUG(level, action)
#endif
#define Conn_BNC 1
#define Conn_TPE 2
#define Conn_AUI 3
#define CARD_TYPE_EX_10 1
#define CARD_TYPE_EX_10_PLUS 2
struct ex_softc {
struct arpcom arpcom; /* Ethernet common data */
struct ifmedia ifmedia;
device_t dev;
struct resource *ioport;
@ -102,8 +100,6 @@ struct ex_softc {
char * irq2ee; /* irq <-> internal */
u_char * ee2irq; /* representation conversion */
u_short connector; /* Connector type. */
u_int mem_size; /* Total memory size, in bytes. */
u_int rx_mem_size; /* Rx memory size (by default, */
/* first 3/4 of total memory). */
@ -146,6 +142,10 @@ static void ex_start __P((struct ifnet *));
static int ex_ioctl __P((struct ifnet *, u_long, caddr_t));
static void ex_watchdog __P((struct ifnet *));
/* ifmedia Functions */
static int ex_ifmedia_upd __P((struct ifnet *));
static void ex_ifmedia_sts __P((struct ifnet *, struct ifmediareq *));
static void ex_stop __P((struct ex_softc *));
static void ex_reset __P((struct ex_softc *));
@ -208,11 +208,11 @@ ex_get_media (u_int32_t iobase)
outb(iobase + CMD_REG, Bank0_Sel);
if (tmp & TPE_bit)
return(Conn_TPE);
return(IFM_ETHER|IFM_10_T);
if (tmp & BNC_bit)
return(Conn_BNC);
return(IFM_ETHER|IFM_10_2);
return (Conn_AUI);
return (IFM_ETHER|IFM_10_5);
}
static void
@ -374,10 +374,12 @@ ex_isa_attach(device_t dev)
{
struct ex_softc * sc = device_get_softc(dev);
struct ifnet * ifp = &sc->arpcom.ac_if;
struct ifmedia * ifm;
int unit = device_get_unit(dev);
int error;
int rid;
void * ih;
u_int16_t temp;
DODEBUG(Start_End, device_printf(dev, "start\n"););
@ -429,7 +431,6 @@ ex_isa_attach(device_t dev)
sc->ee2irq = ee2irqmap;
}
sc->connector = ex_get_media(sc->iobase);
sc->mem_size = CARD_RAM_SIZE; /* XXX This should be read from the card itself. */
/*
@ -447,15 +448,40 @@ ex_isa_attach(device_t dev)
ifp->if_init = ex_init;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
ifmedia_init(&sc->ifmedia, 0, ex_ifmedia_upd, ex_ifmedia_sts);
temp = eeprom_read(sc->iobase, EE_W5);
if (temp & EE_W5_PORT_TPE)
ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_T, 0, NULL);
if (temp & EE_W5_PORT_BNC)
ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_2, 0, NULL);
if (temp & EE_W5_PORT_AUI)
ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_5, 0, NULL);
ifmedia_set(&sc->ifmedia, ex_get_media(sc->iobase));
ifm = &sc->ifmedia;
ifm->ifm_media = ifm->ifm_cur->ifm_media;
ex_ifmedia_upd(ifp);
/*
* Attach the interface.
*/
if_attach(ifp);
ether_ifattach(ifp);
temp = eeprom_read(sc->iobase, EE_W0);
device_printf(sc->dev, "%s config, %s bus, ",
(temp & EE_W0_PNP) ? "PnP" : "Manual",
(temp & EE_W0_BUS16) ? "16-bit" : "8-bit");
temp = eeprom_read(sc->iobase, EE_W6);
printf("board id 0x%03x, stepping 0x%01x\n",
(temp & EE_W6_BOARD_MASK) >> EE_W6_BOARD_SHIFT,
temp & EE_W6_STEP_MASK);
device_printf(sc->dev, "Ethernet address %6D\n",
sc->arpcom.ac_enaddr, ":");
/*
* If BPF is in the kernel, call the attach for it
*/
@ -1000,6 +1026,7 @@ static int
ex_ioctl(register struct ifnet *ifp, u_long cmd, caddr_t data)
{
struct ex_softc * sc = ifp->if_softc;
struct ifreq * ifr = (struct ifreq *)data;
int s;
int error = 0;
@ -1039,6 +1066,10 @@ ex_ioctl(register struct ifnet *ifp, u_long cmd, caddr_t data)
/* XXX Support not done yet. */
error = EINVAL;
break;
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, cmd);
break;
default:
DODEBUG(Start_End, printf("unknown"););
error = EINVAL;
@ -1071,7 +1102,6 @@ ex_reset(struct ex_softc *sc)
return;
}
static void
ex_watchdog(struct ifnet *ifp)
{
@ -1092,6 +1122,26 @@ ex_watchdog(struct ifnet *ifp)
return;
}
static int
ex_ifmedia_upd (ifp)
struct ifnet * ifp;
{
struct ex_softc * sc = ifp->if_softc;
return (0);
}
static void
ex_ifmedia_sts(ifp, ifmr)
struct ifnet * ifp;
struct ifmediareq * ifmr;
{
struct ex_softc * sc = ifp->if_softc;
ifmr->ifm_active = ex_get_media(sc->iobase);
return;
}
static u_short
eeprom_read(int iobase, int location)

View File

@ -23,6 +23,8 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
/*
@ -124,12 +126,58 @@
/* EEPROM memory positions (16-bit wide). */
#define EE_W0 0x00
# define EE_W0_PNP 0x0001
# define EE_W0_BUS16 0x0004
# define EE_W0_FLASH_ADDR_MASK 0x0038
# define EE_W0_FLASH_ADDR_SHIFT 3
# define EE_W0_AUTO_IO 0x0040
# define EE_W0_FLASH 0x0100
# define EE_W0_AUTO_NEG 0x0200
# define EE_W0_IO_MASK 0xFC00
# define EE_W0_IO_SHIFT 10
#define EE_IRQ_No 1
#define IRQ_No_Mask 0x07
#define EE_W1 0x01
# define EE_W1_INT_SEL 0x0007
# define EE_W1_NO_LINK_INT 0x0008 /* Link Integrity Off */
# define EE_W1_NO_POLARITY 0x0010 /* Polarity Correction Off */
# define EE_W1_TPE_AUI 0x0020 /* 1 = TPE, 0 = AUI */
# define EE_W1_NO_JABBER_PREV 0x0040 /* Jabber prevention Off */
# define EE_W1_NO_AUTO_SELECT 0x0080 /* Auto Port Selection Off */
# define EE_W1_SMOUT 0x0100 /* SMout Pin Control 0= Input */
# define EE_W1_PROM 0x0200 /* Flash = 0, PROM = 1 */
# define EE_W1_ALT_READY 0x2000 /* Alternate Ready, 0=normal */
# define EE_W1_FULL_DUPLEX 0x8000
#define EE_W2 0x02
#define EE_W3 0x03
#define EE_W4 0x04
#define EE_Eth_Addr_Lo 2
#define EE_Eth_Addr_Mid 3
#define EE_Eth_Addr_Hi 4
#define EE_W5 0x05
# define EE_W5_BNC_TPE 0x0001 /* 0 = TPE, 1 = BNC */
# define EE_W5_BOOT_IPX 0x0002
# define EE_W5_BOOT_ODI 0x0004
# define EE_W5_BOOT_NDIS (EE_W5_BOOT_IPX|EE_W5_BOOT_ODI)
# define EE_W5_NUM_CONN 0x0008 /* 0 = 2, 1 = 3 */
# define EE_W5_NOFLASH 0x0010 /* No flash socket present */
# define EE_W5_PORT_TPE 0x0020 /* TPE present */
# define EE_W5_PORT_BNC 0x0040 /* BNC present */
# define EE_W5_PORT_AUI 0x0080 /* AUI present */
# define EE_W5_PWR_MGT 0x0100 /* Power Management */
# define EE_W5_CP 0x0200 /* COncurrent Processing */
#define EE_W6 0x05
# define EE_W6_STEP_MASK 0x000F
# define EE_W6_BOARD_MASK 0xFFF0
# define EE_W6_BOARD_SHIFT 4
/* EEPROM serial interface. */
#define EESK 0x01