MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / include / linux / mmc / mmc.h
blob05eeeda232b448fb464b771e8566265344458ed3
1 /*
2 * linux/include/linux/mmc/mmc.h
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8 #ifndef MMC_H
9 #define MMC_H
11 #include <linux/list.h>
12 #include <linux/interrupt.h>
13 #include <linux/device.h>
15 struct request;
16 struct mmc_data;
17 struct mmc_request;
19 struct mmc_command {
20 u32 opcode;
21 u32 arg;
22 u32 resp[4];
23 unsigned int flags; /* expected response type */
24 #if 1 // add by Victor Yu. 03-07-2007 to compatible with 2.6.9
25 #define MMC_RSP_SHORT (1 << 0)
26 #define MMC_RSP_LONG (2 << 0)
27 #define MMC_RSP_MASK (3 << 0)
28 #endif
29 #define MMC_RSP_PRESENT (1 << 0)
30 #define MMC_RSP_136 (1 << 1) /* 136 bit response */
31 #define MMC_RSP_CRC (1 << 2) /* expect valid crc */
32 #define MMC_RSP_BUSY (1 << 3) /* card may send busy */
33 #define MMC_RSP_OPCODE (1 << 4) /* response contains opcode */
34 #define MMC_CMD_MASK (3 << 5) /* command type */
35 #define MMC_CMD_AC (0 << 5)
36 #define MMC_CMD_ADTC (1 << 5)
37 #define MMC_CMD_BC (2 << 5)
38 #define MMC_CMD_BCR (3 << 5)
41 * These are the response types, and correspond to valid bit
42 * patterns of the above flags. One additional valid pattern
43 * is all zeros, which means we don't expect a response.
45 #define MMC_RSP_NONE (0)
46 #define MMC_RSP_R1 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE)
47 #define MMC_RSP_R1B (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE|MMC_RSP_BUSY)
48 #define MMC_RSP_R2 (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC)
49 #define MMC_RSP_R3 (MMC_RSP_PRESENT)
50 #define MMC_RSP_R6 (MMC_RSP_PRESENT|MMC_RSP_CRC)
52 #define mmc_resp_type(cmd) ((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE))
55 * These are the command types.
57 #define mmc_cmd_type(cmd) ((cmd)->flags & MMC_CMD_MASK)
59 unsigned int retries; /* max number of retries */
60 unsigned int error; /* command error */
62 #define MMC_ERR_NONE 0
63 #define MMC_ERR_TIMEOUT 1
64 #define MMC_ERR_BADCRC 2
65 #define MMC_ERR_FIFO 3
66 #define MMC_ERR_FAILED 4
67 #define MMC_ERR_INVALID 5
69 struct mmc_data *data; /* data segment associated with cmd */
70 struct mmc_request *mrq; /* associated request */
73 struct mmc_data {
74 unsigned int timeout_ns; /* data timeout (in ns, max 80ms) */
75 unsigned int timeout_clks; /* data timeout (in clocks) */
76 unsigned int blksz; /* data block size */
77 unsigned int blocks; /* number of blocks */
78 unsigned int error; /* data error */
79 unsigned int flags;
81 #define MMC_DATA_WRITE (1 << 8)
82 #define MMC_DATA_READ (1 << 9)
83 #define MMC_DATA_STREAM (1 << 10)
84 #define MMC_DATA_MULTI (1 << 11)
86 unsigned int bytes_xfered;
88 struct mmc_command *stop; /* stop command */
89 struct mmc_request *mrq; /* associated request */
91 unsigned int sg_len; /* size of scatter list */
92 struct scatterlist *sg; /* I/O scatter list */
95 struct mmc_request {
96 struct mmc_command *cmd;
97 struct mmc_data *data;
98 struct mmc_command *stop;
100 void *done_data; /* completion data */
101 void (*done)(struct mmc_request *);/* completion function */
104 struct mmc_host;
105 struct mmc_card;
107 extern int mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
108 extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
109 extern int mmc_wait_for_app_cmd(struct mmc_host *, unsigned int,
110 struct mmc_command *, int);
112 extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *, int);
114 extern int __mmc_claim_host(struct mmc_host *host, struct mmc_card *card);
116 static inline void mmc_claim_host(struct mmc_host *host)
118 __mmc_claim_host(host, (struct mmc_card *)-1);
121 extern void mmc_release_host(struct mmc_host *host);
123 #endif