Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef MMC_QUEUE_H |
| 2 | #define MMC_QUEUE_H |
| 3 | |
Seungwon Jeon | ef3a69c7 | 2013-03-14 15:17:13 +0900 | [diff] [blame] | 4 | #define MMC_REQ_SPECIAL_MASK (REQ_DISCARD | REQ_FLUSH) |
| 5 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | struct request; |
| 7 | struct task_struct; |
| 8 | |
Per Forlin | 97868a2 | 2011-07-09 17:12:36 -0400 | [diff] [blame] | 9 | struct 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 Hunter | b8360a4 | 2015-05-07 13:10:24 +0300 | [diff] [blame] | 15 | int retune_retry_done; |
Per Forlin | 97868a2 | 2011-07-09 17:12:36 -0400 | [diff] [blame] | 16 | }; |
| 17 | |
Seungwon Jeon | ce39f9d | 2013-02-06 17:02:46 +0900 | [diff] [blame] | 18 | enum 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 | |
| 26 | struct 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 Forlin | 97868a2 | 2011-07-09 17:12:36 -0400 | [diff] [blame] | 35 | struct 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 Forlin | ee8a43a | 2011-07-01 18:55:33 +0200 | [diff] [blame] | 42 | struct mmc_async_req mmc_active; |
Seungwon Jeon | ce39f9d | 2013-02-06 17:02:46 +0900 | [diff] [blame] | 43 | enum mmc_packed_type cmd_type; |
| 44 | struct mmc_packed *packed; |
Per Forlin | 97868a2 | 2011-07-09 17:12:36 -0400 | [diff] [blame] | 45 | }; |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | struct mmc_queue { |
| 48 | struct mmc_card *card; |
Christoph Hellwig | 87598a2 | 2006-11-13 20:23:52 +0100 | [diff] [blame] | 49 | struct task_struct *thread; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | struct semaphore thread_sem; |
| 51 | unsigned int flags; |
Konstantin Dorfman | 2220eed | 2013-01-14 14:28:17 -0500 | [diff] [blame] | 52 | #define MMC_QUEUE_SUSPENDED (1 << 0) |
| 53 | #define MMC_QUEUE_NEW_REQUEST (1 << 1) |
| 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | int (*issue_fn)(struct mmc_queue *, struct request *); |
| 56 | void *data; |
| 57 | struct request_queue *queue; |
Per Forlin | 04296b7 | 2011-07-01 18:55:31 +0200 | [diff] [blame] | 58 | struct mmc_queue_req mqrq[2]; |
Per Forlin | 97868a2 | 2011-07-09 17:12:36 -0400 | [diff] [blame] | 59 | struct mmc_queue_req *mqrq_cur; |
Per Forlin | 04296b7 | 2011-07-01 18:55:31 +0200 | [diff] [blame] | 60 | struct mmc_queue_req *mqrq_prev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | }; |
| 62 | |
Adrian Hunter | d09408a | 2011-06-23 13:40:28 +0300 | [diff] [blame] | 63 | extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *, |
| 64 | const char *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | extern void mmc_cleanup_queue(struct mmc_queue *); |
| 66 | extern void mmc_queue_suspend(struct mmc_queue *); |
| 67 | extern void mmc_queue_resume(struct mmc_queue *); |
| 68 | |
Per Forlin | 97868a2 | 2011-07-09 17:12:36 -0400 | [diff] [blame] | 69 | extern unsigned int mmc_queue_map_sg(struct mmc_queue *, |
| 70 | struct mmc_queue_req *); |
| 71 | extern void mmc_queue_bounce_pre(struct mmc_queue_req *); |
| 72 | extern void mmc_queue_bounce_post(struct mmc_queue_req *); |
Pierre Ossman | 98ccf14 | 2007-05-12 00:26:16 +0200 | [diff] [blame] | 73 | |
Seungwon Jeon | ce39f9d | 2013-02-06 17:02:46 +0900 | [diff] [blame] | 74 | extern int mmc_packed_init(struct mmc_queue *, struct mmc_card *); |
| 75 | extern void mmc_packed_clean(struct mmc_queue *); |
| 76 | |
Chuanxiao Dong | 4e93b9a | 2014-08-12 12:01:30 +0800 | [diff] [blame] | 77 | extern int mmc_access_rpmb(struct mmc_queue *); |
| 78 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | #endif |