Date: Sun, 15 May 2016 15:52:34 +0000 (UTC) From: Jared McNeill <jmcneill@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r299859 - head/sys/arm/allwinner Message-ID: <201605151552.u4FFqYa6088295@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jmcneill Date: Sun May 15 15:52:34 2016 New Revision: 299859 URL: https://svnweb.freebsd.org/changeset/base/299859 Log: Allow RSB to be used from interrupt handlers. The driver uses polling mode if cold or !THREAD_CAN_SLEEP() and now implements the bus_* interface. Modified: head/sys/arm/allwinner/aw_rsb.c Modified: head/sys/arm/allwinner/aw_rsb.c ============================================================================== --- head/sys/arm/allwinner/aw_rsb.c Sun May 15 15:31:44 2016 (r299858) +++ head/sys/arm/allwinner/aw_rsb.c Sun May 15 15:52:34 2016 (r299859) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include <sys/bus.h> #include <sys/rman.h> #include <sys/kernel.h> +#include <sys/proc.h> #include <sys/module.h> #include <machine/bus.h> @@ -201,21 +202,22 @@ static int rsb_start(device_t dev) { struct rsb_softc *sc; - int error, retry; + int error, retry, polling; sc = device_get_softc(dev); + polling = cold || !THREAD_CAN_SLEEP(); RSB_ASSERT_LOCKED(sc); /* Enable interrupts */ - if (!cold) + if (!polling) RSB_WRITE(sc, RSB_INTE, INT_MASK); /* Start the transfer */ RSB_WRITE(sc, RSB_CTRL, GLOBAL_INT_ENB | START_TRANS); /* Wait for transfer to complete */ - if (cold) { + if (polling) { error = ETIMEDOUT; for (retry = RSB_I2C_TIMEOUT; retry > 0; retry--) { sc->status |= RSB_READ(sc, RSB_INTS); @@ -482,6 +484,17 @@ static device_method_t rsb_methods[] = { DEVMETHOD(device_probe, rsb_probe), DEVMETHOD(device_attach, rsb_attach), + /* Bus interface */ + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), + DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), + DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), + /* OFW methods */ DEVMETHOD(ofw_bus_get_node, rsb_get_node),
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605151552.u4FFqYa6088295>