xref: /OK3568_Linux_fs/kernel/drivers/rk_nand/rk_nand_blk.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  */
9 
10 #ifndef __RKNAND_BLK_H
11 #define __RKNAND_BLK_H
12 
13 #include <linux/semaphore.h>
14 
15 #define MAX_PART_COUNT 32
16 
17 struct nand_part {
18 	unsigned char name[32];
19 	unsigned long offset;
20 	unsigned long size;
21 	unsigned char type;
22 };
23 
24 struct nand_blk_dev {
25 	struct nand_blk_ops *nand_ops;
26 	struct list_head list;
27 	int devnum;
28 	unsigned long size;
29 	unsigned long off_size;
30 	int readonly;
31 	int writeonly;
32 	int disable_access;
33 	void *blkcore_priv;
34 };
35 
36 struct nand_blk_ops {
37 	char *name;
38 	int major;
39 	int minorbits;
40 	int last_dev_index;
41 	struct completion thread_exit;
42 	int quit;
43 	int nand_th_quited;
44 	wait_queue_head_t thread_wq; /* thread wait queue */
45 	struct request_queue *rq;
46 	spinlock_t queue_lock; /* queue lock */
47 
48 	/* block-mq */
49 	struct list_head rq_list;
50 	struct blk_mq_tag_set *tag_set;
51 
52 	struct list_head devs;
53 	struct module *owner;
54 };
55 
56 extern struct device *g_nand_device;
57 void rknand_dev_suspend(void);
58 void rknand_dev_resume(void);
59 void rknand_dev_shutdown(void);
60 void rknand_dev_flush(void);
61 int __init rknand_dev_init(void);
62 int rknand_dev_exit(void);
63 void rknand_device_lock(void);
64 int rknand_device_trylock(void);
65 void rknand_device_unlock(void);
66 int nand_blk_add_whole_disk(void);
67 #endif
68