Date: Sun, 13 May 2007 21:20:24 GMT From: Bruce M Simpson <bms@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 119797 for review Message-ID: <200705132120.l4DLKOKf077481@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=119797 Change 119797 by bms@bms_anglepoise on 2007/05/13 21:19:41 Tweak bfe(4) so that it may attach to a SiBA system bus. Bring in the new bfe driver attachment in SENTRY5 config. Note, this is not ready for prime time yet; mips nexus needs to be taught how to allocate dma maps, as the bfe core can only DMA into a 1GB bus address range. This is a SiBa limitation. Affected files ... .. //depot/projects/mips2/src/sys/conf/files#6 edit .. //depot/projects/mips2/src/sys/dev/bfe/if_bfe.c#4 edit .. //depot/projects/mips2/src/sys/dev/bfe/if_bfe_pci.c#1 add .. //depot/projects/mips2/src/sys/dev/bfe/if_bfe_siba.c#1 add .. //depot/projects/mips2/src/sys/dev/bfe/if_bfereg.h#3 edit .. //depot/projects/mips2/src/sys/mips/conf/SENTRY5#6 edit Differences ... ==== //depot/projects/mips2/src/sys/conf/files#6 (text+ko) ==== @@ -488,6 +488,8 @@ dev/awi/if_awi_pccard.c optional awi pccard dev/bce/if_bce.c optional bce dev/bfe/if_bfe.c optional bfe +dev/bfe/if_bfe_pci.c optional bfe pci +dev/bfe/if_bfe_siba.c optional bfe siba dev/bge/if_bge.c optional bge dev/bktr/bktr_audio.c optional bktr pci dev/bktr/bktr_card.c optional bktr pci ==== //depot/projects/mips2/src/sys/dev/bfe/if_bfe.c#4 (text+ko) ==== @@ -67,30 +67,9 @@ #include <dev/bfe/if_bfereg.h> -MODULE_DEPEND(bfe, pci, 1, 1, 1); -MODULE_DEPEND(bfe, ether, 1, 1, 1); -MODULE_DEPEND(bfe, miibus, 1, 1, 1); - /* "device miibus" required. See GENERIC if you get errors here. */ #include "miibus_if.h" -#define BFE_DEVDESC_MAX 64 /* Maximum device description length */ - -static struct bfe_type bfe_devs[] = { - { BCOM_VENDORID, BCOM_DEVICEID_BCM4401, - "Broadcom BCM4401 Fast Ethernet" }, - { BCOM_VENDORID, BCOM_DEVICEID_BCM4401B0, - "Broadcom BCM4401-B0 Fast Ethernet" }, - { BCOM_VENDORID, BCOM_DEVICEID_BCM4713, - "Broadcom BCM4713 Fast Ethernet" }, - { 0, 0, NULL } -}; - -static int bfe_probe (device_t); -static int bfe_attach (device_t); -static int bfe_detach (device_t); -static int bfe_suspend (device_t); -static int bfe_resume (device_t); static void bfe_release_resources (struct bfe_softc *); static void bfe_intr (void *); static void bfe_start (struct ifnet *); @@ -100,7 +79,6 @@ static void bfe_init_locked (void *); static void bfe_stop (struct bfe_softc *); static void bfe_watchdog (struct ifnet *); -static void bfe_shutdown (device_t); static void bfe_tick (void *); static void bfe_txeof (struct bfe_softc *); static void bfe_rxeof (struct bfe_softc *); @@ -112,9 +90,6 @@ static void bfe_pci_setup (struct bfe_softc *, u_int32_t); static int bfe_ifmedia_upd (struct ifnet *); static void bfe_ifmedia_sts (struct ifnet *, struct ifmediareq *); -static int bfe_miibus_readreg (device_t, int, int); -static int bfe_miibus_writereg (device_t, int, int, int); -static void bfe_miibus_statchg (device_t); static int bfe_wait_bit (struct bfe_softc *, u_int32_t, u_int32_t, u_long, const int); static void bfe_get_config (struct bfe_softc *sc); @@ -134,67 +109,9 @@ static void bfe_dma_map (void *, bus_dma_segment_t *, int, int); static void bfe_cam_write (struct bfe_softc *, u_char *, int); -static device_method_t bfe_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, bfe_probe), - DEVMETHOD(device_attach, bfe_attach), - DEVMETHOD(device_detach, bfe_detach), - DEVMETHOD(device_shutdown, bfe_shutdown), - DEVMETHOD(device_suspend, bfe_suspend), - DEVMETHOD(device_resume, bfe_resume), - - /* bus interface */ - DEVMETHOD(bus_print_child, bus_generic_print_child), - DEVMETHOD(bus_driver_added, bus_generic_driver_added), - - /* MII interface */ - DEVMETHOD(miibus_readreg, bfe_miibus_readreg), - DEVMETHOD(miibus_writereg, bfe_miibus_writereg), - DEVMETHOD(miibus_statchg, bfe_miibus_statchg), +devclass_t bfe_devclass; - { 0, 0 } -}; - -static driver_t bfe_driver = { - "bfe", - bfe_methods, - sizeof(struct bfe_softc) -}; - -static devclass_t bfe_devclass; - -DRIVER_MODULE(bfe, pci, bfe_driver, bfe_devclass, 0, 0); -DRIVER_MODULE(miibus, bfe, miibus_driver, miibus_devclass, 0, 0); - -/* - * Probe for a Broadcom 4401 chip. - */ static int -bfe_probe(device_t dev) -{ - struct bfe_type *t; - struct bfe_softc *sc; - - t = bfe_devs; - - sc = device_get_softc(dev); - bzero(sc, sizeof(struct bfe_softc)); - sc->bfe_unit = device_get_unit(dev); - sc->bfe_dev = dev; - - while(t->bfe_name != NULL) { - if ((pci_get_vendor(dev) == t->bfe_vid) && - (pci_get_device(dev) == t->bfe_did)) { - device_set_desc_copy(dev, t->bfe_name); - return (BUS_PROBE_DEFAULT); - } - t++; - } - - return (ENXIO); -} - -static int bfe_dma_alloc(device_t dev) { struct bfe_softc *sc; @@ -327,7 +244,7 @@ return (0); } -static int +int bfe_attach(device_t dev) { struct ifnet *ifp = NULL; @@ -345,9 +262,13 @@ /* * Map control/status registers. */ - pci_enable_busmaster(dev); + if (sc->bfe_bus_type == BFE_BUS_PCI) { + pci_enable_busmaster(dev); + rid = BFE_PCI_MEMLO; + } else if (sc->bfe_bus_type == BFE_BUS_SIBA) { + rid = 0x20; /* XXX MIPS hardcoded */ + } - rid = BFE_PCI_MEMLO; sc->bfe_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); if (sc->bfe_res == NULL) { @@ -437,7 +358,7 @@ return (error); } -static int +int bfe_detach(device_t dev) { struct bfe_softc *sc; @@ -472,7 +393,7 @@ * Stop all chip I/O so that the kernel's probe routines don't * get confused by errant DMAs when rebooting. */ -static void +void bfe_shutdown(device_t dev) { struct bfe_softc *sc; @@ -485,7 +406,7 @@ return; } -static int +int bfe_suspend(device_t dev) { struct bfe_softc *sc; @@ -498,7 +419,7 @@ return (0); } -static int +int bfe_resume(device_t dev) { struct bfe_softc *sc; @@ -519,7 +440,7 @@ return (0); } -static int +int bfe_miibus_readreg(device_t dev, int phy, int reg) { struct bfe_softc *sc; @@ -533,7 +454,7 @@ return (ret); } -static int +int bfe_miibus_writereg(device_t dev, int phy, int reg, int val) { struct bfe_softc *sc; @@ -546,7 +467,7 @@ return (0); } -static void +void bfe_miibus_statchg(device_t dev) { return; @@ -664,9 +585,12 @@ sc->bfe_enaddr[4] = eeprom[83]; sc->bfe_enaddr[5] = eeprom[82]; - sc->bfe_phyaddr = eeprom[90] & 0x1f; + if (sc->bfe_bus_type == BFE_BUS_PCI) { + sc->bfe_phyaddr = eeprom[90] & 0x1f; + } else if (sc->bfe_bus_type == BFE_BUS_SIBA) { + sc->bfe_phyaddr = 0x30; /* XXX */ + } sc->bfe_mdc_port = (eeprom[90] >> 14) & 0x1; - sc->bfe_core_unit = 0; sc->bfe_dma_offset = BFE_PCI_DMA; } @@ -744,7 +668,8 @@ BFE_LOCK_ASSERT(sc); /* Set the interrupt vector for the enet core */ - bfe_pci_setup(sc, BFE_INTVEC_ENET0); + if (sc->bfe_bus_type == BFE_BUS_PCI) + bfe_pci_setup(sc, BFE_INTVEC_ENET0); /* is core up? */ val = CSR_READ_4(sc, BFE_SBTMSLOW) & @@ -1645,3 +1570,7 @@ ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); } + +MODULE_DEPEND(bfe, ether, 1, 1, 1); +MODULE_DEPEND(bfe, miibus, 1, 1, 1); +DRIVER_MODULE(miibus, bfe, miibus_driver, miibus_devclass, 0, 0); ==== //depot/projects/mips2/src/sys/dev/bfe/if_bfereg.h#3 (text+ko) ==== @@ -453,6 +453,9 @@ #define BFE_INC(x, y) (x) = ((x) == ((y)-1)) ? 0 : (x)+1 +#define BFE_BUS_PCI (0) /* device lives on a PCI bus */ +#define BFE_BUS_SIBA (1) /* device lives on a SiBa bus */ + struct bfe_data { struct mbuf *bfe_mbuf; bus_dmamap_t bfe_map; @@ -523,6 +526,7 @@ u_int8_t bfe_unit; /* interface number */ u_int8_t bfe_core_unit; u_int8_t bfe_up; + u_int8_t bfe_bus_type; u_char bfe_enaddr[6]; int bfe_if_flags; char *bfe_vpd_prodname; @@ -536,4 +540,16 @@ char *bfe_name; }; +int bfe_attach(device_t); +int bfe_detach(device_t); +int bfe_suspend(device_t); +int bfe_resume(device_t); +void bfe_shutdown(device_t); + +int bfe_miibus_readreg(device_t, int, int); +int bfe_miibus_writereg(device_t, int, int, int); +void bfe_miibus_statchg(device_t); + +extern devclass_t bfe_devclass; + #endif /* _BFE_H */ ==== //depot/projects/mips2/src/sys/mips/conf/SENTRY5#6 (text+ko) ==== @@ -1,6 +1,6 @@ # # $FreeBSD$ -# $P4: //depot/projects/mips2/src/sys/mips/conf/SENTRY5#5 $ +# $P4: //depot/projects/mips2/src/sys/mips/conf/SENTRY5#6 $ # # The Broadcom Sentry5 series of processors and boards is very commonly # used in COTS hardware including the Netgear WGT634U. @@ -69,14 +69,13 @@ device siba # Sonics SiliconBackplane device pci # siba_pcib -# XXX notyet; need to be auto probed children of siba. +device bfe # XXX will build both pci and siba +device miibus # attachments + +# XXX notyet; need to be auto probed children of siba_cc. #device uart #device uart_ns8250 -# XXX notyet; bfe needs to attach via siba *and* pci. -#device bfe -#device miibus - device genclock device loop device ether
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705132120.l4DLKOKf077481>