Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Minor tidying up of the HME driver attach:



details:   https://anonhg.NetBSD.org/src/rev/a55dd6f4e33c
branches:  trunk
changeset: 515830:a55dd6f4e33c
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Oct 05 17:49:43 2001 +0000

description:
Minor tidying up of the HME driver attach:
- Print nicer-looking message.
- Use bus_space_subregion() when appropriate, rather than arithmetic
  on a bus_space_handle_t.

diffstat:

 sys/dev/ic/hme.c           |   5 +-
 sys/dev/pci/if_hme_pci.c   |  91 ++++++++++++++++++++++++++-------------------
 sys/dev/sbus/if_hme_sbus.c |  16 +++++---
 3 files changed, 66 insertions(+), 46 deletions(-)

diffs (219 lines):

diff -r 873b23de7a5f -r a55dd6f4e33c sys/dev/ic/hme.c
--- a/sys/dev/ic/hme.c  Fri Oct 05 16:26:01 2001 +0000
+++ b/sys/dev/ic/hme.c  Fri Oct 05 17:49:43 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hme.c,v 1.21 2001/07/07 15:59:37 thorpej Exp $ */
+/*     $NetBSD: hme.c,v 1.22 2001/10/05 17:49:45 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -240,7 +240,8 @@
        }
        sc->sc_rb.rb_dmabase = sc->sc_dmamap->dm_segs[0].ds_addr;
 
-       printf(": address %s\n", ether_sprintf(sc->sc_enaddr));
+       printf("%s: Ethernet address %s\n", sc->sc_dev.dv_xname,
+           ether_sprintf(sc->sc_enaddr));
 
        /* Initialize ifnet structure. */
        strcpy(ifp->if_xname, sc->sc_dev.dv_xname);
diff -r 873b23de7a5f -r a55dd6f4e33c sys/dev/pci/if_hme_pci.c
--- a/sys/dev/pci/if_hme_pci.c  Fri Oct 05 16:26:01 2001 +0000
+++ b/sys/dev/pci/if_hme_pci.c  Fri Oct 05 17:49:43 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_hme_pci.c,v 1.6 2001/09/26 20:53:13 eeh Exp $       */
+/*     $NetBSD: if_hme_pci.c,v 1.7 2001/10/05 17:49:43 thorpej Exp $   */
 
 /*
  * Copyright (c) 2000 Matthew R. Green
@@ -92,13 +92,17 @@
        struct pci_attach_args *pa = aux;
        struct hme_pci_softc *hsc = (void *)self;
        struct hme_softc *sc = &hsc->hsc_hme;
-       pci_intr_handle_t intrhandle;
-       /* XXX the following declarations should be elsewhere */
-       extern void myetheraddr __P((u_char *));
+       pci_intr_handle_t ih;
        pcireg_t csr;
        const char *intrstr;
        int type;
 
+       /* XXX the following declarations should be elsewhere */
+       extern void myetheraddr __P((u_char *));
+
+       printf(": Sun Happy Meal Ethernet, rev. %d\n",
+           PCI_REVISION(pa->pa_class));
+
        /*
         * enable io/memory-space accesses.  this is kinda of gross; but
         # the hme comes up with neither IO space enabled, or memory space.
@@ -138,17 +142,56 @@
        if (pci_mapreg_map(pa, PCI_HME_BASEADDR, type, 0,
            &hsc->hsc_memt, &hsc->hsc_memh, NULL, NULL) != 0)
        {
-               printf(": could not map hme registers\n");
+               printf("%s: unable to map device registers\n",
+                   sc->sc_dev.dv_xname);
                return;
        }
        sc->sc_seb = hsc->hsc_memh;
-       sc->sc_etx = hsc->hsc_memh + 0x2000;
-       sc->sc_erx = hsc->hsc_memh + 0x4000;
-       sc->sc_mac = hsc->hsc_memh + 0x6000;
-       sc->sc_mif = hsc->hsc_memh + 0x7000;
+       if (bus_space_subregion(hsc->hsc_memt, hsc->hsc_memh, 0x2000,
+           0x1000, &sc->sc_etx)) {
+               printf("%s: unable to subregion ETX registers\n",
+                   sc->sc_dev.dv_xname);
+               return;
+       }
+       if (bus_space_subregion(hsc->hsc_memt, hsc->hsc_memh, 0x4000,
+           0x1000, &sc->sc_erx)) {
+               printf("%s: unable to subregion ERX registers\n",
+                   sc->sc_dev.dv_xname);
+               return;
+       }
+       if (bus_space_subregion(hsc->hsc_memt, hsc->hsc_memh, 0x6000,
+           0x1000, &sc->sc_mac)) {
+               printf("%s: unable to subregion MAC registers\n",
+                   sc->sc_dev.dv_xname);
+               return;
+       }
+       if (bus_space_subregion(hsc->hsc_memt, hsc->hsc_memh, 0x7000,
+           0x1000, &sc->sc_mif)) {
+               printf("%s: unable to subregion MIF registers\n",
+                   sc->sc_dev.dv_xname);
+               return;
+       }
 
        myetheraddr(sc->sc_enaddr);
 
+       /*
+        * Map and establish our interrupt.
+        */
+       if (pci_intr_map(pa, &ih) != 0) {
+               printf("%s: unable to map interrupt\n", sc->sc_dev.dv_xname);
+               return;
+       }       
+       intrstr = pci_intr_string(pa->pa_pc, ih);
+       hsc->hsc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_NET, hme_intr, sc);
+       if (hsc->hsc_ih == NULL) {
+               printf("%s: unable to establish interrupt",
+                   sc->sc_dev.dv_xname);
+               if (intrstr != NULL)
+                       printf(" at %s", intrstr);
+               printf("\n");
+       }
+       printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
+
 #if 0
        /*
         * Get transfer burst size from PROM and pass it on
@@ -173,34 +216,6 @@
 
        sc->sc_burst = 16;      /* XXX */
 
