diff --git a/sys/dev/mmc/bridge.h b/sys/dev/mmc/bridge.h --- a/sys/dev/mmc/bridge.h +++ b/sys/dev/mmc/bridge.h @@ -103,6 +103,10 @@ cs_dontcare = 0, cs_high, cs_low }; +enum mmc_bus_type { + bus_type_default = 0, bus_type_spi +}; + enum mmc_bus_width { bus_width_1 = 0, bus_width_4 = 2, bus_width_8 = 3 }; @@ -123,6 +127,7 @@ uint32_t clock; /* Speed of the clock in Hz to move data */ enum mmc_vdd vdd; /* Voltage to apply to the power pins */ enum mmc_vccq vccq; /* Voltage to use for signaling */ + enum mmc_bus_type bus_type; enum mmc_bus_mode bus_mode; enum mmc_chip_select chip_select; enum mmc_bus_width bus_width; diff --git a/sys/dev/mmc/mmc.c b/sys/dev/mmc/mmc.c --- a/sys/dev/mmc/mmc.c +++ b/sys/dev/mmc/mmc.c @@ -701,6 +701,10 @@ { int err, flags; + /* No card selection in SPI mode. */ + if (mmcbr_get_bus_type(sc->dev) == bus_type_spi) + return (MMC_ERR_NONE); + flags = (rca ? MMC_RSP_R1B : MMC_RSP_NONE) | MMC_CMD_AC; sc->retune_paused++; err = mmc_wait_for_command(sc, MMC_SELECT_CARD, (uint32_t)rca << 16, @@ -900,6 +904,10 @@ uint8_t value; int err; + /* No timings in SPI mode. */ + if (mmcbr_get_bus_type(sc->dev) == bus_type_spi) + return (MMC_ERR_NONE); + if (mmcbr_get_mode(sc->dev) == mode_sd) { switch (timing) { case bus_timing_normal: diff --git a/sys/dev/mmc/mmc_subr.c b/sys/dev/mmc/mmc_subr.c --- a/sys/dev/mmc/mmc_subr.c +++ b/sys/dev/mmc/mmc_subr.c @@ -112,6 +112,8 @@ sc = device_get_softc(busdev); + cmd->flags |= MMC_CMD_IS_APP; + /* Squelch error reporting at lower levels, we report below. */ sc->squelched++; do { diff --git a/sys/dev/mmc/mmcbrvar.h b/sys/dev/mmc/mmcbrvar.h --- a/sys/dev/mmc/mmcbrvar.h +++ b/sys/dev/mmc/mmcbrvar.h @@ -60,6 +60,7 @@ #include "mmcbr_if.h" enum mmcbr_device_ivars { + MMCBR_IVAR_BUS_TYPE, MMCBR_IVAR_BUS_MODE, MMCBR_IVAR_BUS_WIDTH, MMCBR_IVAR_CHIP_SELECT, @@ -113,6 +114,17 @@ return ((int)v); } +static int __inline +mmcbr_get_bus_type(device_t dev) +{ + uintptr_t v; + + if (__predict_false(BUS_READ_IVAR(device_get_parent(dev), dev, + MMCBR_IVAR_BUS_TYPE, &v) != 0)) + return (bus_type_default); + return ((int)v); +} + /* * Convenience wrappers for the mmcbr interface */ diff --git a/sys/dev/mmc/mmcreg.h b/sys/dev/mmc/mmcreg.h --- a/sys/dev/mmc/mmcreg.h +++ b/sys/dev/mmc/mmcreg.h @@ -80,6 +80,7 @@ #define MMC_CMD_BC (2ul << 5) /* Broadcast command, no response */ #define MMC_CMD_BCR (3ul << 5) /* Broadcast command with response */ #define MMC_CMD_MASK (3ul << 5) +#define MMC_CMD_IS_APP (1ul << 7) /* Next cmd after MMC_APP_CMD */ /* Possible response types defined in the standard: */ #define MMC_RSP_NONE (0)