blob: 4d1170ee6afaf1ccdd2bef225febfdcef6e14755 [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"
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070020
Lloyd Atkinson5d722782016-05-30 14:09:41 -040021/**
22 * sde_ctl_mode_sel: Interface mode selection
23 * SDE_CTL_MODE_SEL_VID: Video mode interface
24 * SDE_CTL_MODE_SEL_CMD: Command mode interface
25 */
26enum sde_ctl_mode_sel {
27 SDE_CTL_MODE_SEL_VID = 0,
28 SDE_CTL_MODE_SEL_CMD
29};
30
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070031struct sde_hw_ctl;
32/**
33 * struct sde_hw_stage_cfg - blending stage cfg
Jeykumar Sankaran2e655032017-02-04 14:05:45 -080034 * @stage : SSPP_ID at each stage
35 * @multirect_index: index of the rectangle of SSPP.
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070036 */
37struct sde_hw_stage_cfg {
Dhaval Patel48c76022016-09-01 17:51:23 -070038 enum sde_sspp stage[CRTC_DUAL_MIXERS][SDE_STAGE_MAX][PIPES_PER_STAGE];
Jeykumar Sankaran2e655032017-02-04 14:05:45 -080039 enum sde_sspp_multirect_index multirect_index[CRTC_DUAL_MIXERS]
40 [SDE_STAGE_MAX][PIPES_PER_STAGE];
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070041};
42
43/**
Lloyd Atkinson5d722782016-05-30 14:09:41 -040044 * struct sde_hw_intf_cfg :Describes how the SDE writes data to output interface
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040045 * @intf : Interface id
Lloyd Atkinson5d722782016-05-30 14:09:41 -040046 * @wb: Writeback id
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040047 * @mode_3d: 3d mux configuration
Lloyd Atkinson5d722782016-05-30 14:09:41 -040048 * @intf_mode_sel: Interface mode, cmd / vid
49 * @stream_sel: Stream selection for multi-stream interfaces
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040050 */
51struct sde_hw_intf_cfg {
52 enum sde_intf intf;
53 enum sde_wb wb;
54 enum sde_3d_blend_mode mode_3d;
Lloyd Atkinson5d722782016-05-30 14:09:41 -040055 enum sde_ctl_mode_sel intf_mode_sel;
56 int stream_sel;
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040057};
58
59/**
Narendra Muppalla1b0b3352015-09-29 10:16:51 -070060 * struct sde_hw_ctl_ops - Interface to the wb Hw driver functions
61 * Assumption is these functions will be called after clocks are enabled
62 */
63struct sde_hw_ctl_ops {
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040064 /**
65 * kickoff hw operation for Sw controlled interfaces
66 * DSI cmd mode and WB interface are SW controlled
67 * @ctx : ctl path ctx pointer
68 */
Lloyd Atkinson5d722782016-05-30 14:09:41 -040069 void (*trigger_start)(struct sde_hw_ctl *ctx);
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040070
71 /**
Lloyd Atkinson5d722782016-05-30 14:09:41 -040072 * Clear the value of the cached pending_flush_mask
73 * No effect on hardware
74 * @ctx : ctl path ctx pointer
75 */
76 void (*clear_pending_flush)(struct sde_hw_ctl *ctx);
77
78 /**
Clarence Ip110d15c2016-08-16 14:44:41 -040079 * Query the value of the cached pending_flush_mask
80 * No effect on hardware
81 * @ctx : ctl path ctx pointer
82 */
83 u32 (*get_pending_flush)(struct sde_hw_ctl *ctx);
84
85 /**
Lloyd Atkinson5d722782016-05-30 14:09:41 -040086 * OR in the given flushbits to the cached pending_flush_mask
87 * No effect on hardware
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040088 * @ctx : ctl path ctx pointer
89 * @flushbits : module flushmask
90 */
Lloyd Atkinson5d722782016-05-30 14:09:41 -040091 void (*update_pending_flush)(struct sde_hw_ctl *ctx,
92 u32 flushbits);
93
94 /**
95 * Write the value of the pending_flush_mask to hardware
96 * @ctx : ctl path ctx pointer
97 */
98 void (*trigger_flush)(struct sde_hw_ctl *ctx);
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -040099
100 /**
101 * Setup ctl_path interface config
102 * @ctx
103 * @cfg : interface config structure pointer
104 */
105 void (*setup_intf_cfg)(struct sde_hw_ctl *ctx,
106 struct sde_hw_intf_cfg *cfg);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700107
108 int (*reset)(struct sde_hw_ctl *c);
109
Lloyd Atkinson6cc9de32016-11-17 17:56:13 -0500110 /*
111 * wait_reset_status - checks ctl reset status
112 * @ctx : ctl path ctx pointer
113 *
114 * This function checks the ctl reset status bit.
115 * If the reset bit is set, it keeps polling the status till the hw
116 * reset is complete.
117 * Returns: 0 on success or -error if reset incomplete within interval
118 */
119 int (*wait_reset_status)(struct sde_hw_ctl *ctx);
120
Dhaval Patel48c76022016-09-01 17:51:23 -0700121 uint32_t (*get_bitmask_sspp)(struct sde_hw_ctl *ctx,
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700122 enum sde_sspp blk);
123
Dhaval Patel48c76022016-09-01 17:51:23 -0700124 uint32_t (*get_bitmask_mixer)(struct sde_hw_ctl *ctx,
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700125 enum sde_lm blk);
126
127 int (*get_bitmask_dspp)(struct sde_hw_ctl *ctx,
128 u32 *flushbits,
129 enum sde_dspp blk);
130
131 int (*get_bitmask_intf)(struct sde_hw_ctl *ctx,
132 u32 *flushbits,
133 enum sde_intf blk);
134
135 int (*get_bitmask_cdm)(struct sde_hw_ctl *ctx,
136 u32 *flushbits,
137 enum sde_cdm blk);
138
Alan Kwong3232ca52016-07-29 02:27:47 -0400139 int (*get_bitmask_wb)(struct sde_hw_ctl *ctx,
140 u32 *flushbits,
141 enum sde_wb blk);
142
Lloyd Atkinsone5ec30d2016-08-23 14:32:32 -0400143 /**
144 * Set all blend stages to disabled
145 * @ctx : ctl path ctx pointer
146 */
147 void (*clear_all_blendstages)(struct sde_hw_ctl *ctx);
148
149 /**
150 * Configure layer mixer to pipe configuration
151 * @ctx : ctl path ctx pointer
152 * @lm : layer mixer enumeration
153 * @cfg : blend stage configuration
154 */
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700155 void (*setup_blendstage)(struct sde_hw_ctl *ctx,
Dhaval Patel44f12472016-08-29 12:19:47 -0700156 enum sde_lm lm, struct sde_hw_stage_cfg *cfg, u32 index);
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700157};
158
159/**
160 * struct sde_hw_ctl : CTL PATH driver object
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400161 * @hw: block register map object
162 * @idx: control path index
163 * @ctl_hw_caps: control path capabilities
164 * @mixer_count: number of mixers
165 * @mixer_hw_caps: mixer hardware capabilities
166 * @pending_flush_mask: storage for pending ctl_flush managed via ops
167 * @ops: operation list
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700168 */
169struct sde_hw_ctl {
170 /* base */
171 struct sde_hw_blk_reg_map hw;
172
173 /* ctl path */
174 int idx;
175 const struct sde_ctl_cfg *caps;
176 int mixer_count;
177 const struct sde_lm_cfg *mixer_hw_caps;
Lloyd Atkinson5d722782016-05-30 14:09:41 -0400178 u32 pending_flush_mask;
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700179
180 /* ops */
181 struct sde_hw_ctl_ops ops;
182};
183
184/**
185 * sde_hw_ctl_init(): Initializes the ctl_path hw driver object.
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400186 * should be called before accessing every ctl path registers.
Narendra Muppalla1b0b3352015-09-29 10:16:51 -0700187 * @idx: ctl_path index for which driver object is required
188 * @addr: mapped register io address of MDP
189 * @m : pointer to mdss catalog data
190 */
191struct sde_hw_ctl *sde_hw_ctl_init(enum sde_ctl idx,
192 void __iomem *addr,
193 struct sde_mdss_cfg *m);
194
Abhijit Kulkarni3e3e0d22016-06-24 17:56:13 -0400195/**
196 * sde_hw_ctl_destroy(): Destroys ctl driver context
197 * should be called to free the context
198 */
199void sde_hw_ctl_destroy(struct sde_hw_ctl *ctx);
200
Clarence Ipc475b082016-06-26 09:27:23 -0400201#endif /*_SDE_HW_CTL_H */