8.2.5 Setting the LAN Media
The following code shows how the
el_init_locked( )
routine sets the
LAN media. This task is specific to the 3Com 3C5x9 device. You may want
to perform similar initialization tasks for the hardware device that your
network driver controls.
i = READ_ACR(sc);
1
i &=
~ (ACR_BASE|ACR_10B2);
2
switch (sc->lm_media) {
3
case LAN_MEDIA_BNC:
4
WRITE_ACR(sc,
i | ACR_10B2 | sc->iobase);
5
WRITE_CMD(sc, CMD_START2);
6
DELAY(800);
7
break;
case LAN_MEDIA_AUI:
8
WRITE_ACR(sc,
i | ACR_10B5 | sc->iobase);
9
break;
default:
10
sc->lm_media = LAN_MEDIA_UTP;
case LAN_MEDIA_UTP:
11
WRITE_ACR(sc,
i | ACR_10BT | sc->iobase);
12
WRITE_CMD(sc, CMD_WINDOW4);
13
i = READ_MD(sc);
WRITE_MD(sc, i | (MD_LBE | MD_JABE));
14
break;
}
1
Calls the
READ_ACR
macro to read the data from the address control
register.
2
Clears the
ACR_BASE
(the I/O base address) and the
ACR_10B2
(Ethernet thin coaxial cable) bits.
3
Evaluates the value that is stored in the
lm_media
member of the
el_softc
data structure for this device.
4
Determines whether
lm_media
evaluates to
LAN_MEDIA_BNC
(media
mode is thin wire).
5
Calls the
WRITE_ACR
macro to write data to the address control register.
The data to be written establishes the Ethernet thin coaxial cable as
the media.
6
Calls the
WRITE_CMD
macro a second time to write data to the command
port register. In this call, the data that is written to the command port
register is
CMD_START2
(the start 10Base2 command bit).
7
Calls the
DELAY
macro to wait 800 microseconds.
8
Determines whether
lm_media
evaluates to
LAN_MEDIA_AUI
(media
mode is the Attachment Unit Interface).
9
Calls
WRITE_ACR
to write to the address control register. The data to be
written establishes the Ethernet thick coaxial cable as the media.
8–6 Implementing the Initialization Section