1 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 and
5  * only version 2 as published by the Free Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  */
12 
13 #ifndef _DPU_HW_VBIF_H
14 #define _DPU_HW_VBIF_H
15 
16 #include "dpu_hw_catalog.h"
17 #include "dpu_hw_mdss.h"
18 #include "dpu_hw_util.h"
19 
20 struct dpu_hw_vbif;
21 
22 /**
23  * struct dpu_hw_vbif_ops : Interface to the VBIF hardware driver functions
24  *  Assumption is these functions will be called after clocks are enabled
25  */
26 struct dpu_hw_vbif_ops {
27 	/**
28 	 * set_limit_conf - set transaction limit config
29 	 * @vbif: vbif context driver
30 	 * @xin_id: client interface identifier
31 	 * @rd: true for read limit; false for write limit
32 	 * @limit: outstanding transaction limit
33 	 */
34 	void (*set_limit_conf)(struct dpu_hw_vbif *vbif,
35 			u32 xin_id, bool rd, u32 limit);
36 
37 	/**
38 	 * get_limit_conf - get transaction limit config
39 	 * @vbif: vbif context driver
40 	 * @xin_id: client interface identifier
41 	 * @rd: true for read limit; false for write limit
42 	 * @return: outstanding transaction limit
43 	 */
44 	u32 (*get_limit_conf)(struct dpu_hw_vbif *vbif,
45 			u32 xin_id, bool rd);
46 
47 	/**
48 	 * set_halt_ctrl - set halt control
49 	 * @vbif: vbif context driver
50 	 * @xin_id: client interface identifier
51 	 * @enable: halt control enable
52 	 */
53 	void (*set_halt_ctrl)(struct dpu_hw_vbif *vbif,
54 			u32 xin_id, bool enable);
55 
56 	/**
57 	 * get_halt_ctrl - get halt control
58 	 * @vbif: vbif context driver
59 	 * @xin_id: client interface identifier
60 	 * @return: halt control enable
61 	 */
62 	bool (*get_halt_ctrl)(struct dpu_hw_vbif *vbif,
63 			u32 xin_id);
64 
65 	/**
66 	 * set_qos_remap - set QoS priority remap
67 	 * @vbif: vbif context driver
68 	 * @xin_id: client interface identifier
69 	 * @level: priority level
70 	 * @remap_level: remapped level
71 	 */
72 	void (*set_qos_remap)(struct dpu_hw_vbif *vbif,
73 			u32 xin_id, u32 level, u32 remap_level);
74 
75 	/**
76 	 * set_mem_type - set memory type
77 	 * @vbif: vbif context driver
78 	 * @xin_id: client interface identifier
79 	 * @value: memory type value
80 	 */
81 	void (*set_mem_type)(struct dpu_hw_vbif *vbif,
82 			u32 xin_id, u32 value);
83 
84 	/**
85 	 * clear_errors - clear any vbif errors
86 	 *	This function clears any detected pending/source errors
87 	 *	on the VBIF interface, and optionally returns the detected
88 	 *	error mask(s).
89 	 * @vbif: vbif context driver
90 	 * @pnd_errors: pointer to pending error reporting variable
91 	 * @src_errors: pointer to source error reporting variable
92 	 */
93 	void (*clear_errors)(struct dpu_hw_vbif *vbif,
94 		u32 *pnd_errors, u32 *src_errors);
95 
96 	/**
97 	 * set_write_gather_en - set write_gather enable
98 	 * @vbif: vbif context driver
99 	 * @xin_id: client interface identifier
100 	 */
101 	void (*set_write_gather_en)(struct dpu_hw_vbif *vbif, u32 xin_id);
102 };
103 
104 struct dpu_hw_vbif {
105 	/* base */
106 	struct dpu_hw_blk_reg_map hw;
107 
108 	/* vbif */
109 	enum dpu_vbif idx;
110 	const struct dpu_vbif_cfg *cap;
111 
112 	/* ops */
113 	struct dpu_hw_vbif_ops ops;
114 };
115 
116 /**
117  * dpu_hw_vbif_init - initializes the vbif driver for the passed interface idx
118  * @idx:  Interface index for which driver object is required
119  * @addr: Mapped register io address of MDSS
120  * @m:    Pointer to mdss catalog data
121  */
122 struct dpu_hw_vbif *dpu_hw_vbif_init(enum dpu_vbif idx,
123 		void __iomem *addr,
124 		const struct dpu_mdss_cfg *m);
125 
126 void dpu_hw_vbif_destroy(struct dpu_hw_vbif *vbif);
127 
128 #endif /*_DPU_HW_VBIF_H */
129