Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 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 | |
Clarence Ip | c475b08 | 2016-06-26 09:27:23 -0400 | [diff] [blame] | 13 | #ifndef _SDE_HW_CTL_H |
| 14 | #define _SDE_HW_CTL_H |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 15 | |
| 16 | #include "sde_hw_mdss.h" |
Clarence Ip | c475b08 | 2016-06-26 09:27:23 -0400 | [diff] [blame] | 17 | #include "sde_hw_util.h" |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 18 | #include "sde_hw_catalog.h" |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 19 | #include "sde_hw_sspp.h" |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 20 | |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 21 | /** |
| 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 | */ |
| 26 | enum sde_ctl_mode_sel { |
| 27 | SDE_CTL_MODE_SEL_VID = 0, |
| 28 | SDE_CTL_MODE_SEL_CMD |
| 29 | }; |
| 30 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 31 | /** |
| 32 | * sde_ctl_rot_op_mode - inline rotation mode |
| 33 | * SDE_CTL_ROT_OP_MODE_OFFLINE: offline rotation |
| 34 | * SDE_CTL_ROT_OP_MODE_RESERVED: reserved |
| 35 | * SDE_CTL_ROT_OP_MODE_INLINE_SYNC: inline rotation synchronous mode |
| 36 | * SDE_CTL_ROT_OP_MODE_INLINE_ASYNC: inline rotation asynchronous mode |
| 37 | */ |
| 38 | enum sde_ctl_rot_op_mode { |
| 39 | SDE_CTL_ROT_OP_MODE_OFFLINE, |
| 40 | SDE_CTL_ROT_OP_MODE_RESERVED, |
| 41 | SDE_CTL_ROT_OP_MODE_INLINE_SYNC, |
| 42 | SDE_CTL_ROT_OP_MODE_INLINE_ASYNC, |
| 43 | }; |
| 44 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 45 | struct sde_hw_ctl; |
| 46 | /** |
| 47 | * struct sde_hw_stage_cfg - blending stage cfg |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 48 | * @stage : SSPP_ID at each stage |
| 49 | * @multirect_index: index of the rectangle of SSPP. |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 50 | */ |
| 51 | struct sde_hw_stage_cfg { |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 52 | enum sde_sspp stage[CRTC_DUAL_MIXERS][SDE_STAGE_MAX][PIPES_PER_STAGE]; |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 53 | enum sde_sspp_multirect_index multirect_index[CRTC_DUAL_MIXERS] |
| 54 | [SDE_STAGE_MAX][PIPES_PER_STAGE]; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | /** |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 58 | * struct sde_hw_intf_cfg :Describes how the SDE writes data to output interface |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 59 | * @intf : Interface id |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 60 | * @wb: Writeback id |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 61 | * @mode_3d: 3d mux configuration |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 62 | * @intf_mode_sel: Interface mode, cmd / vid |
| 63 | * @stream_sel: Stream selection for multi-stream interfaces |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 64 | */ |
| 65 | struct sde_hw_intf_cfg { |
| 66 | enum sde_intf intf; |
| 67 | enum sde_wb wb; |
| 68 | enum sde_3d_blend_mode mode_3d; |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 69 | enum sde_ctl_mode_sel intf_mode_sel; |
| 70 | int stream_sel; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | /** |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 74 | * struct sde_ctl_sbuf_cfg - control for stream buffer configuration |
| 75 | * @rot_op_mode: rotator operation mode |
| 76 | */ |
| 77 | struct sde_ctl_sbuf_cfg { |
| 78 | enum sde_ctl_rot_op_mode rot_op_mode; |
| 79 | }; |
| 80 | |
| 81 | /** |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 82 | * struct sde_hw_ctl_ops - Interface to the wb Hw driver functions |
| 83 | * Assumption is these functions will be called after clocks are enabled |
| 84 | */ |
| 85 | struct sde_hw_ctl_ops { |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 86 | /** |
| 87 | * kickoff hw operation for Sw controlled interfaces |
| 88 | * DSI cmd mode and WB interface are SW controlled |
| 89 | * @ctx : ctl path ctx pointer |
| 90 | */ |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 91 | void (*trigger_start)(struct sde_hw_ctl *ctx); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 92 | |
| 93 | /** |
Dhaval Patel | 0e558f4 | 2017-04-30 00:51:40 -0700 | [diff] [blame] | 94 | * kickoff prepare is in progress hw operation for sw |
| 95 | * controlled interfaces: DSI cmd mode and WB interface |
| 96 | * are SW controlled |
| 97 | * @ctx : ctl path ctx pointer |
| 98 | */ |
| 99 | void (*trigger_pending)(struct sde_hw_ctl *ctx); |
| 100 | |
| 101 | /** |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 102 | * kickoff rotator operation for Sw controlled interfaces |
| 103 | * DSI cmd mode and WB interface are SW controlled |
| 104 | * @ctx : ctl path ctx pointer |
| 105 | */ |
| 106 | void (*trigger_rot_start)(struct sde_hw_ctl *ctx); |
| 107 | |
| 108 | /** |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 109 | * Clear the value of the cached pending_flush_mask |
| 110 | * No effect on hardware |
| 111 | * @ctx : ctl path ctx pointer |
| 112 | */ |
| 113 | void (*clear_pending_flush)(struct sde_hw_ctl *ctx); |
| 114 | |
| 115 | /** |
Clarence Ip | 110d15c | 2016-08-16 14:44:41 -0400 | [diff] [blame] | 116 | * Query the value of the cached pending_flush_mask |
| 117 | * No effect on hardware |
| 118 | * @ctx : ctl path ctx pointer |
| 119 | */ |
| 120 | u32 (*get_pending_flush)(struct sde_hw_ctl *ctx); |
| 121 | |
| 122 | /** |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 123 | * OR in the given flushbits to the cached pending_flush_mask |
| 124 | * No effect on hardware |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 125 | * @ctx : ctl path ctx pointer |
| 126 | * @flushbits : module flushmask |
| 127 | */ |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 128 | void (*update_pending_flush)(struct sde_hw_ctl *ctx, |
| 129 | u32 flushbits); |
| 130 | |
| 131 | /** |
| 132 | * Write the value of the pending_flush_mask to hardware |
| 133 | * @ctx : ctl path ctx pointer |
| 134 | */ |
| 135 | void (*trigger_flush)(struct sde_hw_ctl *ctx); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 136 | |
| 137 | /** |
Lloyd Atkinson | 6340a37 | 2017-04-05 13:04:22 -0700 | [diff] [blame] | 138 | * Read the value of the flush register |
| 139 | * @ctx : ctl path ctx pointer |
| 140 | * @Return: value of the ctl flush register. |
| 141 | */ |
| 142 | u32 (*get_flush_register)(struct sde_hw_ctl *ctx); |
| 143 | |
| 144 | /** |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 145 | * Setup ctl_path interface config |
| 146 | * @ctx |
| 147 | * @cfg : interface config structure pointer |
| 148 | */ |
| 149 | void (*setup_intf_cfg)(struct sde_hw_ctl *ctx, |
| 150 | struct sde_hw_intf_cfg *cfg); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 151 | |
| 152 | int (*reset)(struct sde_hw_ctl *c); |
| 153 | |
Lloyd Atkinson | 6cc9de3 | 2016-11-17 17:56:13 -0500 | [diff] [blame] | 154 | /* |
| 155 | * wait_reset_status - checks ctl reset status |
| 156 | * @ctx : ctl path ctx pointer |
| 157 | * |
| 158 | * This function checks the ctl reset status bit. |
| 159 | * If the reset bit is set, it keeps polling the status till the hw |
| 160 | * reset is complete. |
| 161 | * Returns: 0 on success or -error if reset incomplete within interval |
| 162 | */ |
| 163 | int (*wait_reset_status)(struct sde_hw_ctl *ctx); |
| 164 | |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 165 | uint32_t (*get_bitmask_sspp)(struct sde_hw_ctl *ctx, |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 166 | enum sde_sspp blk); |
| 167 | |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 168 | uint32_t (*get_bitmask_mixer)(struct sde_hw_ctl *ctx, |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 169 | enum sde_lm blk); |
| 170 | |
| 171 | int (*get_bitmask_dspp)(struct sde_hw_ctl *ctx, |
| 172 | u32 *flushbits, |
| 173 | enum sde_dspp blk); |
| 174 | |
| 175 | int (*get_bitmask_intf)(struct sde_hw_ctl *ctx, |
| 176 | u32 *flushbits, |
| 177 | enum sde_intf blk); |
| 178 | |
| 179 | int (*get_bitmask_cdm)(struct sde_hw_ctl *ctx, |
| 180 | u32 *flushbits, |
| 181 | enum sde_cdm blk); |
| 182 | |
Alan Kwong | 3232ca5 | 2016-07-29 02:27:47 -0400 | [diff] [blame] | 183 | int (*get_bitmask_wb)(struct sde_hw_ctl *ctx, |
| 184 | u32 *flushbits, |
| 185 | enum sde_wb blk); |
| 186 | |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 187 | int (*get_bitmask_rot)(struct sde_hw_ctl *ctx, |
| 188 | u32 *flushbits, |
| 189 | enum sde_rot blk); |
| 190 | |
Lloyd Atkinson | e5ec30d | 2016-08-23 14:32:32 -0400 | [diff] [blame] | 191 | /** |
| 192 | * Set all blend stages to disabled |
| 193 | * @ctx : ctl path ctx pointer |
| 194 | */ |
| 195 | void (*clear_all_blendstages)(struct sde_hw_ctl *ctx); |
| 196 | |
| 197 | /** |
| 198 | * Configure layer mixer to pipe configuration |
| 199 | * @ctx : ctl path ctx pointer |
| 200 | * @lm : layer mixer enumeration |
| 201 | * @cfg : blend stage configuration |
| 202 | */ |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 203 | void (*setup_blendstage)(struct sde_hw_ctl *ctx, |
Dhaval Patel | 44f1247 | 2016-08-29 12:19:47 -0700 | [diff] [blame] | 204 | enum sde_lm lm, struct sde_hw_stage_cfg *cfg, u32 index); |
Alan Kwong | 4dd64c8 | 2017-02-04 18:41:51 -0800 | [diff] [blame] | 205 | |
| 206 | void (*setup_sbuf_cfg)(struct sde_hw_ctl *ctx, |
| 207 | struct sde_ctl_sbuf_cfg *cfg); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 208 | }; |
| 209 | |
| 210 | /** |
| 211 | * struct sde_hw_ctl : CTL PATH driver object |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 212 | * @hw: block register map object |
| 213 | * @idx: control path index |
| 214 | * @ctl_hw_caps: control path capabilities |
| 215 | * @mixer_count: number of mixers |
| 216 | * @mixer_hw_caps: mixer hardware capabilities |
| 217 | * @pending_flush_mask: storage for pending ctl_flush managed via ops |
| 218 | * @ops: operation list |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 219 | */ |
| 220 | struct sde_hw_ctl { |
| 221 | /* base */ |
| 222 | struct sde_hw_blk_reg_map hw; |
| 223 | |
| 224 | /* ctl path */ |
| 225 | int idx; |
| 226 | const struct sde_ctl_cfg *caps; |
| 227 | int mixer_count; |
| 228 | const struct sde_lm_cfg *mixer_hw_caps; |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 229 | u32 pending_flush_mask; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 230 | |
| 231 | /* ops */ |
| 232 | struct sde_hw_ctl_ops ops; |
| 233 | }; |
| 234 | |
| 235 | /** |
| 236 | * sde_hw_ctl_init(): Initializes the ctl_path hw driver object. |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 237 | * should be called before accessing every ctl path registers. |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 238 | * @idx: ctl_path index for which driver object is required |
| 239 | * @addr: mapped register io address of MDP |
| 240 | * @m : pointer to mdss catalog data |
| 241 | */ |
| 242 | struct sde_hw_ctl *sde_hw_ctl_init(enum sde_ctl idx, |
| 243 | void __iomem *addr, |
| 244 | struct sde_mdss_cfg *m); |
| 245 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 246 | /** |
| 247 | * sde_hw_ctl_destroy(): Destroys ctl driver context |
| 248 | * should be called to free the context |
| 249 | */ |
| 250 | void sde_hw_ctl_destroy(struct sde_hw_ctl *ctx); |
| 251 | |
Clarence Ip | c475b08 | 2016-06-26 09:27:23 -0400 | [diff] [blame] | 252 | #endif /*_SDE_HW_CTL_H */ |