lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/mmc/mmc_pxa.h |
| 3 | * |
| 4 | * Author: Vladimir Shebordaev, Igor Oblakov |
| 5 | * Copyright: MontaVista Software Inc. |
| 6 | * |
| 7 | * $Id: mmc_pxa.h,v 0.3.1.6 2002/09/25 19:25:48 ted Exp ted $ |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | #ifndef __MMC_ZX_P_H__ |
| 14 | #define __MMC_ZX_P_H__ |
| 15 | |
| 16 | #define SD_VERSION_SD 0x20000 |
| 17 | #define SD_VERSION_2 (SD_VERSION_SD | 0x20) |
| 18 | #define SD_VERSION_1_0 (SD_VERSION_SD | 0x10) |
| 19 | #define SD_VERSION_1_10 (SD_VERSION_SD | 0x1a) |
| 20 | #define MMC_VERSION_MMC 0x10000 |
| 21 | #define MMC_VERSION_UNKNOWN (MMC_VERSION_MMC) |
| 22 | #define MMC_VERSION_1_2 (MMC_VERSION_MMC | 0x12) |
| 23 | #define MMC_VERSION_1_4 (MMC_VERSION_MMC | 0x14) |
| 24 | #define MMC_VERSION_2_2 (MMC_VERSION_MMC | 0x22) |
| 25 | #define MMC_VERSION_3 (MMC_VERSION_MMC | 0x30) |
| 26 | #define MMC_VERSION_4 (MMC_VERSION_MMC | 0x40) |
| 27 | |
| 28 | #define MMC_MODE_HS 0x001 |
| 29 | #define MMC_MODE_HS_52MHz 0x010 |
| 30 | #define MMC_MODE_4BIT 0x100 |
| 31 | #define MMC_MODE_8BIT 0x200 |
| 32 | |
| 33 | #define SD_DATA_4BIT 0x00040000 |
| 34 | |
| 35 | #define IS_SD(x) (x->version & SD_VERSION_SD) |
| 36 | |
| 37 | #define MMC_DATA_READ 1 |
| 38 | #define MMC_DATA_WRITE 2 |
| 39 | |
| 40 | #define NO_CARD_ERR -16 /* No SD/MMC card inserted */ |
| 41 | #define UNUSABLE_ERR -17 /* Unusable Card */ |
| 42 | #define COMM_ERR -18 /* Communications Error */ |
| 43 | #define TIMEOUT -19 |
| 44 | |
| 45 | #define MMC_CMD_GO_IDLE_STATE 0 |
| 46 | #define MMC_CMD_SEND_OP_COND 1 |
| 47 | #define MMC_CMD_ALL_SEND_CID 2 |
| 48 | #define MMC_CMD_SET_RELATIVE_ADDR 3 |
| 49 | #define MMC_CMD_SET_DSR 4 |
| 50 | #define MMC_CMD_SWITCH 6 |
| 51 | #define MMC_CMD_SELECT_CARD 7 |
| 52 | #define MMC_CMD_SEND_EXT_CSD 8 |
| 53 | #define MMC_CMD_SEND_CSD 9 |
| 54 | #define MMC_CMD_SEND_CID 10 |
| 55 | #define MMC_CMD_STOP_TRANSMISSION 12 |
| 56 | #define MMC_CMD_SEND_STATUS 13 |
| 57 | #define MMC_CMD_SET_BLOCKLEN 16 |
| 58 | #define MMC_CMD_READ_SINGLE_BLOCK 17 |
| 59 | #define MMC_CMD_READ_MULTIPLE_BLOCK 18 |
| 60 | #define MMC_CMD_WRITE_SINGLE_BLOCK 24 |
| 61 | #define MMC_CMD_WRITE_MULTIPLE_BLOCK 25 |
| 62 | |
| 63 | #define MMC_CMD_ERASE_GROUP_START 35 |
| 64 | #define MMC_CMD_ERASE_GROUP_END 36 |
| 65 | #define MMC_CMD_ERASE 38 |
| 66 | |
| 67 | #define MMC_CMD_APP_CMD 55 |
| 68 | |
| 69 | #define SD_CMD_SEND_RELATIVE_ADDR 3 |
| 70 | #define SD_CMD_SWITCH_FUNC 6 |
| 71 | #define SD_CMD_SEND_IF_COND 8 |
| 72 | |
| 73 | #define SD_CMD_APP_SET_BUS_WIDTH 6 |
| 74 | #define SD_CMD_APP_SEND_OP_COND 41 |
| 75 | #define SD_CMD_APP_SEND_SCR 51 |
| 76 | |
| 77 | /* SCR definitions in different words */ |
| 78 | #define SD_HIGHSPEED_BUSY 0x00020000 |
| 79 | #define SD_HIGHSPEED_SUPPORTED 0x00020000 |
| 80 | |
| 81 | #define MMC_HS_TIMING 0x00000100 |
| 82 | #define MMC_HS_52MHZ 0x2 |
| 83 | |
| 84 | #define OCR_BUSY 0x80000000 |
| 85 | #define OCR_HCS 0x40000000 |
| 86 | |
| 87 | #define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */ |
| 88 | #define MMC_VDD_20_21 0x00000100 /* VDD voltage 2.0 ~ 2.1 */ |
| 89 | #define MMC_VDD_21_22 0x00000200 /* VDD voltage 2.1 ~ 2.2 */ |
| 90 | #define MMC_VDD_22_23 0x00000400 /* VDD voltage 2.2 ~ 2.3 */ |
| 91 | #define MMC_VDD_23_24 0x00000800 /* VDD voltage 2.3 ~ 2.4 */ |
| 92 | #define MMC_VDD_24_25 0x00001000 /* VDD voltage 2.4 ~ 2.5 */ |
| 93 | #define MMC_VDD_25_26 0x00002000 /* VDD voltage 2.5 ~ 2.6 */ |
| 94 | #define MMC_VDD_26_27 0x00004000 /* VDD voltage 2.6 ~ 2.7 */ |
| 95 | #define MMC_VDD_27_28 0x00008000 /* VDD voltage 2.7 ~ 2.8 */ |
| 96 | #define MMC_VDD_28_29 0x00010000 /* VDD voltage 2.8 ~ 2.9 */ |
| 97 | #define MMC_VDD_29_30 0x00020000 /* VDD voltage 2.9 ~ 3.0 */ |
| 98 | #define MMC_VDD_30_31 0x00040000 /* VDD voltage 3.0 ~ 3.1 */ |
| 99 | #define MMC_VDD_31_32 0x00080000 /* VDD voltage 3.1 ~ 3.2 */ |
| 100 | #define MMC_VDD_32_33 0x00100000 /* VDD voltage 3.2 ~ 3.3 */ |
| 101 | #define MMC_VDD_33_34 0x00200000 /* VDD voltage 3.3 ~ 3.4 */ |
| 102 | #define MMC_VDD_34_35 0x00400000 /* VDD voltage 3.4 ~ 3.5 */ |
| 103 | #define MMC_VDD_35_36 0x00800000 /* VDD voltage 3.5 ~ 3.6 */ |
| 104 | |
| 105 | #define MMC_SWITCH_MODE_CMD_SET 0x00 /* Change the command set */ |
| 106 | #define MMC_SWITCH_MODE_SET_BITS 0x01 /* Set bits in EXT_CSD byte |
| 107 | addressed by index which are |
| 108 | 1 in value field */ |
| 109 | #define MMC_SWITCH_MODE_CLEAR_BITS 0x02 /* Clear bits in EXT_CSD byte |
| 110 | addressed by index, which are |
| 111 | 1 in value field */ |
| 112 | #define MMC_SWITCH_MODE_WRITE_BYTE 0x03 /* Set target byte to value */ |
| 113 | |
| 114 | #define SD_SWITCH_CHECK 0 |
| 115 | #define SD_SWITCH_SWITCH 1 |
| 116 | |
| 117 | /* |
| 118 | * EXT_CSD fields |
| 119 | */ |
| 120 | |
| 121 | #define EXT_CSD_BUS_WIDTH 183 /* R/W */ |
| 122 | #define EXT_CSD_HS_TIMING 185 /* R/W */ |
| 123 | #define EXT_CSD_CARD_TYPE 196 /* RO */ |
| 124 | #define EXT_CSD_REV 192 /* RO */ |
| 125 | #define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ |
| 126 | |
| 127 | /* |
| 128 | * EXT_CSD field definitions |
| 129 | */ |
| 130 | |
| 131 | #define EXT_CSD_CMD_SET_NORMAL (1<<0) |
| 132 | #define EXT_CSD_CMD_SET_SECURE (1<<1) |
| 133 | #define EXT_CSD_CMD_SET_CPSECURE (1<<2) |
| 134 | |
| 135 | #define EXT_CSD_CARD_TYPE_26 (1<<0) /* Card can run at 26MHz */ |
| 136 | #define EXT_CSD_CARD_TYPE_52 (1<<1) /* Card can run at 52MHz */ |
| 137 | |
| 138 | #define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */ |
| 139 | #define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */ |
| 140 | #define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */ |
| 141 | |
| 142 | #define R1_ILLEGAL_COMMAND (1 << 22) |
| 143 | #define R1_APP_CMD (1 << 5) |
| 144 | |
| 145 | #define MMC_RSP_PRESENT (1 << 0) |
| 146 | #define MMC_RSP_136 (1 << 1) /* 136 bit response */ |
| 147 | #define MMC_RSP_CRC (1 << 2) /* expect valid crc */ |
| 148 | #define MMC_RSP_BUSY (1 << 3) /* card may send busy */ |
| 149 | #define MMC_RSP_OPCODE (1 << 4) /* response contains opcode */ |
| 150 | |
| 151 | #define MMC_RSP_NONE (0) |
| 152 | #define MMC_RSP_R1 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) |
| 153 | #define MMC_RSP_R1b (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE| \ |
| 154 | MMC_RSP_BUSY) |
| 155 | #define MMC_RSP_R2 (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC) |
| 156 | #define MMC_RSP_R3 (MMC_RSP_PRESENT) |
| 157 | #define MMC_RSP_R4 (MMC_RSP_PRESENT) |
| 158 | #define MMC_RSP_R5 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) |
| 159 | #define MMC_RSP_R6 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) |
| 160 | #define MMC_RSP_R7 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) |
| 161 | |
| 162 | |
| 163 | struct mmc_cid { |
| 164 | unsigned long psn; |
| 165 | unsigned short oid; |
| 166 | unsigned char mid; |
| 167 | unsigned char prv; |
| 168 | unsigned char mdt; |
| 169 | char pnm[7]; |
| 170 | }; |
| 171 | |
| 172 | |
| 173 | #define MMC_DEFAULT_BLKLEN 512 |
| 174 | #define MMC_DEFAULT_RCA 1 |
| 175 | |
| 176 | /*¼Ä´æÆ÷Æ«ÒÆ*/ |
| 177 | #define ZXMCI_CTRL (0x00) |
| 178 | #define ZXMCI_PWREN (0x04) |
| 179 | #define ZXMCI_CLKDIV (0x08) |
| 180 | #define ZXMCI_CLKSRC (0x0C) |
| 181 | #define ZXMCI_CLKENA (0x10) |
| 182 | #define ZXMCI_TMOUT (0x14) |
| 183 | #define ZXMCI_CTYPE (0x18) |
| 184 | #define ZXMCI_BLKSIZ (0x1C) |
| 185 | #define ZXMCI_BYTCNT (0x20) |
| 186 | #define ZXMCI_INTMSK (0x24) |
| 187 | #define ZXMCI_CMDARG (0x28) |
| 188 | #define ZXMCI_CMD (0x2C) |
| 189 | #define ZXMCI_RESP0 (0x30) |
| 190 | #define ZXMCI_RESP1 (0x34) |
| 191 | #define ZXMCI_RESP2 (0x38) |
| 192 | #define ZXMCI_RESP3 (0x3C) |
| 193 | #define ZXMCI_MINTSTS (0x40) |
| 194 | #define ZXMCI_RINTSTS (0x44) |
| 195 | #define ZXMCI_STATUS (0x48) |
| 196 | #define ZXMCI_FIFOTH (0x4C) |
| 197 | |
| 198 | #define ZXMCI_CDETECT (0x50) |
| 199 | #define ZXMCI_CDETECT_MASK (0x3fffffff) |
| 200 | |
| 201 | #define ZXMCI_WRTPRT (0x54) |
| 202 | #define ZXMCI_GPIO (0x58) |
| 203 | #define ZXMCI_TCBCNT (0x5C) |
| 204 | #define ZXMCI_TBBCNT (0x60) |
| 205 | #define ZXMCI_DEBNCE (0x64) |
| 206 | #define ZXMCI_USRID (0x68) |
| 207 | #define ZXMCI_VERID (0x6C) |
| 208 | #define ZXMCI_HCON (0x70) |
| 209 | #define ZXMCI_BMOD (0x80) |
| 210 | #define ZXMCI_PLDMND (0x84) |
| 211 | #define ZXMCI_DBADDR (0x88) |
| 212 | #define ZXMCI_IDSTS (0x8C) |
| 213 | #define ZXMCI_IDINTEN (0x90) |
| 214 | #define ZXMCI_DSCADDR (0x94) |
| 215 | #define ZXMCI_BUFADDR (0x98) |
| 216 | #define ZXMCI_CARDRDTHRCTRL (0x100) |
| 217 | |
| 218 | #define ZXMCI_FIFO (0x200) |
| 219 | |
| 220 | #define ZXMCI_FIFO_DEPTH 128 |
| 221 | |
| 222 | /*CTRL Register BIT*/ |
| 223 | #define ZXMCI_CTRL_OD_PULLUP (1 << 24) |
| 224 | |
| 225 | |
| 226 | /*rintstsÖжÏ״̬¼Ä´æÆ÷*/ |
| 227 | #define ZXMCI_STS_CRC (1<<15) //End-bit error (read)/write no CRC |
| 228 | #define ZXMCI_STS_ACD (1<<14) //auto command done |
| 229 | #define ZXMCI_STS_SBE (1<<13) //Start-bit error |
| 230 | #define ZXMCI_STS_HLE (1<<12) //Hardware locked write error |
| 231 | #define ZXMCI_STS_FRUN (1<<11) //FIFO underrun/overrun error |
| 232 | #define ZXMCI_STS_HTO (1<<10) //Data starvation-by-host timeout |
| 233 | #define ZXMCI_STS_DRTO (1<<9) //Data read timeout |
| 234 | #define ZXMCI_STS_RTO (1<<8) //Response timeout |
| 235 | #define ZXMCI_STS_DCRC (1<<7) //Data CRC error |
| 236 | #define ZXMCI_STS_RCRC (1<<6) //Response CRC error |
| 237 | #define ZXMCI_STS_RXDR (1<<5) //Receive FIFO data request |
| 238 | #define ZXMCI_STS_TXDR (1<<4) //Transmit FIFO data request |
| 239 | #define ZXMCI_STS_DTO (1<<3) //Data transfer over Êý¾Ý´«ÊäÍê±Ï |
| 240 | #define ZXMCI_STS_CD (1<<2) //Command done |
| 241 | #define ZXMCI_STS_RE (1<<1) //Response error |
| 242 | #define ZXMCI_STS_CDT (1<<0) //Card detect |
| 243 | |
| 244 | /*ÃüÁî¼Ä´æÆ÷*/ |
| 245 | #define ZXMCI_CMD_START (1U<<31) //Start command,Once command is taken by CIU, bit is cleared |
| 246 | #define ZXMCI_CMD_CCS (1<<23) // 1= Interrupts are enabled in CE-ATA device |
| 247 | #define ZXMCI_CMD_RCEATA (1<<22) // 1= Host is performing read access (RW_REG or RW_BLK)towards CE-ATA |
| 248 | #define ZXMCI_CMD_UCREG (1<<21) //0= Normal command sequencregisters_only,1= Do not send commands |
| 249 | #define ZXMCI_CMD_CNUM (1<<16) //Card number in use |
| 250 | #define ZXMCI_CMD_SINIT (1<<15) // 1= Send initialization sequence before sending this comman |
| 251 | #define ZXMCI_CMD_STOP (1<<14) // 1= Stop or abort command intended to stop current data transferin progress. |
| 252 | #define ZXMCI_CMD_WAITC (1<<13) // 1= Wait for previous data transfer completion before sending command |
| 253 | #define ZXMCI_CMD_SSTOP (1<<12) // 1= Send stop command at end of data transfe |
| 254 | #define ZXMCI_CMD_TMODE (1<<11) //0= Block data transfer command,1= Stream |
| 255 | #define ZXMCI_CMD_WRITE (1<<10) //0= Read from card,1= Write |
| 256 | #define ZXMCI_CMD_DEXP (1<<9) //0= No data transfer expected (read/write) |
| 257 | #define ZXMCI_CMD_CRSP (1<<8) // 1= Check response CRC |
| 258 | #define ZXMCI_CMD_RSPLEN (1<<7) // 1= Long response expected from car,0=Short |
| 259 | #define ZXMCI_CMD_RSPEXP (1<<6) // 1= Response expected from car |
| 260 | #define ZXMCI_CMD_INDEX (1<<0) //Command index |
| 261 | #define ZXMCI_CMD_INDEX_MASK 0x3f |
| 262 | |
| 263 | /*״̬¼Ä´æÆ÷*/ |
| 264 | #define ZXMCI_STA_DMAREQ (1<<31) //DMA request signal state |
| 265 | #define ZXMCI_STA_DMAACK (1<<30) //DMA acknowledge signal state |
| 266 | #define ZXMCI_STA_FIFOCNT (1<<17) //FIFO count= Number of filled locations in FIFO |
| 267 | #define ZXMCI_STA_PRERSP (1<<11) //Index of previous response, including any auto-stop sent by core |
| 268 | #define ZXMCI_STA_TMTBUSY (1<<10) //Data transmit or receive state-machine is busy |
| 269 | #define ZXMCI_STA_DATBUSY (1<<9) //Inverted version of raw selected card_data[0],1=BUSY |
| 270 | #define ZXMCI_STA_D3STA (1<<8) //Raw selected card_data[3];1=card present |
| 271 | #define ZXMCI_STA_FSMSTA (1<<4) //Command FSM states |
| 272 | #define ZXMCI_STA_FIFOFULL (1<<3) //FIFO is full status |
| 273 | #define ZXMCI_STA_FIFOEMPTY (1<<2) //FIFO is empty status |
| 274 | #define ZXMCI_STA_TXWMARK (1<<1) //µ½´ï·§ÖµÁËFIFO reached Transmit watermark level; not qualified with data transfer |
| 275 | #define ZXMCI_STA_RXWMARK (1<<0) //FIFO reached Receive watermark level |
| 276 | |
| 277 | #define ZXMCI_STA_FSM_MASK (0xF0) |
| 278 | #define ZXMCI_STA_FSM_POS (0x04) |
| 279 | #define ZXMCI_STA_FSM_IDLE (0x00) |
| 280 | |
| 281 | |
| 282 | //#define R1 (ZXMCI_CMD_RSPEXP /*| ZXMCI_CMD_CRSP*/) |
| 283 | #define R1 (ZXMCI_CMD_RSPEXP | ZXMCI_CMD_CRSP) |
| 284 | #define R1B (ZXMCI_CMD_RSPEXP | ZXMCI_CMD_CRSP) |
| 285 | //#define R2 (ZXMCI_CMD_RSPEXP | /*ZXMCI_CMD_CRSP |*/ZXMCI_CMD_RSPLEN) |
| 286 | #define R2 (ZXMCI_CMD_RSPEXP | ZXMCI_CMD_CRSP |ZXMCI_CMD_RSPLEN) |
| 287 | #define R3 (ZXMCI_CMD_RSPEXP) |
| 288 | #define R4 (ZXMCI_CMD_RSPEXP) |
| 289 | #define R5 (ZXMCI_CMD_RSPEXP | ZXMCI_CMD_CRSP) |
| 290 | #define R6 (ZXMCI_CMD_RSPEXP | ZXMCI_CMD_CRSP) |
| 291 | #define R7 (ZXMCI_CMD_RSPEXP | ZXMCI_CMD_CRSP) |
| 292 | #define CF_DATA (ZXMCI_CMD_DEXP | ZXMCI_CMD_WAITC | ZXMCI_CMD_SSTOP) |
| 293 | #define CF_WR ZXMCI_CMD_WRITE |
| 294 | |
| 295 | #define ERR_STS (ZXMCI_STS_CRC | ZXMCI_STS_DCRC | ZXMCI_STS_RCRC) |
| 296 | |
| 297 | /*SD/MMC ²ÎÊý*/ |
| 298 | #define SYS_EMMC_REGS_BASE 0x01210000 //SD0 |
| 299 | #define CFG_EMMC_CLK_REF 26000000 |
| 300 | #define CFG_EMMC_CLK_ENUM 400000 |
| 301 | #define CFG_EMMC_CLK_WORK 26000000 |
| 302 | |
| 303 | #define SYS_STD_CRM_BASE 0x1307000 |
| 304 | |
| 305 | |
| 306 | |
| 307 | #endif /* __MMC_PXA_P_H__ */ |