Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/nvidia Add error interrupt handler to for Tegra...



details:   https://anonhg.NetBSD.org/src/rev/fd6f3552e6c2
branches:  trunk
changeset: 341768:fd6f3552e6c2
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Sat Nov 21 16:50:29 2015 +0000

description:
Add error interrupt handler to for Tegra MC.

diffstat:

 sys/arch/arm/nvidia/tegra_mc.c |  54 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 52 insertions(+), 2 deletions(-)

diffs (93 lines):

diff -r ea76280a2d40 -r fd6f3552e6c2 sys/arch/arm/nvidia/tegra_mc.c
--- a/sys/arch/arm/nvidia/tegra_mc.c    Sat Nov 21 16:48:33 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_mc.c    Sat Nov 21 16:50:29 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_mc.c,v 1.2 2015/03/29 22:27:04 jmcneill Exp $ */
+/* $NetBSD: tegra_mc.c,v 1.3 2015/11/21 16:50:29 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #include "locators.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_mc.c,v 1.2 2015/03/29 22:27:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_mc.c,v 1.3 2015/11/21 16:50:29 jakllsch Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -45,10 +45,13 @@
 static int     tegra_mc_match(device_t, cfdata_t, void *);
 static void    tegra_mc_attach(device_t, device_t, void *);
 
+static int     tegra_mc_intr(void *);
+
 struct tegra_mc_softc {
        device_t                sc_dev;
        bus_space_tag_t         sc_bst;
        bus_space_handle_t      sc_bsh;
+       void                    *sc_ih;
 };
 
 static struct tegra_mc_softc *mc_softc = NULL;
@@ -56,6 +59,19 @@
 CFATTACH_DECL_NEW(tegra_mc, sizeof(struct tegra_mc_softc),
        tegra_mc_match, tegra_mc_attach, NULL, NULL);
 
+static inline uint32_t
+mc_read(const struct tegra_mc_softc * const sc, const bus_size_t offset)
+{
+       return bus_space_read_4(sc->sc_bst, sc->sc_bsh, offset);
+}
+
+static inline void
+mc_write(const struct tegra_mc_softc * const sc, const bus_size_t offset,
+    const uint32_t value)
+{
+       bus_space_write_4(sc->sc_bst, sc->sc_bsh, offset, value);
+}
+
 static int
 tegra_mc_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -79,6 +95,40 @@
 
        aprint_naive("\n");
        aprint_normal(": MC\n");
+
+       sc->sc_ih = intr_establish(loc->loc_intr, IPL_VM, IST_LEVEL,
+           tegra_mc_intr, sc);
+       if (sc->sc_ih == NULL) {
+               aprint_error_dev(self, "failed to establish interrupt %d\n",
+                   loc->loc_intr);
+               return;
+       }
+       aprint_normal_dev(self, "interrupting on irq %d\n", loc->loc_intr);
+
+       mc_write(sc, MC_INTSTATUS_REG, MC_INT__ALL);
+       mc_write(sc, MC_INTMASK_REG, MC_INT__ALL);
+}
+
+int
+tegra_mc_intr(void *v)
+{
+       struct tegra_mc_softc * const sc = v;
+
+       const uint32_t status = mc_read(sc, MC_INTSTATUS_REG);
+
+       if (status == 0) {
+               return 0;
+       }
+
+       const uint32_t err_status = mc_read(sc, MC_ERR_STATUS_REG);
+       const uint32_t err_adr = mc_read(sc, MC_ERR_ADR_REG);
+
+       device_printf(sc->sc_dev, "intrstatus %#x err %#x adr %#x\n",
+           status, err_status, err_adr);
+
+       mc_write(sc, MC_INTSTATUS_REG, status);
+
+       return status;
 }
 
 psize_t



Home | Main Index | Thread Index | Old Index