Root/
Source at commit ee76fb4f890f40f18832f5f0e93213a995efb17c created 13 years 5 months ago. By Xiangfu Liu, remove useless functions in jz_mmc.c: mmc_block_write, mmc_write, mmc_ident, mmc2info | |
---|---|
1 | /* |
2 | * linux/drivers/mmc/jz_mmc.h |
3 | * |
4 | * Author: Vladimir Shebordaev, Igor Oblakov |
5 | * Copyright: MontaVista Software Inc. |
6 | * |
7 | * $Id: jz_mmc.h,v 1.3 2007-06-15 08:04:20 jlwei Exp $ |
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_JZMMC_H__ |
14 | #define __MMC_JZMMC_H__ |
15 | |
16 | #define ID_TO_RCA(x) ((x)+1) |
17 | #define MMC_OCR_ARG 0x00ff8000 /* Argument of OCR */ |
18 | |
19 | /* Standard MMC/SD clock speeds */ |
20 | #define MMC_CLOCK_SLOW 400000 /* 400 kHz for initial setup */ |
21 | #define MMC_CLOCK_FAST 20000000 /* 20 MHz for maximum for normal operation */ |
22 | #define SD_CLOCK_FAST 24000000 /* 24 MHz for SD Cards */ |
23 | |
24 | /* Use negative numbers to disambiguate */ |
25 | #define MMC_CIM_RESET -1 |
26 | #define SET_BUS_WIDTH 6 /* ac [1:0] bus width R1 */ |
27 | |
28 | #define R1_OUT_OF_RANGE (1 << 31) /* er, c */ |
29 | #define R1_ADDRESS_ERROR (1 << 30) /* erx, c */ |
30 | #define R1_BLOCK_LEN_ERROR (1 << 29) /* er, c */ |
31 | #define R1_ERASE_SEQ_ERROR (1 << 28) /* er, c */ |
32 | #define R1_ERASE_PARAM (1 << 27) /* ex, c */ |
33 | #define R1_WP_VIOLATION (1 << 26) /* erx, c */ |
34 | #define R1_CARD_IS_LOCKED (1 << 25) /* sx, a */ |
35 | #define R1_LOCK_UNLOCK_FAILED (1 << 24) /* erx, c */ |
36 | #define R1_COM_CRC_ERROR (1 << 23) /* er, b */ |
37 | #define R1_ILLEGAL_COMMAND (1 << 22) /* er, b */ |
38 | #define R1_CARD_ECC_FAILED (1 << 21) /* ex, c */ |
39 | #define R1_CC_ERROR (1 << 20) /* erx, c */ |
40 | #define R1_ERROR (1 << 19) /* erx, c */ |
41 | #define R1_UNDERRUN (1 << 18) /* ex, c */ |
42 | #define R1_OVERRUN (1 << 17) /* ex, c */ |
43 | #define R1_CID_CSD_OVERWRITE (1 << 16) /* erx, c, CID/CSD overwrite */ |
44 | #define R1_WP_ERASE_SKIP (1 << 15) /* sx, c */ |
45 | #define R1_CARD_ECC_DISABLED (1 << 14) /* sx, a */ |
46 | #define R1_ERASE_RESET (1 << 13) /* sr, c */ |
47 | #define R1_STATUS(x) (x & 0xFFFFE000) |
48 | |
49 | #define MMC_CARD_BUSY 0x80000000 /* Card Power up status bit */ |
50 | |
51 | #define MMC_PROGRAM_CID 26 /* adtc R1 */ |
52 | #define MMC_PROGRAM_CSD 27 /* adtc R1 */ |
53 | |
54 | #define MMC_GO_IRQ_STATE 40 /* bcr R5 */ |
55 | #define MMC_GEN_CMD 56 /* adtc [0] RD/WR R1b */ |
56 | #define MMC_LOCK_UNLOCK 42 /* adtc R1b */ |
57 | #define MMC_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */ |
58 | #define MMC_READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */ |
59 | #define MMC_SEND_WRITE_PROT 30 /* adtc [31:0] wpdata addr R1 */ |
60 | |
61 | |
62 | enum mmc_result_t { |
63 | MMC_NO_RESPONSE = -1, |
64 | MMC_NO_ERROR = 0, |
65 | MMC_ERROR_OUT_OF_RANGE, |
66 | MMC_ERROR_ADDRESS, |
67 | MMC_ERROR_BLOCK_LEN, |
68 | MMC_ERROR_ERASE_SEQ, |
69 | MMC_ERROR_ERASE_PARAM, |
70 | MMC_ERROR_WP_VIOLATION, |
71 | MMC_ERROR_CARD_IS_LOCKED, |
72 | MMC_ERROR_LOCK_UNLOCK_FAILED, |
73 | MMC_ERROR_COM_CRC, |
74 | MMC_ERROR_ILLEGAL_COMMAND, |
75 | MMC_ERROR_CARD_ECC_FAILED, |
76 | MMC_ERROR_CC, |
77 | MMC_ERROR_GENERAL, |
78 | MMC_ERROR_UNDERRUN, |
79 | MMC_ERROR_OVERRUN, |
80 | MMC_ERROR_CID_CSD_OVERWRITE, |
81 | MMC_ERROR_STATE_MISMATCH, |
82 | MMC_ERROR_HEADER_MISMATCH, |
83 | MMC_ERROR_TIMEOUT, |
84 | MMC_ERROR_CRC, |
85 | MMC_ERROR_DRIVER_FAILURE, |
86 | }; |
87 | |
88 | enum card_state { |
89 | CARD_STATE_EMPTY = -1, |
90 | CARD_STATE_IDLE = 0, |
91 | CARD_STATE_READY = 1, |
92 | CARD_STATE_IDENT = 2, |
93 | CARD_STATE_STBY = 3, |
94 | CARD_STATE_TRAN = 4, |
95 | CARD_STATE_DATA = 5, |
96 | CARD_STATE_RCV = 6, |
97 | CARD_STATE_PRG = 7, |
98 | CARD_STATE_DIS = 8, |
99 | }; |
100 | |
101 | enum mmc_rsp_t { |
102 | RESPONSE_NONE = 0, |
103 | RESPONSE_R1 = 1, |
104 | RESPONSE_R1B = 2, |
105 | RESPONSE_R2_CID = 3, |
106 | RESPONSE_R2_CSD = 4, |
107 | RESPONSE_R3 = 5, |
108 | RESPONSE_R4 = 6, |
109 | RESPONSE_R5 = 7, |
110 | RESPONSE_R6 = 8, |
111 | }; |
112 | |
113 | struct mmc_response_r1 { |
114 | u8 cmd; |
115 | u32 status; |
116 | }; |
117 | |
118 | struct mmc_response_r3 { |
119 | u32 ocr; |
120 | }; |
121 | |
122 | /* the information structure of MMC/SD Card */ |
123 | struct mmc_info { |
124 | int id; /* Card index */ |
125 | int sd; /* MMC or SD card */ |
126 | int rca; /* RCA */ |
127 | u32 scr; /* SCR 63:32*/ |
128 | int flags; /* Ejected, inserted */ |
129 | enum card_state state; /* empty, ident, ready, whatever */ |
130 | |
131 | /* Card specific information */ |
132 | struct mmc_cid cid; |
133 | struct mmc_csd csd; |
134 | u32 block_num; |
135 | u32 block_len; |
136 | u32 erase_unit; |
137 | }; |
138 | |
139 | struct mmc_info mmcinfo; |
140 | |
141 | struct mmc_request { |
142 | int index; /* Slot index - used for CS lines */ |
143 | int cmd; /* Command to send */ |
144 | u32 arg; /* Argument to send */ |
145 | enum mmc_rsp_t rtype; /* Response type expected */ |
146 | |
147 | /* Data transfer (these may be modified at the low level) */ |
148 | u16 nob; /* Number of blocks to transfer*/ |
149 | u16 block_len; /* Block length */ |
150 | u8 *buffer; /* Data buffer */ |
151 | u32 cnt; /* Data length, for PIO */ |
152 | |
153 | /* Results */ |
154 | u8 response[18]; /* Buffer to store response - CRC is optional */ |
155 | enum mmc_result_t result; |
156 | }; |
157 | |
158 | char * mmc_result_to_string(int); |
159 | int mmc_unpack_csd(struct mmc_request *request, struct mmc_csd *csd); |
160 | int mmc_unpack_r1(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state); |
161 | int mmc_unpack_r6(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state, int *rca); |
162 | int mmc_unpack_scr(struct mmc_request *request, struct mmc_response_r1 *r1, enum card_state state, u32 *scr); |
163 | int mmc_unpack_cid(struct mmc_request *request, struct mmc_cid *cid); |
164 | int mmc_unpack_r3(struct mmc_request *request, struct mmc_response_r3 *r3); |
165 | |
166 | void mmc_send_cmd(struct mmc_request *request, int cmd, u32 arg, |
167 | u16 nob, u16 block_len, enum mmc_rsp_t rtype, u8 *buffer); |
168 | u32 mmc_tran_speed(u8 ts); |
169 | void jz_mmc_set_clock(int sd, u32 rate); |
170 | |
171 | static inline void mmc_simple_cmd(struct mmc_request *request, int cmd, u32 arg, enum mmc_rsp_t rtype) |
172 | { |
173 | mmc_send_cmd( request, cmd, arg, 0, 0, rtype, 0); |
174 | } |
175 | |
176 | #endif /* __MMC_JZMMC_H__ */ |
177 |