Skip to content

Commit db2f204

Browse files
gneworldxiaoxiang781216
authored andcommitted
mmcsd: support dump cid and csd with mmc-utils
Signed-off-by: wanggang26 <[email protected]>
1 parent 707dd12 commit db2f204

File tree

6 files changed

+608
-41
lines changed

6 files changed

+608
-41
lines changed

drivers/mmcsd/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,9 @@ if(CONFIG_MMCSD)
3131
list(APPEND SRCS mmcsd_spi.c mmcsd_debug.c)
3232
endif()
3333

34+
if(CONFIG_MMCSD_PROCFS)
35+
list(APPEND SRCS mmcsd_procfs.c)
36+
endif()
37+
3438
target_sources(drivers PRIVATE ${SRCS})
3539
endif()

drivers/mmcsd/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ config MMCSD_NSLOTS
4040
Number of MMC/SD slots supported by the
4141
driver. Default is one.
4242

43+
config MMCSD_PROCFS
44+
bool "MMCSD proc fs support"
45+
default n
46+
depends on FS_PROCFS_REGISTER
47+
---help---
48+
Enable procfs for mmcsd.
49+
4350
config MMCSD_READONLY
4451
bool "Disable MMC/SD write access"
4552
default n

drivers/mmcsd/Make.defs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ ifeq ($(CONFIG_MMCSD_SPI),y)
3030
CSRCS += mmcsd_spi.c mmcsd_debug.c
3131
endif
3232

33+
ifeq ($(CONFIG_MMCSD_PROCFS),y)
34+
CSRCS += mmcsd_procfs.c
35+
endif
36+
3337
# Include MMC/SD driver build support
3438

3539
DEPPATH += --dep-path mmcsd

drivers/mmcsd/mmcsd.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
****************************************************************************/
2727

2828
#include <nuttx/config.h>
29+
#include <nuttx/sdio.h>
2930
#include <stdint.h>
3031
#include <debug.h>
3132

@@ -59,6 +60,43 @@
5960
* Public Types
6061
****************************************************************************/
6162

63+
/* This structure is contains the unique state of the MMC/SD block driver */
64+
65+
struct mmcsd_state_s
66+
{
67+
FAR struct sdio_dev_s *dev; /* The SDIO device bound to this instance */
68+
uint8_t crefs; /* Open references on the driver */
69+
mutex_t lock; /* Assures mutually exclusive access to the slot */
70+
71+
/* Status flags */
72+
73+
uint8_t probed:1; /* true: mmcsd_probe() discovered a card */
74+
uint8_t widebus:1; /* true: Wide 4-bit bus selected */
75+
uint8_t mediachanged:1; /* true: Media changed since last check */
76+
uint8_t wrbusy:1; /* true: Last transfer was a write, card may be busy */
77+
uint8_t wrprotect:1; /* true: Card is write protected (from CSD) */
78+
uint8_t locked:1; /* true: Media is locked (from R1) */
79+
uint8_t dsrimp:1; /* true: card supports CMD4/DSR setting (from CSD) */
80+
#ifdef CONFIG_SDIO_DMA
81+
uint8_t dma:1; /* true: hardware supports DMA */
82+
#endif
83+
84+
uint8_t mode:2; /* (See MMCSDMODE_* definitions) */
85+
uint8_t type:4; /* Card type (See MMCSD_CARDTYPE_* definitions) */
86+
uint8_t buswidth:4; /* Bus widths supported (SD only) */
87+
sdio_capset_t caps; /* SDIO driver capabilities/limitations */
88+
uint32_t cid[4]; /* CID register */
89+
uint32_t csd[4]; /* CSD register */
90+
uint16_t selblocklen; /* The currently selected block length */
91+
uint16_t rca; /* Relative Card Address (RCS) register */
92+
93+
/* Memory card geometry (extracted from the CSD) */
94+
95+
uint8_t blockshift; /* Log2 of blocksize */
96+
uint16_t blocksize; /* Read block length (== block size) */
97+
uint32_t nblocks; /* Number of blocks */
98+
};
99+
62100
/****************************************************************************
63101
* Public Functions Definitions
64102
****************************************************************************/
@@ -72,6 +110,10 @@ extern "C"
72110
#define EXTERN extern
73111
#endif
74112

113+
#ifdef CONFIG_MMCSD_PROCFS
114+
void mmcsd_initialize_procfs(void);
115+
#endif
116+
75117
#ifdef CONFIG_MMCSD_DUMPALL
76118
# define mmcsd_dumpbuffer(m,b,l) finfodumpbuffer(m,b,l)
77119
#else

0 commit comments

Comments
 (0)