Merge tag 'v4.14-rockchip-dts64fixes-2' of git://git.kernel.org/pub/scm/linux/kernel...
[sfrench/cifs-2.6.git] / drivers / mmc / core / queue.h
1 #ifndef MMC_QUEUE_H
2 #define MMC_QUEUE_H
3
4 #include <linux/types.h>
5 #include <linux/blkdev.h>
6 #include <linux/blk-mq.h>
7 #include <linux/mmc/core.h>
8 #include <linux/mmc/host.h>
9
10 static inline struct mmc_queue_req *req_to_mmc_queue_req(struct request *rq)
11 {
12         return blk_mq_rq_to_pdu(rq);
13 }
14
15 struct mmc_queue_req;
16
17 static inline struct request *mmc_queue_req_to_req(struct mmc_queue_req *mqr)
18 {
19         return blk_mq_rq_from_pdu(mqr);
20 }
21
22 struct task_struct;
23 struct mmc_blk_data;
24 struct mmc_blk_ioc_data;
25
26 struct mmc_blk_request {
27         struct mmc_request      mrq;
28         struct mmc_command      sbc;
29         struct mmc_command      cmd;
30         struct mmc_command      stop;
31         struct mmc_data         data;
32         int                     retune_retry_done;
33 };
34
35 /**
36  * enum mmc_drv_op - enumerates the operations in the mmc_queue_req
37  * @MMC_DRV_OP_IOCTL: ioctl operation
38  * @MMC_DRV_OP_BOOT_WP: write protect boot partitions
39  * @MMC_DRV_OP_GET_CARD_STATUS: get card status
40  * @MMC_DRV_OP_GET_EXT_CSD: get the EXT CSD from an eMMC card
41  */
42 enum mmc_drv_op {
43         MMC_DRV_OP_IOCTL,
44         MMC_DRV_OP_BOOT_WP,
45         MMC_DRV_OP_GET_CARD_STATUS,
46         MMC_DRV_OP_GET_EXT_CSD,
47 };
48
49 struct mmc_queue_req {
50         struct mmc_blk_request  brq;
51         struct scatterlist      *sg;
52         struct mmc_async_req    areq;
53         enum mmc_drv_op         drv_op;
54         int                     drv_op_result;
55         void                    *drv_op_data;
56         unsigned int            ioc_count;
57 };
58
59 struct mmc_queue {
60         struct mmc_card         *card;
61         struct task_struct      *thread;
62         struct semaphore        thread_sem;
63         bool                    suspended;
64         bool                    asleep;
65         struct mmc_blk_data     *blkdata;
66         struct request_queue    *queue;
67         /*
68          * FIXME: this counter is not a very reliable way of keeping
69          * track of how many requests that are ongoing. Switch to just
70          * letting the block core keep track of requests and per-request
71          * associated mmc_queue_req data.
72          */
73         int                     qcnt;
74 };
75
76 extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
77                           const char *);
78 extern void mmc_cleanup_queue(struct mmc_queue *);
79 extern void mmc_queue_suspend(struct mmc_queue *);
80 extern void mmc_queue_resume(struct mmc_queue *);
81 extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
82                                      struct mmc_queue_req *);
83
84 extern int mmc_access_rpmb(struct mmc_queue *);
85
86 #endif