blob: 36cddab57d776322c3912241f274e06620a77251 [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;
Adrian Hunterb8360a42015-05-07 13:10:24 +030015 int retune_retry_done;
Per Forlin97868a22011-07-09 17:12:36 -040016};
17
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090018enum mmc_packed_type {
19 MMC_PACKED_NONE = 0,
20 MMC_PACKED_WRITE,
21};
22
23#define mmc_packed_cmd(type) ((type) != MMC_PACKED_NONE)
24#define mmc_packed_wr(type) ((type) == MMC_PACKED_WRITE)
25
26struct mmc_packed {
27 struct list_head list;
28 u32 cmd_hdr[1024];
29 unsigned int blocks;
30 u8 nr_entries;
31 u8 retries;
32 s16 idx_failure;
33};
34
Per Forlin97868a22011-07-09 17:12:36 -040035struct mmc_queue_req {
36 struct request *req;
37 struct mmc_blk_request brq;
38 struct scatterlist *sg;
39 char *bounce_buf;
40 struct scatterlist *bounce_sg;
41 unsigned int bounce_sg_len;
Per Forlinee8a43a2011-07-01 18:55:33 +020042 struct mmc_async_req mmc_active;
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090043 enum mmc_packed_type cmd_type;
44 struct mmc_packed *packed;
Per Forlin97868a22011-07-09 17:12:36 -040045};
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047struct mmc_queue {
48 struct mmc_card *card;
Christoph Hellwig87598a22006-11-13 20:23:52 +010049 struct task_struct *thread;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 struct semaphore thread_sem;
51 unsigned int flags;
Konstantin Dorfman2220eed2013-01-14 14:28:17 -050052#define MMC_QUEUE_SUSPENDED (1 << 0)
53#define MMC_QUEUE_NEW_REQUEST (1 << 1)
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 int (*issue_fn)(struct mmc_queue *, struct request *);
56 void *data;
57 struct request_queue *queue;
Per Forlin04296b72011-07-01 18:55:31 +020058 struct mmc_queue_req mqrq[2];
Per Forlin97868a22011-07-09 17:12:36 -040059 struct mmc_queue_req *mqrq_cur;
Per Forlin04296b72011-07-01 18:55:31 +020060 struct mmc_queue_req *mqrq_prev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070061};
62
Adrian Hunterd09408a2011-06-23 13:40:28 +030063extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
64 const char *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065extern void mmc_cleanup_queue(struct mmc_queue *);
66extern void mmc_queue_suspend(struct mmc_queue *);
67extern void mmc_queue_resume(struct mmc_queue *);
68
Per Forlin97868a22011-07-09 17:12:36 -040069extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
70 struct mmc_queue_req *);
71extern void mmc_queue_bounce_pre(struct mmc_queue_req *);
72extern void mmc_queue_bounce_post(struct mmc_queue_req *);
Pierre Ossman98ccf142007-05-12 00:26:16 +020073
Seungwon Jeonce39f9d2013-02-06 17:02:46 +090074extern int mmc_packed_init(struct mmc_queue *, struct mmc_card *);
75extern void mmc_packed_clean(struct mmc_queue *);
76
Chuanxiao Dong4e93b9a2014-08-12 12:01:30 +080077extern int mmc_access_rpmb(struct mmc_queue *);
78
Linus Torvalds1da177e2005-04-16 15:20:36 -070079#endif