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 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 31 | struct sde_hw_ctl; |
| 32 | /** |
| 33 | * struct sde_hw_stage_cfg - blending stage cfg |
Jeykumar Sankaran | 2e65503 | 2017-02-04 14:05:45 -0800 | [diff] [blame] | 34 | * @stage : SSPP_ID at each stage |
| 35 | * @multirect_index: index of the rectangle of SSPP. |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 36 | */ |
| 37 | struct sde_hw_stage_cfg { |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 38 | 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] | 39 | enum sde_sspp_multirect_index multirect_index[CRTC_DUAL_MIXERS] |
| 40 | [SDE_STAGE_MAX][PIPES_PER_STAGE]; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | /** |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 44 | * 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] | 45 | * @intf : Interface id |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 46 | * @wb: Writeback id |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 47 | * @mode_3d: 3d mux configuration |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 48 | * @intf_mode_sel: Interface mode, cmd / vid |
| 49 | * @stream_sel: Stream selection for multi-stream interfaces |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 50 | */ |
| 51 | struct sde_hw_intf_cfg { |
| 52 | enum sde_intf intf; |
| 53 | enum sde_wb wb; |
| 54 | enum sde_3d_blend_mode mode_3d; |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 55 | enum sde_ctl_mode_sel intf_mode_sel; |
| 56 | int stream_sel; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | /** |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 60 | * 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 | */ |
| 63 | struct sde_hw_ctl_ops { |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 64 | /** |
| 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 Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 69 | void (*trigger_start)(struct sde_hw_ctl *ctx); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 70 | |
| 71 | /** |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 72 | * 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 Ip | 110d15c | 2016-08-16 14:44:41 -0400 | [diff] [blame] | 79 | * 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 Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 86 | * OR in the given flushbits to the cached pending_flush_mask |
| 87 | * No effect on hardware |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 88 | * @ctx : ctl path ctx pointer |
| 89 | * @flushbits : module flushmask |
| 90 | */ |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 91 | 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 Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 99 | |
| 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 Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 107 | |
| 108 | int (*reset)(struct sde_hw_ctl *c); |
| 109 | |
Lloyd Atkinson | 6cc9de3 | 2016-11-17 17:56:13 -0500 | [diff] [blame^] | 110 | /* |
| 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 Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 121 | uint32_t (*get_bitmask_sspp)(struct sde_hw_ctl *ctx, |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 122 | enum sde_sspp blk); |
| 123 | |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 124 | uint32_t (*get_bitmask_mixer)(struct sde_hw_ctl *ctx, |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 125 | 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 Kwong | 3232ca5 | 2016-07-29 02:27:47 -0400 | [diff] [blame] | 139 | int (*get_bitmask_wb)(struct sde_hw_ctl *ctx, |
| 140 | u32 *flushbits, |
| 141 | enum sde_wb blk); |
| 142 | |
Lloyd Atkinson | e5ec30d | 2016-08-23 14:32:32 -0400 | [diff] [blame] | 143 | /** |
| 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 Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 155 | void (*setup_blendstage)(struct sde_hw_ctl *ctx, |
Dhaval Patel | 44f1247 | 2016-08-29 12:19:47 -0700 | [diff] [blame] | 156 | enum sde_lm lm, struct sde_hw_stage_cfg *cfg, u32 index); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 157 | }; |
| 158 | |
| 159 | /** |
| 160 | * struct sde_hw_ctl : CTL PATH driver object |
Lloyd Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 161 | * @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 Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 168 | */ |
| 169 | struct 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 Atkinson | 5d72278 | 2016-05-30 14:09:41 -0400 | [diff] [blame] | 178 | u32 pending_flush_mask; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 179 | |
| 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 Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 186 | * should be called before accessing every ctl path registers. |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 187 | * @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 | */ |
| 191 | struct sde_hw_ctl *sde_hw_ctl_init(enum sde_ctl idx, |
| 192 | void __iomem *addr, |
| 193 | struct sde_mdss_cfg *m); |
| 194 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 195 | /** |
| 196 | * sde_hw_ctl_destroy(): Destroys ctl driver context |
| 197 | * should be called to free the context |
| 198 | */ |
| 199 | void sde_hw_ctl_destroy(struct sde_hw_ctl *ctx); |
| 200 | |
Clarence Ip | c475b08 | 2016-06-26 09:27:23 -0400 | [diff] [blame] | 201 | #endif /*_SDE_HW_CTL_H */ |