/* * Header for MultiMediaCard (MMC) * * Copyright 2002 Hewlett-Packard Company * * Use consistent with the GNU GPL is permitted, * provided that this copyright notice is * preserved in its entirety in all copies and derived works. * * HEWLETT-PACKARD COMPANY MAKES NO WARRANTIES, EXPRESSED OR IMPLIED, * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS * FITNESS FOR ANY PARTICULAR PURPOSE. * * Many thanks to Alessandro Rubini and Jonathan Corbet! * * Based strongly on code by: * * Author: Yong-iL Joh <tolkien@mizi.com> * * Author: Andrew Christian * 15 May 2002
*/
#ifndef LINUX_MMC_MMC_H #define LINUX_MMC_MMC_H
#include <linux/types.h>
/* Standard MMC commands (4.1) type argument response */ /* class 1 */ #define MMC_GO_IDLE_STATE 0/* bc */ #define MMC_SEND_OP_COND 1/* bcr [31:0] OCR R3 */ #define MMC_ALL_SEND_CID 2/* bcr R2 */ #define MMC_SET_RELATIVE_ADDR 3/* ac [31:16] RCA R1 */ #define MMC_SET_DSR 4/* bc [31:16] RCA */ #define MMC_SLEEP_AWAKE 5/* ac [31:16] RCA 15:flg R1b */ #define MMC_SWITCH 6/* ac [31:0] See below R1b */ #define MMC_SELECT_CARD 7/* ac [31:16] RCA R1 */ #define MMC_SEND_EXT_CSD 8/* adtc R1 */ #define MMC_SEND_CSD 9/* ac [31:16] RCA R2 */ #define MMC_SEND_CID 10/* ac [31:16] RCA R2 */ #define MMC_READ_DAT_UNTIL_STOP 11/* adtc [31:0] dadr R1 */ #define MMC_STOP_TRANSMISSION 12/* ac R1b */ #define MMC_SEND_STATUS 13/* ac [31:16] RCA R1 */ #define MMC_BUS_TEST_R 14/* adtc R1 */ #define MMC_GO_INACTIVE_STATE 15/* ac [31:16] RCA */ #define MMC_BUS_TEST_W 19/* adtc R1 */ #define MMC_SPI_READ_OCR 58/* spi spi_R3 */ #define MMC_SPI_CRC_ON_OFF 59/* spi [0:0] flag spi_R1 */
/* class 2 */ #define MMC_SET_BLOCKLEN 16/* ac [31:0] block len R1 */ #define MMC_READ_SINGLE_BLOCK 17/* adtc [31:0] data addr R1 */ #define MMC_READ_MULTIPLE_BLOCK 18/* adtc [31:0] data addr R1 */ #define MMC_SEND_TUNING_BLOCK 19/* adtc R1 */ #define MMC_SEND_TUNING_BLOCK_HS200 21/* adtc R1 */
/* class 3 */ #define MMC_WRITE_DAT_UNTIL_STOP 20/* adtc [31:0] data addr R1 */
/* class 6 */ #define MMC_SET_WRITE_PROT 28/* ac [31:0] data addr R1b */ #define MMC_CLR_WRITE_PROT 29/* ac [31:0] data addr R1b */ #define MMC_SEND_WRITE_PROT 30/* adtc [31:0] wpdata addr R1 */
/* class 5 */ #define MMC_ERASE_GROUP_START 35/* ac [31:0] data addr R1 */ #define MMC_ERASE_GROUP_END 36/* ac [31:0] data addr R1 */ #define MMC_ERASE 38/* ac R1b */
/* class 9 */ #define MMC_FAST_IO 39/* ac <Complex> R4 */ #define MMC_GO_IRQ_STATE 40/* bcr R5 */
/* class 7 */ #define MMC_LOCK_UNLOCK 42/* adtc R1b */
/* class 8 */ #define MMC_APP_CMD 55/* ac [31:16] RCA R1 */ #define MMC_GEN_CMD 56/* adtc [0] RD/WR R1 */
/* class 11 */ #define MMC_QUE_TASK_PARAMS 44/* ac [20:16] task id R1 */ #define MMC_QUE_TASK_ADDR 45/* ac [31:0] data addr R1 */ #define MMC_EXECUTE_READ_TASK 46/* adtc [20:16] task id R1 */ #define MMC_EXECUTE_WRITE_TASK 47/* adtc [20:16] task id R1 */ #define MMC_CMDQ_TASK_MGMT 48/* ac [20:16] task id R1b */
/* * MMC_SWITCH argument format: * * [31:26] Always 0 * [25:24] Access Mode * [23:16] Location of target Byte in EXT_CSD * [15:08] Value Byte * [07:03] Always 0 * [02:00] Command Set
*/
/* MMC status in R1, for native mode (SPI bits are different) Type e : error bit s : status bit r : detected and set for the actual command response x : detected and set during command execution. the host must poll the card by sending status command in order to read these bits. Clear condition a : according to the card state b : always related to the previous command. Reception of a valid command will clear it (with a delay of one command) c : clear by read
*/
#define R1_OUT_OF_RANGE (1 << 31) /* er, c */ #define R1_ADDRESS_ERROR (1 << 30) /* erx, c */ #define R1_BLOCK_LEN_ERROR (1 << 29) /* er, c */ #define R1_ERASE_SEQ_ERROR (1 << 28) /* er, c */ #define R1_ERASE_PARAM (1 << 27) /* ex, c */ #define R1_WP_VIOLATION (1 << 26) /* erx, c */ #define R1_CARD_IS_LOCKED (1 << 25) /* sx, a */ #define R1_LOCK_UNLOCK_FAILED (1 << 24) /* erx, c */ #define R1_COM_CRC_ERROR (1 << 23) /* er, b */ #define R1_ILLEGAL_COMMAND (1 << 22) /* er, b */ #define R1_CARD_ECC_FAILED (1 << 21) /* ex, c */ #define R1_CC_ERROR (1 << 20) /* erx, c */ #define R1_ERROR (1 << 19) /* erx, c */ #define R1_UNDERRUN (1 << 18) /* ex, c */ #define R1_OVERRUN (1 << 17) /* ex, c */ #define R1_CID_CSD_OVERWRITE (1 << 16) /* erx, c, CID/CSD overwrite */ #define R1_WP_ERASE_SKIP (1 << 15) /* sx, c */ #define R1_CARD_ECC_DISABLED (1 << 14) /* sx, a */ #define R1_ERASE_RESET (1 << 13) /* sr, c */ #define R1_STATUS(x) (x & 0xFFF9A000) #define R1_CURRENT_STATE(x) ((x & 0x00001E00) >> 9) /* sx, b (4 bits) */ #define R1_READY_FOR_DATA (1 << 8) /* sx, a */ #define R1_SWITCH_ERROR (1 << 7) /* sx, c */ #define R1_EXCEPTION_EVENT (1 << 6) /* sr, a */ #define R1_APP_CMD (1 << 5) /* sr, c */
staticinlinebool mmc_ready_for_data(u32 status)
{ /* * Some cards mishandle the status bits, so make sure to check both the * busy indication and the card state.
*/ return status & R1_READY_FOR_DATA &&
R1_CURRENT_STATE(status) == R1_STATE_TRAN;
}
/* * MMC/SD in SPI mode reports R1 status always, and R2 for SEND_STATUS * R1 is the low order byte; R2 is the next highest byte, when present.
*/ #define R1_SPI_IDLE (1 << 0) #define R1_SPI_ERASE_RESET (1 << 1) #define R1_SPI_ILLEGAL_COMMAND (1 << 2) #define R1_SPI_COM_CRC (1 << 3) #define R1_SPI_ERASE_SEQ (1 << 4) #define R1_SPI_ADDRESS (1 << 5) #define R1_SPI_PARAMETER (1 << 6) /* R1 bit 7 is always zero */ #define R2_SPI_CARD_LOCKED (1 << 8) #define R2_SPI_WP_ERASE_SKIP (1 << 9) /* or lock/unlock fail */ #define R2_SPI_LOCK_UNLOCK_FAIL R2_SPI_WP_ERASE_SKIP #define R2_SPI_ERROR (1 << 10) #define R2_SPI_CC_ERROR (1 << 11) #define R2_SPI_CARD_ECC_ERROR (1 << 12) #define R2_SPI_WP_VIOLATION (1 << 13) #define R2_SPI_ERASE_PARAM (1 << 14) #define R2_SPI_OUT_OF_RANGE (1 << 15) /* or CSD overwrite */ #define R2_SPI_CSD_OVERWRITE R2_SPI_OUT_OF_RANGE
/* * OCR bits are mostly in host.h
*/ #define MMC_CARD_BUSY 0x80000000 /* Card Power up status bit */
#define CSD_STRUCT_VER_1_0 0/* Valid for system specification 1.0 - 1.2 */ #define CSD_STRUCT_VER_1_1 1/* Valid for system specification 1.4 - 2.2 */ #define CSD_STRUCT_VER_1_2 2/* Valid for system specification 3.1 - 3.2 - 3.31 - 4.0 - 4.1 */ #define CSD_STRUCT_EXT_CSD 3/* Version is coded in CSD_STRUCTURE in EXT_CSD */
#define CSD_SPEC_VER_0 0/* Implements system specification 1.0 - 1.2 */ #define CSD_SPEC_VER_1 1/* Implements system specification 1.4 */ #define CSD_SPEC_VER_2 2/* Implements system specification 2.0 - 2.2 */ #define CSD_SPEC_VER_3 3/* Implements system specification 3.1 - 3.2 - 3.31 */ #define CSD_SPEC_VER_4 4/* Implements system specification 4.0 - 4.1 */
#define EXT_CSD_CARD_TYPE_HS_26 (1<<0) /* Card can run at 26MHz */ #define EXT_CSD_CARD_TYPE_HS_52 (1<<1) /* Card can run at 52MHz */ #define EXT_CSD_CARD_TYPE_HS (EXT_CSD_CARD_TYPE_HS_26 | \
EXT_CSD_CARD_TYPE_HS_52) #define EXT_CSD_CARD_TYPE_DDR_1_8V (1<<2) /* Card can run at 52MHz */ /* DDR mode @1.8V or 3V I/O */ #define EXT_CSD_CARD_TYPE_DDR_1_2V (1<<3) /* Card can run at 52MHz */ /* DDR mode @1.2V I/O */ #define EXT_CSD_CARD_TYPE_DDR_52 (EXT_CSD_CARD_TYPE_DDR_1_8V \
| EXT_CSD_CARD_TYPE_DDR_1_2V) #define EXT_CSD_CARD_TYPE_HS200_1_8V (1<<4) /* Card can run at 200MHz */ #define EXT_CSD_CARD_TYPE_HS200_1_2V (1<<5) /* Card can run at 200MHz */ /* SDR mode @1.2V I/O */ #define EXT_CSD_CARD_TYPE_HS200 (EXT_CSD_CARD_TYPE_HS200_1_8V | \
EXT_CSD_CARD_TYPE_HS200_1_2V) #define EXT_CSD_CARD_TYPE_HS400_1_8V (1<<6) /* Card can run at 200MHz DDR, 1.8V */ #define EXT_CSD_CARD_TYPE_HS400_1_2V (1<<7) /* Card can run at 200MHz DDR, 1.2V */ #define EXT_CSD_CARD_TYPE_HS400 (EXT_CSD_CARD_TYPE_HS400_1_8V | \
EXT_CSD_CARD_TYPE_HS400_1_2V) #define EXT_CSD_CARD_TYPE_HS400ES (1<<8) /* Card can run at HS400ES */
#define EXT_CSD_BUS_WIDTH_1 0/* Card is in 1 bit mode */ #define EXT_CSD_BUS_WIDTH_4 1/* Card is in 4 bit mode */ #define EXT_CSD_BUS_WIDTH_8 2/* Card is in 8 bit mode */ #define EXT_CSD_DDR_BUS_WIDTH_4 5/* Card is in 4 bit DDR mode */ #define EXT_CSD_DDR_BUS_WIDTH_8 6/* Card is in 8 bit DDR mode */ #define EXT_CSD_BUS_WIDTH_STROBE BIT(7) /* Enhanced strobe mode */
/* * MMC_SWITCH access modes
*/ #define MMC_SWITCH_MODE_CMD_SET 0x00 /* Change the command set */ #define MMC_SWITCH_MODE_SET_BITS 0x01 /* Set bits which are 1 in value */ #define MMC_SWITCH_MODE_CLEAR_BITS 0x02 /* Clear bits which are 1 in value */ #define MMC_SWITCH_MODE_WRITE_BYTE 0x03 /* Set target to value */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.