Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/amiga/pci Fix PCI interrupt handling on empb. Also, ...



details:   https://anonhg.NetBSD.org/src/rev/86b1867be836
branches:  trunk
changeset: 779583:86b1867be836
user:      rkujawa <rkujawa%NetBSD.org@localhost>
date:      Mon Jun 04 12:56:48 2012 +0000

description:
Fix PCI interrupt handling on empb. Also, continue work on memory accesses. Now empb is good enough to handle satalink!

diffstat:

 sys/arch/amiga/pci/empb.c     |   66 ++-
 sys/arch/amiga/pci/empb_bsm.c |  768 +++++++++++++++++++++++++++++++++++++++++-
 sys/arch/amiga/pci/empbreg.h  |    5 +-
 sys/arch/amiga/pci/empbvar.h  |   21 +-
 4 files changed, 826 insertions(+), 34 deletions(-)

diffs (truncated from 1056 to 300 lines):

diff -r 8c121bc5b4d7 -r 86b1867be836 sys/arch/amiga/pci/empb.c
--- a/sys/arch/amiga/pci/empb.c Mon Jun 04 10:18:01 2012 +0000
+++ b/sys/arch/amiga/pci/empb.c Mon Jun 04 12:56:48 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: empb.c,v 1.4 2012/06/01 17:41:16 rkujawa Exp $ */
+/*     $NetBSD: empb.c,v 1.5 2012/06/04 12:56:48 rkujawa Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
 
 #include "opt_pci.h"
 
-#define EMPB_DEBUG 1 
+/* #define EMPB_DEBUG 1  */
 
 #define        PCI_CONF_LOCK(s)        (s) = splhigh()
 #define        PCI_CONF_UNLOCK(s)      splx((s))
@@ -70,6 +70,7 @@
 
 static void    empb_find_mem(struct empb_softc *sc);
 static void    empb_switch_bridge(struct empb_softc *sc, uint8_t mode);
+static void    empb_intr_enable(struct empb_softc *sc);
 
 pcireg_t       empb_pci_conf_read(pci_chipset_tag_t, pcitag_t, int);
 void           empb_pci_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
@@ -84,6 +85,8 @@
                    pci_intr_handle_t *ihp);
 const struct evcnt * empb_pci_intr_evcnt(pci_chipset_tag_t pc, 
                    pci_intr_handle_t ih);
+int            empb_pci_conf_hook(pci_chipset_tag_t pct, int bus, 
+                   int dev, int func, pcireg_t id);
 
 CFATTACH_DECL_NEW(empb, sizeof(struct empb_softc),
     empb_match, empb_attach, NULL, NULL);
@@ -181,6 +184,11 @@
 
        sc->pci_confio_t = &(sc->pci_confio_area);
 
+       /*
+        * We should not map I/O space here, however we have no choice 
+        * since these addresses are shared between configuration space and
+        * I/O space. Not really a problem on m68k, however on PPC... 
+        */
        if (bus_space_map(sc->pci_confio_t, 0, EMPB_BRIDGE_SIZE, 0, 
            &sc->pci_confio_h)) 
                aprint_error_dev(self,
@@ -220,7 +228,7 @@
        sc->apc.pc_intr_establish = amiga_pci_intr_establish;
        sc->apc.pc_intr_disestablish = amiga_pci_intr_disestablish;
 
-       sc->apc.pc_conf_hook = amiga_pci_conf_hook;
+       sc->apc.pc_conf_hook = empb_pci_conf_hook;
        sc->apc.pc_conf_interrupt = amiga_pci_conf_interrupt;
 
        sc->apc.cookie = sc;
@@ -254,9 +262,18 @@
        pba.pba_bus = 0;
        pba.pba_bridgetag = NULL;
 
+       empb_intr_enable(sc);
+
        config_found_ia(self, "pcibus", &pba, pcibusprint);
 }
 
+static void 
+empb_intr_enable(struct empb_softc *sc) 
+{
+       bus_space_write_1(sc->setup_area_t, sc->setup_area_h,
+           EMPB_SETUP_INTR_OFF, EMPB_INTR_ENABLE);
+}
+
 /*
  * Switch between configuration space and I/O space.
  */
@@ -287,9 +304,9 @@
        mem_sc = device_private(memdev);
 
        sc->pci_mem_win.base = (bus_addr_t) mem_sc->sc_base;
