From 7d9bd41111430c047b7a751ce6163d92afa9228a Mon Sep 17 00:00:00 2001 From: Till Straumann Date: Thu, 23 Apr 2009 04:21:10 +0000 Subject: - added 'bootverbose' (in new 'misc.c' file) - added rtems_mii_phy_probe(). This is a helper albeit RTEMS specific. Porting the whole MII/media stuff is still too much ATM. --- bsd_eth_drivers/libbsdport/Makefile.am | 2 +- bsd_eth_drivers/libbsdport/miistuff.c | 58 ++++++++++++++++++++++++++++++++++ bsd_eth_drivers/libbsdport/misc.c | 1 + 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 bsd_eth_drivers/libbsdport/miistuff.c create mode 100644 bsd_eth_drivers/libbsdport/misc.c (limited to 'bsd_eth_drivers/libbsdport') diff --git a/bsd_eth_drivers/libbsdport/Makefile.am b/bsd_eth_drivers/libbsdport/Makefile.am index e6e31cd..2abfcfb 100644 --- a/bsd_eth_drivers/libbsdport/Makefile.am +++ b/bsd_eth_drivers/libbsdport/Makefile.am @@ -5,7 +5,7 @@ include $(top_srcdir)/rtems-pre.am libbsdport_a_SOURCES = rtems_callout.c rtems_taskqueue.c rtems_udelay.c libbsdport_a_SOURCES += ifstuff.c devicet.c alldrv.c contigmalloc.c -libbsdport_a_SOURCES += sysbus.c malloc.c ifmedia.c +libbsdport_a_SOURCES += sysbus.c malloc.c ifmedia.c misc.c miistuff.c libbsdport_a_SOURCES += rtems_verscheck.h bus.h callout.h devicet.h libbsdport_a_SOURCES += libbsdport.h libbsdport_post.h mutex.h diff --git a/bsd_eth_drivers/libbsdport/miistuff.c b/bsd_eth_drivers/libbsdport/miistuff.c new file mode 100644 index 0000000..b15545f --- /dev/null +++ b/bsd_eth_drivers/libbsdport/miistuff.c @@ -0,0 +1,58 @@ +#include +#define _KERNEL +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#define PHY_MAX 32 + +#undef DEBUG + +/* A helper to find the active PHY. We really should port + * the entire BSD miibus/phy support but that's a bigger + * project... + */ +int +rtems_mii_phy_probe(struct rtems_mdio_info *mdio, void *softc) +{ +int phy; +uint32_t bmsr, bmcr; + for ( phy = 0; phymdio_r(phy, softc, MII_BMSR, &bmsr) ) + continue; + + bmsr &= 0xffff; + + if ( 0 == bmsr || 0xffff == bmsr ) + continue; /* nothing here */ + + /* no media supported ? */ + if ( 0 == ((BMSR_EXTSTAT | 0xfe00) & bmsr ) ) + continue; /* probably nothing there */ + + if ( mdio->mdio_r(phy, softc, MII_BMCR, &bmcr) ) + continue; + + /* skip isolated or powered-down phys */ + if ( (BMCR_PDOWN | BMCR_ISO) & bmcr ) + continue; + +#ifdef DEBUG + printk("PHY #%u seems active; link status is %s\n", phy, BMSR_LINK & bmsr ? "UP" : "DOWN"); +#endif + + /* seems we found one */ + return phy; + } + + return -1; +} diff --git a/bsd_eth_drivers/libbsdport/misc.c b/bsd_eth_drivers/libbsdport/misc.c new file mode 100644 index 0000000..78f1fca --- /dev/null +++ b/bsd_eth_drivers/libbsdport/misc.c @@ -0,0 +1 @@ +int libbsdport_bootverbose = 0; -- cgit v1.2.3