The pci attachment of pcic(4) is currently only available on i386, and
has too many ties with the isa logic.

While working on getting this attachment working on another platform, I
had to make the pci glue a bit more bus-agnostic, and compensate in the
per-platform pcic_pci_machdep.c routines.

I have tried not to break anything, but I don't have an i386 system with
a pcic@pci attachment to test. The most important change is that the
card status change interrupt now gets set up before the card sockets are
probed and initialized.

According to our dmesg archive, this device may be found in several
laptops from the Pentium era (list below). Does anyone here still has
such a system (or any other machine with pcic@pci, really) to test these
changes?

TIA,
Miod

  Dell Latitude LMP-133ST
  IBM Thinkpad 380D, 390ED
  IBM Thinkpad 560, 560E
  AST Ascentia J30
  Siemens Mobile 310
  HP Omnibook 5000

Index: arch/i386/pci/pcic_pci_machdep.c
===================================================================
RCS file: /OpenBSD/src/sys/arch/i386/pci/pcic_pci_machdep.c,v
retrieving revision 1.5
diff -u -p -r1.5 pcic_pci_machdep.c
--- arch/i386/pci/pcic_pci_machdep.c    26 Jun 2008 05:42:11 -0000      1.5
+++ arch/i386/pci/pcic_pci_machdep.c    26 Jul 2015 02:51:51 -0000
@@ -42,13 +42,19 @@
 #include <dev/pci/i82365_pcivar.h>
 
 void *
-pcic_pci_machdep_intr_est(pci_chipset_tag_t pc)
+pcic_pci_intr_ct(pci_chipset_tag_t pc)
 {
        return NULL;
 }
 
+int
+pcic_pci_intr_find(struct pcic_softc *sc, int type)
+{
+       return pcic_intr_find(sc, type);
+}
+
 void *
