1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
/* Copyright (c) 2013-2014, 2016, The Linux Foundation. All rights reserved.
* Copyright (C) 2007 Google Incorporated
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef MDP3_H
#define MDP3_H
#include <linux/types.h>
#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/msm_iommu_domains.h>
#include "mdss_dsi_clk.h"
#include "mdp3_dma.h"
#include "mdss_fb.h"
#include "mdss.h"
#define MDP_VSYNC_CLK_RATE 19200000
#define MDP_CORE_CLK_RATE_SVS 160000000
#define MDP_CORE_CLK_RATE_SUPER_SVS 200000000
#define MDP_CORE_CLK_RATE_MAX 307200000
/* PPP cant work at SVS for panel res above qHD */
#define SVS_MAX_PIXEL (540 * 960)
#define KOFF_TIMEOUT msecs_to_jiffies(84)
#define WAIT_DMA_TIMEOUT msecs_to_jiffies(84)
/*
* MDP_DEINTERLACE & MDP_SHARPENING Flags are not valid for MDP3
* so using them together for MDP_SMART_BLIT.
*/
#define MDP_SMART_BLIT 0xC0000000
enum {
MDP3_CLK_AHB,
MDP3_CLK_AXI,
MDP3_CLK_MDP_SRC,
MDP3_CLK_MDP_CORE,
MDP3_CLK_VSYNC,
MDP3_CLK_DSI,
MDP3_MAX_CLK
};
enum {
MDP3_BUS_HANDLE,
MDP3_BUS_HANDLE_MAX,
};
enum {
MDP3_IOMMU_DOMAIN_UNSECURE,
MDP3_IOMMU_DOMAIN_SECURE,
MDP3_IOMMU_DOMAIN_MAX,
};
enum {
MDP3_IOMMU_CTX_MDP_0,
MDP3_IOMMU_CTX_MDP_1,
MDP3_IOMMU_CTX_MAX
};
/* Keep DSI entry in sync with mdss
which is being used by DSI 6G */
enum {
MDP3_CLIENT_DMA_P,
MDP3_CLIENT_DSI = 1,
MDP3_CLIENT_PPP,
MDP3_CLIENT_IOMMU,
MDP3_CLIENT_MAX,
};
enum {
DI_PARTITION_NUM = 0,
DI_DOMAIN_NUM = 1,
DI_MAX,
};
struct mdp3_bus_handle_map {
struct msm_bus_vectors *bus_vector;
struct msm_bus_paths *usecases;
struct msm_bus_scale_pdata *scale_pdata;
int current_bus_idx;
int ref_cnt;
u64 restore_ab[MDP3_CLIENT_MAX];
u64 restore_ib[MDP3_CLIENT_MAX];
u64 ab[MDP3_CLIENT_MAX];
u64 ib[MDP3_CLIENT_MAX];
u32 handle;
};
struct mdp3_iommu_domain_map {
u32 domain_type;
char *client_name;
struct msm_iova_partition partitions[1];
int npartitions;
int domain_idx;
struct iommu_domain *domain;
};
struct mdp3_iommu_ctx_map {
u32 ctx_type;
struct mdp3_iommu_domain_map *domain;
char *ctx_name;
struct device *ctx;
int attached;
};
struct mdp3_iommu_meta {
struct rb_node node;
struct ion_handle *handle;
struct rb_root iommu_maps;
struct kref ref;
struct sg_table *table;
struct dma_buf *dbuf;
int mapped_size;
unsigned long size;
dma_addr_t iova_addr;
unsigned long flags;
};
#define MDP3_MAX_INTR 28
struct mdp3_intr_cb {
void (*cb)(int type, void *);
void *data;
};
#define SMART_BLIT_RGB_EN 1
#define SMART_BLIT_YUV_EN 2
struct mdp3_hw_resource {
struct platform_device *pdev;
u32 mdp_rev;
struct mutex res_mutex;
struct clk *clocks[MDP3_MAX_CLK];
int clock_ref_count[MDP3_MAX_CLK];
unsigned long dma_core_clk_request;
unsigned long ppp_core_clk_request;
struct mdss_hw mdp3_hw;
struct mdss_util_intf *mdss_util;
char __iomem *mdp_base;
size_t mdp_reg_size;
char __iomem *vbif_base;
size_t vbif_reg_size;
struct mdp3_bus_handle_map *bus_handle;
struct ion_client *ion_client;
struct mdp3_iommu_domain_map *domains;
struct mdp3_iommu_ctx_map *iommu_contexts;
unsigned int iommu_ref_cnt;
bool allow_iommu_update;
struct ion_handle *ion_handle;
struct mutex iommu_lock;
struct mdp3_dma dma[MDP3_DMA_MAX];
struct mdp3_intf intf[MDP3_DMA_OUTPUT_SEL_MAX];
struct rb_root iommu_root;
spinlock_t irq_lock;
u32 irq_ref_count[MDP3_MAX_INTR];
u32 irq_mask;
int irq_ref_cnt;
struct mdp3_intr_cb callbacks[MDP3_MAX_INTR];
u32 underrun_cnt;
int irq_registered;
unsigned long splash_mem_addr;
u32 splash_mem_size;
struct mdss_panel_cfg pan_cfg;
int clk_prepare_count;
int cont_splash_en;
bool batfet_required;
struct regulator *batfet;
struct regulator *vdd_cx;
struct regulator *fs;
bool fs_ena;
int clk_ena;
bool idle_pc_enabled;
bool idle_pc;
atomic_t active_intf_cnt;
u8 smart_blit_en;
bool solid_fill_vote_en;
struct list_head reg_bus_clist;
struct mutex reg_bus_lock;
};
struct mdp3_img_data {
dma_addr_t addr;
unsigned long len;
u32 offset;
u32 flags;
u32 padding;
int p_need;
struct ion_handle *srcp_ihdl;
u32 dir;
u32 domain;
bool mapped;
bool skip_detach;
struct fd srcp_f;
struct dma_buf *srcp_dma_buf;
struct dma_buf_attachment *srcp_attachment;
struct sg_table *srcp_table;
};
extern struct mdp3_hw_resource *mdp3_res;
struct mdp3_dma *mdp3_get_dma_pipe(int capability);
struct mdp3_intf *mdp3_get_display_intf(int type);
void mdp3_irq_enable(int type);
void mdp3_irq_disable(int type);
void mdp3_irq_disable_nosync(int type);
int mdp3_set_intr_callback(u32 type, struct mdp3_intr_cb *cb);
void mdp3_irq_register(void);
void mdp3_irq_deregister(void);
int mdp3_clk_set_rate(int clk_type, unsigned long clk_rate, int client);
int mdp3_clk_enable(int enable, int dsi_clk);
int mdp3_res_update(int enable, int dsi_clk, int client);
int mdp3_bus_scale_set_quota(int client, u64 ab_quota, u64 ib_quota);
int mdp3_put_img(struct mdp3_img_data *data, int client);
int mdp3_get_img(struct msmfb_data *img, struct mdp3_img_data *data,
int client);
int mdp3_iommu_enable(int client);
int mdp3_iommu_disable(int client);
int mdp3_iommu_is_attached(void);
void mdp3_free(struct msm_fb_data_type *mfd);
int mdp3_parse_dt_splash(struct msm_fb_data_type *mfd);
void mdp3_release_splash_memory(struct msm_fb_data_type *mfd);
int mdp3_create_sysfs_link(struct device *dev);
int mdp3_get_cont_spash_en(void);
int mdp3_get_mdp_dsi_clk(void);
int mdp3_put_mdp_dsi_clk(void);
int mdp3_misr_set(struct mdp_misr *misr_req);
int mdp3_misr_get(struct mdp_misr *misr_resp);
void mdp3_enable_regulator(int enable);
void mdp3_check_dsi_ctrl_status(struct work_struct *work,
uint32_t interval);
int mdp3_dynamic_clock_gating_ctrl(int enable);
int mdp3_footswitch_ctrl(int enable);
int mdp3_qos_remapper_setup(struct mdss_panel_data *panel);
int mdp3_splash_done(struct mdss_panel_info *panel_info);
int mdp3_autorefresh_disable(struct mdss_panel_info *panel_info);
u64 mdp3_clk_round_off(u64 clk_rate);
void mdp3_calc_dma_res(struct mdss_panel_info *panel_info, u64 *clk_rate,
u64 *ab, u64 *ib, uint32_t bpp);
#define MDP3_REG_WRITE(addr, val) writel_relaxed(val, mdp3_res->mdp_base + addr)
#define MDP3_REG_READ(addr) readl_relaxed(mdp3_res->mdp_base + addr)
#define VBIF_REG_WRITE(off, val) writel_relaxed(val, mdp3_res->vbif_base + off)
#define VBIF_REG_READ(off) readl_relaxed(mdp3_res->vbif_base + off)
#endif /* MDP3_H */
|