-       /*
-        * call the main configure
-        */
+       /* Finish off the attach. */
        hme_config(sc);
-
-#if 0
-printf("%s: ", sc->sc_dev.dv_xname);
-pci_conf_print(pa->pa_pc, pa->pa_tag, 0);
-#endif
-
-       if (pci_intr_map(pa, &intrhandle) != 0) {
-               printf("%s: couldn't map interrupt\n",
-                   sc->sc_dev.dv_xname);
-               return; /* bus_unmap ? */
-       }       
-       intrstr = pci_intr_string(pa->pa_pc, intrhandle);
-       hsc->hsc_ih = pci_intr_establish(pa->pa_pc,
-           intrhandle, IPL_NET, hme_intr, sc);
-       if (hsc->hsc_ih != NULL) {
-               printf("%s: using %s for interrupt\n",
-                   sc->sc_dev.dv_xname,
-                   intrstr ? intrstr : "unknown interrupt");
-       } else {
-               printf("%s: couldn't establish interrupt",
-                   sc->sc_dev.dv_xname);
-               if (intrstr != NULL)
-                       printf(" at %s", intrstr);
-               printf("\n");
-               return; /* bus_unmap ? */
-       }
 }
diff -r 873b23de7a5f -r a55dd6f4e33c sys/dev/sbus/if_hme_sbus.c
--- a/sys/dev/sbus/if_hme_sbus.c        Fri Oct 05 16:26:01 2001 +0000
+++ b/sys/dev/sbus/if_hme_sbus.c        Fri Oct 05 17:49:43 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_hme_sbus.c,v 1.7 2001/09/26 20:53:14 eeh Exp $      */
+/*     $NetBSD: if_hme_sbus.c,v 1.8 2001/10/05 17:49:45 thorpej Exp $  */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -98,6 +98,7 @@
        struct sbusdev *sd = &hsc->hsc_sbus;
        u_int32_t burst, sbusburst;
        int node;
+
        /* XXX the following declarations should be elsewhere */
        extern void myetheraddr __P((u_char *));
 
@@ -107,6 +108,9 @@
        sc->sc_bustag = sa->sa_bustag;
        sc->sc_dmatag = sa->sa_dmatag;
 
+       printf(": Sun Happy Meal Ethernet (%s)\n",
+           sa->sa_name);
+
        if (sa->sa_nreg < 5) {
                printf("%s: only %d register sets\n",
                        self->dv_xname, sa->sa_nreg);
@@ -128,7 +132,7 @@
                         (bus_addr_t)sa->sa_reg[0].sbr_offset,
                         (bus_size_t)sa->sa_reg[0].sbr_size,
                         BUS_SPACE_MAP_LINEAR, 0, &sc->sc_seb) != 0) {
-               printf("%s @ sbus: cannot map registers\n", self->dv_xname);
+               printf("%s: cannot map SEB registers\n", self->dv_xname);
                return;
        }
        if (sbus_bus_map(sa->sa_bustag,
@@ -136,7 +140,7 @@
                         (bus_addr_t)sa->sa_reg[1].sbr_offset,
                         (bus_size_t)sa->sa_reg[1].sbr_size,
                         BUS_SPACE_MAP_LINEAR, 0, &sc->sc_etx) != 0) {
-               printf("%s @ sbus: cannot map registers\n", self->dv_xname);
+               printf("%s: cannot map ETX registers\n", self->dv_xname);
                return;
        }
        if (sbus_bus_map(sa->sa_bustag,
@@ -144,7 +148,7 @@
                         (bus_addr_t)sa->sa_reg[2].sbr_offset,
                         (bus_size_t)sa->sa_reg[2].sbr_size,
                         BUS_SPACE_MAP_LINEAR, 0, &sc->sc_erx) != 0) {
-               printf("%s @ sbus: cannot map registers\n", self->dv_xname);
+               printf("%s: cannot map ERX registers\n", self->dv_xname);
                return;
        }
        if (sbus_bus_map(sa->sa_bustag,
@@ -152,7 +156,7 @@
                         (bus_addr_t)sa->sa_reg[3].sbr_offset,
                         (bus_size_t)sa->sa_reg[3].sbr_size,
                         BUS_SPACE_MAP_LINEAR, 0, &sc->sc_mac) != 0) {
-               printf("%s @ sbus: cannot map registers\n", self->dv_xname);
+               printf("%s: cannot map MAC registers\n", self->dv_xname);
                return;
        }
        if (sbus_bus_map(sa->sa_bustag,
@@ -160,7 +164,7 @@
                         (bus_addr_t)sa->sa_reg[4].sbr_offset,
                         (bus_size_t)sa->sa_reg[4].sbr_size,
                         BUS_SPACE_MAP_LINEAR, 0, &sc->sc_mif) != 0) {
-               printf("%s @ sbus: cannot map registers\n", self->dv_xname);
+               printf("%s: cannot map MIF registers\n", self->dv_xname);
                return;
        }
 



Home | Main Index | Thread Index | Old Index