Deleted Added
full compact
if_bge.c (213844) if_bge.c (213893)
1/*-
2 * Copyright (c) 2001 Wind River Systems
3 * Copyright (c) 1997, 1998, 1999, 2001
4 * Bill Paul <wpaul@windriver.com>. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 18 unchanged lines hidden (view full) ---

27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001 Wind River Systems
3 * Copyright (c) 1997, 1998, 1999, 2001
4 * Bill Paul <wpaul@windriver.com>. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 18 unchanged lines hidden (view full) ---

27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/dev/bge/if_bge.c 213844 2010-10-14 18:31:40Z yongari $");
35__FBSDID("$FreeBSD: head/sys/dev/bge/if_bge.c 213893 2010-10-15 14:52:11Z marius $");
36
37/*
38 * Broadcom BCM570x family gigabit ethernet driver for FreeBSD.
39 *
40 * The Broadcom BCM5700 is based on technology originally developed by
41 * Alteon Networks as part of the Tigon I and Tigon II gigabit ethernet
42 * MAC chips. The BCM5700, sometimes refered to as the Tigon III, has
43 * two on-board MIPS R4000 CPUs and can have as much as 16MB of external

--- 732 unchanged lines hidden (view full) ---

776bge_miibus_readreg(device_t dev, int phy, int reg)
777{
778 struct bge_softc *sc;
779 uint32_t val;
780 int i;
781
782 sc = device_get_softc(dev);
783
36
37/*
38 * Broadcom BCM570x family gigabit ethernet driver for FreeBSD.
39 *
40 * The Broadcom BCM5700 is based on technology originally developed by
41 * Alteon Networks as part of the Tigon I and Tigon II gigabit ethernet
42 * MAC chips. The BCM5700, sometimes refered to as the Tigon III, has
43 * two on-board MIPS R4000 CPUs and can have as much as 16MB of external

--- 732 unchanged lines hidden (view full) ---

776bge_miibus_readreg(device_t dev, int phy, int reg)
777{
778 struct bge_softc *sc;
779 uint32_t val;
780 int i;
781
782 sc = device_get_softc(dev);
783
784 /* Prevent the probe from finding incorrect devices. */
785 if (phy != sc->bge_phy_addr)
786 return (0);
787
788 /* Clear the autopoll bit if set, otherwise may trigger PCI errors. */
789 if ((sc->bge_mi_mode & BGE_MIMODE_AUTOPOLL) != 0) {
790 CSR_WRITE_4(sc, BGE_MI_MODE,
791 sc->bge_mi_mode & ~BGE_MIMODE_AUTOPOLL);
792 DELAY(80);
793 }
794
795 CSR_WRITE_4(sc, BGE_MI_COMM, BGE_MICMD_READ | BGE_MICOMM_BUSY |

--- 1762 unchanged lines hidden (view full) ---

2558
2559static int
2560bge_attach(device_t dev)
2561{
2562 struct ifnet *ifp;
2563 struct bge_softc *sc;
2564 uint32_t hwcfg = 0, misccfg;
2565 u_char eaddr[ETHER_ADDR_LEN];
784 /* Clear the autopoll bit if set, otherwise may trigger PCI errors. */
785 if ((sc->bge_mi_mode & BGE_MIMODE_AUTOPOLL) != 0) {
786 CSR_WRITE_4(sc, BGE_MI_MODE,
787 sc->bge_mi_mode & ~BGE_MIMODE_AUTOPOLL);
788 DELAY(80);
789 }
790
791 CSR_WRITE_4(sc, BGE_MI_COMM, BGE_MICMD_READ | BGE_MICOMM_BUSY |

--- 1762 unchanged lines hidden (view full) ---

2554
2555static int
2556bge_attach(device_t dev)
2557{
2558 struct ifnet *ifp;
2559 struct bge_softc *sc;
2560 uint32_t hwcfg = 0, misccfg;
2561 u_char eaddr[ETHER_ADDR_LEN];
2566 int error, msicount, reg, rid, trys;
2562 int error, msicount, phy_addr, reg, rid, trys;
2567
2568 sc = device_get_softc(dev);
2569 sc->bge_dev = dev;
2570
2571 TASK_INIT(&sc->bge_intr_task, 0, bge_intr_task, sc);
2572
2573 /*
2574 * Map control/status registers.

--- 16 unchanged lines hidden (view full) ---

2591 BGE_PCIMISCCTL_ASICREV_SHIFT;
2592 if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_USE_PRODID_REG)
2593 sc->bge_chipid = pci_read_config(dev, BGE_PCI_PRODID_ASICREV,
2594 4);
2595 sc->bge_asicrev = BGE_ASICREV(sc->bge_chipid);
2596 sc->bge_chiprev = BGE_CHIPREV(sc->bge_chipid);
2597
2598 /* Set default PHY address. */
2563
2564 sc = device_get_softc(dev);
2565 sc->bge_dev = dev;
2566
2567 TASK_INIT(&sc->bge_intr_task, 0, bge_intr_task, sc);
2568
2569 /*
2570 * Map control/status registers.

--- 16 unchanged lines hidden (view full) ---

2587 BGE_PCIMISCCTL_ASICREV_SHIFT;
2588 if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_USE_PRODID_REG)
2589 sc->bge_chipid = pci_read_config(dev, BGE_PCI_PRODID_ASICREV,
2590 4);
2591 sc->bge_asicrev = BGE_ASICREV(sc->bge_chipid);
2592 sc->bge_chiprev = BGE_CHIPREV(sc->bge_chipid);
2593
2594 /* Set default PHY address. */
2599 sc->bge_phy_addr = 1;
2595 phy_addr = 1;
2600
2601 /*
2602 * Don't enable Ethernet@WireSpeed for the 5700, 5906, or the
2603 * 5705 A0 and A1 chips.
2604 */
2605 if (sc->bge_asicrev != BGE_ASICREV_BCM5700 &&
2606 sc->bge_asicrev != BGE_ASICREV_BCM5906 &&
2607 sc->bge_chipid != BGE_CHIPID_BCM5705_A0 &&

--- 348 unchanged lines hidden (view full) ---

2956 * if we get a conflict with the ASF firmware accessing
2957 * the PHY.
2958 */
2959 trys = 0;
2960 BGE_CLRBIT(sc, BGE_MODE_CTL, BGE_MODECTL_STACKUP);
2961again:
2962 bge_asf_driver_up(sc);
2963
2596
2597 /*
2598 * Don't enable Ethernet@WireSpeed for the 5700, 5906, or the
2599 * 5705 A0 and A1 chips.
2600 */
2601 if (sc->bge_asicrev != BGE_ASICREV_BCM5700 &&
2602 sc->bge_asicrev != BGE_ASICREV_BCM5906 &&
2603 sc->bge_chipid != BGE_CHIPID_BCM5705_A0 &&

--- 348 unchanged lines hidden (view full) ---

2952 * if we get a conflict with the ASF firmware accessing
2953 * the PHY.
2954 */
2955 trys = 0;
2956 BGE_CLRBIT(sc, BGE_MODE_CTL, BGE_MODECTL_STACKUP);
2957again:
2958 bge_asf_driver_up(sc);
2959
2964 if (mii_phy_probe(dev, &sc->bge_miibus,
2965 bge_ifmedia_upd, bge_ifmedia_sts)) {
2960 error = (mii_attach(dev, &sc->bge_miibus, ifp,
2961 bge_ifmedia_upd, bge_ifmedia_sts, BMSR_DEFCAPMASK,
2962 phy_addr, MII_OFFSET_ANY, 0));
2963 if (error != 0) {
2966 if (trys++ < 4) {
2967 device_printf(sc->bge_dev, "Try again\n");
2968 bge_miibus_writereg(sc->bge_dev, 1, MII_BMCR,
2969 BMCR_RESET);
2970 goto again;
2971 }
2964 if (trys++ < 4) {
2965 device_printf(sc->bge_dev, "Try again\n");
2966 bge_miibus_writereg(sc->bge_dev, 1, MII_BMCR,
2967 BMCR_RESET);
2968 goto again;
2969 }
2972
2973 device_printf(sc->bge_dev, "MII without any PHY!\n");
2974 error = ENXIO;
2970 device_printf(sc->bge_dev, "attaching PHYs failed\n");
2975 goto fail;
2976 }
2977
2978 /*
2979 * Now tell the firmware we are going up after probing the PHY
2980 */
2981 if (sc->bge_asf_mode & ASF_STACKUP)
2982 BGE_SETBIT(sc, BGE_MODE_CTL, BGE_MODECTL_STACKUP);

--- 2625 unchanged lines hidden ---
2971 goto fail;
2972 }
2973
2974 /*
2975 * Now tell the firmware we are going up after probing the PHY
2976 */
2977 if (sc->bge_asf_mode & ASF_STACKUP)
2978 BGE_SETBIT(sc, BGE_MODE_CTL, BGE_MODECTL_STACKUP);

--- 2625 unchanged lines hidden ---