mirror of
https://github.com/apache/nuttx.git
synced 2026-05-19 03:03:37 +08:00
mmcsd: support dump cid and csd with mmc-utils
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
This commit is contained in:
@@ -31,5 +31,9 @@ if(CONFIG_MMCSD)
|
||||
list(APPEND SRCS mmcsd_spi.c mmcsd_debug.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_MMCSD_PROCFS)
|
||||
list(APPEND SRCS mmcsd_procfs.c)
|
||||
endif()
|
||||
|
||||
target_sources(drivers PRIVATE ${SRCS})
|
||||
endif()
|
||||
|
||||
@@ -40,6 +40,13 @@ config MMCSD_NSLOTS
|
||||
Number of MMC/SD slots supported by the
|
||||
driver. Default is one.
|
||||
|
||||
config MMCSD_PROCFS
|
||||
bool "MMCSD proc fs support"
|
||||
default n
|
||||
depends on FS_PROCFS_REGISTER
|
||||
---help---
|
||||
Enable procfs for mmcsd.
|
||||
|
||||
config MMCSD_READONLY
|
||||
bool "Disable MMC/SD write access"
|
||||
default n
|
||||
|
||||
@@ -30,6 +30,10 @@ ifeq ($(CONFIG_MMCSD_SPI),y)
|
||||
CSRCS += mmcsd_spi.c mmcsd_debug.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_MMCSD_PROCFS),y)
|
||||
CSRCS += mmcsd_procfs.c
|
||||
endif
|
||||
|
||||
# Include MMC/SD driver build support
|
||||
|
||||
DEPPATH += --dep-path mmcsd
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/sdio.h>
|
||||
#include <stdint.h>
|
||||
#include <debug.h>
|
||||
|
||||
@@ -59,6 +60,43 @@
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This structure is contains the unique state of the MMC/SD block driver */
|
||||
|
||||
struct mmcsd_state_s
|
||||
{
|
||||
FAR struct sdio_dev_s *dev; /* The SDIO device bound to this instance */
|
||||
uint8_t crefs; /* Open references on the driver */
|
||||
mutex_t lock; /* Assures mutually exclusive access to the slot */
|
||||
|
||||
/* Status flags */
|
||||
|
||||
uint8_t probed:1; /* true: mmcsd_probe() discovered a card */
|
||||
uint8_t widebus:1; /* true: Wide 4-bit bus selected */
|
||||
uint8_t mediachanged:1; /* true: Media changed since last check */
|
||||
uint8_t wrbusy:1; /* true: Last transfer was a write, card may be busy */
|
||||
uint8_t wrprotect:1; /* true: Card is write protected (from CSD) */
|
||||
uint8_t locked:1; /* true: Media is locked (from R1) */
|
||||
uint8_t dsrimp:1; /* true: card supports CMD4/DSR setting (from CSD) */
|
||||
#ifdef CONFIG_SDIO_DMA
|
||||
uint8_t dma:1; /* true: hardware supports DMA */
|
||||
#endif
|
||||
|
||||
uint8_t mode:2; /* (See MMCSDMODE_* definitions) */
|
||||
uint8_t type:4; /* Card type (See MMCSD_CARDTYPE_* definitions) */
|
||||
uint8_t buswidth:4; /* Bus widths supported (SD only) */
|
||||
sdio_capset_t caps; /* SDIO driver capabilities/limitations */
|
||||
uint32_t cid[4]; /* CID register */
|
||||
uint32_t csd[4]; /* CSD register */
|
||||
uint16_t selblocklen; /* The currently selected block length */
|
||||
uint16_t rca; /* Relative Card Address (RCS) register */
|
||||
|
||||
/* Memory card geometry (extracted from the CSD) */
|
||||
|
||||
uint8_t blockshift; /* Log2 of blocksize */
|
||||
uint16_t blocksize; /* Read block length (== block size) */
|
||||
uint32_t nblocks; /* Number of blocks */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions Definitions
|
||||
****************************************************************************/
|
||||
@@ -72,6 +110,10 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MMCSD_PROCFS
|
||||
void mmcsd_initialize_procfs(void);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MMCSD_DUMPALL
|
||||
# define mmcsd_dumpbuffer(m,b,l) finfodumpbuffer(m,b,l)
|
||||
#else
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -102,41 +102,6 @@
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This structure is contains the unique state of the MMC/SD block driver */
|
||||
|
||||
struct mmcsd_state_s
|
||||
{
|
||||
FAR struct sdio_dev_s *dev; /* The SDIO device bound to this instance */
|
||||
uint8_t crefs; /* Open references on the driver */
|
||||
mutex_t lock; /* Assures mutually exclusive access to the slot */
|
||||
|
||||
/* Status flags */
|
||||
|
||||
uint8_t probed:1; /* true: mmcsd_probe() discovered a card */
|
||||
uint8_t widebus:1; /* true: Wide 4-bit bus selected */
|
||||
uint8_t mediachanged:1; /* true: Media changed since last check */
|
||||
uint8_t wrbusy:1; /* true: Last transfer was a write, card may be busy */
|
||||
uint8_t wrprotect:1; /* true: Card is write protected (from CSD) */
|
||||
uint8_t locked:1; /* true: Media is locked (from R1) */
|
||||
uint8_t dsrimp:1; /* true: card supports CMD4/DSR setting (from CSD) */
|
||||
#ifdef CONFIG_SDIO_DMA
|
||||
uint8_t dma:1; /* true: hardware supports DMA */
|
||||
#endif
|
||||
|
||||
uint8_t mode:2; /* (See MMCSDMODE_* definitions) */
|
||||
uint8_t type:4; /* Card type (See MMCSD_CARDTYPE_* definitions) */
|
||||
uint8_t buswidth:4; /* Bus widths supported (SD only) */
|
||||
sdio_capset_t caps; /* SDIO driver capabilities/limitations */
|
||||
uint16_t selblocklen; /* The currently selected block length */
|
||||
uint16_t rca; /* Relative Card Address (RCS) register */
|
||||
|
||||
/* Memory card geometry (extracted from the CSD) */
|
||||
|
||||
uint8_t blockshift; /* Log2 of blocksize */
|
||||
uint16_t blocksize; /* Read block length (== block size) */
|
||||
uint32_t nblocks; /* Number of blocks */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
@@ -2639,8 +2604,6 @@ static int mmcsd_widebus(FAR struct mmcsd_state_s *priv)
|
||||
#ifdef CONFIG_MMCSD_MMCSUPPORT
|
||||
static int mmcsd_mmcinitialize(FAR struct mmcsd_state_s *priv)
|
||||
{
|
||||
uint32_t cid[4];
|
||||
uint32_t csd[4];
|
||||
int ret;
|
||||
|
||||
/* At this point, slow, ID mode clocking has been supplied to the card
|
||||
@@ -2659,7 +2622,7 @@ static int mmcsd_mmcinitialize(FAR struct mmcsd_state_s *priv)
|
||||
finfo("Initialising MMC card.\n");
|
||||
|
||||
mmcsd_sendcmdpoll(priv, MMCSD_CMD2, 0);
|
||||
ret = SDIO_RECVR2(priv->dev, MMCSD_CMD2, cid);
|
||||
ret = SDIO_RECVR2(priv->dev, MMCSD_CMD2, priv->cid);
|
||||
if (ret != OK)
|
||||
{
|
||||
ferr("ERROR: SDIO_RECVR2 for MMC CID failed: %d\n", ret);
|
||||
@@ -2711,7 +2674,7 @@ static int mmcsd_mmcinitialize(FAR struct mmcsd_state_s *priv)
|
||||
*/
|
||||
|
||||
mmcsd_sendcmdpoll(priv, MMCSD_CMD9, (uint32_t)priv->rca << 16);
|
||||
ret = SDIO_RECVR2(priv->dev, MMCSD_CMD9, csd);
|
||||
ret = SDIO_RECVR2(priv->dev, MMCSD_CMD9, priv->csd);
|
||||
if (ret != OK)
|
||||
{
|
||||
ferr("ERROR: Could not get SD CSD register: %d\n", ret);
|
||||
@@ -2723,7 +2686,7 @@ static int mmcsd_mmcinitialize(FAR struct mmcsd_state_s *priv)
|
||||
* ext_csd commands.
|
||||
*/
|
||||
|
||||
mmcsd_decode_csd(priv, csd);
|
||||
mmcsd_decode_csd(priv, priv->csd);
|
||||
|
||||
/* Set the Driver Stage Register (DSR) if (1) a CONFIG_MMCSD_DSR has been
|
||||
* provided and (2) the card supports a DSR register. If no DSR value
|
||||
@@ -2781,7 +2744,7 @@ static int mmcsd_mmcinitialize(FAR struct mmcsd_state_s *priv)
|
||||
}
|
||||
}
|
||||
|
||||
mmcsd_decode_csd(priv, csd);
|
||||
mmcsd_decode_csd(priv, priv->csd);
|
||||
|
||||
/* It's up to the driver to act on the widebus request. mmcsd_widebus()
|
||||
* enables the CLOCK_MMC_TRANSFER, so call it here always.
|
||||
@@ -4201,6 +4164,10 @@ int mmcsd_slotinitialize(int minor, FAR struct sdio_dev_s *dev)
|
||||
goto errout_with_hwinit;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MMCSD_PROCFS
|
||||
mmcsd_initialize_procfs();
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
|
||||
errout_with_hwinit:
|
||||
|
||||
Reference in New Issue
Block a user