1 /* $NetBSD: if_ec.c,v 1.32 2008/03/12 14:31:11 cube Exp $ */
4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
34 * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
37 * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
39 * Copyright (C) 1993, David Greenman. This software may be used, modified,
40 * copied, distributed, and sold, in both source and binary form provided that
41 * the above copyright and these terms are retained. Under no circumstances is
42 * the author responsible for the proper functioning of this software, nor does
43 * the author assume any responsibility for damages incurred with its use.
47 * Device driver for the 3Com Etherlink II (3c503).
50 #include <sys/cdefs.h>
51 __KERNEL_RCSID(0, "$NetBSD: if_ec.c,v 1.32 2008/03/12 14:31:11 cube Exp $");
53 #include <sys/param.h>
54 #include <sys/systm.h>
55 #include <sys/device.h>
56 #include <sys/socket.h>
58 #include <sys/syslog.h>
61 #include <net/if_dl.h>
62 #include <net/if_types.h>
63 #include <net/if_media.h>
65 #include <net/if_ether.h>
70 #include <dev/isa/isareg.h>
71 #include <dev/isa/isavar.h>
73 #include <dev/ic/dp8390reg.h>
74 #include <dev/ic/dp8390var.h>
76 #include <dev/isa/if_ecreg.h>
79 struct dp8390_softc sc_dp8390
;
81 bus_space_tag_t sc_asict
; /* space tag for ASIC */
82 bus_space_handle_t sc_asich
; /* space handle for ASIC */
84 int sc_16bitp
; /* are we 16 bit? */
86 void *sc_ih
; /* interrupt handle */
89 int ec_probe(device_t
, cfdata_t
, void *);
90 void ec_attach(device_t
, device_t
, void *);
92 CFATTACH_DECL_NEW(ec
, sizeof(struct ec_softc
),
93 ec_probe
, ec_attach
, NULL
, NULL
);
95 int ec_set_media(struct ec_softc
*, int);
97 void ec_media_init(struct dp8390_softc
*);
99 int ec_mediachange(struct dp8390_softc
*);
100 void ec_mediastatus(struct dp8390_softc
*, struct ifmediareq
*);
102 void ec_init_card(struct dp8390_softc
*);
103 int ec_write_mbuf(struct dp8390_softc
*, struct mbuf
*, int);
104 int ec_ring_copy(struct dp8390_softc
*, int, void *, u_short
);
105 void ec_read_hdr(struct dp8390_softc
*, int, struct dp8390_ring
*);
106 int ec_fake_test_mem(struct dp8390_softc
*);
107 int ec_test_mem(struct dp8390_softc
*);
109 inline void ec_readmem(struct ec_softc
*, int, u_int8_t
*, int);
111 static const int ec_iobase
[] = {
112 0x2e0, 0x2a0, 0x280, 0x250, 0x350, 0x330, 0x310, 0x300,
114 #define NEC_IOBASE (sizeof(ec_iobase) / sizeof(ec_iobase[0]))
116 static const int ec_membase
[] = {
118 0xc8000, 0xcc000, 0xd8000, 0xdc000,
120 #define NEC_MEMBASE (sizeof(ec_membase) / sizeof(ec_membase[0]))
123 ec_probe(device_t parent
, cfdata_t match
, void *aux
)
125 struct isa_attach_args
*ia
= aux
;
126 bus_space_tag_t nict
, asict
, memt
;
127 bus_space_handle_t nich
, asich
, memh
;
129 int nich_valid
, asich_valid
, memh_valid
;
133 nict
= asict
= ia
->ia_iot
;
136 nich_valid
= asich_valid
= memh_valid
= 0;
139 * Hmm, a 16-bit card has 16k of memory, but only an 8k window
146 if (ia
->ia_niomem
< 1)
151 if (ISA_DIRECT_CONFIG(ia
))
154 /* Disallow wildcarded i/o addresses. */
155 if (ia
->ia_io
[0].ir_addr
== ISA_UNKNOWN_PORT
)
158 /* Disallow wildcarded mem address. */
159 if (ia
->ia_iomem
[0].ir_addr
== ISA_UNKNOWN_IOMEM
)
162 /* Validate the i/o base. */
163 for (i
= 0; i
< NEC_IOBASE
; i
++)
164 if (ia
->ia_io
[0].ir_addr
== ec_iobase
[i
])
169 /* Validate the mem base. */
170 for (i
= 0; i
< NEC_MEMBASE
; i
++) {
171 if (ec_membase
[i
] == -1)
173 if (ia
->ia_iomem
[0].ir_addr
== ec_membase
[i
])
176 if (i
== NEC_MEMBASE
)
179 /* Attempt to map the NIC space. */
180 if (bus_space_map(nict
, ia
->ia_io
[0].ir_addr
+ ELINK2_NIC_OFFSET
,
181 ELINK2_NIC_PORTS
, 0, &nich
))
185 /* Attempt to map the ASIC space. */
186 if (bus_space_map(asict
, ia
->ia_io
[0].ir_addr
+ ELINK2_ASIC_OFFSET
,
187 ELINK2_ASIC_PORTS
, 0, &asich
))
191 /* Attempt to map the memory space. */
192 if (bus_space_map(memt
, ia
->ia_iomem
[0].ir_addr
, memsize
, 0, &memh
))
197 * Verify that the kernel configured I/O address matches the
198 * board configured I/O address.
200 * This is really only useful to see if something that looks like
201 * the board is there; after all, we're already talking to it at
204 x
= bus_space_read_1(asict
, asich
, ELINK2_BCFR
);
205 if (x
== 0 || (x
& (x
- 1)) != 0)
208 if (ia
->ia_io
[0].ir_addr
!= ec_iobase
[i
])
212 * ...and for the memory address. Note we do not support
213 * cards configured with shared memory disabled.
215 x
= bus_space_read_1(asict
, asich
, ELINK2_PCFR
);
216 if (x
== 0 || (x
& (x
- 1)) != 0)
219 if (ia
->ia_iomem
[0].ir_addr
!= ec_membase
[i
])
222 /* So, we say we've found it! */
223 ia
->ia_nio
= 1; /* XXX Really 2! */
224 ia
->ia_io
[0].ir_size
= ELINK2_NIC_PORTS
;
227 ia
->ia_iomem
[0].ir_size
= memsize
;
237 bus_space_unmap(nict
, nich
, ELINK2_NIC_PORTS
);
239 bus_space_unmap(asict
, asich
, ELINK2_ASIC_PORTS
);
241 bus_space_unmap(memt
, memh
, memsize
);
246 ec_attach(device_t parent
, device_t self
, void *aux
)
248 struct ec_softc
*esc
= device_private(self
);
249 struct dp8390_softc
*sc
= &esc
->sc_dp8390
;
250 struct isa_attach_args
*ia
= aux
;
251 bus_space_tag_t nict
, asict
, memt
;
252 bus_space_handle_t nich
, asich
, memh
;
260 nict
= asict
= ia
->ia_iot
;
264 * Hmm, a 16-bit card has 16k of memory, but only an 8k window
267 memsize
= ia
->ia_iomem
[0].ir_size
;
269 /* Map the NIC space. */
270 if (bus_space_map(nict
, ia
->ia_io
[0].ir_addr
+ ELINK2_NIC_OFFSET
,
271 ELINK2_NIC_PORTS
, 0, &nich
)) {
272 aprint_error_dev(self
, "can't map nic i/o space\n");
276 /* Map the ASIC space. */
277 if (bus_space_map(asict
, ia
->ia_io
[0].ir_addr
+ ELINK2_ASIC_OFFSET
,
278 ELINK2_ASIC_PORTS
, 0, &asich
)) {
279 aprint_error_dev(self
, "can't map asic i/o space\n");
283 /* Map the memory space. */
284 if (bus_space_map(memt
, ia
->ia_iomem
[0].ir_addr
, memsize
, 0, &memh
)) {
285 aprint_error_dev(self
, "can't map shared memory\n");
289 esc
->sc_asict
= asict
;
290 esc
->sc_asich
= asich
;
298 /* Interface is always enabled. */
301 /* Registers are linear. */
302 for (i
= 0; i
< 16; i
++)
303 sc
->sc_reg_map
[i
] = i
;
305 /* Now we can use the NIC_{GET,PUT}() macros. */
308 * Reset NIC and ASIC. Enable on-board transeiver throughout
309 * reset sequence since it will lock up if the cable isn't
310 * connected if we don't.
312 bus_space_write_1(asict
, asich
, ELINK2_CR
,
313 ELINK2_CR_RST
| ELINK2_CR_XSEL
);
315 /* Wait for a while, then un-reset it. */
319 * The 3Com ASIC defaults to rather strange settings for the CR
320 * after a reset. It's important to set it again after the
321 * following write (this is done when we map the PROM below).
323 bus_space_write_1(asict
, asich
, ELINK2_CR
, ELINK2_CR_XSEL
);
325 /* Wait a bit for the NIC to recover from the reset. */
329 * Get the station address from on-board ROM.
331 * First, map Ethernet address PROM over the top of where the NIC
332 * registers normally appear.
334 bus_space_write_1(asict
, asich
, ELINK2_CR
,
335 ELINK2_CR_XSEL
| ELINK2_CR_EALO
);
337 for (i
= 0; i
< ETHER_ADDR_LEN
; i
++)
338 sc
->sc_enaddr
[i
] = NIC_GET(nict
, nich
, i
);
341 * Unmap PROM - select NIC registers. The proper setting of the
342 * transceiver is set in later in ec_init_card() via dp8390_init().
344 bus_space_write_1(asict
, asich
, ELINK2_CR
, ELINK2_CR_XSEL
);
346 /* Determine if this is an 8-bit or 16-bit board. */
348 /* Select page 0 registers. */
349 NIC_PUT(nict
, nich
, ED_P0_CR
, ED_CR_RD2
| ED_CR_PAGE_0
| ED_CR_STP
);
352 * Attempt to clear WTS. If it doesn't clear, then this is a
355 NIC_PUT(nict
, nich
, ED_P0_DCR
, 0);
357 /* Select page 2 registers. */
358 NIC_PUT(nict
, nich
, ED_P0_CR
, ED_CR_RD2
| ED_CR_PAGE_2
| ED_CR_STP
);
360 /* The 3c503 forces the WTS bit to a one if this is a 16-bit board. */
361 if (NIC_GET(nict
, nich
, ED_P2_DCR
) & ED_DCR_WTS
)
366 aprint_normal_dev(self
, "3Com 3c503 Ethernet (%s-bit)\n",
367 esc
->sc_16bitp
? "16" : "8");
369 /* Select page 0 registers. */
370 NIC_PUT(nict
, nich
, ED_P2_CR
, ED_CR_RD2
| ED_CR_PAGE_0
| ED_CR_STP
);
372 sc
->cr_proto
= ED_CR_RD2
;
377 * FIFO threshold to 8, No auto-init Remote DMA,
380 * 16-bit cards also get word-wide DMA transfers.
382 sc
->dcr_reg
= ED_DCR_FT1
| ED_DCR_LS
|
383 (esc
->sc_16bitp
? ED_DCR_WTS
: 0);
385 sc
->test_mem
= ec_fake_test_mem
;
386 sc
->ring_copy
= ec_ring_copy
;
387 sc
->write_mbuf
= ec_write_mbuf
;
388 sc
->read_hdr
= ec_read_hdr
;
389 sc
->init_card
= ec_init_card
;
391 sc
->sc_media_init
= ec_media_init
;
393 sc
->sc_mediachange
= ec_mediachange
;
394 sc
->sc_mediastatus
= ec_mediastatus
;
397 sc
->mem_size
= memsize
;
399 /* Do generic parts of attach. */
400 if (dp8390_config(sc
)) {
401 aprint_error_dev(self
, " configuration failed\n");
406 * We need to override the way dp8390_config() set up our
409 * We have an entire 8k window to put the transmit buffers on the
410 * 16-bit boards. But since the 16bit 3c503's shared memory is only
411 * fast enough to overlap the loading of one full-size packet, trying
412 * to load more than 2 buffers can actually leave the transmitter idle
413 * during the load. So 2 seems the best value. (Although a mix of
414 * variable-sized packets might change this assumption. Nonetheless,
415 * we optimize for linear transfers of same-size packets.)
417 if (esc
->sc_16bitp
) {
418 if (device_cfdata(sc
->sc_dev
)->cf_flags
&
419 DP8390_NO_MULTI_BUFFERING
)
424 sc
->tx_page_start
= ELINK2_TX_PAGE_OFFSET_16BIT
;
425 sc
->rec_page_start
= ELINK2_RX_PAGE_OFFSET_16BIT
;
426 sc
->rec_page_stop
= (memsize
>> ED_PAGE_SHIFT
) +
428 sc
->mem_ring
= sc
->mem_start
;
431 sc
->tx_page_start
= ELINK2_TX_PAGE_OFFSET_8BIT
;
432 sc
->rec_page_start
= sc
->tx_page_start
+ ED_TXBUF_SIZE
;
433 sc
->rec_page_stop
= (memsize
>> ED_PAGE_SHIFT
) +
435 sc
->mem_ring
= sc
->mem_start
+
436 (ED_TXBUF_SIZE
<< ED_PAGE_SHIFT
);
440 * Initialize CA page start/stop registers. Probably only needed
441 * if doing DMA, but what the Hell.
443 bus_space_write_1(asict
, asich
, ELINK2_PSTR
, sc
->rec_page_start
);
444 bus_space_write_1(asict
, asich
, ELINK2_PSPR
, sc
->rec_page_stop
);
449 switch (ia
->ia_irq
[0].ir_irq
) {
450 case 9: tmp
= ELINK2_IDCFR_IRQ2
; break;
451 case 3: tmp
= ELINK2_IDCFR_IRQ3
; break;
452 case 4: tmp
= ELINK2_IDCFR_IRQ4
; break;
453 case 5: tmp
= ELINK2_IDCFR_IRQ5
; break;
456 case ISA_UNKNOWN_IRQ
:
457 aprint_error_dev(self
, "wildcarded IRQ is not allowed\n");
461 aprint_error_dev(self
, "invalid IRQ %d, must be 3, 4, 5, "
462 "or 9\n", ia
->ia_irq
[0].ir_irq
);
466 bus_space_write_1(asict
, asich
, ELINK2_IDCFR
, tmp
);
469 * Initialize the GA configuration register. Set bank and enable
472 bus_space_write_1(asict
, asich
, ELINK2_GACFR
,
473 ELINK2_GACFR_RSEL
| ELINK2_GACFR_MBS0
);
476 * Intialize "Vector Pointer" registers. These gawd-awful things
477 * are compared to 20 bits of the address on the ISA, and if they
478 * match, the shared memory is disabled. We set them to 0xffff0...
479 * allegedly the reset vector.
481 bus_space_write_1(asict
, asich
, ELINK2_VPTR2
, 0xff);
482 bus_space_write_1(asict
, asich
, ELINK2_VPTR1
, 0xff);
483 bus_space_write_1(asict
, asich
, ELINK2_VPTR0
, 0x00);
486 * Now run the real memory test.
488 if (ec_test_mem(sc
)) {
489 aprint_error_dev(self
, "memory test failed\n");
493 /* Establish interrupt handler. */
494 esc
->sc_ih
= isa_intr_establish(ia
->ia_ic
, ia
->ia_irq
[0].ir_irq
,
495 IST_EDGE
, IPL_NET
, dp8390_intr
, sc
);
496 if (esc
->sc_ih
== NULL
)
497 aprint_error_dev(self
, "can't establish interrupt\n");
501 ec_fake_test_mem(struct dp8390_softc
*sc
)
505 * We have to do this after we initialize the GA, but we
506 * have to do that after calling dp8390_config(), which
507 * wants to test memory. Put this noop here, and then
508 * actually test memory later.
514 ec_test_mem(struct dp8390_softc
*sc
)
516 struct ec_softc
*esc
= (struct ec_softc
*)sc
;
517 bus_space_tag_t memt
= sc
->sc_buft
;
518 bus_space_handle_t memh
= sc
->sc_bufh
;
519 bus_size_t memsize
= sc
->mem_size
;
523 bus_space_set_region_2(memt
, memh
, 0, 0, memsize
>> 1);
525 bus_space_set_region_1(memt
, memh
, 0, 0, memsize
);
527 if (esc
->sc_16bitp
) {
528 for (i
= 0; i
< memsize
; i
+= 2) {
529 if (bus_space_read_2(memt
, memh
, i
) != 0)
533 for (i
= 0; i
< memsize
; i
++) {
534 if (bus_space_read_1(memt
, memh
, i
) != 0)
542 aprint_error_dev(sc
->sc_dev
,
543 "failed to clear shared memory at offset 0x%x\n", i
);
548 * Given a NIC memory source address and a host memory destination address,
549 * copy 'len' from NIC to host using shared memory. The 'len' is rounded
550 * up to a word - ok as long as mbufs are word-sized.
553 ec_readmem(struct ec_softc
*esc
, int from
, uint8_t *to
, int len
)
555 bus_space_tag_t memt
= esc
->sc_dp8390
.sc_buft
;
556 bus_space_handle_t memh
= esc
->sc_dp8390
.sc_bufh
;
562 bus_space_read_region_2(memt
, memh
, from
, (u_int16_t
*)to
,
565 bus_space_read_region_1(memt
, memh
, from
, to
, len
);
569 ec_write_mbuf(struct dp8390_softc
*sc
, struct mbuf
*m
, int buf
)
571 struct ec_softc
*esc
= (struct ec_softc
*)sc
;
572 bus_space_tag_t asict
= esc
->sc_asict
;
573 bus_space_handle_t asich
= esc
->sc_asich
;
574 bus_space_tag_t memt
= esc
->sc_dp8390
.sc_buft
;
575 bus_space_handle_t memh
= esc
->sc_dp8390
.sc_bufh
;
576 u_int8_t
*data
, savebyte
[2];
577 int savelen
, len
, leftover
;
582 savelen
= m
->m_pkthdr
.len
;
585 * 8-bit boards are simple: we're already in the correct
586 * page, and no alignment tricks are necessary.
588 if (esc
->sc_16bitp
== 0) {
589 for (; m
!= NULL
; buf
+= m
->m_len
, m
= m
->m_next
)
590 bus_space_write_region_1(memt
, memh
, buf
,
591 mtod(m
, u_int8_t
*), m
->m_len
);
592 if (savelen
< ETHER_MIN_LEN
- ETHER_CRC_LEN
) {
593 bus_space_set_region_1(memt
, memh
, buf
,
594 0, ETHER_MIN_LEN
- ETHER_CRC_LEN
- savelen
);
595 savelen
= ETHER_MIN_LEN
- ETHER_CRC_LEN
;
601 * If it's a 16-bit board, we have transmit buffers
602 * in a different page; switch to it.
605 bus_space_write_1(asict
, asich
, ELINK2_GACFR
,
608 /* Start out with no leftover data. */
610 savebyte
[0] = savebyte
[1] = 0;
612 for (; m
!= NULL
; m
= m
->m_next
) {
616 data
= mtod(m
, u_int8_t
*);
623 * Data left over (from mbuf or realignment).
624 * Buffer the next byte, and write it and
625 * the leftover data out.
627 savebyte
[1] = *data
++;
629 bus_space_write_2(memt
, memh
, buf
,
630 *(u_int16_t
*)savebyte
);
633 } else if (BUS_SPACE_ALIGNED_POINTER(data
, u_int16_t
)
636 * Unaligned data; buffer the next byte.
638 savebyte
[0] = *data
++;
643 * Aligned data; output contiguous words as
644 * much as we can, then buffer the remaining
649 bus_space_write_region_2(memt
, memh
, buf
,
650 (u_int16_t
*)data
, len
>> 1);
654 savebyte
[0] = *data
++;
659 panic("ec_write_mbuf: negative len");
662 panic("ec_write_mbuf: data != lim");
667 bus_space_write_2(memt
, memh
, buf
, *(u_int16_t
*)savebyte
);
670 if (savelen
< ETHER_MIN_LEN
- ETHER_CRC_LEN
) {
671 bus_space_set_region_2(memt
, memh
, buf
,
672 0, (ETHER_MIN_LEN
- ETHER_CRC_LEN
- savelen
) >> 1);
673 savelen
= ETHER_MIN_LEN
- ETHER_CRC_LEN
;
677 * Switch back to receive page.
680 bus_space_write_1(asict
, asich
, ELINK2_GACFR
,
681 ELINK2_GACFR_RSEL
| ELINK2_GACFR_MBS0
);
687 ec_ring_copy(struct dp8390_softc
*sc
, int src
, void *dst
, u_short amount
)
689 struct ec_softc
*esc
= (struct ec_softc
*)sc
;
692 /* Does copy wrap to lower addr in ring buffer? */
693 if (src
+ amount
> sc
->mem_end
) {
694 tmp_amount
= sc
->mem_end
- src
;
696 /* Copy amount up to end of NIC memory. */
697 ec_readmem(esc
, src
, dst
, tmp_amount
);
699 amount
-= tmp_amount
;
701 dst
= (char *)dst
+ tmp_amount
;
704 ec_readmem(esc
, src
, dst
, amount
);
706 return (src
+ amount
);
710 ec_read_hdr(struct dp8390_softc
*sc
, int packet_ptr
,
711 struct dp8390_ring
*packet_hdrp
)
713 struct ec_softc
*esc
= (struct ec_softc
*)sc
;
715 ec_readmem(esc
, packet_ptr
, (u_int8_t
*)packet_hdrp
,
716 sizeof(struct dp8390_ring
));
717 #if BYTE_ORDER == BIG_ENDIAN
718 packet_hdrp
->count
= bswap16(packet_hdrp
->count
);
723 ec_media_init(struct dp8390_softc
*sc
)
726 ifmedia_init(&sc
->sc_media
, 0, dp8390_mediachange
, dp8390_mediastatus
);
727 ifmedia_add(&sc
->sc_media
, IFM_ETHER
|IFM_10_2
, 0, NULL
);
728 ifmedia_add(&sc
->sc_media
, IFM_ETHER
|IFM_10_5
, 0, NULL
);
729 ifmedia_set(&sc
->sc_media
, IFM_ETHER
|IFM_10_2
);
733 ec_mediachange(struct dp8390_softc
*sc
)
735 struct ec_softc
*esc
= (struct ec_softc
*)sc
;
736 struct ifmedia
*ifm
= &sc
->sc_media
;
738 return (ec_set_media(esc
, ifm
->ifm_media
));
742 ec_mediastatus(struct dp8390_softc
*sc
, struct ifmediareq
*ifmr
)
744 struct ifmedia
*ifm
= &sc
->sc_media
;
747 * The currently selected media is always the active media.
749 ifmr
->ifm_active
= ifm
->ifm_cur
->ifm_media
;
753 ec_init_card(struct dp8390_softc
*sc
)
755 struct ec_softc
*esc
= (struct ec_softc
*)sc
;
756 struct ifmedia
*ifm
= &sc
->sc_media
;
758 (void) ec_set_media(esc
, ifm
->ifm_cur
->ifm_media
);
762 ec_set_media(struct ec_softc
*esc
, int media
)
766 if (IFM_TYPE(media
) != IFM_ETHER
)
769 switch (IFM_SUBTYPE(media
)) {
771 new = ELINK2_CR_XSEL
;
782 bus_space_write_1(esc
->sc_asict
, esc
->sc_asich
, ELINK2_CR
, new);