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