blob: 031bf6376c994ae566e4edbfc0a886c40f1728a6 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef MMC_QUEUE_H
2#define MMC_QUEUE_H
3
4struct request;
5struct task_struct;
6
Per Forlin97868a22011-07-09 17:12:36 -04007struct mmc_blk_request {
8 struct mmc_request mrq;
9 struct mmc_command sbc;
10 struct mmc_command cmd;
11 struct mmc_command stop;
12 struct mmc_data data;
13};
14
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090015enum mmc_packed_type {
16 MMC_PACKED_NONE = 0,
17 MMC_PACKED_WRITE,
18};
19
20#define mmc_packed_cmd(type) ((type) != MMC_PACKED_NONE)
21#define mmc_packed_wr(type) ((type) == MMC_PACKED_WRITE)
22
23struct mmc_packed {
24 struct list_head list;
25 u32 cmd_hdr[1024];
26 unsigned int blocks;
27 u8 nr_entries;
28 u8 retries;
29 s16 idx_failure;
30};
31
Per Forlin97868a22011-07-09 17:12:36 -040032struct mmc_queue_req {
33 struct request *req;
34 struct mmc_blk_request brq;
35 struct scatterlist *sg;
36 char *bounce_buf;
37 struct scatterlist *bounce_sg;
38 unsigned int bounce_sg_len;
Per Forlinee8a43a2011-07-01 18:55:33 +020039 struct mmc_async_req mmc_active;
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090040 enum mmc_packed_type cmd_type;
41 struct mmc_packed *packed;
Per Forlin97868a22011-07-09 17:12:36 -040042};
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044struct mmc_queue {
45 struct mmc_card *card;
Christoph Hellwig87598a22006-11-13 20:23:52 +010046 struct task_struct *thread;
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 struct semaphore thread_sem;
48 unsigned int flags;
Konstantin Dorfman2220eed2013-01-14 14:28:17 -050049#define MMC_QUEUE_SUSPENDED (1 << 0)
50#define MMC_QUEUE_NEW_REQUEST (1 << 1)
51
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 int (*issue_fn)(struct mmc_queue *, struct request *);
53 void *data;
54 struct request_queue *queue;
Per Forlin04296b72011-07-01 18:55:31 +020055 struct mmc_queue_req mqrq[2];
Per Forlin97868a22011-07-09 17:12:36 -040056 struct mmc_queue_req *mqrq_cur;
Per Forlin04296b72011-07-01 18:55:31 +020057 struct mmc_queue_req *mqrq_prev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058};
59
Adrian Hunterd09408a2011-06-23 13:40:28 +030060extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
61 const char *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062extern void mmc_cleanup_queue(struct mmc_queue *);
63extern void mmc_queue_suspend(struct mmc_queue *);
64extern void mmc_queue_resume(struct mmc_queue *);
65
Per Forlin97868a22011-07-09 17:12:36 -040066extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
67 struct mmc_queue_req *);
68extern void mmc_queue_bounce_pre(struct mmc_queue_req *);
69extern void mmc_queue_bounce_post(struct mmc_queue_req *);
Pierre Ossman98ccf142007-05-12 00:26:16 +020070
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090071extern int mmc_packed_init(struct mmc_queue *, struct mmc_card *);
72extern void mmc_packed_clean(struct mmc_queue *);
73
Linus Torvalds1da177e2005-04-16 15:20:36 -070074#endif