blob: 5d3ced30df45466b59c8434b9ce41577709e66f8 [file] [log] [blame]
Jeykumar Sankaran2e655032017-02-04 14:05:45 -08001/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
Narendra Muppalla1b0b3352015-09-29 10:16:51 -07002 *
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
Clarence Ipc475b082016-06-26 09:27:23 -040013#ifndef _SDE_HW_CTL_H
14#define _SDE_HW_CTL_H
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070015
16#include "sde_hw_mdss.h"
Clarence Ipc475b082016-06-26 09:27:23 -040017#include "sde_hw_util.h"
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070018#include "sde_hw_catalog.h"
Jeykumar Sankaran2e655032017-02-04 14:05:45 -080019#include "sde_hw_sspp.h"
Lloyd Atkinson652e59b2017-05-03 11:20:30 -040020#include "sde_hw_blk.h"
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070021
Lloyd Atkinson5d722782016-05-30 14:09:41 -040022/**
23 * sde_ctl_mode_sel: Interface mode selection
24 * SDE_CTL_MODE_SEL_VID: Video mode interface
25 * SDE_CTL_MODE_SEL_CMD: Command mode interface
26 */
27enum sde_ctl_mode_sel {
28 SDE_CTL_MODE_SEL_VID = 0,
29 SDE_CTL_MODE_SEL_CMD
30};
31
Alan Kwong4dd64c82017-02-04 18:41:51 -080032/**
33 * sde_ctl_rot_op_mode - inline rotation mode
34 * SDE_CTL_ROT_OP_MODE_OFFLINE: offline rotation
35 * SDE_CTL_ROT_OP_MODE_RESERVED: reserved
36 * SDE_CTL_ROT_OP_MODE_INLINE_SYNC: inline rotation synchronous mode
37 * SDE_CTL_ROT_OP_MODE_INLINE_ASYNC: inline rotation asynchronous mode
38 */
39enum sde_ctl_rot_op_mode {
40 SDE_CTL_ROT_OP_MODE_OFFLINE,
41 SDE_CTL_ROT_OP_MODE_RESERVED,
42 SDE_CTL_ROT_OP_MODE_INLINE_SYNC,
43 SDE_CTL_ROT_OP_MODE_INLINE_ASYNC,
44};
45
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070046struct sde_hw_ctl;
47/**
48 * struct sde_hw_stage_cfg - blending stage cfg
Jeykumar Sankaran2e655032017-02-04 14:05:45 -080049 * @stage : SSPP_ID at each stage
50 * @multirect_index: index of the rectangle of SSPP.
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070051 */
52struct sde_hw_stage_cfg {
Dhaval Patel572cfd22017-06-12 19:33:39 -070053 enum sde_sspp stage[SDE_STAGE_MAX][PIPES_PER_STAGE];
54 enum sde_sspp_multirect_index multirect_index
Jeykumar Sankaran2e655032017-02-04 14:05:45 -080055 [SDE_STAGE_MAX][PIPES_PER_STAGE];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070056};
57
58/**
Lloyd Atkinson5d722782016-05-30 14:09:41 -040059 * struct sde_hw_intf_cfg :Describes how the SDE writes data to output interface
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040060 * @intf : Interface id
Lloyd Atkinson5d722782016-05-30 14:09:41 -040061 * @wb: Writeback id
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040062 * @mode_3d: 3d mux configuration
Lloyd Atkinson5d722782016-05-30 14:09:41 -040063 * @intf_mode_sel: Interface mode, cmd / vid
64 * @stream_sel: Stream selection for multi-stream interfaces
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040065 */
66struct sde_hw_intf_cfg {
67 enum sde_intf intf;
68 enum sde_wb wb;
69 enum sde_3d_blend_mode mode_3d;
Lloyd Atkinson5d722782016-05-30 14:09:41 -040070 enum sde_ctl_mode_sel intf_mode_sel;
71 int stream_sel;
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040072};
73
74/**
Alan Kwong4dd64c82017-02-04 18:41:51 -080075 * struct sde_ctl_sbuf_cfg - control for stream buffer configuration
76 * @rot_op_mode: rotator operation mode
77 */
78struct sde_ctl_sbuf_cfg {
79 enum sde_ctl_rot_op_mode rot_op_mode;
80};
81
82/**
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070083 * struct sde_hw_ctl_ops - Interface to the wb Hw driver functions
84 * Assumption is these functions will be called after clocks are enabled
85 */
86struct sde_hw_ctl_ops {
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040087 /**
88 * kickoff hw operation for Sw controlled interfaces
89 * DSI cmd mode and WB interface are SW controlled
90 * @ctx : ctl path ctx pointer
91 */
Lloyd Atkinson5d722782016-05-30 14:09:41 -040092 void (*trigger_start)(struct sde_hw_ctl *ctx);
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040093
94 /**
Dhaval Patel0e558f42017-04-30 00:51:40 -070095 * kickoff prepare is in progress hw operation for sw
96 * controlled interfaces: DSI cmd mode and WB interface
97 * are SW controlled
98 * @ctx : ctl path ctx pointer
99 */
100 void (*trigger_pending)(struct sde_hw_ctl *ctx);
101
102 /**
Alan Kwong4dd64c82017-02-04 18:41:51 -0800103 * kickoff rotator operation for Sw controlled interfaces
104 * DSI cmd mode and WB interface are SW controlled
105 * @ctx : ctl path ctx pointer
106 */
107 void (*trigger_rot_start)(struct sde_hw_ctl *ctx);
108
109 /**
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400110 * Clear the value of the cached pending_flush_mask
111 * No effect on hardware
112 * @ctx : ctl path ctx pointer
113 */
114 void (*clear_pending_flush)(struct sde_hw_ctl *ctx);
115
116 /**
Clarence Ip110d15c2016-08-16 14:44:41 -0400117 * Query the value of the cached pending_flush_mask
118 * No effect on hardware
119 * @ctx : ctl path ctx pointer
120 */
121 u32 (*get_pending_flush)(struct sde_hw_ctl *ctx);
122
123 /**
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400124 * OR in the given flushbits to the cached pending_flush_mask
125 * No effect on hardware
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400126 * @ctx : ctl path ctx pointer
127 * @flushbits : module flushmask
128 */
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400129 void (*update_pending_flush)(struct sde_hw_ctl *ctx,
130 u32 flushbits);
131
132 /**
133 * Write the value of the pending_flush_mask to hardware
134 * @ctx : ctl path ctx pointer
135 */
136 void (*trigger_flush)(struct sde_hw_ctl *ctx);
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400137
138 /**
Lloyd Atkinson6340a372017-04-05 13:04:22 -0700139 * Read the value of the flush register
140 * @ctx : ctl path ctx pointer
141 * @Return: value of the ctl flush register.
142 */
143 u32 (*get_flush_register)(struct sde_hw_ctl *ctx);
144
145 /**
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400146 * Setup ctl_path interface config
147 * @ctx
148 * @cfg : interface config structure pointer
149 */
150 void (*setup_intf_cfg)(struct sde_hw_ctl *ctx,
151 struct sde_hw_intf_cfg *cfg);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700152
153 int (*reset)(struct sde_hw_ctl *c);
154
Lloyd Atkinson6cc9de32016-11-17 17:56:13 -0500155 /*
156 * wait_reset_status - checks ctl reset status
157 * @ctx : ctl path ctx pointer
158 *
159 * This function checks the ctl reset status bit.
160 * If the reset bit is set, it keeps polling the status till the hw
161 * reset is complete.
162 * Returns: 0 on success or -error if reset incomplete within interval
163 */
164 int (*wait_reset_status)(struct sde_hw_ctl *ctx);
165
Dhaval Patel48c76022016-09-01 17:51:23 -0700166 uint32_t (*get_bitmask_sspp)(struct sde_hw_ctl *ctx,
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700167 enum sde_sspp blk);
168
Dhaval Patel48c76022016-09-01 17:51:23 -0700169 uint32_t (*get_bitmask_mixer)(struct sde_hw_ctl *ctx,
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700170 enum sde_lm blk);
171
172 int (*get_bitmask_dspp)(struct sde_hw_ctl *ctx,
173 u32 *flushbits,
174 enum sde_dspp blk);
175
176 int (*get_bitmask_intf)(struct sde_hw_ctl *ctx,
177 u32 *flushbits,
178 enum sde_intf blk);
179
180 int (*get_bitmask_cdm)(struct sde_hw_ctl *ctx,
181 u32 *flushbits,
182 enum sde_cdm blk);
183
Alan Kwong3232ca52016-07-29 02:27:47 -0400184 int (*get_bitmask_wb)(struct sde_hw_ctl *ctx,
185 u32 *flushbits,
186 enum sde_wb blk);
187
Alan Kwong4dd64c82017-02-04 18:41:51 -0800188 int (*get_bitmask_rot)(struct sde_hw_ctl *ctx,
189 u32 *flushbits,
190 enum sde_rot blk);
191
Lloyd Atkinsone5ec30d2016-08-23 14:32:32 -0400192 /**
193 * Set all blend stages to disabled
194 * @ctx : ctl path ctx pointer
195 */
196 void (*clear_all_blendstages)(struct sde_hw_ctl *ctx);
197
198 /**
199 * Configure layer mixer to pipe configuration
200 * @ctx : ctl path ctx pointer
201 * @lm : layer mixer enumeration
202 * @cfg : blend stage configuration
203 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700204 void (*setup_blendstage)(struct sde_hw_ctl *ctx,
Dhaval Patel572cfd22017-06-12 19:33:39 -0700205 enum sde_lm lm, struct sde_hw_stage_cfg *cfg);
Alan Kwong4dd64c82017-02-04 18:41:51 -0800206
207 void (*setup_sbuf_cfg)(struct sde_hw_ctl *ctx,
208 struct sde_ctl_sbuf_cfg *cfg);
Gopikrishnaiah Anandan38726842017-08-23 17:56:35 -0700209
210 /**
211 * Flush the reg dma by sending last command.
212 * @ctx : ctl path ctx pointer
213 */
214 void (*reg_dma_flush)(struct sde_hw_ctl *ctx);
215
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700216};
217
218/**
219 * struct sde_hw_ctl : CTL PATH driver object
Lloyd Atkinson652e59b2017-05-03 11:20:30 -0400220 * @base: hardware block base structure
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400221 * @hw: block register map object
222 * @idx: control path index
Lloyd Atkinson652e59b2017-05-03 11:20:30 -0400223 * @caps: control path capabilities
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400224 * @mixer_count: number of mixers
225 * @mixer_hw_caps: mixer hardware capabilities
226 * @pending_flush_mask: storage for pending ctl_flush managed via ops
227 * @ops: operation list
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700228 */
229struct sde_hw_ctl {
Lloyd Atkinson652e59b2017-05-03 11:20:30 -0400230 struct sde_hw_blk base;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700231 struct sde_hw_blk_reg_map hw;
232
233 /* ctl path */
234 int idx;
235 const struct sde_ctl_cfg *caps;
236 int mixer_count;
237 const struct sde_lm_cfg *mixer_hw_caps;
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400238 u32 pending_flush_mask;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700239
240 /* ops */
241 struct sde_hw_ctl_ops ops;
242};
243
244/**
Lloyd Atkinsonccb56212017-05-19 16:18:05 -0400245 * sde_hw_ctl - convert base object sde_hw_base to container
246 * @hw: Pointer to base hardware block
247 * return: Pointer to hardware block container
248 */
249static inline struct sde_hw_ctl *to_sde_hw_ctl(struct sde_hw_blk *hw)
250{
251 return container_of(hw, struct sde_hw_ctl, base);
252}
253
254/**
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700255 * sde_hw_ctl_init(): Initializes the ctl_path hw driver object.
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400256 * should be called before accessing every ctl path registers.
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700257 * @idx: ctl_path index for which driver object is required
258 * @addr: mapped register io address of MDP
259 * @m : pointer to mdss catalog data
260 */
261struct sde_hw_ctl *sde_hw_ctl_init(enum sde_ctl idx,
262 void __iomem *addr,
263 struct sde_mdss_cfg *m);
264
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400265/**
266 * sde_hw_ctl_destroy(): Destroys ctl driver context
267 * should be called to free the context
268 */
269void sde_hw_ctl_destroy(struct sde_hw_ctl *ctx);
270
Clarence Ipc475b082016-06-26 09:27:23 -0400271#endif /*_SDE_HW_CTL_H */