1 /* $OpenBSD: brgphy.c,v 1.48 2006/05/20 23:03:53 brad Exp $ */
5 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Bill Paul.
18 * 4. Neither the name of the author nor the names of any co-contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE.
34 * $FreeBSD: src/sys/dev/mii/brgphy.c,v 1.1.2.7 2003/05/11 18:00:55 ps Exp $
35 * $DragonFly: src/sys/dev/netif/mii_layer/brgphy.c,v 1.22 2008/10/22 14:24:24 sephe Exp $
39 * Driver for the Broadcom BCR5400 1000baseT PHY. Speed is always
40 * 1000mbps; all we need to negotiate here is full or half duplex.
43 #include <sys/param.h>
44 #include <sys/systm.h>
45 #include <sys/kernel.h>
46 #include <sys/socket.h>
48 #include <sys/sysctl.h>
50 #include <net/ethernet.h>
52 #include <net/if_media.h>
53 #include <net/if_arp.h>
59 #include "brgphyreg.h"
60 #include <dev/netif/bge/if_bgereg.h>
62 #include "miibus_if.h"
64 static int brgphy_probe(device_t
);
65 static int brgphy_attach(device_t
);
67 static const struct mii_phydesc brgphys
[] = {
68 MII_PHYDESC(xxBROADCOM
, BCM5400
),
69 MII_PHYDESC(xxBROADCOM
, BCM5401
),
70 MII_PHYDESC(xxBROADCOM
, BCM5411
),
71 MII_PHYDESC(xxBROADCOM
, BCM5421
),
72 MII_PHYDESC(xxBROADCOM
, BCM54K2
),
73 MII_PHYDESC(xxBROADCOM
, BCM5462
),
75 MII_PHYDESC(xxBROADCOM
, BCM5701
),
76 MII_PHYDESC(xxBROADCOM
, BCM5703
),
77 MII_PHYDESC(xxBROADCOM
, BCM5704
),
78 MII_PHYDESC(xxBROADCOM
, BCM5705
),
80 MII_PHYDESC(xxBROADCOM
, BCM5714
),
81 MII_PHYDESC(xxBROADCOM2
,BCM5722
),
82 MII_PHYDESC(xxBROADCOM
, BCM5750
),
83 MII_PHYDESC(xxBROADCOM
, BCM5752
),
84 MII_PHYDESC(xxBROADCOM2
,BCM5755
),
85 MII_PHYDESC(xxBROADCOM
, BCM5780
),
86 MII_PHYDESC(xxBROADCOM2
,BCM5787
),
88 MII_PHYDESC(xxBROADCOM
, BCM5706C
),
89 MII_PHYDESC(xxBROADCOM
, BCM5708C
),
91 MII_PHYDESC(BROADCOM2
, BCM5906
),
96 static device_method_t brgphy_methods
[] = {
97 /* device interface */
98 DEVMETHOD(device_probe
, brgphy_probe
),
99 DEVMETHOD(device_attach
, brgphy_attach
),
100 DEVMETHOD(device_detach
, ukphy_detach
),
101 DEVMETHOD(device_shutdown
, bus_generic_shutdown
),
105 static devclass_t brgphy_devclass
;
107 static driver_t brgphy_driver
= {
110 sizeof(struct mii_softc
)
113 DRIVER_MODULE(brgphy
, miibus
, brgphy_driver
, brgphy_devclass
, 0, 0);
115 static int brgphy_service(struct mii_softc
*, struct mii_data
*, int);
116 static void brgphy_status(struct mii_softc
*);
117 static void brgphy_mii_phy_auto(struct mii_softc
*);
118 static void brgphy_reset(struct mii_softc
*);
119 static void brgphy_loop(struct mii_softc
*);
121 static void brgphy_bcm5401_dspcode(struct mii_softc
*);
122 static void brgphy_bcm5411_dspcode(struct mii_softc
*);
123 static void brgphy_bcm5421_dspcode(struct mii_softc
*);
124 static void brgphy_bcm54k2_dspcode(struct mii_softc
*);
126 static void brgphy_adc_bug(struct mii_softc
*);
127 static void brgphy_5704_a0_bug(struct mii_softc
*);
128 static void brgphy_ber_bug(struct mii_softc
*);
129 static void brgphy_crc_bug(struct mii_softc
*);
131 static void brgphy_jumbo_settings(struct mii_softc
*, u_long
);
132 static void brgphy_eth_wirespeed(struct mii_softc
*);
135 brgphy_probe(device_t dev
)
137 struct mii_attach_args
*ma
= device_get_ivars(dev
);
138 const struct mii_phydesc
*mpd
;
140 mpd
= mii_phy_match(ma
, brgphys
);
142 device_set_desc(dev
, mpd
->mpd_name
);
149 brgphy_attach(device_t dev
)
151 struct mii_softc
*sc
;
152 struct mii_attach_args
*ma
;
153 struct mii_data
*mii
;
155 sc
= device_get_softc(dev
);
156 ma
= device_get_ivars(dev
);
157 mii_softc_init(sc
, ma
);
158 sc
->mii_dev
= device_get_parent(dev
);
159 mii
= device_get_softc(sc
->mii_dev
);
160 LIST_INSERT_HEAD(&mii
->mii_phys
, sc
, mii_list
);
162 sc
->mii_inst
= mii
->mii_instance
;
163 sc
->mii_service
= brgphy_service
;
164 sc
->mii_reset
= brgphy_reset
;
167 sc
->mii_flags
|= MIIF_NOISOLATE
;
172 #define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
174 ADD(IFM_MAKEWORD(IFM_ETHER
, IFM_NONE
, 0, sc
->mii_inst
),
177 ADD(IFM_MAKEWORD(IFM_ETHER
, IFM_100_TX
, IFM_LOOP
, sc
->mii_inst
),
183 sc
->mii_capabilities
= PHY_READ(sc
, MII_BMSR
) & ma
->mii_capmask
;
184 if (sc
->mii_capabilities
& BMSR_EXTSTAT
)
185 sc
->mii_extcapabilities
= PHY_READ(sc
, MII_EXTSR
);
187 device_printf(dev
, " ");
188 if ((sc
->mii_capabilities
& BMSR_MEDIAMASK
) ||
189 (sc
->mii_extcapabilities
& EXTSR_MEDIAMASK
))
190 mii_phy_add_media(sc
);
192 kprintf("no media present");
195 MIIBUS_MEDIAINIT(sc
->mii_dev
);
200 brgphy_service(struct mii_softc
*sc
, struct mii_data
*mii
, int cmd
)
202 struct ifmedia_entry
*ife
= mii
->mii_media
.ifm_cur
;
208 * If we're not polling our PHY instance, just return.
210 if (IFM_INST(ife
->ifm_media
) != sc
->mii_inst
)
216 * If the media indicates a different PHY instance,
219 if (IFM_INST(ife
->ifm_media
) != sc
->mii_inst
) {
220 reg
= PHY_READ(sc
, MII_BMCR
);
221 PHY_WRITE(sc
, MII_BMCR
, reg
| BMCR_ISO
);
226 * If the interface is not up, don't do anything.
228 if ((mii
->mii_ifp
->if_flags
& IFF_UP
) == 0)
231 brgphy_reset(sc
); /* XXX hardware bug work-around */
233 switch (IFM_SUBTYPE(ife
->ifm_media
)) {
237 * If we're already in auto mode, just return.
239 if (PHY_READ(sc
, BRGPHY_MII_BMCR
) & BRGPHY_BMCR_AUTOEN
)
242 brgphy_mii_phy_auto(sc
);
245 speed
= BRGPHY_S1000
;
254 if ((ife
->ifm_media
& IFM_GMASK
) == IFM_FDX
) {
255 speed
|= BRGPHY_BMCR_FDX
;
256 gig
= BRGPHY_1000CTL_AFD
;
258 gig
= BRGPHY_1000CTL_AHD
;
261 PHY_WRITE(sc
, BRGPHY_MII_1000CTL
, 0);
262 PHY_WRITE(sc
, BRGPHY_MII_BMCR
, speed
);
263 PHY_WRITE(sc
, BRGPHY_MII_ANAR
, BRGPHY_SEL_TYPE
);
265 if (IFM_SUBTYPE(ife
->ifm_media
) != IFM_1000_T
)
268 PHY_WRITE(sc
, BRGPHY_MII_1000CTL
, gig
);
269 PHY_WRITE(sc
, BRGPHY_MII_BMCR
,
270 speed
|BRGPHY_BMCR_AUTOEN
|BRGPHY_BMCR_STARTNEG
);
272 if (sc
->mii_model
!= MII_MODEL_xxBROADCOM_BCM5701
)
276 * When settning the link manually, one side must
277 * be the master and the other the slave. However
278 * ifmedia doesn't give us a good way to specify
279 * this, so we fake it by using one of the LINK
280 * flags. If LINK0 is set, we program the PHY to
281 * be a master, otherwise it's a slave.
283 if ((mii
->mii_ifp
->if_flags
& IFF_LINK0
)) {
284 PHY_WRITE(sc
, BRGPHY_MII_1000CTL
,
285 gig
|BRGPHY_1000CTL_MSE
|BRGPHY_1000CTL_MSC
);
287 PHY_WRITE(sc
, BRGPHY_MII_1000CTL
,
288 gig
|BRGPHY_1000CTL_MSE
);
293 PHY_WRITE(sc
, MII_BMCR
, BMCR_ISO
|BMCR_PDOWN
);
304 * If we're not currently selected, just return.
306 if (IFM_INST(ife
->ifm_media
) != sc
->mii_inst
)
310 * Is the interface even up?
312 if ((mii
->mii_ifp
->if_flags
& IFF_UP
) == 0)
316 * Only used for autonegotiation.
318 if (IFM_SUBTYPE(ife
->ifm_media
) != IFM_AUTO
)
322 * Check to see if we have link. If we do, we don't
323 * need to restart the autonegotiation process.
325 reg
= PHY_READ(sc
, BRGPHY_MII_AUXSTS
);
326 if (reg
& BRGPHY_AUXSTS_LINK
) {
332 * Only retry autonegotiation every 5 seconds.
334 if (++sc
->mii_ticks
<= sc
->mii_anegticks
)
338 brgphy_mii_phy_auto(sc
);
342 /* Update the media status. */
346 * Callback if something changed. Note that we need to poke
347 * the DSP on the Broadcom PHYs if the media changes.
349 if (sc
->mii_media_active
!= mii
->mii_media_active
||
350 sc
->mii_media_status
!= mii
->mii_media_status
||
351 cmd
== MII_MEDIACHG
) {
352 switch (sc
->mii_model
) {
353 case MII_MODEL_xxBROADCOM_BCM5400
:
354 brgphy_bcm5401_dspcode(sc
);
356 case MII_MODEL_xxBROADCOM_BCM5401
:
357 if (sc
->mii_rev
== 1 || sc
->mii_rev
== 3)
358 brgphy_bcm5401_dspcode(sc
);
360 case MII_MODEL_xxBROADCOM_BCM5411
:
361 brgphy_bcm5411_dspcode(sc
);
365 mii_phy_update(sc
, cmd
);
370 brgphy_status(struct mii_softc
*sc
)
372 struct mii_data
*mii
= sc
->mii_pdata
;
375 mii
->mii_media_status
= IFM_AVALID
;
376 mii
->mii_media_active
= IFM_ETHER
;
378 aux
= PHY_READ(sc
, BRGPHY_MII_AUXSTS
);
379 if (aux
& BRGPHY_AUXSTS_LINK
)
380 mii
->mii_media_status
|= IFM_ACTIVE
;
382 bmcr
= PHY_READ(sc
, BRGPHY_MII_BMCR
);
383 if (bmcr
& BRGPHY_BMCR_LOOP
)
384 mii
->mii_media_active
|= IFM_LOOP
;
386 if (bmcr
& BRGPHY_BMCR_AUTOEN
) {
387 if ((PHY_READ(sc
, BRGPHY_MII_BMSR
) & BRGPHY_BMSR_ACOMP
) == 0) {
388 /* Erg, still trying, I guess... */
389 mii
->mii_media_active
|= IFM_NONE
;
393 switch (aux
& BRGPHY_AUXSTS_AN_RES
) {
394 case BRGPHY_RES_1000FD
:
395 mii
->mii_media_active
|= IFM_1000_T
| IFM_FDX
;
397 case BRGPHY_RES_1000HD
:
398 mii
->mii_media_active
|= IFM_1000_T
| IFM_HDX
;
400 case BRGPHY_RES_100FD
:
401 mii
->mii_media_active
|= IFM_100_TX
| IFM_FDX
;
403 case BRGPHY_RES_100T4
:
404 mii
->mii_media_active
|= IFM_100_T4
;
406 case BRGPHY_RES_100HD
:
407 mii
->mii_media_active
|= IFM_100_TX
| IFM_HDX
;
409 case BRGPHY_RES_10FD
:
410 mii
->mii_media_active
|= IFM_10_T
| IFM_FDX
;
412 case BRGPHY_RES_10HD
:
413 mii
->mii_media_active
|= IFM_10_T
| IFM_HDX
;
416 mii
->mii_media_active
|= IFM_NONE
;
420 mii
->mii_media_active
= mii
->mii_media
.ifm_cur
->ifm_media
;
426 brgphy_mii_phy_auto(struct mii_softc
*sc
)
432 ktcr
= BRGPHY_1000CTL_AFD
|BRGPHY_1000CTL_AHD
;
433 if (sc
->mii_model
== MII_MODEL_xxBROADCOM_BCM5701
)
434 ktcr
|= BRGPHY_1000CTL_MSE
|BRGPHY_1000CTL_MSC
;
435 PHY_WRITE(sc
, BRGPHY_MII_1000CTL
, ktcr
);
436 ktcr
= PHY_READ(sc
, BRGPHY_MII_1000CTL
);
438 PHY_WRITE(sc
, BRGPHY_MII_ANAR
,
439 BMSR_MEDIA_TO_ANAR(sc
->mii_capabilities
) | ANAR_CSMA
);
441 PHY_WRITE(sc
, BRGPHY_MII_BMCR
,
442 BRGPHY_BMCR_AUTOEN
| BRGPHY_BMCR_STARTNEG
);
443 PHY_WRITE(sc
, BRGPHY_MII_IMR
, 0xFF00);
447 brgphy_loop(struct mii_softc
*sc
)
452 PHY_WRITE(sc
, BRGPHY_MII_BMCR
, BRGPHY_BMCR_LOOP
);
453 for (i
= 0; i
< 15000; i
++) {
454 bmsr
= PHY_READ(sc
, BRGPHY_MII_BMSR
);
455 if (!(bmsr
& BRGPHY_BMSR_LINK
))
462 brgphy_reset(struct mii_softc
*sc
)
468 switch (sc
->mii_model
) {
469 case MII_MODEL_xxBROADCOM_BCM5400
:
470 brgphy_bcm5401_dspcode(sc
);
472 case MII_MODEL_xxBROADCOM_BCM5401
:
473 if (sc
->mii_rev
== 1 || sc
->mii_rev
== 3)
474 brgphy_bcm5401_dspcode(sc
);
476 case MII_MODEL_xxBROADCOM_BCM5411
:
477 brgphy_bcm5411_dspcode(sc
);
479 case MII_MODEL_xxBROADCOM_BCM5421
:
480 brgphy_bcm5421_dspcode(sc
);
482 case MII_MODEL_xxBROADCOM_BCM54K2
:
483 brgphy_bcm54k2_dspcode(sc
);
487 ifp
= sc
->mii_pdata
->mii_ifp
;
488 if (strncmp(ifp
->if_xname
, "bge", 3) == 0) {
489 struct bge_softc
*bge_sc
= ifp
->if_softc
;
491 if (bge_sc
->bge_flags
& BGE_FLAG_ADC_BUG
)
493 if (bge_sc
->bge_flags
& BGE_FLAG_5704_A0_BUG
)
494 brgphy_5704_a0_bug(sc
);
495 if (bge_sc
->bge_flags
& BGE_FLAG_BER_BUG
) {
497 } else if (bge_sc
->bge_flags
& BGE_FLAG_JITTER_BUG
) {
498 PHY_WRITE(sc
, BRGPHY_MII_AUXCTL
, 0x0c00);
499 PHY_WRITE(sc
, BRGPHY_MII_DSP_ADDR_REG
, 0x000a);
501 if (bge_sc
->bge_flags
& BGE_FLAG_ADJUST_TRIM
) {
502 PHY_WRITE(sc
, BRGPHY_MII_DSP_RW_PORT
, 0x110b);
503 PHY_WRITE(sc
, BRGPHY_TEST1
,
504 BRGPHY_TEST1_TRIM_EN
| 0x4);
506 PHY_WRITE(sc
, BRGPHY_MII_DSP_RW_PORT
, 0x010b);
509 PHY_WRITE(sc
, BRGPHY_MII_AUXCTL
, 0x0400);
511 if (bge_sc
->bge_flags
& BGE_FLAG_CRC_BUG
)
514 /* Set Jumbo frame settings in the PHY. */
515 brgphy_jumbo_settings(sc
, ifp
->if_mtu
);
517 /* Enable Ethernet@Wirespeed */
518 if (bge_sc
->bge_flags
& BGE_FLAG_ETH_WIRESPEED
)
519 brgphy_eth_wirespeed(sc
);
521 /* Enable Link LED on Dell boxes */
522 if (bge_sc
->bge_flags
& BGE_FLAG_NO_3LED
) {
523 PHY_WRITE(sc
, BRGPHY_MII_PHY_EXTCTL
,
524 PHY_READ(sc
, BRGPHY_MII_PHY_EXTCTL
)
525 & ~BRGPHY_PHY_EXTCTL_3_LED
);
528 /* Adjust output voltage (From Linux driver) */
529 if (bge_sc
->bge_asicrev
== BGE_ASICREV_BCM5906
)
530 PHY_WRITE(sc
, BRGPHY_MII_EPHY_PTEST
, 0x12);
531 } else if (strncmp(ifp
->if_xname
, "bce", 3) == 0) {
533 brgphy_jumbo_settings(sc
, ifp
->if_mtu
);
534 brgphy_eth_wirespeed(sc
);
538 /* Turn off tap power management on 5401. */
540 brgphy_bcm5401_dspcode(struct mii_softc
*sc
)
542 static const struct {
546 { BRGPHY_MII_AUXCTL
, 0x0c20 },
547 { BRGPHY_MII_DSP_ADDR_REG
, 0x0012 },
548 { BRGPHY_MII_DSP_RW_PORT
, 0x1804 },
549 { BRGPHY_MII_DSP_ADDR_REG
, 0x0013 },
550 { BRGPHY_MII_DSP_RW_PORT
, 0x1204 },
551 { BRGPHY_MII_DSP_ADDR_REG
, 0x8006 },
552 { BRGPHY_MII_DSP_RW_PORT
, 0x0132 },
553 { BRGPHY_MII_DSP_ADDR_REG
, 0x8006 },
554 { BRGPHY_MII_DSP_RW_PORT
, 0x0232 },
555 { BRGPHY_MII_DSP_ADDR_REG
, 0x201f },
556 { BRGPHY_MII_DSP_RW_PORT
, 0x0a20 },
561 for (i
= 0; dspcode
[i
].reg
!= 0; i
++)
562 PHY_WRITE(sc
, dspcode
[i
].reg
, dspcode
[i
].val
);
566 /* Setting some undocumented voltage */
568 brgphy_bcm5411_dspcode(struct mii_softc
*sc
)
570 static const struct {
581 for (i
= 0; dspcode
[i
].reg
!= 0; i
++)
582 PHY_WRITE(sc
, dspcode
[i
].reg
, dspcode
[i
].val
);
586 brgphy_bcm5421_dspcode(struct mii_softc
*sc
)
590 /* Set Class A mode */
591 PHY_WRITE(sc
, BRGPHY_MII_AUXCTL
, 0x1007);
592 data
= PHY_READ(sc
, BRGPHY_MII_AUXCTL
);
593 PHY_WRITE(sc
, BRGPHY_MII_AUXCTL
, data
| 0x0400);
595 /* Set FFE gamma override to -0.125 */
596 PHY_WRITE(sc
, BRGPHY_MII_AUXCTL
, 0x0007);
597 data
= PHY_READ(sc
, BRGPHY_MII_AUXCTL
);
598 PHY_WRITE(sc
, BRGPHY_MII_AUXCTL
, data
| 0x0800);
599 PHY_WRITE(sc
, BRGPHY_MII_DSP_ADDR_REG
, 0x000a);
600 data
= PHY_READ(sc
, BRGPHY_MII_DSP_RW_PORT
);
601 PHY_WRITE(sc
, BRGPHY_MII_DSP_RW_PORT
, data
| 0x0200);
605 brgphy_bcm54k2_dspcode(struct mii_softc
*sc
)
607 static const struct {
617 for (i
= 0; dspcode
[i
].reg
!= 0; i
++)
618 PHY_WRITE(sc
, dspcode
[i
].reg
, dspcode
[i
].val
);
622 brgphy_adc_bug(struct mii_softc
*sc
)
624 static const struct {
628 { BRGPHY_MII_AUXCTL
, 0x0c00 },
629 { BRGPHY_MII_DSP_ADDR_REG
, 0x201f },
630 { BRGPHY_MII_DSP_RW_PORT
, 0x2aaa },
631 { BRGPHY_MII_DSP_ADDR_REG
, 0x000a },
632 { BRGPHY_MII_DSP_RW_PORT
, 0x0323 },
633 { BRGPHY_MII_AUXCTL
, 0x0400 },
638 for (i
= 0; dspcode
[i
].reg
!= 0; i
++)
639 PHY_WRITE(sc
, dspcode
[i
].reg
, dspcode
[i
].val
);
643 brgphy_5704_a0_bug(struct mii_softc
*sc
)
645 static const struct {
655 for (i
= 0; dspcode
[i
].reg
!= 0; i
++)
656 PHY_WRITE(sc
, dspcode
[i
].reg
, dspcode
[i
].val
);
660 brgphy_ber_bug(struct mii_softc
*sc
)
662 static const struct {
666 { BRGPHY_MII_AUXCTL
, 0x0c00 },
667 { BRGPHY_MII_DSP_ADDR_REG
, 0x000a },
668 { BRGPHY_MII_DSP_RW_PORT
, 0x310b },
669 { BRGPHY_MII_DSP_ADDR_REG
, 0x201f },
670 { BRGPHY_MII_DSP_RW_PORT
, 0x9506 },
671 { BRGPHY_MII_DSP_ADDR_REG
, 0x401f },
672 { BRGPHY_MII_DSP_RW_PORT
, 0x14e2 },
673 { BRGPHY_MII_AUXCTL
, 0x0400 },
678 for (i
= 0; dspcode
[i
].reg
!= 0; i
++)
679 PHY_WRITE(sc
, dspcode
[i
].reg
, dspcode
[i
].val
);
683 brgphy_crc_bug(struct mii_softc
*sc
)
685 static const struct {
689 { BRGPHY_MII_DSP_ADDR_REG
, 0x0a75 },
697 for (i
= 0; dspcode
[i
].reg
!= 0; i
++)
698 PHY_WRITE(sc
, dspcode
[i
].reg
, dspcode
[i
].val
);
702 brgphy_jumbo_settings(struct mii_softc
*sc
, u_long mtu
)
706 /* Set or clear jumbo frame settings in the PHY. */
707 if (mtu
> ETHER_MAX_LEN
) {
708 if (sc
->mii_model
== MII_MODEL_xxBROADCOM_BCM5401
) {
709 /* BCM5401 PHY cannot read-modify-write. */
710 PHY_WRITE(sc
, BRGPHY_MII_AUXCTL
, 0x4c20);
712 PHY_WRITE(sc
, BRGPHY_MII_AUXCTL
, 0x7);
713 val
= PHY_READ(sc
, BRGPHY_MII_AUXCTL
);
714 PHY_WRITE(sc
, BRGPHY_MII_AUXCTL
,
715 val
| BRGPHY_AUXCTL_LONG_PKT
);
718 val
= PHY_READ(sc
, BRGPHY_MII_PHY_EXTCTL
);
719 PHY_WRITE(sc
, BRGPHY_MII_PHY_EXTCTL
,
720 val
| BRGPHY_PHY_EXTCTL_HIGH_LA
);
722 PHY_WRITE(sc
, BRGPHY_MII_AUXCTL
, 0x7);
723 val
= PHY_READ(sc
, BRGPHY_MII_AUXCTL
);
724 PHY_WRITE(sc
, BRGPHY_MII_AUXCTL
,
725 val
& ~(BRGPHY_AUXCTL_LONG_PKT
| 0x7));
727 val
= PHY_READ(sc
, BRGPHY_MII_PHY_EXTCTL
);
728 PHY_WRITE(sc
, BRGPHY_MII_PHY_EXTCTL
,
729 val
& ~BRGPHY_PHY_EXTCTL_HIGH_LA
);
734 brgphy_eth_wirespeed(struct mii_softc
*sc
)
738 /* Enable Ethernet@Wirespeed */
739 PHY_WRITE(sc
, BRGPHY_MII_AUXCTL
, 0x7007);
740 val
= PHY_READ(sc
, BRGPHY_MII_AUXCTL
);
741 PHY_WRITE(sc
, BRGPHY_MII_AUXCTL
, (val
| (1 << 15) | (1 << 4)));