mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 09:41:03 -04:00
mmc: support for SPI bus type
- Introduce the bus_type accessor, which allows to skip card selection and timing settings in SPI mode; - Add MMC_CMD_IS_APP flag for commands followed by the APP command, which is required by the upcoming MMCSPI driver. Reviewed by: pkelsey Sponsored by: UKRI Differential Revision: https://reviews.freebsd.org/D49249
This commit is contained in:
parent
8e7d333f92
commit
07da3bb5d5
5 changed files with 28 additions and 0 deletions
|
|
@ -103,6 +103,10 @@ enum mmc_chip_select {
|
|||
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 @@ struct mmc_ios {
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -701,6 +701,10 @@ mmc_select_card(struct mmc_softc *sc, uint16_t rca)
|
|||
{
|
||||
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 @@ mmc_set_timing(struct mmc_softc *sc, struct mmc_ivars *ivar,
|
|||
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:
|
||||
|
|
|
|||
|
|
@ -112,6 +112,8 @@ mmc_wait_for_app_cmd(device_t busdev, device_t dev, uint16_t rca,
|
|||
|
||||
sc = device_get_softc(busdev);
|
||||
|
||||
cmd->flags |= MMC_CMD_IS_APP;
|
||||
|
||||
/* Squelch error reporting at lower levels, we report below. */
|
||||
sc->squelched++;
|
||||
do {
|
||||
|
|
|
|||
|
|
@ -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 @@ mmcbr_get_retune_req(device_t dev)
|
|||
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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ struct mmc_command {
|
|||
#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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue