diff options
Diffstat (limited to 'include/linux/mmc/core.h')
| -rw-r--r-- | include/linux/mmc/core.h | 65 |
1 files changed, 53 insertions, 12 deletions
diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h index 04bbe12fae8d..d0c3abed74c2 100644 --- a/include/linux/mmc/core.h +++ b/include/linux/mmc/core.h | |||
| @@ -25,14 +25,20 @@ struct mmc_command { | |||
| 25 | #define MMC_RSP_CRC (1 << 2) /* expect valid crc */ | 25 | #define MMC_RSP_CRC (1 << 2) /* expect valid crc */ |
| 26 | #define MMC_RSP_BUSY (1 << 3) /* card may send busy */ | 26 | #define MMC_RSP_BUSY (1 << 3) /* card may send busy */ |
| 27 | #define MMC_RSP_OPCODE (1 << 4) /* response contains opcode */ | 27 | #define MMC_RSP_OPCODE (1 << 4) /* response contains opcode */ |
| 28 | #define MMC_CMD_MASK (3 << 5) /* command type */ | 28 | |
| 29 | #define MMC_CMD_MASK (3 << 5) /* non-SPI command type */ | ||
| 29 | #define MMC_CMD_AC (0 << 5) | 30 | #define MMC_CMD_AC (0 << 5) |
| 30 | #define MMC_CMD_ADTC (1 << 5) | 31 | #define MMC_CMD_ADTC (1 << 5) |
| 31 | #define MMC_CMD_BC (2 << 5) | 32 | #define MMC_CMD_BC (2 << 5) |
| 32 | #define MMC_CMD_BCR (3 << 5) | 33 | #define MMC_CMD_BCR (3 << 5) |
| 33 | 34 | ||
| 35 | #define MMC_RSP_SPI_S1 (1 << 7) /* one status byte */ | ||
| 36 | #define MMC_RSP_SPI_S2 (1 << 8) /* second byte */ | ||
| 37 | #define MMC_RSP_SPI_B4 (1 << 9) /* four data bytes */ | ||
| 38 | #define MMC_RSP_SPI_BUSY (1 << 10) /* card may send busy */ | ||
| 39 | |||
| 34 | /* | 40 | /* |
| 35 | * These are the response types, and correspond to valid bit | 41 | * These are the native response types, and correspond to valid bit |
| 36 | * patterns of the above flags. One additional valid pattern | 42 | * patterns of the above flags. One additional valid pattern |
| 37 | * is all zeros, which means we don't expect a response. | 43 | * is all zeros, which means we don't expect a response. |
| 38 | */ | 44 | */ |
| @@ -41,12 +47,30 @@ struct mmc_command { | |||
| 41 | #define MMC_RSP_R1B (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE|MMC_RSP_BUSY) | 47 | #define MMC_RSP_R1B (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE|MMC_RSP_BUSY) |
| 42 | #define MMC_RSP_R2 (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC) | 48 | #define MMC_RSP_R2 (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC) |
| 43 | #define MMC_RSP_R3 (MMC_RSP_PRESENT) | 49 | #define MMC_RSP_R3 (MMC_RSP_PRESENT) |
| 50 | #define MMC_RSP_R4 (MMC_RSP_PRESENT) | ||
| 51 | #define MMC_RSP_R5 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) | ||
| 44 | #define MMC_RSP_R6 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) | 52 | #define MMC_RSP_R6 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) |
| 45 | #define MMC_RSP_R7 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) | 53 | #define MMC_RSP_R7 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) |
| 46 | 54 | ||
| 47 | #define mmc_resp_type(cmd) ((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE)) | 55 | #define mmc_resp_type(cmd) ((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE)) |
| 48 | 56 | ||
| 49 | /* | 57 | /* |
| 58 | * These are the SPI response types for MMC, SD, and SDIO cards. | ||
| 59 | * Commands return R1, with maybe more info. Zero is an error type; | ||
| 60 | * callers must always provide the appropriate MMC_RSP_SPI_Rx flags. | ||
| 61 | */ | ||
| 62 | #define MMC_RSP_SPI_R1 (MMC_RSP_SPI_S1) | ||
| 63 | #define MMC_RSP_SPI_R1B (MMC_RSP_SPI_S1|MMC_RSP_SPI_BUSY) | ||
| 64 | #define MMC_RSP_SPI_R2 (MMC_RSP_SPI_S1|MMC_RSP_SPI_S2) | ||
| 65 | #define MMC_RSP_SPI_R3 (MMC_RSP_SPI_S1|MMC_RSP_SPI_B4) | ||
| 66 | #define MMC_RSP_SPI_R4 (MMC_RSP_SPI_S1|MMC_RSP_SPI_B4) | ||
| 67 | #define MMC_RSP_SPI_R5 (MMC_RSP_SPI_S1|MMC_RSP_SPI_S2) | ||
| 68 | #define MMC_RSP_SPI_R7 (MMC_RSP_SPI_S1|MMC_RSP_SPI_B4) | ||
| 69 | |||
| 70 | #define mmc_spi_resp_type(cmd) ((cmd)->flags & \ | ||
| 71 | (MMC_RSP_SPI_S1|MMC_RSP_SPI_BUSY|MMC_RSP_SPI_S2|MMC_RSP_SPI_B4)) | ||
| 72 | |||
| 73 | /* | ||
| 50 | * These are the command types. | 74 | * These are the command types. |
| 51 | */ | 75 | */ |
| 52 | #define mmc_cmd_type(cmd) ((cmd)->flags & MMC_CMD_MASK) | 76 | #define mmc_cmd_type(cmd) ((cmd)->flags & MMC_CMD_MASK) |
| @@ -54,12 +78,19 @@ struct mmc_command { | |||
| 54 | unsigned int retries; /* max number of retries */ | 78 | unsigned int retries; /* max number of retries */ |
| 55 | unsigned int error; /* command error */ | 79 | unsigned int error; /* command error */ |
| 56 | 80 | ||
| 57 | #define MMC_ERR_NONE 0 | 81 | /* |
| 58 | #define MMC_ERR_TIMEOUT 1 | 82 | * Standard errno values are used for errors, but some have specific |
| 59 | #define MMC_ERR_BADCRC 2 | 83 | * meaning in the MMC layer: |
| 60 | #define MMC_ERR_FIFO 3 | 84 | * |
| 61 | #define MMC_ERR_FAILED 4 | 85 | * ETIMEDOUT Card took too long to respond |
| 62 | #define MMC_ERR_INVALID 5 | 86 | * EILSEQ Basic format problem with the received or sent data |
| 87 | * (e.g. CRC check failed, incorrect opcode in response | ||
| 88 | * or bad end bit) | ||
| 89 | * EINVAL Request cannot be performed because of restrictions | ||
| 90 | * in hardware and/or the driver | ||
| 91 | * ENOMEDIUM Host can determine that the slot is empty and is | ||
| 92 | * actively failing requests | ||
| 93 | */ | ||
| 63 | 94 | ||
| 64 | struct mmc_data *data; /* data segment associated with cmd */ | 95 | struct mmc_data *data; /* data segment associated with cmd */ |
| 65 | struct mmc_request *mrq; /* associated request */ | 96 | struct mmc_request *mrq; /* associated request */ |
| @@ -76,7 +107,6 @@ struct mmc_data { | |||
| 76 | #define MMC_DATA_WRITE (1 << 8) | 107 | #define MMC_DATA_WRITE (1 << 8) |
| 77 | #define MMC_DATA_READ (1 << 9) | 108 | #define MMC_DATA_READ (1 << 9) |
| 78 | #define MMC_DATA_STREAM (1 << 10) | 109 | #define MMC_DATA_STREAM (1 << 10) |
| 79 | #define MMC_DATA_MULTI (1 << 11) | ||
| 80 | 110 | ||
| 81 | unsigned int bytes_xfered; | 111 | unsigned int bytes_xfered; |
| 82 | 112 | ||
| @@ -99,14 +129,25 @@ struct mmc_request { | |||
| 99 | struct mmc_host; | 129 | struct mmc_host; |
| 100 | struct mmc_card; | 130 | struct mmc_card; |
| 101 | 131 | ||
| 102 | extern int mmc_wait_for_req(struct mmc_host *, struct mmc_request *); | 132 | extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *); |
| 103 | extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int); | 133 | extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int); |
| 104 | extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *, | 134 | extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *, |
| 105 | struct mmc_command *, int); | 135 | struct mmc_command *, int); |
| 106 | 136 | ||
| 107 | extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *, int); | 137 | extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *); |
| 108 | 138 | ||
| 109 | extern void mmc_claim_host(struct mmc_host *host); | 139 | extern int __mmc_claim_host(struct mmc_host *host, atomic_t *abort); |
| 110 | extern void mmc_release_host(struct mmc_host *host); | 140 | extern void mmc_release_host(struct mmc_host *host); |
| 111 | 141 | ||
| 142 | /** | ||
| 143 | * mmc_claim_host - exclusively claim a host | ||
| 144 | * @host: mmc host to claim | ||
| 145 | * | ||
| 146 | * Claim a host for a set of operations. | ||
| 147 | */ | ||
| 148 | static inline void mmc_claim_host(struct mmc_host *host) | ||
| 149 | { | ||
| 150 | __mmc_claim_host(host, NULL); | ||
| 151 | } | ||
| 152 | |||
| 112 | #endif | 153 | #endif |
