aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_runtime_pm.c
diff options
context:
space:
mode:
authorImre Deak <imre.deak@intel.com>2018-08-06 05:58:38 -0400
committerImre Deak <imre.deak@intel.com>2018-08-08 06:51:19 -0400
commitd13dd05a1f20262e32335a1f1363809185e3d2e1 (patch)
tree0fb5853a75da2202d1416d96b7dc173b8be680fd /drivers/gpu/drm/i915/intel_runtime_pm.c
parentf28ec6f4ea483554aacc59e8eb4a7667ecaf58ad (diff)
drm/i915/vlv: Use power well CTL IDX instead of ID
Atm, we determine the control/status flag offsets within the PUNIT control/status registers based on the power well's ID. Since the power well ID enum is global across all platforms, the associated macros to get the flag offsets involves some magic. This makes checking the register/bit definitions against the specification more difficult than necessary. Also the values in the power well ID enum must stay fixed, making code maintenance of the enum cumbersome. To solve the above define the control/status flag indices right after the corresponding registers and use these to derive the control/status flag values by storing the indices in the i915_power_well_desc struct. Initializing anonymous union fields require the preceding field in the struct to be explicitly initialized - even when using named initializers - and the initialization to be done right before the union initialization, hence the reordering of the .id fields. v2: - Clarify commit log message about anonymous union initializers. (Paulo) Cc: Ville Syrjala <ville.syrjala@linux.intel.com> Cc: Paulo Zanoni <paulo.r.zanoni@intel.com> Cc: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Imre Deak <imre.deak@intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20180806095843.13294-6-imre.deak@intel.com
Diffstat (limited to 'drivers/gpu/drm/i915/intel_runtime_pm.c')
-rw-r--r--drivers/gpu/drm/i915/intel_runtime_pm.c52
1 files changed, 38 insertions, 14 deletions
diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c b/drivers/gpu/drm/i915/intel_runtime_pm.c
index 9f44a2b0113a..bcdf04847b49 100644
--- a/drivers/gpu/drm/i915/intel_runtime_pm.c
+++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
@@ -872,14 +872,14 @@ static void i830_pipes_power_well_sync_hw(struct drm_i915_private *dev_priv,
872static void vlv_set_power_well(struct drm_i915_private *dev_priv, 872static void vlv_set_power_well(struct drm_i915_private *dev_priv,
873 struct i915_power_well *power_well, bool enable) 873 struct i915_power_well *power_well, bool enable)
874{ 874{
875 enum i915_power_well_id power_well_id = power_well->desc->id; 875 int pw_idx = power_well->desc->vlv.idx;
876 u32 mask; 876 u32 mask;
877 u32 state; 877 u32 state;
878 u32 ctrl; 878 u32 ctrl;
879 879
880 mask = PUNIT_PWRGT_MASK(power_well_id); 880 mask = PUNIT_PWRGT_MASK(pw_idx);
881 state = enable ? PUNIT_PWRGT_PWR_ON(power_well_id) : 881 state = enable ? PUNIT_PWRGT_PWR_ON(pw_idx) :
882 PUNIT_PWRGT_PWR_GATE(power_well_id); 882 PUNIT_PWRGT_PWR_GATE(pw_idx);
883 883
884 mutex_lock(&dev_priv->pcu_lock); 884 mutex_lock(&dev_priv->pcu_lock);
885 885
@@ -920,14 +920,14 @@ static void vlv_power_well_disable(struct drm_i915_private *dev_priv,
920static bool vlv_power_well_enabled(struct drm_i915_private *dev_priv, 920static bool vlv_power_well_enabled(struct drm_i915_private *dev_priv,
921 struct i915_power_well *power_well) 921 struct i915_power_well *power_well)
922{ 922{
923 enum i915_power_well_id power_well_id = power_well->desc->id; 923 int pw_idx = power_well->desc->vlv.idx;
924 bool enabled = false; 924 bool enabled = false;
925 u32 mask; 925 u32 mask;
926 u32 state; 926 u32 state;
927 u32 ctrl; 927 u32 ctrl;
928 928
929 mask = PUNIT_PWRGT_MASK(power_well_id); 929 mask = PUNIT_PWRGT_MASK(pw_idx);
930 ctrl = PUNIT_PWRGT_PWR_ON(power_well_id); 930 ctrl = PUNIT_PWRGT_PWR_ON(pw_idx);
931 931
932 mutex_lock(&dev_priv->pcu_lock); 932 mutex_lock(&dev_priv->pcu_lock);
933 933
@@ -936,8 +936,8 @@ static bool vlv_power_well_enabled(struct drm_i915_private *dev_priv,
936 * We only ever set the power-on and power-gate states, anything 936 * We only ever set the power-on and power-gate states, anything
937 * else is unexpected. 937 * else is unexpected.
938 */ 938 */
939 WARN_ON(state != PUNIT_PWRGT_PWR_ON(power_well_id) && 939 WARN_ON(state != PUNIT_PWRGT_PWR_ON(pw_idx) &&
940 state != PUNIT_PWRGT_PWR_GATE(power_well_id)); 940 state != PUNIT_PWRGT_PWR_GATE(pw_idx));
941 if (state == ctrl) 941 if (state == ctrl)
942 enabled = true; 942 enabled = true;
943 943
@@ -2179,8 +2179,11 @@ static const struct i915_power_well_desc vlv_power_wells[] = {
2179 { 2179 {
2180 .name = "display", 2180 .name = "display",
2181 .domains = VLV_DISPLAY_POWER_DOMAINS, 2181 .domains = VLV_DISPLAY_POWER_DOMAINS,
2182 .id = PUNIT_POWER_WELL_DISP2D,
2183 .ops = &vlv_display_power_well_ops, 2182 .ops = &vlv_display_power_well_ops,
2183 .id = PUNIT_POWER_WELL_DISP2D,
2184 {
2185 .vlv.idx = PUNIT_PWGT_IDX_DISP2D,
2186 },
2184 }, 2187 },
2185 { 2188 {
2186 .name = "dpio-tx-b-01", 2189 .name = "dpio-tx-b-01",
@@ -2190,6 +2193,9 @@ static const struct i915_power_well_desc vlv_power_wells[] = {
2190 VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS, 2193 VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS,
2191 .ops = &vlv_dpio_power_well_ops, 2194 .ops = &vlv_dpio_power_well_ops,
2192 .id = PUNIT_POWER_WELL_DPIO_TX_B_LANES_01, 2195 .id = PUNIT_POWER_WELL_DPIO_TX_B_LANES_01,
2196 {
2197 .vlv.idx = PUNIT_PWGT_IDX_DPIO_TX_B_LANES_01,
2198 },
2193 }, 2199 },
2194 { 2200 {
2195 .name = "dpio-tx-b-23", 2201 .name = "dpio-tx-b-23",
@@ -2199,6 +2205,9 @@ static const struct i915_power_well_desc vlv_power_wells[] = {
2199 VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS, 2205 VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS,
2200 .ops = &vlv_dpio_power_well_ops, 2206 .ops = &vlv_dpio_power_well_ops,
2201 .id = PUNIT_POWER_WELL_DPIO_TX_B_LANES_23, 2207 .id = PUNIT_POWER_WELL_DPIO_TX_B_LANES_23,
2208 {
2209 .vlv.idx = PUNIT_PWGT_IDX_DPIO_TX_B_LANES_23,
2210 },
2202 }, 2211 },
2203 { 2212 {
2204 .name = "dpio-tx-c-01", 2213 .name = "dpio-tx-c-01",
@@ -2208,6 +2217,9 @@ static const struct i915_power_well_desc vlv_power_wells[] = {
2208 VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS, 2217 VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS,
2209 .ops = &vlv_dpio_power_well_ops, 2218 .ops = &vlv_dpio_power_well_ops,
2210 .id = PUNIT_POWER_WELL_DPIO_TX_C_LANES_01, 2219 .id = PUNIT_POWER_WELL_DPIO_TX_C_LANES_01,
2220 {
2221 .vlv.idx = PUNIT_PWGT_IDX_DPIO_TX_C_LANES_01,
2222 },
2211 }, 2223 },
2212 { 2224 {
2213 .name = "dpio-tx-c-23", 2225 .name = "dpio-tx-c-23",
@@ -2217,12 +2229,18 @@ static const struct i915_power_well_desc vlv_power_wells[] = {
2217 VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS, 2229 VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS,
2218 .ops = &vlv_dpio_power_well_ops, 2230 .ops = &vlv_dpio_power_well_ops,
2219 .id = PUNIT_POWER_WELL_DPIO_TX_C_LANES_23, 2231 .id = PUNIT_POWER_WELL_DPIO_TX_C_LANES_23,
2232 {
2233 .vlv.idx = PUNIT_PWGT_IDX_DPIO_TX_C_LANES_23,
2234 },
2220 }, 2235 },
2221 { 2236 {
2222 .name = "dpio-common", 2237 .name = "dpio-common",
2223 .domains = VLV_DPIO_CMN_BC_POWER_DOMAINS, 2238 .domains = VLV_DPIO_CMN_BC_POWER_DOMAINS,
2224 .id = PUNIT_POWER_WELL_DPIO_CMN_BC,
2225 .ops = &vlv_dpio_cmn_power_well_ops, 2239 .ops = &vlv_dpio_cmn_power_well_ops,
2240 .id = PUNIT_POWER_WELL_DPIO_CMN_BC,
2241 {
2242 .vlv.idx = PUNIT_PWGT_IDX_DPIO_CMN_BC,
2243 },
2226 }, 2244 },
2227}; 2245};
2228 2246
@@ -2242,20 +2260,26 @@ static const struct i915_power_well_desc chv_power_wells[] = {
2242 * required for any pipe to work. 2260 * required for any pipe to work.
2243 */ 2261 */
2244 .domains = CHV_DISPLAY_POWER_DOMAINS, 2262 .domains = CHV_DISPLAY_POWER_DOMAINS,
2245 .id = CHV_DISP_PW_PIPE_A,
2246 .ops = &chv_pipe_power_well_ops, 2263 .ops = &chv_pipe_power_well_ops,
2264 .id = CHV_DISP_PW_PIPE_A,
2247 }, 2265 },
2248 { 2266 {
2249 .name = "dpio-common-bc", 2267 .name = "dpio-common-bc",
2250 .domains = CHV_DPIO_CMN_BC_POWER_DOMAINS, 2268 .domains = CHV_DPIO_CMN_BC_POWER_DOMAINS,
2251 .id = PUNIT_POWER_WELL_DPIO_CMN_BC,
2252 .ops = &chv_dpio_cmn_power_well_ops, 2269 .ops = &chv_dpio_cmn_power_well_ops,
2270 .id = PUNIT_POWER_WELL_DPIO_CMN_BC,
2271 {
2272 .vlv.idx = PUNIT_PWGT_IDX_DPIO_CMN_BC,
2273 },
2253 }, 2274 },
2254 { 2275 {
2255 .name = "dpio-common-d", 2276 .name = "dpio-common-d",
2256 .domains = CHV_DPIO_CMN_D_POWER_DOMAINS, 2277 .domains = CHV_DPIO_CMN_D_POWER_DOMAINS,
2257 .id = PUNIT_POWER_WELL_DPIO_CMN_D,
2258 .ops = &chv_dpio_cmn_power_well_ops, 2278 .ops = &chv_dpio_cmn_power_well_ops,
2279 .id = PUNIT_POWER_WELL_DPIO_CMN_D,
2280 {
2281 .vlv.idx = PUNIT_PWGT_IDX_DPIO_CMN_D,
2282 },
2259 }, 2283 },
2260}; 2284};
2261 2285