Date: Thu, 16 Apr 2020 16:00:21 +0000 (UTC) From: Emmanuel Vadot <manu@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r360011 - in head/sys: arm/allwinner modules/allwinner modules/allwinner/aw_mmc Message-ID: <202004161600.03GG0L9p032181@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: manu Date: Thu Apr 16 16:00:21 2020 New Revision: 360011 URL: https://svnweb.freebsd.org/changeset/base/360011 Log: arm: allwinner: aw_mmc: Make it possible to unload the module While here, add a makefile in sys/modules/allwinner so it is built. Also add the PNP info so devmatch will load this module automatically. MFC after: 1 month Added: head/sys/modules/allwinner/aw_mmc/ head/sys/modules/allwinner/aw_mmc/Makefile (contents, props changed) Modified: head/sys/arm/allwinner/aw_mmc.c head/sys/modules/allwinner/Makefile Modified: head/sys/arm/allwinner/aw_mmc.c ============================================================================== --- head/sys/arm/allwinner/aw_mmc.c Thu Apr 16 15:59:23 2020 (r360010) +++ head/sys/arm/allwinner/aw_mmc.c Thu Apr 16 16:00:21 2020 (r360011) @@ -163,6 +163,7 @@ static int aw_mmc_probe(device_t); static int aw_mmc_attach(device_t); static int aw_mmc_detach(device_t); static int aw_mmc_setup_dma(struct aw_mmc_softc *); +static void aw_mmc_teardown_dma(struct aw_mmc_softc *sc); static int aw_mmc_reset(struct aw_mmc_softc *); static int aw_mmc_init(struct aw_mmc_softc *); static void aw_mmc_intr(void *); @@ -559,8 +560,46 @@ fail: static int aw_mmc_detach(device_t dev) { + struct aw_mmc_softc *sc; + device_t d; - return (EBUSY); + sc = device_get_softc(dev); + + clk_disable(sc->aw_clk_mmc); + clk_disable(sc->aw_clk_ahb); + hwreset_assert(sc->aw_rst_ahb); + + mmc_fdt_gpio_teardown(&sc->mmc_helper); + + callout_drain(&sc->aw_timeoutc); + + AW_MMC_LOCK(sc); + d = sc->child; + sc->child = NULL; + AW_MMC_UNLOCK(sc); + if (d != NULL) + device_delete_child(sc->aw_dev, d); + + aw_mmc_teardown_dma(sc); + + mtx_destroy(&sc->aw_mtx); + + bus_teardown_intr(dev, sc->aw_res[AW_MMC_IRQRES], sc->aw_intrhand); + bus_release_resources(dev, aw_mmc_res_spec, sc->aw_res); + +#ifdef MMCCAM + if (sc->sim != NULL) { + mtx_lock(&sc->sim_mtx); + xpt_bus_deregister(cam_sim_path(sc->sim)); + cam_sim_free(sc->sim, FALSE); + mtx_unlock(&sc->sim_mtx); + } + + if (sc->devq != NULL) + cam_simq_free(sc->devq); +#endif + + return (0); } static void @@ -635,6 +674,21 @@ aw_mmc_setup_dma(struct aw_mmc_softc *sc) } static void +aw_mmc_teardown_dma(struct aw_mmc_softc *sc) +{ + + bus_dmamap_unload(sc->aw_dma_tag, sc->aw_dma_map); + bus_dmamem_free(sc->aw_dma_tag, sc->aw_dma_desc, sc->aw_dma_map); + if (bus_dma_tag_destroy(sc->aw_dma_tag) != 0) + device_printf(sc->aw_dev, "Cannot destroy the dma tag\n"); + + bus_dmamap_unload(sc->aw_dma_buf_tag, sc->aw_dma_buf_map); + bus_dmamap_destroy(sc->aw_dma_buf_tag, sc->aw_dma_buf_map); + if (bus_dma_tag_destroy(sc->aw_dma_buf_tag) != 0) + device_printf(sc->aw_dev, "Cannot destroy the dma buf tag\n"); +} + +static void aw_dma_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int err) { int i; @@ -1519,3 +1573,4 @@ DRIVER_MODULE(aw_mmc, simplebus, aw_mmc_driver, aw_mmc #ifndef MMCCAM MMC_DECLARE_BRIDGE(aw_mmc); #endif +SIMPLEBUS_PNP_INFO(compat_data); Modified: head/sys/modules/allwinner/Makefile ============================================================================== --- head/sys/modules/allwinner/Makefile Thu Apr 16 15:59:23 2020 (r360010) +++ head/sys/modules/allwinner/Makefile Thu Apr 16 16:00:21 2020 (r360011) @@ -2,6 +2,7 @@ # Build modules specific to Allwinner. SUBDIR = \ + aw_mmc \ aw_pwm \ aw_rtc \ aw_rsb \ Added: head/sys/modules/allwinner/aw_mmc/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/allwinner/aw_mmc/Makefile Thu Apr 16 16:00:21 2020 (r360011) @@ -0,0 +1,14 @@ +# $FreeBSD$ + +.PATH: ${SRCTOP}/sys/arm/allwinner + +KMOD= aw_mmc +SRCS= aw_mmc.c + +SRCS+= \ + bus_if.h \ + clknode_if.h \ + device_if.h \ + ofw_bus_if.h + +.include <bsd.kmod.mk>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004161600.03GG0L9p032181>