> Date: Sun, 31 Dec 2017 13:46:44 +0200 > From: Artturi Alm <artturi....@gmail.com> > > On Sat, Dec 30, 2017 at 08:39:42PM +0200, Artturi Alm wrote: > > Hi, > > > > porting sdhc driver(bcm2835_emmc.c) from NetBSD does lack something > > like this, among possibly few other (small?) changes, but consider this > > as a step towards. > > > > Comments? to keep changes minimal/safe/easy to review like below, or to > > backport in bigger chunks? > > > > -Artturi > > > > Hi, > > while working out the second step i came to a conclusion, > that the diff should work in theory like below, > and be easier to review w/o the use of SHF_USE_DMA flag. > > any comments?
Is the BCM2835 hardware really a standard SDHC controller? If there are too many quirks, I tend to prefer a seperate driver instead of a bit of SoC-specific glue for shdc(4). Otherwise this mostly makes sense to me as infrastructure to use an external DMA controller. I don't think we should at it unless there is an actual user though. Cheers, Mark > diff --git a/sys/dev/sdmmc/sdhc.c b/sys/dev/sdmmc/sdhc.c > index c242a600d4a..f65790ff581 100644 > --- a/sys/dev/sdmmc/sdhc.c > +++ b/sys/dev/sdmmc/sdhc.c > @@ -187,6 +187,10 @@ sdhc_host_found(struct sdhc_softc *sc, bus_space_tag_t > iot, > /* Use DMA if the host system and the controller support it. */ > if (usedma && ISSET(caps, SDHC_ADMA2_SUPP)) > SET(hp->flags, SHF_USE_DMA); > + if (!usedma) > + sc->sc_extdma_transfer = NULL; > + else if (sc->sc_extdma_transfer) > + CLR(hp->flags, SHF_USE_DMA); > > /* > * Determine the base clock frequency. (2.2.24) > @@ -302,6 +306,8 @@ sdhc_host_found(struct sdhc_softc *sc, bus_space_tag_t > iot, > saa.dmat = sc->sc_dmat; > if (ISSET(hp->flags, SHF_USE_DMA)) > saa.caps |= SMC_CAPS_DMA; > + else if (sc->sc_extdma_transfer) > + saa.caps |= SMC_CAPS_DMA; > > if (ISSET(caps, SDHC_HIGH_SPEED_SUPP)) > saa.caps |= SMC_CAPS_SD_HIGHSPEED; > @@ -939,6 +945,16 @@ sdhc_transfer_data(struct sdhc_host *hp, struct > sdmmc_command *cmd) > if (cmd->c_dmamap) { > int status; > > + if (sc->sc_extdma_transfer != NULL) { > + error = sc->sc_extdma_transfer(sc, cmd); > + if (error == 0 && !sdhc_wait_intr(hp, > + SDHC_TRANSFER_COMPLETE, SDHC_DMA_TIMEOUT)) { > + DPRINTF(1,("%s: timeout\n", __func__)); > + error = ETIMEDOUT; > + } > + goto done; > + } > + > error = 0; > for (;;) { > status = sdhc_wait_intr(hp, > diff --git a/sys/dev/sdmmc/sdhcvar.h b/sys/dev/sdmmc/sdhcvar.h > index 9d4d759a2bc..5c0f462cfe6 100644 > --- a/sys/dev/sdmmc/sdhcvar.h > +++ b/sys/dev/sdmmc/sdhcvar.h > @@ -22,6 +22,7 @@ > #include <machine/bus.h> > > struct sdhc_host; > +struct sdmmc_command; > > struct sdhc_softc { > struct device sc_dev; > @@ -33,6 +34,7 @@ struct sdhc_softc { > > int (*sc_card_detect)(struct sdhc_softc *); > int (*sc_signal_voltage)(struct sdhc_softc *, int); > + int (*sc_extdma_transfer)(struct sdhc_softc *, struct sdmmc_command *); > }; > > /* Host controller functions called by the attachment driver. */ >