-pcic_pci_machdep_pcic_intr_establish(struct pcic_softc *sc, int (*fct)(void *))
+pcic_pci_pcic_intr_establish(struct pcic_softc *sc, int (*fct)(void *))
 {
        if (isa_intr_alloc(NULL, PCIC_CSC_INTR_IRQ_VALIDMASK & 0xffff,
                           IST_EDGE, &(sc->irq)))
@@ -59,7 +65,7 @@ pcic_pci_machdep_pcic_intr_establish(str
 }
 
 void *
-pcic_pci_machdep_chip_intr_establish(pcmcia_chipset_handle_t pch,
+pcic_pci_chip_intr_establish(pcmcia_chipset_handle_t pch,
     struct pcmcia_function *pf, int ipl, int (*fct)(void *), void *arg,
     char *xname)
 {
@@ -67,7 +73,20 @@ pcic_pci_machdep_chip_intr_establish(pcm
 }
 
 void
-pcic_pci_machdep_chip_intr_disestablish(pcmcia_chipset_handle_t pch, void *ih)
+pcic_pci_chip_intr_disestablish(pcmcia_chipset_handle_t pch, void *ih)
 {
        pcic_isa_chip_intr_disestablish(pch, ih);
+}
+
+const char *
+pcic_pci_chip_intr_string(pcmcia_chipset_handle_t pch, void *ih)
+{
+       return pcic_isa_chip_intr_string(pch, ih);
+}
+
+void
+pcic_pci_setup_io_range(struct pcic_softc *sc)
+{
+       sc->iobase = 0x400;
+       sc->iosize = 0x1000 - sc->iobase - 1;
 }
Index: dev/ic/i82365var.h
===================================================================
RCS file: /OpenBSD/src/sys/dev/ic/i82365var.h,v
retrieving revision 1.14
diff -u -p -r1.14 i82365var.h
--- dev/ic/i82365var.h  23 Nov 2005 11:39:37 -0000      1.14
+++ dev/ic/i82365var.h  26 Jul 2015 02:51:51 -0000
@@ -117,7 +117,7 @@ struct pcic_softc {
        bus_space_handle_t ioh;
 
        /* XXX isa_chipset_tag_t, pci_chipset_tag_t, etc. */
-       void *intr_est;
+       void *intr_ct;
 
        pcmcia_chipset_tag_t pct;
 
Index: dev/isa/i82365_isa.c
===================================================================
RCS file: /OpenBSD/src/sys/dev/isa/i82365_isa.c,v
retrieving revision 1.22
diff -u -p -r1.22 i82365_isa.c
--- dev/isa/i82365_isa.c        7 Sep 2010 16:21:43 -0000       1.22
+++ dev/isa/i82365_isa.c        26 Jul 2015 02:51:51 -0000
@@ -180,7 +180,7 @@ pcic_isa_attach(parent, self, aux)
        sc->membase = ia->ia_maddr;
        sc->subregionmask = (1 << (ia->ia_msize / PCIC_MEM_PAGESIZE)) - 1;
 
-       sc->intr_est = ic;
+       sc->intr_ct = ic;
        sc->pct = (pcmcia_chipset_tag_t)&pcic_isa_functions;
 
        sc->iot = iot;
Index: dev/isa/i82365_isapnp.c
===================================================================
RCS file: /OpenBSD/src/sys/dev/isa/i82365_isapnp.c,v
retrieving revision 1.8
diff -u -p -r1.8 i82365_isapnp.c
--- dev/isa/i82365_isapnp.c     7 Sep 2010 16:21:43 -0000       1.8
+++ dev/isa/i82365_isapnp.c     26 Jul 2015 02:51:51 -0000
@@ -153,7 +153,7 @@ pcic_isapnp_attach(parent, self, aux)
        sc->membase = ipa->ia_maddr;
        sc->subregionmask = (1 << (ipa->ia_msize / PCIC_MEM_PAGESIZE)) - 1;
 
-       sc->intr_est = ic;
+       sc->intr_ct = ic;
        sc->pct = (pcmcia_chipset_tag_t) & pcic_isa_functions;
 
        sc->iot = iot;
Index: dev/isa/i82365_isasubr.c
===================================================================
RCS file: /OpenBSD/src/sys/dev/isa/i82365_isasubr.c,v
retrieving revision 1.24
diff -u -p -r1.24 i82365_isasubr.c
--- dev/isa/i82365_isasubr.c    14 Jul 2013 15:18:36 -0000      1.24
+++ dev/isa/i82365_isasubr.c    26 Jul 2015 02:51:51 -0000
@@ -192,7 +192,7 @@ pcic_isa_chip_intr_establish(pch, pf, ip
 {
        struct pcic_handle *h = (struct pcic_handle *)pch;
        struct pcic_softc *sc = (struct pcic_softc *)(h->ph_parent);
-       isa_chipset_tag_t ic = sc->intr_est;
+       isa_chipset_tag_t ic = sc->intr_ct;
        int irq, ist, reg;
 
        if (pf->cfe->flags & PCMCIA_CFE_IRQLEVEL)
@@ -222,7 +222,7 @@ pcic_isa_chip_intr_disestablish(pch, ih)
 {
        struct pcic_handle *h = (struct pcic_handle *) pch;
        struct pcic_softc *sc = (struct pcic_softc *)(h->ph_parent);
-       isa_chipset_tag_t ic = sc->intr_est;
+       isa_chipset_tag_t ic = sc->intr_ct;
        int reg;
 
        h->ih_irq = 0;
@@ -270,7 +270,7 @@ pcic_intr_find(sc, ist)
        int ist;
 {
        struct pcic_handle *ph = &sc->handle[0];
-       isa_chipset_tag_t ic = sc->intr_est;
+       isa_chipset_tag_t ic = sc->intr_ct;
        int i, tickle, check, irq, chosen_irq = 0, csc_touched = 0;
        void *ih;
        u_int8_t saved_csc_intr;
Index: dev/pci/i82365_pci.c
===================================================================
RCS file: /OpenBSD/src/sys/dev/pci/i82365_pci.c,v
retrieving revision 1.11
diff -u -p -r1.11 i82365_pci.c
--- dev/pci/i82365_pci.c        7 Sep 2010 16:21:44 -0000       1.11
+++ dev/pci/i82365_pci.c        26 Jul 2015 02:51:51 -0000
@@ -48,9 +48,6 @@
 #include <dev/pci/pcidevs.h>
 #include <dev/pci/i82365_pcivar.h>
 
-#include <dev/isa/isavar.h>
-#include <dev/isa/i82365_isavar.h>
-
 /*
  * PCI constants.
  * XXX These should be in a common file!
@@ -61,7 +58,7 @@ int   pcic_pci_match(struct device *, void
 void   pcic_pci_attach(struct device *, struct device *, void *);
 
 struct cfattach pcic_pci_ca = {
-       sizeof(struct pcic_pci_softc), pcic_pci_match, pcic_pci_attach
+       sizeof(struct pcic_softc), pcic_pci_match, pcic_pci_attach
 };
 
 static struct pcmcia_chip_functions pcic_pci_functions = {
@@ -75,10 +72,9 @@ static struct pcmcia_chip_functions pcic
        pcic_chip_io_map,
        pcic_chip_io_unmap,
 
-       /* XXX */
-       pcic_isa_chip_intr_establish,
-       pcic_isa_chip_intr_disestablish,
-       pcic_isa_chip_intr_string,
+       pcic_pci_chip_intr_establish,
+       pcic_pci_chip_intr_disestablish,
+       pcic_pci_chip_intr_string,
 
        pcic_chip_socket_enable,
        pcic_chip_socket_disable,
@@ -98,15 +94,12 @@ pcic_pci_match(parent, match, aux)
        return (0);
 }
 
-void pcic_isa_config_interrupts(struct device *);
-
 void
 pcic_pci_attach(parent, self, aux)
        struct device *parent, *self;
        void *aux;
 {
        struct pcic_softc *sc = (void *) self;
-       struct pcic_pci_softc *psc = (void *) self;
        struct pcic_handle *h;
        struct pci_attach_args *pa = aux;
        pci_chipset_tag_t pc = pa->pa_pc;
@@ -142,9 +135,7 @@ pcic_pci_attach(parent, self, aux)
        sc->subregionmask = (1 << (0x10000 / PCIC_MEM_PAGESIZE)) - 1;
 
        /* same deal for io allocation */
-
-       sc->iobase = 0x400;
-       sc->iosize = 0xbff;
+       pcic_pci_setup_io_range(sc);
 
        /* end XXX */
 
@@ -154,8 +145,8 @@ pcic_pci_attach(parent, self, aux)
        sc->memh = memh;
 
        printf("\n");
+       sc->intr_ct = pcic_pci_intr_ct(pc);
        pcic_attach(sc);
-       pcic_attach_sockets(sc);
 
        /*
         * Check to see if we're using PCI or ISA interrupts. I don't
@@ -172,13 +163,11 @@ pcic_pci_attach(parent, self, aux)
                return;
        }
 
-       psc->intr_est = pcic_pci_machdep_intr_est(pc);
-
-       irq = pcic_intr_find(sc, IST_EDGE);
+       irq = pcic_pci_intr_find(sc, IST_EDGE);
 
        /* Map and establish the interrupt. */
        if (irq) {
-               sc->ih = pcic_pci_machdep_pcic_intr_establish(sc, pcic_intr);
+               sc->ih = pcic_pci_pcic_intr_establish(sc, pcic_intr);
                if (sc->ih == NULL) {
                        printf("%s: couldnt map interrupt\n", sc->dev.dv_xname);
                        bus_space_unmap(memt, memh, 0x10000);
@@ -209,4 +198,6 @@ pcic_pci_attach(parent, self, aux)
                 timeout_add_msec(&sc->poll_timeout, 500);
                 sc->poll_established = 1;
         }
+
+       pcic_attach_sockets(sc);
 }
Index: dev/pci/i82365_pcivar.h
===================================================================
RCS file: /OpenBSD/src/sys/dev/pci/i82365_pcivar.h,v
retrieving revision 1.6
diff -u -p -r1.6 i82365_pcivar.h
--- dev/pci/i82365_pcivar.h     26 Jun 2008 05:42:17 -0000      1.6
+++ dev/pci/i82365_pcivar.h     26 Jul 2015 02:51:51 -0000
@@ -27,22 +27,19 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-struct pcic_pci_softc {
-       struct pcic_softc sc_pcic;      /* real pcic softc */
-       void *intr_est;                 /* XXX */
-};
-
 /* 
  * Establish/disestablish interrupts for PCMCIA functions.
  */
 
-void *pcic_pci_machdep_intr_est(pci_chipset_tag_t);
+void   *pcic_pci_intr_ct(pci_chipset_tag_t);
+int     pcic_pci_intr_find(struct pcic_softc *, int);
+
+void   *pcic_pci_pcic_intr_establish(struct pcic_softc *,
+           int (*)(void *));
 
-void *pcic_pci_machdep_pcic_intr_establish(struct pcic_softc *,
-                                          int (*)(void *));
+void    pcic_pci_setup_io_range(struct pcic_softc *);
 
-void *pcic_pci_machdep_chip_intr_establish(pcmcia_chipset_handle_t,
-                                          struct pcmcia_function *,
-                                          int, int (*)(void *),
-                                          void *, char *);
-void pcic_pci_machdep_chip_intr_disestablish(pcmcia_chipset_handle_t, void *);
+void    pcic_pci_chip_intr_disestablish(pcmcia_chipset_handle_t, void *);
+void   *pcic_pci_chip_intr_establish(pcmcia_chipset_handle_t,
+           struct pcmcia_function *, int, int (*) (void *), void *, char *);
+const char *pcic_pci_chip_intr_string(pcmcia_chipset_handle_t, void *);

Reply via email to