blob: 5752d50049a34c2a9ee8f6585105990f1e018d05 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef MMC_QUEUE_H
2#define MMC_QUEUE_H
3
Seungwon Jeonef3a69c72013-03-14 15:17:13 +09004#define MMC_REQ_SPECIAL_MASK (REQ_DISCARD | REQ_FLUSH)
5
Linus Torvalds1da177e2005-04-16 15:20:36 -07006struct request;
7struct task_struct;
8
Per Forlin97868a22011-07-09 17:12:36 -04009struct mmc_blk_request {
10 struct mmc_request mrq;
11 struct mmc_command sbc;
12 struct mmc_command cmd;
13 struct mmc_command stop;
14 struct mmc_data data;
15};
16
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090017enum mmc_packed_type {
18 MMC_PACKED_NONE = 0,
19 MMC_PACKED_WRITE,
20};
21
22#define mmc_packed_cmd(type) ((type) != MMC_PACKED_NONE)
23#define mmc_packed_wr(type) ((type) == MMC_PACKED_WRITE)
24
25struct mmc_packed {
26 struct list_head list;
27 u32 cmd_hdr[1024];
28 unsigned int blocks;
29 u8 nr_entries;
30 u8 retries;
31 s16 idx_failure;
32};
33
Per Forlin97868a22011-07-09 17:12:36 -040034struct mmc_queue_req {
35 struct request *req;
36 struct mmc_blk_request brq;
37 struct scatterlist *sg;
38 char *bounce_buf;
39 struct scatterlist *bounce_sg;
40 unsigned int bounce_sg_len;
Per Forlinee8a43a2011-07-01 18:55:33 +020041 struct mmc_async_req mmc_active;
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090042 enum mmc_packed_type cmd_type;
43 struct mmc_packed *packed;
Per Forlin97868a22011-07-09 17:12:36 -040044};
45
Linus Torvalds1da177e2005-04-16 15:20:36 -070046struct mmc_queue {
47 struct mmc_card *card;
Christoph Hellwig87598a22006-11-13 20:23:52 +010048 struct task_struct *thread;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 struct semaphore thread_sem;
50 unsigned int flags;
Konstantin Dorfman2220eed2013-01-14 14:28:17 -050051#define MMC_QUEUE_SUSPENDED (1 << 0)
52#define MMC_QUEUE_NEW_REQUEST (1 << 1)
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 int (*issue_fn)(struct mmc_queue *, struct request *);
55 void *data;
56 struct request_queue *queue;
Per Forlin04296b72011-07-01 18:55:31 +020057 struct mmc_queue_req mqrq[2];
Per Forlin97868a22011-07-09 17:12:36 -040058 struct mmc_queue_req *mqrq_cur;
Per Forlin04296b72011-07-01 18:55:31 +020059 struct mmc_queue_req *mqrq_prev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060};
61
Adrian Hunterd09408a2011-06-23 13:40:28 +030062extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
63 const char *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064extern void mmc_cleanup_queue(struct mmc_queue *);
65extern void mmc_queue_suspend(struct mmc_queue *);
66extern void mmc_queue_resume(struct mmc_queue *);
67
Per Forlin97868a22011-07-09 17:12:36 -040068extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
69 struct mmc_queue_req *);
70extern void mmc_queue_bounce_pre(struct mmc_queue_req *);
71extern void mmc_queue_bounce_post(struct mmc_queue_req *);
Pierre Ossman98ccf142007-05-12 00:26:16 +020072
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090073extern int mmc_packed_init(struct mmc_queue *, struct mmc_card *);
74extern void mmc_packed_clean(struct mmc_queue *);
75
Linus Torvalds1da177e2005-04-16 15:20:36 -070076#endif