DCMD_SDMMC_CARD_REGISTER

Read or write a card register

Synopsis:

#include <hw/dcmd_sim_sdmmc.h>

#define DCMD_SDMMC_CARD_REGISTER   __DIOTF(_DCMD_CAM, _SIM_SDMMC + 4, struct _sdmmc_card_register)

Arguments to devctl():

Argument Value
filedes A file descriptor that you obtained by opening the device
dcmd DCMD_SDMMC_CARD_REGISTER
dev_data_ptr A pointer to a SDMMC_CARD_REGISTER structure that's followed by a data buffer
n_bytes sizeof(SDMMC_CARD_REGISTER) plus the size of the data buffer
dev_info_ptr NULL

Description:

This command reads or writes a card register. It uses two data structures to input and output information:

  • A SDMMC_CARD_REGISTER structure is used to specify the action, the register type, and the register address (when doing a write).
  • A register data buffer is used to store the read data or to specify the write data.

SDMMC_CARD_REGISTER:

The SDMMC_CARD_REGISTER structure is defined as follows:

typedef struct _sdmmc_card_register {
        uint32_t                action;
        uint32_t                type;
        uint32_t                address;
        uint32_t                length;
        uint32_t                rsvd[2];
/*      uint8_t                 data[ length ]; variable length data */
} SDMMC_CARD_REGISTER;

The members include:

action
The action to take; currently SDMMC_CR_ACTION_READ and SDMMC_CR_ACTION_WRITE are supported, although the SDMMC_CR_ACTION_WRITE action is only supported for the register type SDMMC_REG_TYPE_EXT_CSD and can only write one byte per devctl() call.
type
The register you want to read or write; one of:
  • SDMMC_REG_TYPE_CID — card ID
  • SDMMC_REG_TYPE_CSD — card-specific data
  • SDMMC_REG_TYPE_EXT_CSD — extended card-specific data (MMC devices only)
  • SDMMC_REG_TYPE_SCR — SD configuration register (SD devices only)

It's set to one of the following on return:

  • SDMMC_CARD_TYPE_UNKNOWN
  • SDMMC_CARD_TYPE_MMC
  • SDMMC_CARD_TYPE_SD
address
The byte offset of the register to write to.
Note: This field is only supported for the SDMMC_CR_ACTION_WRITE action. Currently only registers of type SDMMC_REG_TYPE_EXT_CSD are supported. ECSD registers with a byte offset greater than or equal to 192 are marked as read-only in the JEDEC eMMC specification, so the value of this field must be less than 192.
length
Not used.

Register data buffer:

The register data buffer is used to store the register data in a read or write operation. If the action field of the SDMMC_CARD_REGISTER structure is set to SDMMC_CR_ACTION_READ, the read data will be returned in the data buffer that follows this structure. If the action field is set to SDMMC_CR_ACTION_WRITE, the write data should be stored in the data buffer that follows the structure.

Note: Currently the SDMMC_CR_ACTION_WRITE action is only supported for the SDMMC_REG_TYPE_EXT_CSD register type. Only one byte can be written to ECSD registers per devctl() call.

Data buffer size:

Each register type requires a different data buffer size to store the read or write data without data cropping. You must ensure that your application uses the correct literal value to set the data buffer size. If the data buffer is too small to fit the full register, the driver will not overflow the buffer but will only return a subset of the read data.

Register Type Data Buffer Size
SDMMC_REG_TYPE_CID 16
SDMMC_REG_TYPE_CSD 16
SDMMC_REG_TYPE_EXT_CSD (Read) 512
SDMMC_REG_TYPE_EXT_CSD (Write) 1
SDMMC_REG_TYPE_SCR 8

Input:

Set the action and type members. If using SDMMC_CR_ACTION_WRITE, fill the register data buffer with the value you would like to write to the register.

Output:

The filled-in structure. If using SDMMC_CR_ACTION_READ, the register data buffer will be filled with the register read data.

See also:

devctl() in the QNX Neutrino C Library Reference