svn commit: r362401 - in stable/12/sys: arm/allwinner dev/mmc modules/allwinner modules/allwinner/aw_mmc
Emmanuel Vadot
manu at FreeBSD.org
Fri Jun 19 18:10:40 UTC 2020
Author: manu
Date: Fri Jun 19 18:10:39 2020
New Revision: 362401
URL: https://svnweb.freebsd.org/changeset/base/362401
Log:
MFC r360008-r360009, r360011
r360008:
mmc_fdt_helpers: Always init the timout
We use the taskqueue to schedule card detection so always init it.
This is a proper solution instead of r359965.
MFH: r359924
r360009:
mmc_fdt_helpers: Drain the cd pin taskqueue in mmc_fdt_gpio_teardown
We have no use for it now.
r360011:
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.
Added:
stable/12/sys/modules/allwinner/aw_mmc/
- copied from r360011, head/sys/modules/allwinner/aw_mmc/
Modified:
stable/12/sys/arm/allwinner/aw_mmc.c
stable/12/sys/dev/mmc/mmc_fdt_helpers.c
stable/12/sys/modules/allwinner/Makefile
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/arm/allwinner/aw_mmc.c
==============================================================================
--- stable/12/sys/arm/allwinner/aw_mmc.c Fri Jun 19 18:05:14 2020 (r362400)
+++ stable/12/sys/arm/allwinner/aw_mmc.c Fri Jun 19 18:10:39 2020 (r362401)
@@ -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 *);
@@ -579,8 +580,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
@@ -655,6 +694,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;
@@ -1531,3 +1585,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: stable/12/sys/dev/mmc/mmc_fdt_helpers.c
==============================================================================
--- stable/12/sys/dev/mmc/mmc_fdt_helpers.c Fri Jun 19 18:05:14 2020 (r362400)
+++ stable/12/sys/dev/mmc/mmc_fdt_helpers.c Fri Jun 19 18:10:39 2020 (r362401)
@@ -225,6 +225,10 @@ cd_setup(struct mmc_fdt_helper *helper, phandle_t node
const char *cd_mode_str;
dev = helper->dev;
+
+ TIMEOUT_TASK_INIT(taskqueue_swi_giant, &helper->cd_delayed_task, 0,
+ cd_card_task, helper);
+
/*
* If the device is flagged as non-removable, set that slot option, and
* set a flag to make sdhci_fdt_gpio_get_present() always return true.
@@ -294,9 +298,6 @@ cd_setup(struct mmc_fdt_helper *helper, phandle_t node
}
without_interrupts:
- TIMEOUT_TASK_INIT(taskqueue_swi_giant, &helper->cd_delayed_task, 0,
- cd_card_task, helper);
-
/*
* If we have a readable gpio pin, but didn't successfully configure
* gpio interrupts, setup a timeout task to poll the pin
@@ -384,6 +385,8 @@ mmc_fdt_gpio_teardown(struct mmc_fdt_helper *helper)
gpio_pin_release(helper->cd_pin);
if (helper->cd_ires != NULL)
bus_release_resource(helper->dev, SYS_RES_IRQ, 0, helper->cd_ires);
+
+ taskqueue_drain_timeout(taskqueue_swi_giant, &helper->cd_delayed_task);
}
bool
Modified: stable/12/sys/modules/allwinner/Makefile
==============================================================================
--- stable/12/sys/modules/allwinner/Makefile Fri Jun 19 18:05:14 2020 (r362400)
+++ stable/12/sys/modules/allwinner/Makefile Fri Jun 19 18:10:39 2020 (r362401)
@@ -2,6 +2,7 @@
# Build modules specific to Allwinner.
SUBDIR = \
+ aw_mmc \
aw_pwm \
aw_rtc \
aw_rsb \
More information about the svn-src-stable-12
mailing list