Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic Initial support for 21140[A] GPR media.
details: https://anonhg.NetBSD.org/src/rev/aaa8dad72f76
branches: trunk
changeset: 476775:aaa8dad72f76
user: thorpej <thorpej%NetBSD.org@localhost>
date: Mon Sep 27 19:14:01 1999 +0000
description:
Initial support for 21140[A] GPR media.
diffstat:
sys/dev/ic/tulip.c | 308 ++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 246 insertions(+), 62 deletions(-)
diffs (truncated from 406 to 300 lines):
diff -r 7612fc9a6312 -r aaa8dad72f76 sys/dev/ic/tulip.c
--- a/sys/dev/ic/tulip.c Mon Sep 27 19:03:59 1999 +0000
+++ b/sys/dev/ic/tulip.c Mon Sep 27 19:14:01 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tulip.c,v 1.18 1999/09/26 03:39:01 thorpej Exp $ */
+/* $NetBSD: tulip.c,v 1.19 1999/09/27 19:14:01 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -2824,6 +2824,65 @@
* are potentially common to multiple front-ends.
*****************************************************************************/
+const struct tulip_srom_to_ifmedia tulip_srom_to_ifmedia_table[] = {
+ { TULIP_ROM_MB_MEDIA_TP, IFM_10_T, 0,
+ "10baseT", SIACONN_21041_10BASET,
+ SIATXRX_21041_10BASET, SIAGEN_21041_10BASET },
+
+ { TULIP_ROM_MB_MEDIA_BNC, IFM_10_2, 0,
+ "10base2", SIACONN_21041_BNC,
+ SIATXRX_21041_BNC, SIAGEN_21041_BNC },
+
+ { TULIP_ROM_MB_MEDIA_AUI, IFM_10_5, 0,
+ "10base5", SIACONN_21041_AUI,
+ SIATXRX_21041_AUI, SIAGEN_21041_AUI },
+
+ { TULIP_ROM_MB_MEDIA_100TX, IFM_100_TX, 0,
+ "100baseTX", 0,
+ 0, 0 },
+
+ { TULIP_ROM_MB_MEDIA_TP_FDX, IFM_10_T, IFM_FDX,
+ "10baseT-FDX", SIACONN_21041_10BASET_FDX,
+ SIATXRX_21041_10BASET_FDX, SIAGEN_21041_10BASET_FDX },
+
+ { TULIP_ROM_MB_MEDIA_100TX_FDX, IFM_100_TX, IFM_FDX,
+ "100baseTX-FDX", 0,
+ 0, 0 },
+
+ { TULIP_ROM_MB_MEDIA_100T4, IFM_100_T4, 0,
+ "100baseT4", 0,
+ 0, 0 },
+
+ { TULIP_ROM_MB_MEDIA_100FX, IFM_100_FX, 0,
+ "100baseFX", 0,
+ 0, 0 },
+
+ { TULIP_ROM_MB_MEDIA_100FX_FDX, IFM_100_FX, IFM_FDX,
+ "100baseFX-FDX", 0,
+ 0, 0 },
+
+ { 0, 0, 0,
+ NULL, 0,
+ 0, 0 },
+};
+
+const struct tulip_srom_to_ifmedia *tulip_srom_to_ifmedia __P((u_int8_t));
+
+const struct tulip_srom_to_ifmedia *
+tulip_srom_to_ifmedia(sm)
+ u_int8_t sm;
+{
+ const struct tulip_srom_to_ifmedia *tsti;
+
+ for (tsti = tulip_srom_to_ifmedia_table;
+ tsti->tsti_name != NULL; tsti++) {
+ if (tsti->tsti_srom == sm)
+ return (tsti);
+ }
+
+ return (NULL);
+}
+
/*
* 21040 and 21041 media switches.
*/
@@ -2975,6 +3034,7 @@
struct tulip_softc *sc;
{
int i, defmedia, devcnt, leaf_offset, mb_offset, m_cnt;
+ const struct tulip_srom_to_ifmedia *tsti;
struct tulip_21040_21041_sia_media *tsm;
const char *sep = "", *defstr;
u_int16_t romdef;
@@ -3012,71 +3072,29 @@
M_DEVBUF, M_WAITOK);
switch (mb & TULIP_ROM_MB_MEDIA_CODE) {
case TULIP_ROM_MB_MEDIA_TP:
+ case TULIP_ROM_MB_MEDIA_BNC:
+ case TULIP_ROM_MB_MEDIA_AUI:
+ case TULIP_ROM_MB_MEDIA_TP_FDX:
+ tsti = tulip_srom_to_ifmedia(mb &
+ TULIP_ROM_MB_MEDIA_CODE);
+
tsm->tsm_siaconn = (mb & TULIP_ROM_MB_EXT) ?
TULIP_ROM_GETW(sc->sc_srom,
mb_offset + TULIP_ROM_MB_CSR13) :
- SIACONN_21041_10BASET;
+ tsti->tsti_21041_siaconn;
tsm->tsm_siatxrx = (mb & TULIP_ROM_MB_EXT) ?
TULIP_ROM_GETW(sc->sc_srom,
mb_offset + TULIP_ROM_MB_CSR14) :
- SIATXRX_21041_10BASET;
- tsm->tsm_siagen = (mb & TULIP_ROM_MB_EXT) ?
- TULIP_ROM_GETW(sc->sc_srom,
- mb_offset + TULIP_ROM_MB_CSR15) :
- SIAGEN_21041_10BASET;
- ADD(IFM_ETHER|IFM_10_T, tsm);
- PRINT("10baseT");
- break;
-
- case TULIP_ROM_MB_MEDIA_BNC:
- tsm->tsm_siaconn = (mb & TULIP_ROM_MB_EXT) ?
- TULIP_ROM_GETW(sc->sc_srom,
- mb_offset + TULIP_ROM_MB_CSR13) :
- SIACONN_21041_BNC;
- tsm->tsm_siatxrx = (mb & TULIP_ROM_MB_EXT) ?
- TULIP_ROM_GETW(sc->sc_srom,
- mb_offset + TULIP_ROM_MB_CSR14) :
- SIATXRX_21041_BNC;
+ tsti->tsti_21041_siatxrx;
tsm->tsm_siagen = (mb & TULIP_ROM_MB_EXT) ?
TULIP_ROM_GETW(sc->sc_srom,
mb_offset + TULIP_ROM_MB_CSR15) :
- SIAGEN_21041_BNC;
- ADD(IFM_ETHER|IFM_10_2, tsm);
- PRINT("10base2");
- break;
-
- case TULIP_ROM_MB_MEDIA_AUI:
- tsm->tsm_siaconn = (mb & TULIP_ROM_MB_EXT) ?
- TULIP_ROM_GETW(sc->sc_srom,
- mb_offset + TULIP_ROM_MB_CSR13) :
- SIACONN_21041_AUI;
- tsm->tsm_siatxrx = (mb & TULIP_ROM_MB_EXT) ?
- TULIP_ROM_GETW(sc->sc_srom,
- mb_offset + TULIP_ROM_MB_CSR14) :
- SIATXRX_21041_AUI;
- tsm->tsm_siagen = (mb & TULIP_ROM_MB_EXT) ?
- TULIP_ROM_GETW(sc->sc_srom,
- mb_offset + TULIP_ROM_MB_CSR15) :
- SIAGEN_21041_AUI;
- ADD(IFM_ETHER|IFM_10_5, tsm);
- PRINT("10base5");
- break;
-
- case TULIP_ROM_MB_MEDIA_TP_FDX:
- tsm->tsm_siaconn = (mb & TULIP_ROM_MB_EXT) ?
- TULIP_ROM_GETW(sc->sc_srom,
- mb_offset + TULIP_ROM_MB_CSR13) :
- SIACONN_21041_10BASET_FDX;
- tsm->tsm_siatxrx = (mb & TULIP_ROM_MB_EXT) ?
- TULIP_ROM_GETW(sc->sc_srom,
- mb_offset + TULIP_ROM_MB_CSR14) :
- SIATXRX_21041_10BASET_FDX;
- tsm->tsm_siagen = (mb & TULIP_ROM_MB_EXT) ?
- TULIP_ROM_GETW(sc->sc_srom,
- mb_offset + TULIP_ROM_MB_CSR15) :
- SIAGEN_21041_10BASET_FDX;
- ADD(IFM_ETHER|IFM_10_T|IFM_FDX, tsm);
- PRINT("10baseT-FDX");
+ tsti->tsti_21041_siagen;
+
+ ifmedia_add(&sc->sc_mii.mii_media,
+ IFM_MAKEWORD(IFM_ETHER, tsti->tsti_subtype,
+ tsti->tsti_options, 0), 0, tsm);
+ PRINT(tsti->tsti_name);
break;
default:
@@ -3262,7 +3280,7 @@
/*
* DECchip 2114x ISV media switch.
- * XXX Currently only handles 21140[A] MII.
+ * XXX Currently only handles 21140[A] GPR and MII.
*/
void tlp_2114x_isv_tmsw_init __P((struct tulip_softc *));
void tlp_2114x_isv_tmsw_get __P((struct tulip_softc *, struct ifmediareq *));
@@ -3272,6 +3290,10 @@
tlp_2114x_isv_tmsw_init, tlp_2114x_isv_tmsw_get, tlp_2114x_isv_tmsw_set
};
+void tlp_21140_gpr_getmedia __P((struct tulip_softc *sc,
+ struct ifmediareq *ifmr));
+int tlp_21140_gpr_setmedia __P((struct tulip_softc *sc));
+
void
tlp_2114x_isv_tmsw_init(sc)
struct tulip_softc *sc;
@@ -3280,7 +3302,9 @@
struct ifmedia_entry *ife;
struct mii_softc *phy;
struct tulip_2114x_media *tm;
- int i, devcnt, leaf_offset, m_cnt, type, length, seen, defmedia;
+ const struct tulip_srom_to_ifmedia *tsti;
+ int i, devcnt, leaf_offset, m_cnt, type, length, seen, defmedia, minst;
+ u_int16_t word;
u_int8_t *cp, *ncp;
seen = defmedia = 0;
@@ -3353,7 +3377,52 @@
/* Now, parse the block. */
switch (type) {
case TULIP_ROM_MB_21140_GPR:
- printf("%s: 21140 GPR block\n", sc->sc_dev.dv_xname);
+ seen |= 1 << TULIP_ROM_MB_21140_GPR;
+
+ tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK);
+ memset(tm, 0, sizeof(*tm));
+
+ tm->tm_type = TULIP_ROM_MB_21140_GPR;
+ tm->tm_get = tlp_21140_gpr_getmedia;
+ tm->tm_set = tlp_21140_gpr_setmedia;
+
+ minst = 0; /* XXX compute new instance */
+
+ /* First is the media type code. */
+ tsti = tulip_srom_to_ifmedia(cp[0] &
+ TULIP_ROM_MB_MEDIA_CODE);
+ if (tsti == NULL) {
+ /* Invalid media code. */
+ free(tm, M_DEVBUF);
+ break;
+ }
+ tm->tm_name = tsti->tsti_name;
+
+ /* Next is any GPIO info for this media. */
+ tm->tm_gpdata = cp[1];
+
+ /*
+ * Next is a word containing OPMODE information
+ * and info on how to detect if this media is
+ * active.
+ */
+ word = TULIP_ROM_GETW(cp, 2);
+ tm->tm_opmode = TULIP_ROM_MB_OPMODE(word);
+ if ((word & TULIP_ROM_MB_NOINDICATOR) == 0) {
+ tm->tm_actmask =
+ TULIP_ROM_MB_BITPOS(word);
+ tm->tm_actdata =
+ (word & TULIP_ROM_MB_POLARITY) ?
+ 0 : tm->tm_actmask;
+ }
+
+ /*
+ * Now, add the media to our list. We will
+ * print them out later.
+ */
+ ifmedia_add(&sc->sc_mii.mii_media,
+ IFM_MAKEWORD(IFM_ETHER, tsti->tsti_subtype,
+ tsti->tsti_options, minst), 0, tm);
break;
case TULIP_ROM_MB_21140_MII:
@@ -3366,7 +3435,8 @@
tm->tm_get = tlp_mii_getmedia;
tm->tm_set = tlp_mii_setmedia;
- sc->sc_reset = tlp_21140_reset;
+ if (sc->sc_reset == NULL)
+ sc->sc_reset = tlp_21140_reset;
/* First is the PHY number. */
tm->tm_phyno = *cp++;
@@ -3501,12 +3571,35 @@
goto set_default;
}
+#define PRINT(s) printf("%s%s", sep, s); sep = ", "
+
/*
* Display any non-MII media we've located.
*/
if (seen & (1 << TULIP_ROM_MB_21140_GPR)) {
+ const char *sep = "";
printf("%s: GPR media: ", sc->sc_dev.dv_xname);
- /* XXX */
+ for (ife = LIST_FIRST(&sc->sc_mii.mii_media.ifm_list);
+ ife != NULL;
+ ife = LIST_NEXT(ife, ifm_list)) {
+ minst = IFM_INST(ife->ifm_media);
+ tm = ife->ifm_aux;
+ if (tm->tm_type != TULIP_ROM_MB_21140_GPR)
+ continue;
+ PRINT(tm->tm_name);
+ }
+
+ /*
+ * XXX Pick a better default. Should come
+ * XXX from SROM on 21140[A], and should
+ * XXX be "auto" on Macronix chips (which
+ * XXX have an internal NWay block).
+ */
+ if (defmedia == 0) {
+ defmedia = IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0,
+ minst);
+ printf(", default 10baseT");
+ }
printf("\n");
}
Home |
Main Index |
Thread Index |
Old Index