Module Name: src Committed By: jakllsch Date: Sat Nov 21 16:50:29 UTC 2015
Modified Files: src/sys/arch/arm/nvidia: tegra_mc.c Log Message: Add error interrupt handler to for Tegra MC. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/nvidia/tegra_mc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/arm/nvidia/tegra_mc.c diff -u src/sys/arch/arm/nvidia/tegra_mc.c:1.2 src/sys/arch/arm/nvidia/tegra_mc.c:1.3 --- src/sys/arch/arm/nvidia/tegra_mc.c:1.2 Sun Mar 29 22:27:04 2015 +++ src/sys/arch/arm/nvidia/tegra_mc.c Sat Nov 21 16:50:29 2015 @@ -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 <jmcne...@invisible.ca> @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: tegra_mc.c,v 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 @@ static struct tegra_mc_softc *mc_softc = 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 @@ tegra_mc_attach(device_t parent, device_ 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