-       sc->pci_mem_win.absm = &amiga_bus_stride_1;
-
+       sc->pci_mem_win.absm = &empb_bus_swap;
        sc->pci_mem_win_size = mem_sc->sc_size;
+       sc->pci_mem_win_t = &sc->pci_mem_win;
 
        if(sc->pci_mem_win_size == 8*1024*1024)
                sc->pci_mem_win_mask = EMPB_WINDOW_MASK_8M;
@@ -307,37 +324,39 @@
 }
 
 /*
- * Switch memory window position.
+ * Switch memory window position. Return PCI mem address seen at the beginning
+ * of window.
  */
-void
+bus_addr_t
 empb_switch_window(struct empb_softc *sc, bus_addr_t address) 
 {
        int s;
        uint16_t win_reg;
+#ifdef EMPB_DEBUG
+       uint16_t rwin_reg;
+#endif /* EMPB_DEBUG */
 
        WINDOW_LOCK(s);
 
        win_reg = bswap16((address >> EMPB_WINDOW_SHIFT) 
            & sc->pci_mem_win_mask);
 
-#ifdef EMPB_DEBUG
-       aprint_normal("empb: access to %p window switch to %x (@%p)\n", 
-           (void*) address, win_reg, (void*) sc->setup_area_h);
-#endif /* EMPB_DEBUG */
-
        bus_space_write_2(sc->setup_area_t, sc->setup_area_h,
            EMPB_SETUP_WINDOW_OFF, win_reg);
 
        /* store window pos, like: sc->pci_mem_win_pos = win_reg ? */
 
-       win_reg = bus_space_read_2(sc->setup_area_t, sc->setup_area_h,
+#ifdef EMPB_DEBUG
+       rwin_reg = bus_space_read_2(sc->setup_area_t, sc->setup_area_h,
            EMPB_SETUP_WINDOW_OFF);
 
+       aprint_normal("empb: access to %p window switch to %x => reg now %x\n",
+           (void*) address, win_reg, rwin_reg);
+#endif /* EMPB_DEBUG */
+
        WINDOW_UNLOCK(s);       
 
-#ifdef EMPB_DEBUG
-       aprint_normal("empb: window reg now %x\n", win_reg);
-#endif /* EMPB_DEBUG */
+       return (bus_addr_t)((bswap16(win_reg)) << EMPB_WINDOW_SHIFT);
 }
 
 
@@ -427,3 +446,18 @@
        return NULL;
 }
 
+int
+empb_pci_conf_hook(pci_chipset_tag_t pct, int bus, int dev, int func,
+    pcireg_t id)
+{
+
+       /* 
+        * Register information about some known PCI devices with
+        * DMA-able memory.
+        */
+       /*if ((PCI_VENDOR(id) == PCI_VENDOR_3DFX) &&
+               (PCI_PRODUCT(id) >= PCI_PRODUCT_3DFX_VOODOO3))*/
+
+
+        return PCI_CONF_DEFAULT;
+}
diff -r 8c121bc5b4d7 -r 86b1867be836 sys/arch/amiga/pci/empb_bsm.c
--- a/sys/arch/amiga/pci/empb_bsm.c     Mon Jun 04 10:18:01 2012 +0000
+++ b/sys/arch/amiga/pci/empb_bsm.c     Mon Jun 04 12:56:48 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: empb_bsm.c,v 1.2 2012/06/01 17:41:16 rkujawa Exp $ */
+/*     $NetBSD: empb_bsm.c,v 1.3 2012/06/04 12:56:48 rkujawa Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,9 @@
  */
 
 /*
- * Special bus space methods handling PCI memory window.
+ * Special bus space methods handling PCI memory window. Used only by empb.
+ *
+ * XXX: Handle ops on window boundary! Currently these are broken!
  */
 
 #include <sys/bus.h>
@@ -38,26 +40,759 @@
 #include <sys/param.h>
 #include <sys/device.h>
 #include <sys/systm.h>
+#include <sys/types.h>
 
 #include <amiga/pci/empbreg.h>
 #include <amiga/pci/empbvar.h>
 #include <amiga/pci/emmemvar.h>
 
