Annotation of funnyos/dev/sdmmc/sdmmcvar.h, Revision 1.3
1.1 nbrk 1: /*
1.3 ! nbrk 2: * $Id: sdmmcvar.h,v 1.2 2007/12/20 15:23:15 nbrk Exp $
1.1 nbrk 3: */
4: #ifndef _DEV_SDMMC_SDMMCVAR_H
5: #define _DEV_SDMMC_SDMMCVAR_H
6:
1.3 ! nbrk 7: #define SDMMC_BLOCK_SIZE 512
! 8:
1.1 nbrk 9: /*
10: * SD/MMC simplified commands set.
11: */
12: #define CMD0_GO_IDLE_STATE 0
13: #define CMD1_SEND_OP_COND 1
14: #define CMD8_SEND_IF_COND 8
15: #define CMD9_SEND_CSD 9
16: #define CMD10_SEND_CID 10
17: #define CMD12_STOP_TRANSMISSION 12
18: #define CMD16_SET_BLOCKLEN 16
19: #define CMD17_READ_SINGLE_BLOCK 17
20: #define CMD18_READ_MULTIPLE_BLOCK 18
21: #define CMD23_SET_BLOCK_COUNT 23
22: #define CMD24_WRITE_BLOCK 24
23: #define CMD25_WRITE_MULTIPLE_BLOCK 25
24: #define CMD41_APP_SEND_OP_COND 41
25: #define CMD55_APP_CMD 55
26: #define CMD58_READ_OCR 58
27:
1.2 nbrk 28: /* will use this when switch card from native mode to spi */
29: #define CMD0_HARDCODED_CRC 0x95
30:
1.1 nbrk 31: /*
32: * Command frame.
33: */
34: struct sdmmc_cmdframe {
35: uint8_t sc_cmd;
36: uint32_t sc_arg;
37: uint8_t sc_crc;
38:
39: } __attribute__((packed));
40:
41: /*
42: * Macross to construct frame header and footer.
43: */
44: #define CMDFRAME_CMD(c) ((c & 0x3f) | 0x40)
45: #define CMDFRAME_CRC(c) (c << 1 | 0x01)
46:
47: /*
48: * Responses bitfields.
49: */
1.2 nbrk 50: #define R1_IN_IDLE_STATE 0x01
51: #define R1_ERASE_RESET 0x02
52: #define R1_ILLEGAL_COMMAND 0x04
53: #define R1_COMMAND_CRC_ERROR 0x08
54: #define R1_ERASE_SEQUENSE_ERROR 0x10
55: #define R1_ADDRESS_ERROR 0x20
56: #define R1_PARAMETER_ERROR 0x40
57: #define R2_CARD_LOCKED 0x01
58: #define R2_LOCKUNLOCK_FAILED 0x02
59: #define R2_UNSPECIFIED_ERROR 0x04
60: #define R2_CARD_CONTROLLER_ERROR 0x08
61: #define R2_CARD_ECC_FAILED 0x10
62: #define R2_WRITE_PROTECT_VIOLATION 0x20
63: #define R2_ERASE_PARAMETER 0x40
64: #define R2_OUT_OF_RANGE 0x80
65:
1.1 nbrk 66:
67: /*
1.2 nbrk 68: * R1 response.
1.1 nbrk 69: */
70: struct sdmmc_r1resp {
71: uint8_t sr_eflags;
72:
73: };
74:
1.2 nbrk 75:
76: /*
77: * R2 response.
78: */
79: struct sdmmc_r2resp {
80: uint8_t sr_eflags1;
81: uint8_t sr_eflags2;
82:
83: } __attribute__((packed));
84:
85:
1.1 nbrk 86: /*
1.2 nbrk 87: * R3 response.
1.1 nbrk 88: */
89: struct sdmmc_r3resp {
90: uint8_t sr_eflags;
91: uint32_t sr_ocr;
92:
93: } __attribute__((packed));
1.2 nbrk 94:
95:
96: /*
1.3 ! nbrk 97: * Tokens.
! 98: */
! 99: #define TOK_READ_BLOCK 0xfe
! 100: #define TOK_READ_BLOCK_MULTIPLE 0xfe
! 101: #define TOK_WRITE_BLOCK 0xfe
! 102: #define TOK_WRITE_BLOCK_MULTIPLE 0xfc
! 103: #define TOK_STOP_MULTIPLE 0xfd
! 104:
! 105:
! 106: /*
1.2 nbrk 107: * Read Error Token bits.
108: */
109: #define RE_UNSPECIFIED_ERROR 0x01
110: #define RE_CARD_CONTROLLER_ERROR 0x02
111: #define RE_CARD_ECC_FAILED 0x04
112: #define RE_OUT_OF_RANGE 0x08
113: #define RE_CARD_LOCKED 0x10
1.3 ! nbrk 114:
! 115: /*
! 116: * Card CID (Card ID) register.
! 117: */
! 118: struct sdmmc_cid {
! 119: uint8_t cid_mid;
! 120: uint16_t cid_oid;
! 121: uint8_t cid_pnm[5];
! 122: uint8_t cid_prv;
! 123: uint32_t cid_psn;
! 124: uint16_t cid_mdt;
! 125: uint8_t cid_crc;
! 126:
! 127: } __attribute__((packed));
1.2 nbrk 128:
129: /*
130: * SD/MMC bus handle.
131: */
132: struct sdmmc_bus_handle {
133: void (*sb_send_command)(void *dd, uint8_t cmd, uint32_t arg);
134: uint8_t (*sb_get_response)(void *dd);
135: uint8_t (*sb_get_spec_response)(void *dd, uint8_t response);
136: uint8_t (*sb_read_register)(void *dd, uint8_t reg);
137: uint8_t (*sb_read_block)(void *dd, uint32_t addr, uint32_t count);
138: uint8_t (*sb_write_block)(void *dd, uint32_t addr, void *data);
139: uint8_t (*sb_check_busy)(void *dd);
140:
141: void *sb_dd;
142: };
143:
144: /*
145: * Functions.
146: */
147: struct sdmmc_cmdframe sdmmc_command(uint8_t cmd, uint32_t arg, uint8_t crc);
1.1 nbrk 148:
149:
150: #endif /* !_DEV_SDMMC_SDMMCVAR_H */
151:
CVSweb