From: miod Date: Mon, 28 Jul 2014 18:31:39 +0000 (+0000) Subject: On SPARCbook systems, the ledma device node has a `cable-selection' property X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=09b3691db13c9f77d6839213ee221a34f7ecbcf8;p=openbsd On SPARCbook systems, the ledma device node has a `cable-selection' property specifying which media the on-board interface uses. We already query it to set up proper register values; extend this to be able to pass a default media to the le(4) child. This makes SPARCbook system default to AUI without needing for a manual media change. tested by sebastia@ --- diff --git a/sys/arch/sparc/dev/dma.c b/sys/arch/sparc/dev/dma.c index e9805a250aa..351b4b7a5d6 100644 --- a/sys/arch/sparc/dev/dma.c +++ b/sys/arch/sparc/dev/dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dma.c,v 1.29 2014/05/09 20:15:06 miod Exp $ */ +/* $OpenBSD: dma.c,v 1.30 2014/07/28 18:31:39 miod Exp $ */ /* $NetBSD: dma.c,v 1.46 1997/08/27 11:24:16 bouyer Exp $ */ /* @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,9 @@ #include +#include +#include + #include #include @@ -157,11 +161,14 @@ dmaattach(parent, self, aux) char *cabletype = getpropstring(devnode, "cable-selection"); if (strcmp(cabletype, "tpe") == 0) { sc->sc_regs->csr |= E_TP_AUI; + sc->sc_defaultmedia = IFM_ETHER | IFM_10_T; } else if (strcmp(cabletype, "aui") == 0) { sc->sc_regs->csr &= ~E_TP_AUI; + sc->sc_defaultmedia = IFM_ETHER | IFM_10_5; } else { /* assume TP if nothing there */ sc->sc_regs->csr |= E_TP_AUI; + sc->sc_defaultmedia = IFM_ETHER | IFM_AUTO; } delay(20000); /* manual says we need 20ms delay */ } diff --git a/sys/arch/sparc/dev/dmavar.h b/sys/arch/sparc/dev/dmavar.h index 7056b5ae908..7807272c329 100644 --- a/sys/arch/sparc/dev/dmavar.h +++ b/sys/arch/sparc/dev/dmavar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dmavar.h,v 1.7 2006/06/02 20:00:54 miod Exp $ */ +/* $OpenBSD: dmavar.h,v 1.8 2014/07/28 18:31:39 miod Exp $ */ /* $NetBSD: dmavar.h,v 1.11 1996/11/27 21:49:53 pk Exp $ */ /* @@ -27,7 +27,7 @@ struct dma_softc { struct device sc_dev; /* us as a device */ struct esp_softc *sc_esp; /* my scsi */ - struct le_softc *sc_le; /* my ethernet */ + struct le_softc *sc_le; /* my Ethernet */ struct dma_regs *sc_regs; /* the registers */ int sc_active; /* DMA active ? */ u_int sc_rev; /* revision */ @@ -44,6 +44,7 @@ struct dma_softc { int (*setup)(struct dma_softc *, caddr_t *, size_t *, int, size_t *); void (*go)(struct dma_softc *); u_int sc_dmactl; + int sc_defaultmedia; /* default Ethernet media */ }; #define DMACSR(sc) (sc->sc_regs->csr) diff --git a/sys/arch/sparc/dev/if_le.c b/sys/arch/sparc/dev/if_le.c index 0a9a891aa3e..a310c3cc52f 100644 --- a/sys/arch/sparc/dev/if_le.c +++ b/sys/arch/sparc/dev/if_le.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_le.c,v 1.34 2013/09/24 20:10:49 miod Exp $ */ +/* $OpenBSD: if_le.c,v 1.35 2014/07/28 18:31:39 miod Exp $ */ /* $NetBSD: if_le.c,v 1.50 1997/09/09 20:54:48 pk Exp $ */ /*- @@ -583,19 +583,21 @@ leattach(struct device *parent, struct device *self, void *aux) if (lebufchild) { sc->sc_supmedia = lebufmedia; sc->sc_nsupmedia = nitems(lebufmedia); + sc->sc_defaultmedia = sc->sc_supmedia[sc->sc_nsupmedia - 1]; } else #endif #if defined(SUN4M) if (CPU_ISSUN4M && lesc->sc_dma) { sc->sc_supmedia = ledmamedia; sc->sc_nsupmedia = nitems(ledmamedia); + sc->sc_defaultmedia = lesc->sc_dma->sc_defaultmedia; } else #endif { sc->sc_supmedia = lebaremedia; sc->sc_nsupmedia = nitems(lebaremedia); + sc->sc_defaultmedia = sc->sc_supmedia[sc->sc_nsupmedia - 1]; } - sc->sc_defaultmedia = sc->sc_supmedia[sc->sc_nsupmedia - 1]; am7990_config(&lesc->sc_am7990);