+static bool empb_bsm_init(void);
+
 /*
-int
+ * The bus_space functions are prototyped below. Due to macro-ridden 
+ * maddness of amiga port bus_space implementation, these prototypes look
+ * somewhat different than what you can read in bus_space(9) man page.
+ */
+
+static int     empb_bsm(bus_space_tag_t space, bus_addr_t address, 
+                   bus_size_t size, int flags, bus_space_handle_t *handlep);
+static int     empb_bsms(bus_space_handle_t handle, bus_size_t offset, 
+                   bus_size_t size, bus_space_handle_t *nhandlep);
+static void    empb_bsu(bus_space_handle_t handle,
+                   bus_size_t size);
+
+static bsr(empb_bsr1, u_int8_t);
+static bsw(empb_bsw1, u_int8_t);
+static bsrm(empb_bsrm1, u_int8_t);
+static bswm(empb_bswm1, u_int8_t);
+static bsrm(empb_bsrr1, u_int8_t);
+static bswm(empb_bswr1, u_int8_t);
+static bssr(empb_bssr1, u_int8_t);
+static bscr(empb_bscr1, u_int8_t);
+
+static bsr(empb_bsr2_swap, u_int16_t);
+static bsw(empb_bsw2_swap, u_int16_t);
+static bsr(empb_bsr2, u_int16_t);
+static bsw(empb_bsw2, u_int16_t);
+static bsrm(empb_bsrm2_swap, u_int16_t);
+static bswm(empb_bswm2_swap, u_int16_t);
+static bsrm(empb_bsrm2, u_int16_t);
+static bswm(empb_bswm2, u_int16_t);
+static bsrm(empb_bsrr2_swap, u_int16_t);
+static bswm(empb_bswr2_swap, u_int16_t);
+static bsrm(empb_bsrr2, u_int16_t);
+static bswm(empb_bswr2, u_int16_t);
+static bssr(empb_bssr2_swap, u_int16_t);
+static bscr(empb_bscr2, u_int16_t);
+
+/*static bsr(empb_bsr4_swap, u_int32_t);
+static bsw(empb_bsw4_swap, u_int32_t);
+static bsr(empb_bsr4, u_int32_t);
+static bsw(empb_bsw4, u_int32_t);
+static bsrm(empb_bsrm4_swap, u_int32_t);
+static bswm(empb_bswm4_swap, u_int32_t);
+static bsrm(empb_bsrm4, u_int32_t);
+static bswm(empb_bswm4, u_int32_t);
+static bsrm(empb_bsrr4_swap, u_int32_t);
+static bswm(empb_bswr4_swap, u_int32_t);
+static bsrm(empb_bsrr4, u_int32_t);
+static bswm(empb_bswr4, u_int32_t);
+static bssr(empb_bssr4_swap, u_int32_t);
+static bscr(empb_bscr4, u_int32_t);*/
+/* 
+ * Hold pointer to bridge driver here. We need to access it to switch 
+ * window position. Perhaps it should be stored in bus_space_tag instead...
+ */
+static struct empb_softc *empb_sc = NULL;
+
+static bool 
+empb_bsm_init(void) 
+{
+       device_t dev;
+
+       /* We can't have more than one Mediator anyway. */
+       if (!(dev = device_find_by_xname("empb0"))) {
+               aprint_error("empb: can't find bridge device\n");
+               return false;
+       }
+
+       if (!(empb_sc = device_private(dev))) {
+               aprint_error_dev(dev, "can't obtain bridge softc\n");
+               return false;
+       }
+
+       if (empb_sc->pci_mem_win_size == 0) {
+               aprint_error_dev(dev, "no PCI memory window found\n");
+               return false;
+       }
+
+       return true;
+}
+
+/* === common bus space methods === */
+
+static int
 empb_bsm(bus_space_tag_t space, bus_addr_t address, bus_size_t size,
-    int flags, bus_space_handle_t *handlep);
-int
-empb_bsms(bus_space_tag_t space, bus_space_handle_t handle,
-    bus_size_t offset, bus_size_t size, bus_space_handle_t *nhandlep);
+    int flags, bus_space_handle_t *handlep) 
+{
+
+       /* Check for bridge driver softc. */
+       if (empb_sc==NULL)
+               if(empb_bsm_init() == false)
+                       return -1; 
+               
+       /* Fail miserably if the driver wants linear space. */  
+       if (flags & BUS_SPACE_MAP_LINEAR)
+       {
+               aprint_error("empb: linear space mapping not possible\n");
+               return -1;
+       }
+
+       /* 
+        * Just store the desired PCI bus address as handlep. Don't make things 
+        * more complicated than they need to be.
+        */
+       *handlep = address;
+



Home | Main Index | Thread Index | Old Index