2021-01-08 19:44:09 +02:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
/*
|
|
|
|
* Copyright © 2020 Intel Corporation
|
|
|
|
*/
|
|
|
|
|
2024-08-27 13:45:21 +03:00
|
|
|
#include <linux/debugfs.h>
|
|
|
|
|
2025-06-26 13:16:36 +03:00
|
|
|
#include <drm/drm_print.h>
|
|
|
|
|
2021-03-18 18:10:13 +02:00
|
|
|
#include "g4x_dp.h"
|
2022-11-09 17:35:22 +02:00
|
|
|
#include "i915_reg.h"
|
2025-06-26 13:16:36 +03:00
|
|
|
#include "i915_utils.h"
|
2021-04-30 17:39:44 +03:00
|
|
|
#include "intel_de.h"
|
2022-04-15 00:06:40 +03:00
|
|
|
#include "intel_display_power_well.h"
|
2025-06-06 13:22:56 +03:00
|
|
|
#include "intel_display_regs.h"
|
2021-01-08 19:44:09 +02:00
|
|
|
#include "intel_display_types.h"
|
|
|
|
#include "intel_dp.h"
|
2022-11-02 12:08:13 +02:00
|
|
|
#include "intel_dpio_phy.h"
|
2021-02-05 16:48:40 +02:00
|
|
|
#include "intel_dpll.h"
|
2021-09-30 12:22:59 +03:00
|
|
|
#include "intel_lvds.h"
|
2023-01-31 11:00:52 +02:00
|
|
|
#include "intel_lvds_regs.h"
|
2021-01-08 19:44:09 +02:00
|
|
|
#include "intel_pps.h"
|
2023-03-16 15:29:30 +02:00
|
|
|
#include "intel_pps_regs.h"
|
2022-08-29 16:18:21 +03:00
|
|
|
#include "intel_quirks.h"
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
static void vlv_steal_power_sequencer(struct intel_display *display,
|
2021-01-08 19:44:09 +02:00
|
|
|
enum pipe pipe);
|
2021-01-08 19:44:21 +02:00
|
|
|
|
|
|
|
static void pps_init_delays(struct intel_dp *intel_dp);
|
|
|
|
static void pps_init_registers(struct intel_dp *intel_dp, bool force_disable_vdd);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:44 +03:00
|
|
|
static const char *pps_name(struct intel_dp *intel_dp)
|
2022-11-27 17:52:39 +02:00
|
|
|
{
|
2024-08-30 13:15:44 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
|
|
|
struct intel_pps *pps = &intel_dp->pps;
|
|
|
|
|
2024-10-28 21:48:45 +02:00
|
|
|
if (display->platform.valleyview || display->platform.cherryview) {
|
2024-09-18 20:47:41 +03:00
|
|
|
switch (pps->vlv_pps_pipe) {
|
2022-11-27 17:52:39 +02:00
|
|
|
case INVALID_PIPE:
|
|
|
|
/*
|
|
|
|
* FIXME would be nice if we can guarantee
|
|
|
|
* to always have a valid PPS when calling this.
|
|
|
|
*/
|
|
|
|
return "PPS <none>";
|
|
|
|
case PIPE_A:
|
|
|
|
return "PPS A";
|
|
|
|
case PIPE_B:
|
|
|
|
return "PPS B";
|
|
|
|
default:
|
2024-09-18 20:47:41 +03:00
|
|
|
MISSING_CASE(pps->vlv_pps_pipe);
|
2022-11-27 17:52:39 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (pps->pps_idx) {
|
|
|
|
case 0:
|
|
|
|
return "PPS 0";
|
|
|
|
case 1:
|
|
|
|
return "PPS 1";
|
|
|
|
default:
|
|
|
|
MISSING_CASE(pps->pps_idx);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return "PPS <invalid>";
|
|
|
|
}
|
|
|
|
|
2021-01-08 19:44:10 +02:00
|
|
|
intel_wakeref_t intel_pps_lock(struct intel_dp *intel_dp)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
|
|
|
|
/*
|
2024-09-19 12:04:27 +03:00
|
|
|
* See vlv_pps_reset_all() why we need a power domain reference here.
|
2021-01-08 19:44:09 +02:00
|
|
|
*/
|
2025-02-06 20:55:27 +02:00
|
|
|
wakeref = intel_display_power_get(display, POWER_DOMAIN_DISPLAY_CORE);
|
2024-08-30 13:15:45 +03:00
|
|
|
mutex_lock(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
return wakeref;
|
|
|
|
}
|
|
|
|
|
2021-01-08 19:44:10 +02:00
|
|
|
intel_wakeref_t intel_pps_unlock(struct intel_dp *intel_dp,
|
|
|
|
intel_wakeref_t wakeref)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
mutex_unlock(&display->pps.mutex);
|
2025-02-06 20:55:27 +02:00
|
|
|
intel_display_power_put(display, POWER_DOMAIN_DISPLAY_CORE, wakeref);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-10-02 21:16:55 +03:00
|
|
|
return NULL;
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vlv_power_sequencer_kick(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
|
2024-09-18 20:47:41 +03:00
|
|
|
enum pipe pipe = intel_dp->pps.vlv_pps_pipe;
|
2021-01-08 19:44:09 +02:00
|
|
|
bool pll_enabled, release_cl_override = false;
|
2023-11-14 12:45:33 +02:00
|
|
|
enum dpio_phy phy = vlv_pipe_to_phy(pipe);
|
2021-01-08 19:44:09 +02:00
|
|
|
enum dpio_channel ch = vlv_pipe_to_channel(pipe);
|
|
|
|
u32 DP;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
if (drm_WARN(display->drm,
|
|
|
|
intel_de_read(display, intel_dp->output_reg) & DP_PORT_EN,
|
2022-11-27 17:52:39 +02:00
|
|
|
"skipping %s kick due to [ENCODER:%d:%s] being active\n",
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp),
|
2022-11-27 17:52:39 +02:00
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name))
|
2021-01-08 19:44:09 +02:00
|
|
|
return;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-11-27 17:52:39 +02:00
|
|
|
"kicking %s for [ENCODER:%d:%s]\n",
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp),
|
2022-11-27 17:52:39 +02:00
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/* Preserve the BIOS-computed detected bit. This is
|
|
|
|
* supposed to be read-only.
|
|
|
|
*/
|
2024-08-30 13:15:45 +03:00
|
|
|
DP = intel_de_read(display, intel_dp->output_reg) & DP_DETECTED;
|
2021-01-08 19:44:09 +02:00
|
|
|
DP |= DP_VOLTAGE_0_4 | DP_PRE_EMPHASIS_0;
|
|
|
|
DP |= DP_PORT_WIDTH(1);
|
|
|
|
DP |= DP_LINK_TRAIN_PAT_1;
|
|
|
|
|
2024-10-28 21:48:45 +02:00
|
|
|
if (display->platform.cherryview)
|
2021-01-08 19:44:09 +02:00
|
|
|
DP |= DP_PIPE_SEL_CHV(pipe);
|
|
|
|
else
|
|
|
|
DP |= DP_PIPE_SEL(pipe);
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
pll_enabled = intel_de_read(display, DPLL(display, pipe)) & DPLL_VCO_ENABLE;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The DPLL for the pipe must be enabled for this to work.
|
|
|
|
* So enable temporarily it if it's not already enabled.
|
|
|
|
*/
|
|
|
|
if (!pll_enabled) {
|
2024-10-28 21:48:45 +02:00
|
|
|
release_cl_override = display->platform.cherryview &&
|
2024-11-28 17:38:21 +02:00
|
|
|
!chv_phy_powergate_ch(display, phy, ch, true);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2025-03-25 14:36:33 +02:00
|
|
|
if (vlv_force_pll_on(display, pipe, vlv_get_dpll(display))) {
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_err(display->drm,
|
2022-11-27 17:52:39 +02:00
|
|
|
"Failed to force on PLL for pipe %c!\n",
|
2021-01-08 19:44:09 +02:00
|
|
|
pipe_name(pipe));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Similar magic as in intel_dp_enable_port().
|
|
|
|
* We _must_ do this port enable + disable trick
|
|
|
|
* to make this power sequencer lock onto the port.
|
|
|
|
* Otherwise even VDD force bit won't work.
|
|
|
|
*/
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_write(display, intel_dp->output_reg, DP);
|
|
|
|
intel_de_posting_read(display, intel_dp->output_reg);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_write(display, intel_dp->output_reg, DP | DP_PORT_EN);
|
|
|
|
intel_de_posting_read(display, intel_dp->output_reg);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_write(display, intel_dp->output_reg, DP & ~DP_PORT_EN);
|
|
|
|
intel_de_posting_read(display, intel_dp->output_reg);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
if (!pll_enabled) {
|
2025-03-25 14:36:33 +02:00
|
|
|
vlv_force_pll_off(display, pipe);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
if (release_cl_override)
|
2024-11-28 17:38:21 +02:00
|
|
|
chv_phy_powergate_ch(display, phy, ch, false);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
static enum pipe vlv_find_free_pps(struct intel_display *display)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
|
|
|
struct intel_encoder *encoder;
|
|
|
|
unsigned int pipes = (1 << PIPE_A) | (1 << PIPE_B);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't have power sequencer currently.
|
|
|
|
* Pick one that's not used by other ports.
|
|
|
|
*/
|
2024-08-30 13:15:45 +03:00
|
|
|
for_each_intel_dp(display->drm, encoder) {
|
2021-01-08 19:44:09 +02:00
|
|
|
struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
|
|
|
|
|
|
|
|
if (encoder->type == INTEL_OUTPUT_EDP) {
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_WARN_ON(display->drm,
|
2024-09-18 20:47:41 +03:00
|
|
|
intel_dp->pps.vlv_active_pipe != INVALID_PIPE &&
|
|
|
|
intel_dp->pps.vlv_active_pipe !=
|
|
|
|
intel_dp->pps.vlv_pps_pipe);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-09-18 20:47:41 +03:00
|
|
|
if (intel_dp->pps.vlv_pps_pipe != INVALID_PIPE)
|
|
|
|
pipes &= ~(1 << intel_dp->pps.vlv_pps_pipe);
|
2021-01-08 19:44:09 +02:00
|
|
|
} else {
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_WARN_ON(display->drm,
|
2024-09-18 20:47:41 +03:00
|
|
|
intel_dp->pps.vlv_pps_pipe != INVALID_PIPE);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-09-18 20:47:41 +03:00
|
|
|
if (intel_dp->pps.vlv_active_pipe != INVALID_PIPE)
|
|
|
|
pipes &= ~(1 << intel_dp->pps.vlv_active_pipe);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pipes == 0)
|
|
|
|
return INVALID_PIPE;
|
|
|
|
|
|
|
|
return ffs(pipes) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum pipe
|
|
|
|
vlv_power_sequencer_pipe(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
|
|
|
|
enum pipe pipe;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/* We should never land here with regular DP ports */
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_WARN_ON(display->drm, !intel_dp_is_edp(intel_dp));
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-09-18 20:47:41 +03:00
|
|
|
drm_WARN_ON(display->drm, intel_dp->pps.vlv_active_pipe != INVALID_PIPE &&
|
|
|
|
intel_dp->pps.vlv_active_pipe != intel_dp->pps.vlv_pps_pipe);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-09-18 20:47:41 +03:00
|
|
|
if (intel_dp->pps.vlv_pps_pipe != INVALID_PIPE)
|
|
|
|
return intel_dp->pps.vlv_pps_pipe;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
pipe = vlv_find_free_pps(display);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Didn't find one. This should not happen since there
|
|
|
|
* are two power sequencers and up to two eDP ports.
|
|
|
|
*/
|
2024-08-30 13:15:45 +03:00
|
|
|
if (drm_WARN_ON(display->drm, pipe == INVALID_PIPE))
|
2021-01-08 19:44:09 +02:00
|
|
|
pipe = PIPE_A;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
vlv_steal_power_sequencer(display, pipe);
|
2024-09-18 20:47:41 +03:00
|
|
|
intel_dp->pps.vlv_pps_pipe = pipe;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-11-27 17:52:39 +02:00
|
|
|
"picked %s for [ENCODER:%d:%s]\n",
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp),
|
2022-11-27 17:52:39 +02:00
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/* init power sequencer on this pipe and port */
|
2021-01-08 19:44:21 +02:00
|
|
|
pps_init_delays(intel_dp);
|
|
|
|
pps_init_registers(intel_dp, true);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Even vdd force doesn't work until we've made
|
|
|
|
* the power sequencer lock in on the port.
|
|
|
|
*/
|
|
|
|
vlv_power_sequencer_kick(intel_dp);
|
|
|
|
|
2024-09-18 20:47:41 +03:00
|
|
|
return intel_dp->pps.vlv_pps_pipe;
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
bxt_power_sequencer_idx(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2022-11-25 19:31:51 +02:00
|
|
|
int pps_idx = intel_dp->pps.pps_idx;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/* We should never land here with regular DP ports */
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_WARN_ON(display->drm, !intel_dp_is_edp(intel_dp));
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-09-18 20:47:42 +03:00
|
|
|
if (!intel_dp->pps.bxt_pps_reset)
|
2022-11-25 19:31:51 +02:00
|
|
|
return pps_idx;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-09-18 20:47:42 +03:00
|
|
|
intel_dp->pps.bxt_pps_reset = false;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Only the HW needs to be reprogrammed, the SW state is fixed and
|
|
|
|
* has been setup during connector init.
|
|
|
|
*/
|
2021-01-08 19:44:21 +02:00
|
|
|
pps_init_registers(intel_dp, false);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2022-11-25 19:31:51 +02:00
|
|
|
return pps_idx;
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
typedef bool (*pps_check)(struct intel_display *display, int pps_idx);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
static bool pps_has_pp_on(struct intel_display *display, int pps_idx)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
return intel_de_read(display, PP_STATUS(display, pps_idx)) & PP_ON;
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
static bool pps_has_vdd_on(struct intel_display *display, int pps_idx)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
return intel_de_read(display, PP_CONTROL(display, pps_idx)) & EDP_FORCE_VDD;
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
static bool pps_any(struct intel_display *display, int pps_idx)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum pipe
|
2024-08-30 13:15:45 +03:00
|
|
|
vlv_initial_pps_pipe(struct intel_display *display,
|
2022-11-25 19:31:50 +02:00
|
|
|
enum port port, pps_check check)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
|
|
|
enum pipe pipe;
|
|
|
|
|
|
|
|
for (pipe = PIPE_A; pipe <= PIPE_B; pipe++) {
|
2024-08-30 13:15:45 +03:00
|
|
|
u32 port_sel = intel_de_read(display,
|
|
|
|
PP_ON_DELAYS(display, pipe)) &
|
2021-01-08 19:44:09 +02:00
|
|
|
PANEL_PORT_SELECT_MASK;
|
|
|
|
|
|
|
|
if (port_sel != PANEL_PORT_SELECT_VLV(port))
|
|
|
|
continue;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
if (!check(display, pipe))
|
2021-01-08 19:44:09 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
return pipe;
|
|
|
|
}
|
|
|
|
|
|
|
|
return INVALID_PIPE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vlv_initial_power_sequencer_setup(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
|
|
|
|
enum port port = dig_port->base.port;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/* try to find a pipe with this port selected */
|
|
|
|
/* first pick one where the panel is on */
|
2024-09-18 20:47:41 +03:00
|
|
|
intel_dp->pps.vlv_pps_pipe = vlv_initial_pps_pipe(display, port,
|
|
|
|
pps_has_pp_on);
|
2021-01-08 19:44:09 +02:00
|
|
|
/* didn't find one? pick one where vdd is on */
|
2024-09-18 20:47:41 +03:00
|
|
|
if (intel_dp->pps.vlv_pps_pipe == INVALID_PIPE)
|
|
|
|
intel_dp->pps.vlv_pps_pipe = vlv_initial_pps_pipe(display, port,
|
|
|
|
pps_has_vdd_on);
|
2021-01-08 19:44:09 +02:00
|
|
|
/* didn't find one? pick one with just the correct port */
|
2024-09-18 20:47:41 +03:00
|
|
|
if (intel_dp->pps.vlv_pps_pipe == INVALID_PIPE)
|
|
|
|
intel_dp->pps.vlv_pps_pipe = vlv_initial_pps_pipe(display, port,
|
|
|
|
pps_any);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/* didn't find one? just let vlv_power_sequencer_pipe() pick one when needed */
|
2024-09-18 20:47:41 +03:00
|
|
|
if (intel_dp->pps.vlv_pps_pipe == INVALID_PIPE) {
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-11-27 17:52:39 +02:00
|
|
|
"[ENCODER:%d:%s] no initial power sequencer\n",
|
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name);
|
2021-01-08 19:44:09 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-11-27 17:52:39 +02:00
|
|
|
"[ENCODER:%d:%s] initial power sequencer: %s\n",
|
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp));
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
static int intel_num_pps(struct intel_display *display)
|
2022-11-25 19:31:52 +02:00
|
|
|
{
|
2024-10-28 21:48:45 +02:00
|
|
|
if (display->platform.valleyview || display->platform.cherryview)
|
2022-11-25 19:31:52 +02:00
|
|
|
return 2;
|
|
|
|
|
2024-10-28 21:48:45 +02:00
|
|
|
if (display->platform.geminilake || display->platform.broxton)
|
2022-11-25 19:31:52 +02:00
|
|
|
return 2;
|
|
|
|
|
2025-04-17 12:10:36 +03:00
|
|
|
if (INTEL_PCH_TYPE(display) >= PCH_MTL)
|
2024-08-01 16:41:41 +05:30
|
|
|
return 2;
|
|
|
|
|
2025-04-17 12:10:36 +03:00
|
|
|
if (INTEL_PCH_TYPE(display) >= PCH_DG1)
|
2022-11-25 19:31:52 +02:00
|
|
|
return 1;
|
|
|
|
|
2025-04-17 12:10:36 +03:00
|
|
|
if (INTEL_PCH_TYPE(display) >= PCH_ICP)
|
2022-11-25 19:31:52 +02:00
|
|
|
return 2;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2022-11-25 19:31:53 +02:00
|
|
|
static bool intel_pps_is_valid(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2022-11-25 19:31:53 +02:00
|
|
|
|
|
|
|
if (intel_dp->pps.pps_idx == 1 &&
|
2025-04-17 12:10:36 +03:00
|
|
|
INTEL_PCH_TYPE(display) >= PCH_ICP &&
|
|
|
|
INTEL_PCH_TYPE(display) <= PCH_ADP)
|
2024-08-30 13:15:45 +03:00
|
|
|
return intel_de_read(display, SOUTH_CHICKEN1) & ICP_SECOND_PPS_IO_SELECT;
|
2022-11-25 19:31:53 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-11-25 19:31:51 +02:00
|
|
|
static int
|
2024-08-30 13:15:45 +03:00
|
|
|
bxt_initial_pps_idx(struct intel_display *display, pps_check check)
|
2022-11-25 19:31:51 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
int pps_idx, pps_num = intel_num_pps(display);
|
2022-11-25 19:31:51 +02:00
|
|
|
|
|
|
|
for (pps_idx = 0; pps_idx < pps_num; pps_idx++) {
|
2024-08-30 13:15:45 +03:00
|
|
|
if (check(display, pps_idx))
|
2022-11-25 19:31:51 +02:00
|
|
|
return pps_idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-11-25 19:31:53 +02:00
|
|
|
static bool
|
2022-11-25 19:31:51 +02:00
|
|
|
pps_initial_setup(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2022-11-25 19:31:51 +02:00
|
|
|
struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
|
|
|
|
struct intel_connector *connector = intel_dp->attached_connector;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2022-11-25 19:31:51 +02:00
|
|
|
|
2024-10-28 21:48:45 +02:00
|
|
|
if (display->platform.valleyview || display->platform.cherryview) {
|
2022-11-25 19:31:51 +02:00
|
|
|
vlv_initial_power_sequencer_setup(intel_dp);
|
2022-11-25 19:31:53 +02:00
|
|
|
return true;
|
2022-11-25 19:31:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* first ask the VBT */
|
2024-08-30 13:15:45 +03:00
|
|
|
if (intel_num_pps(display) > 1)
|
2022-11-25 19:31:52 +02:00
|
|
|
intel_dp->pps.pps_idx = connector->panel.vbt.backlight.controller;
|
|
|
|
else
|
|
|
|
intel_dp->pps.pps_idx = 0;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
if (drm_WARN_ON(display->drm, intel_dp->pps.pps_idx >= intel_num_pps(display)))
|
2022-11-25 19:31:51 +02:00
|
|
|
intel_dp->pps.pps_idx = -1;
|
|
|
|
|
|
|
|
/* VBT wasn't parsed yet? pick one where the panel is on */
|
|
|
|
if (intel_dp->pps.pps_idx < 0)
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_dp->pps.pps_idx = bxt_initial_pps_idx(display, pps_has_pp_on);
|
2022-11-25 19:31:51 +02:00
|
|
|
/* didn't find one? pick one where vdd is on */
|
|
|
|
if (intel_dp->pps.pps_idx < 0)
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_dp->pps.pps_idx = bxt_initial_pps_idx(display, pps_has_vdd_on);
|
2022-11-25 19:31:51 +02:00
|
|
|
/* didn't find one? pick any */
|
|
|
|
if (intel_dp->pps.pps_idx < 0) {
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_dp->pps.pps_idx = bxt_initial_pps_idx(display, pps_any);
|
2022-11-25 19:31:51 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-11-27 17:52:39 +02:00
|
|
|
"[ENCODER:%d:%s] no initial power sequencer, assuming %s\n",
|
2022-11-25 19:31:51 +02:00
|
|
|
encoder->base.base.id, encoder->base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp));
|
2022-11-25 19:31:53 +02:00
|
|
|
} else {
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-11-27 17:52:39 +02:00
|
|
|
"[ENCODER:%d:%s] initial power sequencer: %s\n",
|
2022-11-25 19:31:53 +02:00
|
|
|
encoder->base.base.id, encoder->base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp));
|
2022-11-25 19:31:51 +02:00
|
|
|
}
|
|
|
|
|
2022-11-25 19:31:53 +02:00
|
|
|
return intel_pps_is_valid(intel_dp);
|
2022-11-25 19:31:51 +02:00
|
|
|
}
|
|
|
|
|
2024-09-19 12:04:27 +03:00
|
|
|
void vlv_pps_reset_all(struct intel_display *display)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
|
|
|
struct intel_encoder *encoder;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
if (!HAS_DISPLAY(display))
|
drm/i915: skip display initialization when there is no display
Display features should not be initialized or de-initialized when there
is no display. Skip modeset initialization, output setup, plane, crtc,
encoder, connector registration, display cdclk and rawclk
initialization, display core initialization, etc.
Skip the functionality at as high level as possible, and remove any
redundant checks. If the functionality is conditional to *other* display
checks, do not add more. If the un-initialization has checks for
initialization, do not add more.
We explicitly do not care about any GMCH/VLV/CHV code paths, as they've
always had and will have display.
Reviewed-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210408203150.237947-3-jose.souza@intel.com
2021-04-08 13:31:50 -07:00
|
|
|
return;
|
|
|
|
|
2021-01-08 19:44:09 +02:00
|
|
|
/*
|
|
|
|
* We can't grab pps_mutex here due to deadlock with power_domain
|
|
|
|
* mutex when power_domain functions are called while holding pps_mutex.
|
2024-09-18 20:47:41 +03:00
|
|
|
* That also means that in order to use vlv_pps_pipe the code needs to
|
2021-01-08 19:44:09 +02:00
|
|
|
* hold both a power domain reference and pps_mutex, and the power domain
|
|
|
|
* reference get/put must be done while _not_ holding pps_mutex.
|
|
|
|
* pps_{lock,unlock}() do these steps in the correct order, so one
|
|
|
|
* should use them always.
|
|
|
|
*/
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
for_each_intel_dp(display->drm, encoder) {
|
2021-01-08 19:44:09 +02:00
|
|
|
struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
|
|
|
|
|
2024-09-19 12:04:27 +03:00
|
|
|
drm_WARN_ON(display->drm, intel_dp->pps.vlv_active_pipe != INVALID_PIPE);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-09-19 12:04:27 +03:00
|
|
|
if (encoder->type == INTEL_OUTPUT_EDP)
|
2024-09-18 20:47:41 +03:00
|
|
|
intel_dp->pps.vlv_pps_pipe = INVALID_PIPE;
|
2024-09-19 12:04:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void bxt_pps_reset_all(struct intel_display *display)
|
|
|
|
{
|
|
|
|
struct intel_encoder *encoder;
|
|
|
|
|
|
|
|
if (!HAS_DISPLAY(display))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* See vlv_pps_reset_all() for why we can't grab pps_mutex here. */
|
|
|
|
|
|
|
|
for_each_intel_dp(display->drm, encoder) {
|
|
|
|
struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
|
|
|
|
|
|
|
|
if (encoder->type == INTEL_OUTPUT_EDP)
|
2024-09-18 20:47:43 +03:00
|
|
|
intel_dp->pps.bxt_pps_reset = true;
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct pps_registers {
|
|
|
|
i915_reg_t pp_ctrl;
|
|
|
|
i915_reg_t pp_stat;
|
|
|
|
i915_reg_t pp_on;
|
|
|
|
i915_reg_t pp_off;
|
|
|
|
i915_reg_t pp_div;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void intel_pps_get_registers(struct intel_dp *intel_dp,
|
|
|
|
struct pps_registers *regs)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2022-11-25 19:31:52 +02:00
|
|
|
int pps_idx;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
memset(regs, 0, sizeof(*regs));
|
|
|
|
|
2024-10-28 21:48:45 +02:00
|
|
|
if (display->platform.valleyview || display->platform.cherryview)
|
2021-01-08 19:44:09 +02:00
|
|
|
pps_idx = vlv_power_sequencer_pipe(intel_dp);
|
2024-10-28 21:48:45 +02:00
|
|
|
else if (display->platform.geminilake || display->platform.broxton)
|
2022-11-25 19:31:51 +02:00
|
|
|
pps_idx = bxt_power_sequencer_idx(intel_dp);
|
2022-11-25 19:31:52 +02:00
|
|
|
else
|
|
|
|
pps_idx = intel_dp->pps.pps_idx;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
regs->pp_ctrl = PP_CONTROL(display, pps_idx);
|
|
|
|
regs->pp_stat = PP_STATUS(display, pps_idx);
|
|
|
|
regs->pp_on = PP_ON_DELAYS(display, pps_idx);
|
|
|
|
regs->pp_off = PP_OFF_DELAYS(display, pps_idx);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/* Cycle delay moved from PP_DIVISOR to PP_CONTROL */
|
2024-10-28 21:48:45 +02:00
|
|
|
if (display->platform.geminilake || display->platform.broxton ||
|
2025-04-17 12:10:36 +03:00
|
|
|
INTEL_PCH_TYPE(display) >= PCH_CNP)
|
2021-01-08 19:44:09 +02:00
|
|
|
regs->pp_div = INVALID_MMIO_REG;
|
|
|
|
else
|
2024-08-30 13:15:45 +03:00
|
|
|
regs->pp_div = PP_DIVISOR(display, pps_idx);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static i915_reg_t
|
|
|
|
_pp_ctrl_reg(struct intel_dp *intel_dp)
|
|
|
|
{
|
|
|
|
struct pps_registers regs;
|
|
|
|
|
|
|
|
intel_pps_get_registers(intel_dp, ®s);
|
|
|
|
|
|
|
|
return regs.pp_ctrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
static i915_reg_t
|
|
|
|
_pp_stat_reg(struct intel_dp *intel_dp)
|
|
|
|
{
|
|
|
|
struct pps_registers regs;
|
|
|
|
|
|
|
|
intel_pps_get_registers(intel_dp, ®s);
|
|
|
|
|
|
|
|
return regs.pp_stat;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool edp_have_panel_power(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-10-28 21:48:45 +02:00
|
|
|
if ((display->platform.valleyview || display->platform.cherryview) &&
|
2024-09-18 20:47:41 +03:00
|
|
|
intel_dp->pps.vlv_pps_pipe == INVALID_PIPE)
|
2021-01-08 19:44:09 +02:00
|
|
|
return false;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
return (intel_de_read(display, _pp_stat_reg(intel_dp)) & PP_ON) != 0;
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool edp_have_panel_vdd(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-10-28 21:48:45 +02:00
|
|
|
if ((display->platform.valleyview || display->platform.cherryview) &&
|
2024-09-18 20:47:41 +03:00
|
|
|
intel_dp->pps.vlv_pps_pipe == INVALID_PIPE)
|
2021-01-08 19:44:09 +02:00
|
|
|
return false;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
return intel_de_read(display, _pp_ctrl_reg(intel_dp)) & EDP_FORCE_VDD;
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2021-01-08 19:44:17 +02:00
|
|
|
void intel_pps_check_power_unlocked(struct intel_dp *intel_dp)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2022-11-27 17:52:39 +02:00
|
|
|
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
if (!intel_dp_is_edp(intel_dp))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!edp_have_panel_power(intel_dp) && !edp_have_panel_vdd(intel_dp)) {
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_WARN(display->drm, 1,
|
2022-11-27 17:52:39 +02:00
|
|
|
"[ENCODER:%d:%s] %s powered off while attempting AUX CH communication.\n",
|
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp));
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-11-27 17:52:39 +02:00
|
|
|
"[ENCODER:%d:%s] %s PP_STATUS: 0x%08x PP_CONTROL: 0x%08x\n",
|
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp),
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_read(display, _pp_stat_reg(intel_dp)),
|
|
|
|
intel_de_read(display, _pp_ctrl_reg(intel_dp)));
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define IDLE_ON_MASK (PP_ON | PP_SEQUENCE_MASK | 0 | PP_SEQUENCE_STATE_MASK)
|
2022-11-25 19:31:55 +02:00
|
|
|
#define IDLE_ON_VALUE (PP_ON | PP_SEQUENCE_NONE | 0 | PP_SEQUENCE_STATE_ON_IDLE)
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
#define IDLE_OFF_MASK (PP_ON | PP_SEQUENCE_MASK | 0 | 0)
|
|
|
|
#define IDLE_OFF_VALUE (0 | PP_SEQUENCE_NONE | 0 | 0)
|
|
|
|
|
|
|
|
#define IDLE_CYCLE_MASK (PP_ON | PP_SEQUENCE_MASK | PP_CYCLE_DELAY_ACTIVE | PP_SEQUENCE_STATE_MASK)
|
|
|
|
#define IDLE_CYCLE_VALUE (0 | PP_SEQUENCE_NONE | 0 | PP_SEQUENCE_STATE_OFF_IDLE)
|
|
|
|
|
|
|
|
static void intel_pps_verify_state(struct intel_dp *intel_dp);
|
|
|
|
|
|
|
|
static void wait_panel_status(struct intel_dp *intel_dp,
|
2022-11-27 17:52:39 +02:00
|
|
|
u32 mask, u32 value)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2022-11-27 17:52:39 +02:00
|
|
|
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
i915_reg_t pp_stat_reg, pp_ctrl_reg;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
intel_pps_verify_state(intel_dp);
|
|
|
|
|
|
|
|
pp_stat_reg = _pp_stat_reg(intel_dp);
|
|
|
|
pp_ctrl_reg = _pp_ctrl_reg(intel_dp);
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-11-27 17:52:39 +02:00
|
|
|
"[ENCODER:%d:%s] %s mask: 0x%08x value: 0x%08x PP_STATUS: 0x%08x PP_CONTROL: 0x%08x\n",
|
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp),
|
2021-01-08 19:44:09 +02:00
|
|
|
mask, value,
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_read(display, pp_stat_reg),
|
|
|
|
intel_de_read(display, pp_ctrl_reg));
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
if (intel_de_wait(display, pp_stat_reg, mask, value, 5000))
|
|
|
|
drm_err(display->drm,
|
2022-11-27 17:52:39 +02:00
|
|
|
"[ENCODER:%d:%s] %s panel status timeout: PP_STATUS: 0x%08x PP_CONTROL: 0x%08x\n",
|
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp),
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_read(display, pp_stat_reg),
|
|
|
|
intel_de_read(display, pp_ctrl_reg));
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm, "Wait complete\n");
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void wait_panel_on(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2022-11-27 17:52:39 +02:00
|
|
|
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
|
|
|
"[ENCODER:%d:%s] %s wait for panel power on\n",
|
2022-11-27 17:52:39 +02:00
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp));
|
2021-01-08 19:44:09 +02:00
|
|
|
wait_panel_status(intel_dp, IDLE_ON_MASK, IDLE_ON_VALUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wait_panel_off(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2022-11-27 17:52:39 +02:00
|
|
|
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
|
|
|
"[ENCODER:%d:%s] %s wait for panel power off time\n",
|
2022-11-27 17:52:39 +02:00
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp));
|
2021-01-08 19:44:09 +02:00
|
|
|
wait_panel_status(intel_dp, IDLE_OFF_MASK, IDLE_OFF_VALUE);
|
|
|
|
}
|
|
|
|
|
2021-01-08 19:44:19 +02:00
|
|
|
static void wait_panel_power_cycle(struct intel_dp *intel_dp)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2022-11-27 17:52:39 +02:00
|
|
|
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
ktime_t panel_power_on_time;
|
2024-12-04 18:00:48 +02:00
|
|
|
s64 panel_power_off_duration, remaining;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2022-05-21 13:11:40 +02:00
|
|
|
/* take the difference of current time and panel power off time
|
2024-11-06 23:58:54 +02:00
|
|
|
* and then make panel wait for power_cycle if needed. */
|
2021-01-08 19:44:09 +02:00
|
|
|
panel_power_on_time = ktime_get_boottime();
|
2021-01-20 12:18:33 +02:00
|
|
|
panel_power_off_duration = ktime_ms_delta(panel_power_on_time, intel_dp->pps.panel_power_off_time);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-12-04 18:00:48 +02:00
|
|
|
remaining = max(0, intel_dp->pps.panel_power_cycle_delay - panel_power_off_duration);
|
|
|
|
|
|
|
|
drm_dbg_kms(display->drm,
|
|
|
|
"[ENCODER:%d:%s] %s wait for panel power cycle (%lld ms remaining)\n",
|
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name,
|
|
|
|
pps_name(intel_dp), remaining);
|
|
|
|
|
2021-01-08 19:44:09 +02:00
|
|
|
/* When we disable the VDD override bit last we have to do the manual
|
|
|
|
* wait. */
|
2024-12-04 18:00:48 +02:00
|
|
|
if (remaining)
|
|
|
|
wait_remaining_ms_from_jiffies(jiffies, remaining);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
wait_panel_status(intel_dp, IDLE_CYCLE_MASK, IDLE_CYCLE_VALUE);
|
|
|
|
}
|
|
|
|
|
2021-01-08 19:44:19 +02:00
|
|
|
void intel_pps_wait_power_cycle(struct intel_dp *intel_dp)
|
|
|
|
{
|
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
|
|
|
|
if (!intel_dp_is_edp(intel_dp))
|
|
|
|
return;
|
|
|
|
|
|
|
|
with_intel_pps_lock(intel_dp, wakeref)
|
|
|
|
wait_panel_power_cycle(intel_dp);
|
|
|
|
}
|
|
|
|
|
2021-01-08 19:44:09 +02:00
|
|
|
static void wait_backlight_on(struct intel_dp *intel_dp)
|
|
|
|
{
|
2021-01-20 12:18:33 +02:00
|
|
|
wait_remaining_ms_from_jiffies(intel_dp->pps.last_power_on,
|
|
|
|
intel_dp->pps.backlight_on_delay);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void edp_wait_backlight_off(struct intel_dp *intel_dp)
|
|
|
|
{
|
2021-01-20 12:18:33 +02:00
|
|
|
wait_remaining_ms_from_jiffies(intel_dp->pps.last_backlight_off,
|
|
|
|
intel_dp->pps.backlight_off_delay);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Read the current pp_control value, unlocking the register if it
|
|
|
|
* is locked
|
|
|
|
*/
|
|
|
|
|
|
|
|
static u32 ilk_get_pp_control(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
u32 control;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
control = intel_de_read(display, _pp_ctrl_reg(intel_dp));
|
|
|
|
if (drm_WARN_ON(display->drm, !HAS_DDI(display) &&
|
2021-01-08 19:44:09 +02:00
|
|
|
(control & PANEL_UNLOCK_MASK) != PANEL_UNLOCK_REGS)) {
|
|
|
|
control &= ~PANEL_UNLOCK_MASK;
|
|
|
|
control |= PANEL_UNLOCK_REGS;
|
|
|
|
}
|
|
|
|
return control;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2021-01-08 19:44:13 +02:00
|
|
|
* Must be paired with intel_pps_vdd_off_unlocked().
|
2021-01-08 19:44:09 +02:00
|
|
|
* Must hold pps_mutex around the whole on/off sequence.
|
2021-01-08 19:44:12 +02:00
|
|
|
* Can be nested with intel_pps_vdd_{on,off}() calls.
|
2021-01-08 19:44:09 +02:00
|
|
|
*/
|
2021-01-08 19:44:13 +02:00
|
|
|
bool intel_pps_vdd_on_unlocked(struct intel_dp *intel_dp)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
|
|
|
|
u32 pp;
|
|
|
|
i915_reg_t pp_stat_reg, pp_ctrl_reg;
|
2021-01-20 12:18:33 +02:00
|
|
|
bool need_to_disable = !intel_dp->pps.want_panel_vdd;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
if (!intel_dp_is_edp(intel_dp))
|
|
|
|
return false;
|
|
|
|
|
2025-03-24 20:01:44 +02:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
|
|
|
|
2021-01-20 12:18:33 +02:00
|
|
|
cancel_delayed_work(&intel_dp->pps.panel_vdd_work);
|
|
|
|
intel_dp->pps.want_panel_vdd = true;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
if (edp_have_panel_vdd(intel_dp))
|
|
|
|
return need_to_disable;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_WARN_ON(display->drm, intel_dp->pps.vdd_wakeref);
|
2025-02-06 20:55:27 +02:00
|
|
|
intel_dp->pps.vdd_wakeref = intel_display_power_get(display,
|
2021-01-20 12:18:33 +02:00
|
|
|
intel_aux_power_domain(dig_port));
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2022-11-27 17:52:39 +02:00
|
|
|
pp_stat_reg = _pp_stat_reg(intel_dp);
|
|
|
|
pp_ctrl_reg = _pp_ctrl_reg(intel_dp);
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm, "[ENCODER:%d:%s] %s turning VDD on\n",
|
2022-11-27 17:52:39 +02:00
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp));
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
if (!edp_have_panel_power(intel_dp))
|
|
|
|
wait_panel_power_cycle(intel_dp);
|
|
|
|
|
|
|
|
pp = ilk_get_pp_control(intel_dp);
|
|
|
|
pp |= EDP_FORCE_VDD;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_write(display, pp_ctrl_reg, pp);
|
|
|
|
intel_de_posting_read(display, pp_ctrl_reg);
|
|
|
|
drm_dbg_kms(display->drm,
|
|
|
|
"[ENCODER:%d:%s] %s PP_STATUS: 0x%08x PP_CONTROL: 0x%08x\n",
|
2022-11-27 17:52:39 +02:00
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp),
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_read(display, pp_stat_reg),
|
|
|
|
intel_de_read(display, pp_ctrl_reg));
|
2021-01-08 19:44:09 +02:00
|
|
|
/*
|
|
|
|
* If the panel wasn't on, delay before accessing aux channel
|
|
|
|
*/
|
|
|
|
if (!edp_have_panel_power(intel_dp)) {
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-11-27 17:52:39 +02:00
|
|
|
"[ENCODER:%d:%s] %s panel power wasn't enabled\n",
|
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp));
|
2021-01-20 12:18:33 +02:00
|
|
|
msleep(intel_dp->pps.panel_power_up_delay);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return need_to_disable;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2024-10-25 19:02:53 +03:00
|
|
|
* Must be paired with intel_pps_vdd_off() or - to disable
|
|
|
|
* both VDD and panel power - intel_pps_off().
|
2021-01-08 19:44:09 +02:00
|
|
|
* Nested calls to these functions are not allowed since
|
|
|
|
* we drop the lock. Caller must use some higher level
|
|
|
|
* locking to prevent nested calls from other threads.
|
|
|
|
*/
|
2021-01-08 19:44:12 +02:00
|
|
|
void intel_pps_vdd_on(struct intel_dp *intel_dp)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
bool vdd;
|
|
|
|
|
|
|
|
if (!intel_dp_is_edp(intel_dp))
|
|
|
|
return;
|
|
|
|
|
|
|
|
vdd = false;
|
2021-01-08 19:44:10 +02:00
|
|
|
with_intel_pps_lock(intel_dp, wakeref)
|
2021-01-08 19:44:13 +02:00
|
|
|
vdd = intel_pps_vdd_on_unlocked(intel_dp);
|
2024-10-24 19:25:10 +03:00
|
|
|
INTEL_DISPLAY_STATE_WARN(display, !vdd, "[ENCODER:%d:%s] %s VDD already requested on\n",
|
|
|
|
dp_to_dig_port(intel_dp)->base.base.base.id,
|
|
|
|
dp_to_dig_port(intel_dp)->base.base.name,
|
|
|
|
pps_name(intel_dp));
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2021-01-08 19:44:14 +02:00
|
|
|
static void intel_pps_vdd_off_sync_unlocked(struct intel_dp *intel_dp)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
|
|
|
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
u32 pp;
|
|
|
|
i915_reg_t pp_stat_reg, pp_ctrl_reg;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_WARN_ON(display->drm, intel_dp->pps.want_panel_vdd);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
if (!edp_have_panel_vdd(intel_dp))
|
|
|
|
return;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm, "[ENCODER:%d:%s] %s turning VDD off\n",
|
2022-11-27 17:52:39 +02:00
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp));
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
pp = ilk_get_pp_control(intel_dp);
|
|
|
|
pp &= ~EDP_FORCE_VDD;
|
|
|
|
|
|
|
|
pp_ctrl_reg = _pp_ctrl_reg(intel_dp);
|
|
|
|
pp_stat_reg = _pp_stat_reg(intel_dp);
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_write(display, pp_ctrl_reg, pp);
|
|
|
|
intel_de_posting_read(display, pp_ctrl_reg);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/* Make sure sequencer is idle before allowing subsequent activity */
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
|
|
|
"[ENCODER:%d:%s] %s PP_STATUS: 0x%08x PP_CONTROL: 0x%08x\n",
|
2022-11-27 17:52:39 +02:00
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp),
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_read(display, pp_stat_reg),
|
|
|
|
intel_de_read(display, pp_ctrl_reg));
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-10-25 19:02:55 +03:00
|
|
|
if ((pp & PANEL_POWER_ON) == 0) {
|
2021-01-20 12:18:33 +02:00
|
|
|
intel_dp->pps.panel_power_off_time = ktime_get_boottime();
|
2024-10-25 19:02:55 +03:00
|
|
|
intel_dp_invalidate_source_oui(intel_dp);
|
|
|
|
}
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2025-02-06 20:55:27 +02:00
|
|
|
intel_display_power_put(display,
|
2021-01-08 19:44:09 +02:00
|
|
|
intel_aux_power_domain(dig_port),
|
2021-01-20 12:18:33 +02:00
|
|
|
fetch_and_zero(&intel_dp->pps.vdd_wakeref));
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2021-01-08 19:44:14 +02:00
|
|
|
void intel_pps_vdd_off_sync(struct intel_dp *intel_dp)
|
|
|
|
{
|
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
|
|
|
|
if (!intel_dp_is_edp(intel_dp))
|
|
|
|
return;
|
|
|
|
|
2021-01-20 12:18:33 +02:00
|
|
|
cancel_delayed_work_sync(&intel_dp->pps.panel_vdd_work);
|
2021-01-08 19:44:14 +02:00
|
|
|
/*
|
|
|
|
* vdd might still be enabled due to the delayed vdd off.
|
|
|
|
* Make sure vdd is actually turned off here.
|
|
|
|
*/
|
|
|
|
with_intel_pps_lock(intel_dp, wakeref)
|
|
|
|
intel_pps_vdd_off_sync_unlocked(intel_dp);
|
|
|
|
}
|
|
|
|
|
2021-01-08 19:44:15 +02:00
|
|
|
static void edp_panel_vdd_work(struct work_struct *__work)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2021-01-20 12:18:33 +02:00
|
|
|
struct intel_pps *pps = container_of(to_delayed_work(__work),
|
|
|
|
struct intel_pps, panel_vdd_work);
|
|
|
|
struct intel_dp *intel_dp = container_of(pps, struct intel_dp, pps);
|
2021-01-08 19:44:09 +02:00
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
|
2021-01-08 19:44:10 +02:00
|
|
|
with_intel_pps_lock(intel_dp, wakeref) {
|
2021-01-20 12:18:33 +02:00
|
|
|
if (!intel_dp->pps.want_panel_vdd)
|
2021-01-08 19:44:13 +02:00
|
|
|
intel_pps_vdd_off_sync_unlocked(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void edp_panel_vdd_schedule_off(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
unsigned long delay;
|
|
|
|
|
2022-05-10 13:42:36 +03:00
|
|
|
/*
|
|
|
|
* We may not yet know the real power sequencing delays,
|
|
|
|
* so keep VDD enabled until we're done with init.
|
|
|
|
*/
|
|
|
|
if (intel_dp->pps.initializing)
|
|
|
|
return;
|
|
|
|
|
2021-01-08 19:44:09 +02:00
|
|
|
/*
|
|
|
|
* Queue the timer to fire a long time from now (relative to the power
|
|
|
|
* down delay) to keep the panel power up across a sequence of
|
|
|
|
* operations.
|
|
|
|
*/
|
2021-01-20 12:18:33 +02:00
|
|
|
delay = msecs_to_jiffies(intel_dp->pps.panel_power_cycle_delay * 5);
|
2025-06-20 12:15:30 +03:00
|
|
|
queue_delayed_work(display->wq.unordered,
|
2023-06-08 16:35:45 +03:00
|
|
|
&intel_dp->pps.panel_vdd_work, delay);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Must be paired with edp_panel_vdd_on().
|
|
|
|
* Must hold pps_mutex around the whole on/off sequence.
|
2021-01-08 19:44:12 +02:00
|
|
|
* Can be nested with intel_pps_vdd_{on,off}() calls.
|
2021-01-08 19:44:09 +02:00
|
|
|
*/
|
2021-01-08 19:44:13 +02:00
|
|
|
void intel_pps_vdd_off_unlocked(struct intel_dp *intel_dp, bool sync)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
if (!intel_dp_is_edp(intel_dp))
|
|
|
|
return;
|
|
|
|
|
2025-03-24 20:01:44 +02:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
|
|
|
|
2024-10-24 19:25:10 +03:00
|
|
|
INTEL_DISPLAY_STATE_WARN(display, !intel_dp->pps.want_panel_vdd,
|
|
|
|
"[ENCODER:%d:%s] %s VDD not forced on",
|
|
|
|
dp_to_dig_port(intel_dp)->base.base.base.id,
|
|
|
|
dp_to_dig_port(intel_dp)->base.base.name,
|
|
|
|
pps_name(intel_dp));
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2021-01-20 12:18:33 +02:00
|
|
|
intel_dp->pps.want_panel_vdd = false;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
if (sync)
|
2021-01-08 19:44:13 +02:00
|
|
|
intel_pps_vdd_off_sync_unlocked(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
else
|
|
|
|
edp_panel_vdd_schedule_off(intel_dp);
|
|
|
|
}
|
|
|
|
|
2024-10-25 19:02:53 +03:00
|
|
|
void intel_pps_vdd_off(struct intel_dp *intel_dp)
|
|
|
|
{
|
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
|
|
|
|
if (!intel_dp_is_edp(intel_dp))
|
|
|
|
return;
|
|
|
|
|
|
|
|
with_intel_pps_lock(intel_dp, wakeref)
|
|
|
|
intel_pps_vdd_off_unlocked(intel_dp, false);
|
|
|
|
}
|
|
|
|
|
2021-01-08 19:44:13 +02:00
|
|
|
void intel_pps_on_unlocked(struct intel_dp *intel_dp)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
u32 pp;
|
|
|
|
i915_reg_t pp_ctrl_reg;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
if (!intel_dp_is_edp(intel_dp))
|
|
|
|
return;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm, "[ENCODER:%d:%s] %s turn panel power on\n",
|
2021-01-08 19:44:09 +02:00
|
|
|
dp_to_dig_port(intel_dp)->base.base.base.id,
|
2022-11-27 17:52:39 +02:00
|
|
|
dp_to_dig_port(intel_dp)->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp));
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
if (drm_WARN(display->drm, edp_have_panel_power(intel_dp),
|
2022-11-27 17:52:39 +02:00
|
|
|
"[ENCODER:%d:%s] %s panel power already on\n",
|
2021-01-08 19:44:09 +02:00
|
|
|
dp_to_dig_port(intel_dp)->base.base.base.id,
|
2022-11-27 17:52:39 +02:00
|
|
|
dp_to_dig_port(intel_dp)->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp)))
|
2021-01-08 19:44:09 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
wait_panel_power_cycle(intel_dp);
|
|
|
|
|
|
|
|
pp_ctrl_reg = _pp_ctrl_reg(intel_dp);
|
|
|
|
pp = ilk_get_pp_control(intel_dp);
|
2024-10-28 21:48:45 +02:00
|
|
|
if (display->platform.ironlake) {
|
2021-01-08 19:44:09 +02:00
|
|
|
/* ILK workaround: disable reset around power sequence */
|
|
|
|
pp &= ~PANEL_POWER_RESET;
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_write(display, pp_ctrl_reg, pp);
|
|
|
|
intel_de_posting_read(display, pp_ctrl_reg);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2024-08-13 09:58:07 +05:30
|
|
|
/*
|
|
|
|
* WA: 22019252566
|
|
|
|
* Disable DPLS gating around power sequence.
|
|
|
|
*/
|
2024-08-30 13:15:45 +03:00
|
|
|
if (IS_DISPLAY_VER(display, 13, 14))
|
|
|
|
intel_de_rmw(display, SOUTH_DSPCLK_GATE_D,
|
2024-08-13 09:58:07 +05:30
|
|
|
0, PCH_DPLSUNIT_CLOCK_GATE_DISABLE);
|
|
|
|
|
2021-01-08 19:44:09 +02:00
|
|
|
pp |= PANEL_POWER_ON;
|
2024-10-28 21:48:45 +02:00
|
|
|
if (!display->platform.ironlake)
|
2021-01-08 19:44:09 +02:00
|
|
|
pp |= PANEL_POWER_RESET;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_write(display, pp_ctrl_reg, pp);
|
|
|
|
intel_de_posting_read(display, pp_ctrl_reg);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
wait_panel_on(intel_dp);
|
2021-01-20 12:18:33 +02:00
|
|
|
intel_dp->pps.last_power_on = jiffies;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
if (IS_DISPLAY_VER(display, 13, 14))
|
|
|
|
intel_de_rmw(display, SOUTH_DSPCLK_GATE_D,
|
2024-08-13 09:58:07 +05:30
|
|
|
PCH_DPLSUNIT_CLOCK_GATE_DISABLE, 0);
|
|
|
|
|
2024-10-28 21:48:45 +02:00
|
|
|
if (display->platform.ironlake) {
|
2021-01-08 19:44:09 +02:00
|
|
|
pp |= PANEL_POWER_RESET; /* restore panel reset bit */
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_write(display, pp_ctrl_reg, pp);
|
|
|
|
intel_de_posting_read(display, pp_ctrl_reg);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-08 19:44:12 +02:00
|
|
|
void intel_pps_on(struct intel_dp *intel_dp)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
|
|
|
|
if (!intel_dp_is_edp(intel_dp))
|
|
|
|
return;
|
|
|
|
|
2021-01-08 19:44:10 +02:00
|
|
|
with_intel_pps_lock(intel_dp, wakeref)
|
2021-01-08 19:44:13 +02:00
|
|
|
intel_pps_on_unlocked(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2021-01-08 19:44:13 +02:00
|
|
|
void intel_pps_off_unlocked(struct intel_dp *intel_dp)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
|
|
|
|
u32 pp;
|
|
|
|
i915_reg_t pp_ctrl_reg;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
if (!intel_dp_is_edp(intel_dp))
|
|
|
|
return;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm, "[ENCODER:%d:%s] %s turn panel power off\n",
|
2022-11-27 17:52:39 +02:00
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp));
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_WARN(display->drm, !intel_dp->pps.want_panel_vdd,
|
2022-11-27 17:52:39 +02:00
|
|
|
"[ENCODER:%d:%s] %s need VDD to turn off panel\n",
|
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp));
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
pp = ilk_get_pp_control(intel_dp);
|
|
|
|
/* We need to switch off panel power _and_ force vdd, for otherwise some
|
|
|
|
* panels get very unhappy and cease to work. */
|
|
|
|
pp &= ~(PANEL_POWER_ON | PANEL_POWER_RESET | EDP_FORCE_VDD |
|
|
|
|
EDP_BLC_ENABLE);
|
|
|
|
|
|
|
|
pp_ctrl_reg = _pp_ctrl_reg(intel_dp);
|
|
|
|
|
2021-01-20 12:18:33 +02:00
|
|
|
intel_dp->pps.want_panel_vdd = false;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_write(display, pp_ctrl_reg, pp);
|
|
|
|
intel_de_posting_read(display, pp_ctrl_reg);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
wait_panel_off(intel_dp);
|
2021-01-20 12:18:33 +02:00
|
|
|
intel_dp->pps.panel_power_off_time = ktime_get_boottime();
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-10-25 19:02:55 +03:00
|
|
|
intel_dp_invalidate_source_oui(intel_dp);
|
|
|
|
|
2021-01-08 19:44:09 +02:00
|
|
|
/* We got a reference when we enabled the VDD. */
|
2025-02-06 20:55:27 +02:00
|
|
|
intel_display_power_put(display,
|
2021-01-08 19:44:09 +02:00
|
|
|
intel_aux_power_domain(dig_port),
|
2021-01-20 12:18:33 +02:00
|
|
|
fetch_and_zero(&intel_dp->pps.vdd_wakeref));
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2021-01-08 19:44:12 +02:00
|
|
|
void intel_pps_off(struct intel_dp *intel_dp)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
|
|
|
|
if (!intel_dp_is_edp(intel_dp))
|
|
|
|
return;
|
|
|
|
|
2021-01-08 19:44:10 +02:00
|
|
|
with_intel_pps_lock(intel_dp, wakeref)
|
2021-01-08 19:44:13 +02:00
|
|
|
intel_pps_off_unlocked(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable backlight in the panel power control. */
|
2021-01-08 19:44:11 +02:00
|
|
|
void intel_pps_backlight_on(struct intel_dp *intel_dp)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we enable the backlight right away following a panel power
|
|
|
|
* on, we may see slight flicker as the panel syncs with the eDP
|
|
|
|
* link. So delay a bit to make sure the image is solid before
|
|
|
|
* allowing it to appear.
|
|
|
|
*/
|
|
|
|
wait_backlight_on(intel_dp);
|
|
|
|
|
2021-01-08 19:44:10 +02:00
|
|
|
with_intel_pps_lock(intel_dp, wakeref) {
|
2021-01-08 19:44:09 +02:00
|
|
|
i915_reg_t pp_ctrl_reg = _pp_ctrl_reg(intel_dp);
|
|
|
|
u32 pp;
|
|
|
|
|
|
|
|
pp = ilk_get_pp_control(intel_dp);
|
|
|
|
pp |= EDP_BLC_ENABLE;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_write(display, pp_ctrl_reg, pp);
|
|
|
|
intel_de_posting_read(display, pp_ctrl_reg);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Disable backlight in the panel power control. */
|
2021-01-08 19:44:11 +02:00
|
|
|
void intel_pps_backlight_off(struct intel_dp *intel_dp)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
|
|
|
|
if (!intel_dp_is_edp(intel_dp))
|
|
|
|
return;
|
|
|
|
|
2021-01-08 19:44:10 +02:00
|
|
|
with_intel_pps_lock(intel_dp, wakeref) {
|
2021-01-08 19:44:09 +02:00
|
|
|
i915_reg_t pp_ctrl_reg = _pp_ctrl_reg(intel_dp);
|
|
|
|
u32 pp;
|
|
|
|
|
|
|
|
pp = ilk_get_pp_control(intel_dp);
|
|
|
|
pp &= ~EDP_BLC_ENABLE;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_write(display, pp_ctrl_reg, pp);
|
|
|
|
intel_de_posting_read(display, pp_ctrl_reg);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2021-01-20 12:18:33 +02:00
|
|
|
intel_dp->pps.last_backlight_off = jiffies;
|
2021-01-08 19:44:09 +02:00
|
|
|
edp_wait_backlight_off(intel_dp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hook for controlling the panel power control backlight through the bl_power
|
|
|
|
* sysfs attribute. Take care to handle multiple calls.
|
|
|
|
*/
|
2021-01-08 19:44:11 +02:00
|
|
|
void intel_pps_backlight_power(struct intel_connector *connector, bool enable)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(connector);
|
2021-01-08 19:44:09 +02:00
|
|
|
struct intel_dp *intel_dp = intel_attached_dp(connector);
|
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
bool is_enabled;
|
|
|
|
|
|
|
|
is_enabled = false;
|
2021-01-08 19:44:10 +02:00
|
|
|
with_intel_pps_lock(intel_dp, wakeref)
|
2021-01-08 19:44:09 +02:00
|
|
|
is_enabled = ilk_get_pp_control(intel_dp) & EDP_BLC_ENABLE;
|
|
|
|
if (is_enabled == enable)
|
|
|
|
return;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm, "panel power control backlight %s\n",
|
2024-10-23 11:16:55 +05:30
|
|
|
str_enable_disable(enable));
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
if (enable)
|
2021-01-08 19:44:11 +02:00
|
|
|
intel_pps_backlight_on(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
else
|
2021-01-08 19:44:11 +02:00
|
|
|
intel_pps_backlight_off(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void vlv_detach_power_sequencer(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
|
2024-09-18 20:47:41 +03:00
|
|
|
enum pipe pipe = intel_dp->pps.vlv_pps_pipe;
|
2024-08-30 13:15:45 +03:00
|
|
|
i915_reg_t pp_on_reg = PP_ON_DELAYS(display, pipe);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-09-18 20:47:41 +03:00
|
|
|
drm_WARN_ON(display->drm, intel_dp->pps.vlv_active_pipe != INVALID_PIPE);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
if (drm_WARN_ON(display->drm, pipe != PIPE_A && pipe != PIPE_B))
|
2021-01-08 19:44:09 +02:00
|
|
|
return;
|
|
|
|
|
2021-01-08 19:44:13 +02:00
|
|
|
intel_pps_vdd_off_sync_unlocked(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* VLV seems to get confused when multiple power sequencers
|
|
|
|
* have the same port selected (even if only one has power/vdd
|
|
|
|
* enabled). The failure manifests as vlv_wait_port_ready() failing
|
|
|
|
* CHV on the other hand doesn't seem to mind having the same port
|
|
|
|
* selected in multiple power sequencers, but let's clear the
|
|
|
|
* port select always when logically disconnecting a power sequencer
|
|
|
|
* from a port.
|
|
|
|
*/
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-11-27 17:52:39 +02:00
|
|
|
"detaching %s from [ENCODER:%d:%s]\n",
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp),
|
2022-11-27 17:52:39 +02:00
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name);
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_write(display, pp_on_reg, 0);
|
|
|
|
intel_de_posting_read(display, pp_on_reg);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-09-18 20:47:41 +03:00
|
|
|
intel_dp->pps.vlv_pps_pipe = INVALID_PIPE;
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
static void vlv_steal_power_sequencer(struct intel_display *display,
|
2021-01-08 19:44:09 +02:00
|
|
|
enum pipe pipe)
|
|
|
|
{
|
|
|
|
struct intel_encoder *encoder;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
for_each_intel_dp(display->drm, encoder) {
|
2021-01-08 19:44:09 +02:00
|
|
|
struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
|
|
|
|
|
2024-09-18 20:47:41 +03:00
|
|
|
drm_WARN(display->drm, intel_dp->pps.vlv_active_pipe == pipe,
|
2022-11-27 17:52:39 +02:00
|
|
|
"stealing PPS %c from active [ENCODER:%d:%s]\n",
|
2021-01-08 19:44:09 +02:00
|
|
|
pipe_name(pipe), encoder->base.base.id,
|
|
|
|
encoder->base.name);
|
|
|
|
|
2024-09-18 20:47:41 +03:00
|
|
|
if (intel_dp->pps.vlv_pps_pipe != pipe)
|
2021-01-08 19:44:09 +02:00
|
|
|
continue;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-11-27 17:52:39 +02:00
|
|
|
"stealing PPS %c from [ENCODER:%d:%s]\n",
|
2021-01-08 19:44:09 +02:00
|
|
|
pipe_name(pipe), encoder->base.base.id,
|
|
|
|
encoder->base.name);
|
|
|
|
|
|
|
|
/* make sure vdd is off before we steal it */
|
|
|
|
vlv_detach_power_sequencer(intel_dp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-18 20:47:49 +03:00
|
|
|
static enum pipe vlv_active_pipe(struct intel_dp *intel_dp)
|
|
|
|
{
|
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
|
|
|
struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
|
|
|
|
enum pipe pipe;
|
|
|
|
|
2025-02-12 18:36:30 +02:00
|
|
|
if (g4x_dp_port_enabled(display, intel_dp->output_reg,
|
2024-09-18 20:47:49 +03:00
|
|
|
encoder->port, &pipe))
|
|
|
|
return pipe;
|
|
|
|
|
|
|
|
return INVALID_PIPE;
|
|
|
|
}
|
|
|
|
|
2024-09-18 20:47:44 +03:00
|
|
|
/* Call on all DP, not just eDP */
|
|
|
|
void vlv_pps_pipe_init(struct intel_dp *intel_dp)
|
|
|
|
{
|
|
|
|
intel_dp->pps.vlv_pps_pipe = INVALID_PIPE;
|
|
|
|
intel_dp->pps.vlv_active_pipe = vlv_active_pipe(intel_dp);
|
2024-09-18 20:47:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Call on all DP, not just eDP */
|
|
|
|
void vlv_pps_pipe_reset(struct intel_dp *intel_dp)
|
|
|
|
{
|
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
|
|
|
|
with_intel_pps_lock(intel_dp, wakeref)
|
|
|
|
intel_dp->pps.vlv_active_pipe = vlv_active_pipe(intel_dp);
|
2024-09-18 20:47:44 +03:00
|
|
|
}
|
|
|
|
|
2024-09-18 20:47:48 +03:00
|
|
|
enum pipe vlv_pps_backlight_initial_pipe(struct intel_dp *intel_dp)
|
|
|
|
{
|
|
|
|
enum pipe pipe;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Figure out the current pipe for the initial backlight setup. If the
|
|
|
|
* current pipe isn't valid, try the PPS pipe, and if that fails just
|
|
|
|
* assume pipe A.
|
|
|
|
*/
|
|
|
|
pipe = vlv_active_pipe(intel_dp);
|
|
|
|
|
|
|
|
if (pipe != PIPE_A && pipe != PIPE_B)
|
|
|
|
pipe = intel_dp->pps.vlv_pps_pipe;
|
|
|
|
|
|
|
|
if (pipe != PIPE_A && pipe != PIPE_B)
|
|
|
|
pipe = PIPE_A;
|
|
|
|
|
|
|
|
return pipe;
|
|
|
|
}
|
|
|
|
|
2024-09-18 20:47:47 +03:00
|
|
|
/* Call on all DP, not just eDP */
|
|
|
|
void vlv_pps_port_enable_unlocked(struct intel_encoder *encoder,
|
|
|
|
const struct intel_crtc_state *crtc_state)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(encoder);
|
2021-01-08 19:44:09 +02:00
|
|
|
struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
|
|
|
|
struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-09-18 20:47:41 +03:00
|
|
|
drm_WARN_ON(display->drm, intel_dp->pps.vlv_active_pipe != INVALID_PIPE);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-09-18 20:47:41 +03:00
|
|
|
if (intel_dp->pps.vlv_pps_pipe != INVALID_PIPE &&
|
|
|
|
intel_dp->pps.vlv_pps_pipe != crtc->pipe) {
|
2021-01-08 19:44:09 +02:00
|
|
|
/*
|
|
|
|
* If another power sequencer was being used on this
|
|
|
|
* port previously make sure to turn off vdd there while
|
|
|
|
* we still have control of it.
|
|
|
|
*/
|
|
|
|
vlv_detach_power_sequencer(intel_dp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We may be stealing the power
|
|
|
|
* sequencer from another port.
|
|
|
|
*/
|
2024-08-30 13:15:45 +03:00
|
|
|
vlv_steal_power_sequencer(display, crtc->pipe);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-09-18 20:47:41 +03:00
|
|
|
intel_dp->pps.vlv_active_pipe = crtc->pipe;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
if (!intel_dp_is_edp(intel_dp))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* now it's all ours */
|
2024-09-18 20:47:41 +03:00
|
|
|
intel_dp->pps.vlv_pps_pipe = crtc->pipe;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-11-27 17:52:39 +02:00
|
|
|
"initializing %s for [ENCODER:%d:%s]\n",
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp),
|
2022-11-27 17:52:39 +02:00
|
|
|
encoder->base.base.id, encoder->base.name);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/* init power sequencer on this pipe and port */
|
2021-01-08 19:44:21 +02:00
|
|
|
pps_init_delays(intel_dp);
|
|
|
|
pps_init_registers(intel_dp, true);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2024-09-18 20:47:46 +03:00
|
|
|
/* Call on all DP, not just eDP */
|
|
|
|
void vlv_pps_port_disable(struct intel_encoder *encoder,
|
|
|
|
const struct intel_crtc_state *crtc_state)
|
|
|
|
{
|
|
|
|
struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
|
|
|
|
|
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
|
|
|
|
with_intel_pps_lock(intel_dp, wakeref)
|
|
|
|
intel_dp->pps.vlv_active_pipe = INVALID_PIPE;
|
|
|
|
}
|
|
|
|
|
2022-05-10 13:42:34 +03:00
|
|
|
static void pps_vdd_init(struct intel_dp *intel_dp)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
if (!edp_have_panel_vdd(intel_dp))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The VDD bit needs a power domain reference, so if the bit is
|
|
|
|
* already enabled when we boot or resume, grab this reference and
|
|
|
|
* schedule a vdd off, so we don't hold on to the reference
|
|
|
|
* indefinitely.
|
|
|
|
*/
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2022-11-27 17:52:39 +02:00
|
|
|
"[ENCODER:%d:%s] %s VDD left on by BIOS, adjusting state tracking\n",
|
|
|
|
dig_port->base.base.base.id, dig_port->base.base.name,
|
2024-08-30 13:15:44 +03:00
|
|
|
pps_name(intel_dp));
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_WARN_ON(display->drm, intel_dp->pps.vdd_wakeref);
|
2025-02-06 20:55:27 +02:00
|
|
|
intel_dp->pps.vdd_wakeref = intel_display_power_get(display,
|
2021-01-20 12:18:33 +02:00
|
|
|
intel_aux_power_domain(dig_port));
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2022-03-11 10:51:48 -08:00
|
|
|
bool intel_pps_have_panel_power_or_vdd(struct intel_dp *intel_dp)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
bool have_power = false;
|
|
|
|
|
2021-01-08 19:44:10 +02:00
|
|
|
with_intel_pps_lock(intel_dp, wakeref) {
|
2022-03-11 10:51:48 -08:00
|
|
|
have_power = edp_have_panel_power(intel_dp) ||
|
|
|
|
edp_have_panel_vdd(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return have_power;
|
|
|
|
}
|
|
|
|
|
2021-01-08 19:44:21 +02:00
|
|
|
static void pps_init_timestamps(struct intel_dp *intel_dp)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
drm/i915/edp: wait power off delay at driver remove to optimize probe
Panel power off delay is the time the panel power needs to remain off
after being switched off, before it can be switched on again.
For the purpose of respecting panel power off delay at driver probe,
assuming the panel was last switched off at driver probe is overly
pessimistic. If the panel was never on, we'd end up waiting for no
reason.
We don't know what has happened before kernel boot, but we can make some
assumptions:
- The panel may have been switched off right before kernel boot by some
pre-os environment.
- After kernel boot, the panel may only be switched off by i915.
- At i915 driver probe, only a previously loaded and removed i915 may
have switched the panel power off.
With these assumptions, we can initialize the last power off time to
kernel boot time, if we also ensure i915 driver remove waits for the
panel power off delay after switching panel power off.
This shaves off the time it takes from kernel boot to i915 probe from
the first panel enable, if (and only if) the panel was not already
enabled at boot.
The encoder destroy hook is pretty much the last place where we can
wait, right after we've ensured the panel power has been switched off,
and before the whole encoder is destroyed.
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/7417
Cc: Lee Shawn C <shawn.c.lee@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Tested-by: Lee Shawn C <shawn.c.lee@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221116150657.1347504-1-jani.nikula@intel.com
2022-11-16 17:06:57 +02:00
|
|
|
/*
|
|
|
|
* Initialize panel power off time to 0, assuming panel power could have
|
|
|
|
* been toggled between kernel boot and now only by a previously loaded
|
|
|
|
* and removed i915, which has already ensured sufficient power off
|
|
|
|
* delay at module remove.
|
|
|
|
*/
|
|
|
|
intel_dp->pps.panel_power_off_time = 0;
|
2021-01-20 12:18:33 +02:00
|
|
|
intel_dp->pps.last_power_on = jiffies;
|
|
|
|
intel_dp->pps.last_backlight_off = jiffies;
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-11-06 23:58:53 +02:00
|
|
|
intel_pps_readout_hw_state(struct intel_dp *intel_dp, struct intel_pps_delays *seq)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2024-11-06 23:58:52 +02:00
|
|
|
u32 pp_on, pp_off, pp_ctl, power_cycle_delay;
|
2021-01-08 19:44:09 +02:00
|
|
|
struct pps_registers regs;
|
|
|
|
|
|
|
|
intel_pps_get_registers(intel_dp, ®s);
|
|
|
|
|
|
|
|
pp_ctl = ilk_get_pp_control(intel_dp);
|
|
|
|
|
|
|
|
/* Ensure PPS is unlocked */
|
2024-08-30 13:15:45 +03:00
|
|
|
if (!HAS_DDI(display))
|
|
|
|
intel_de_write(display, regs.pp_ctrl, pp_ctl);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
pp_on = intel_de_read(display, regs.pp_on);
|
|
|
|
pp_off = intel_de_read(display, regs.pp_off);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/* Pull timing values out of registers */
|
2024-11-06 23:58:54 +02:00
|
|
|
seq->power_up = REG_FIELD_GET(PANEL_POWER_UP_DELAY_MASK, pp_on);
|
|
|
|
seq->backlight_on = REG_FIELD_GET(PANEL_LIGHT_ON_DELAY_MASK, pp_on);
|
|
|
|
seq->backlight_off = REG_FIELD_GET(PANEL_LIGHT_OFF_DELAY_MASK, pp_off);
|
|
|
|
seq->power_down = REG_FIELD_GET(PANEL_POWER_DOWN_DELAY_MASK, pp_off);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
if (i915_mmio_reg_valid(regs.pp_div)) {
|
|
|
|
u32 pp_div;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
pp_div = intel_de_read(display, regs.pp_div);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-11-06 23:58:52 +02:00
|
|
|
power_cycle_delay = REG_FIELD_GET(PANEL_POWER_CYCLE_DELAY_MASK, pp_div);
|
2021-01-08 19:44:09 +02:00
|
|
|
} else {
|
2024-11-06 23:58:52 +02:00
|
|
|
power_cycle_delay = REG_FIELD_GET(BXT_POWER_CYCLE_DELAY_MASK, pp_ctl);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
2024-11-06 23:58:52 +02:00
|
|
|
|
|
|
|
/* hardware wants <delay>+1 in 100ms units */
|
2024-11-06 23:58:54 +02:00
|
|
|
seq->power_cycle = power_cycle_delay ? (power_cycle_delay - 1) * 1000 : 0;
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-01-21 15:00:31 +02:00
|
|
|
intel_pps_dump_state(struct intel_dp *intel_dp, const char *state_name,
|
2024-11-06 23:58:53 +02:00
|
|
|
const struct intel_pps_delays *seq)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2022-01-21 15:00:31 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2024-11-06 23:58:54 +02:00
|
|
|
"%s power_up %d backlight_on %d backlight_off %d power_down %d power_cycle %d\n",
|
|
|
|
state_name, seq->power_up, seq->backlight_on,
|
|
|
|
seq->backlight_off, seq->power_down, seq->power_cycle);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
intel_pps_verify_state(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2024-11-06 23:58:53 +02:00
|
|
|
struct intel_pps_delays hw;
|
|
|
|
struct intel_pps_delays *sw = &intel_dp->pps.pps_delays;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
intel_pps_readout_hw_state(intel_dp, &hw);
|
|
|
|
|
2024-11-06 23:58:54 +02:00
|
|
|
if (hw.power_up != sw->power_up ||
|
|
|
|
hw.backlight_on != sw->backlight_on ||
|
|
|
|
hw.backlight_off != sw->backlight_off ||
|
|
|
|
hw.power_down != sw->power_down ||
|
|
|
|
hw.power_cycle != sw->power_cycle) {
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_err(display->drm, "PPS state mismatch\n");
|
2022-01-21 15:00:31 +02:00
|
|
|
intel_pps_dump_state(intel_dp, "sw", sw);
|
|
|
|
intel_pps_dump_state(intel_dp, "hw", &hw);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-06 23:58:53 +02:00
|
|
|
static bool pps_delays_valid(struct intel_pps_delays *delays)
|
2022-05-10 13:42:31 +03:00
|
|
|
{
|
2024-11-06 23:58:54 +02:00
|
|
|
return delays->power_up || delays->backlight_on || delays->backlight_off ||
|
|
|
|
delays->power_down || delays->power_cycle;
|
2022-05-10 13:42:31 +03:00
|
|
|
}
|
|
|
|
|
2024-11-06 23:58:57 +02:00
|
|
|
static int msecs_to_pps_units(int msecs)
|
|
|
|
{
|
|
|
|
/* PPS uses 100us units */
|
|
|
|
return msecs * 10;
|
|
|
|
}
|
|
|
|
|
2024-11-06 23:58:58 +02:00
|
|
|
static int pps_units_to_msecs(int val)
|
|
|
|
{
|
|
|
|
/* PPS uses 100us units */
|
|
|
|
return DIV_ROUND_UP(val, 10);
|
|
|
|
}
|
|
|
|
|
2022-05-10 13:42:33 +03:00
|
|
|
static void pps_init_delays_bios(struct intel_dp *intel_dp,
|
2024-11-06 23:58:53 +02:00
|
|
|
struct intel_pps_delays *bios)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2022-05-10 13:42:33 +03:00
|
|
|
if (!pps_delays_valid(&intel_dp->pps.bios_pps_delays))
|
|
|
|
intel_pps_readout_hw_state(intel_dp, &intel_dp->pps.bios_pps_delays);
|
2022-05-10 13:42:30 +03:00
|
|
|
|
2022-05-10 13:42:33 +03:00
|
|
|
*bios = intel_dp->pps.bios_pps_delays;
|
|
|
|
|
|
|
|
intel_pps_dump_state(intel_dp, "bios", bios);
|
2022-05-10 13:42:30 +03:00
|
|
|
}
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2022-05-10 13:42:30 +03:00
|
|
|
static void pps_init_delays_vbt(struct intel_dp *intel_dp,
|
2024-11-06 23:58:53 +02:00
|
|
|
struct intel_pps_delays *vbt)
|
2022-05-10 13:42:30 +03:00
|
|
|
{
|
2024-04-17 16:02:43 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2022-05-10 13:42:39 +03:00
|
|
|
struct intel_connector *connector = intel_dp->attached_connector;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2022-05-10 13:42:39 +03:00
|
|
|
*vbt = connector->panel.vbt.edp.pps;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2022-05-10 13:42:32 +03:00
|
|
|
if (!pps_delays_valid(vbt))
|
|
|
|
return;
|
|
|
|
|
2025-01-20 13:45:16 +05:30
|
|
|
/*
|
|
|
|
* On Toshiba Satellite P50-C-18C system the VBT T12 delay
|
|
|
|
* of 500ms appears to be too short. Occasionally the panel
|
2021-01-08 19:44:09 +02:00
|
|
|
* just fails to power back on. Increasing the delay to 800ms
|
|
|
|
* seems sufficient to avoid this problem.
|
|
|
|
*/
|
2024-04-17 16:02:43 +03:00
|
|
|
if (intel_has_quirk(display, QUIRK_INCREASE_T12_DELAY)) {
|
2024-11-06 23:58:57 +02:00
|
|
|
vbt->power_cycle = max_t(u16, vbt->power_cycle, msecs_to_pps_units(1300));
|
2024-04-17 16:02:43 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2021-01-08 19:44:09 +02:00
|
|
|
"Increasing T12 panel delay as per the quirk to %d\n",
|
2024-11-06 23:58:54 +02:00
|
|
|
vbt->power_cycle);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
2022-05-10 13:42:30 +03:00
|
|
|
|
|
|
|
intel_pps_dump_state(intel_dp, "vbt", vbt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pps_init_delays_spec(struct intel_dp *intel_dp,
|
2024-11-06 23:58:53 +02:00
|
|
|
struct intel_pps_delays *spec)
|
2022-05-10 13:42:30 +03:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2022-05-10 13:42:30 +03:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-11-06 23:58:57 +02:00
|
|
|
/* Upper limits from eDP 1.3 spec */
|
|
|
|
spec->power_up = msecs_to_pps_units(10 + 200); /* T1+T3 */
|
|
|
|
spec->backlight_on = msecs_to_pps_units(50); /* no limit for T8, use T7 instead */
|
|
|
|
spec->backlight_off = msecs_to_pps_units(50); /* no limit for T9, make it symmetric with T8 */
|
|
|
|
spec->power_down = msecs_to_pps_units(500); /* T10 */
|
|
|
|
spec->power_cycle = msecs_to_pps_units(10 + 500); /* T11+T12 */
|
2022-05-10 13:42:30 +03:00
|
|
|
|
|
|
|
intel_pps_dump_state(intel_dp, "spec", spec);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pps_init_delays(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2024-11-06 23:58:53 +02:00
|
|
|
struct intel_pps_delays cur, vbt, spec,
|
2022-05-10 13:42:30 +03:00
|
|
|
*final = &intel_dp->pps.pps_delays;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2022-05-10 13:42:30 +03:00
|
|
|
|
|
|
|
/* already initialized? */
|
2022-05-10 13:42:31 +03:00
|
|
|
if (pps_delays_valid(final))
|
2022-05-10 13:42:30 +03:00
|
|
|
return;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2022-05-10 13:42:33 +03:00
|
|
|
pps_init_delays_bios(intel_dp, &cur);
|
2022-05-10 13:42:30 +03:00
|
|
|
pps_init_delays_vbt(intel_dp, &vbt);
|
|
|
|
pps_init_delays_spec(intel_dp, &spec);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/* Use the max of the register settings and vbt. If both are
|
|
|
|
* unset, fall back to the spec limits. */
|
|
|
|
#define assign_final(field) final->field = (max(cur.field, vbt.field) == 0 ? \
|
|
|
|
spec.field : \
|
|
|
|
max(cur.field, vbt.field))
|
2024-11-06 23:58:54 +02:00
|
|
|
assign_final(power_up);
|
|
|
|
assign_final(backlight_on);
|
|
|
|
assign_final(backlight_off);
|
|
|
|
assign_final(power_down);
|
|
|
|
assign_final(power_cycle);
|
2021-01-08 19:44:09 +02:00
|
|
|
#undef assign_final
|
|
|
|
|
2024-11-06 23:58:59 +02:00
|
|
|
intel_dp->pps.panel_power_up_delay = pps_units_to_msecs(final->power_up);
|
|
|
|
intel_dp->pps.backlight_on_delay = pps_units_to_msecs(final->backlight_on);
|
|
|
|
intel_dp->pps.backlight_off_delay = pps_units_to_msecs(final->backlight_off);
|
|
|
|
intel_dp->pps.panel_power_down_delay = pps_units_to_msecs(final->power_down);
|
|
|
|
intel_dp->pps.panel_power_cycle_delay = pps_units_to_msecs(final->power_cycle);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2021-01-08 19:44:09 +02:00
|
|
|
"panel power up delay %d, power down delay %d, power cycle delay %d\n",
|
2021-01-20 12:18:33 +02:00
|
|
|
intel_dp->pps.panel_power_up_delay,
|
|
|
|
intel_dp->pps.panel_power_down_delay,
|
|
|
|
intel_dp->pps.panel_power_cycle_delay);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm, "backlight on delay %d, off delay %d\n",
|
2021-01-20 12:18:33 +02:00
|
|
|
intel_dp->pps.backlight_on_delay,
|
|
|
|
intel_dp->pps.backlight_off_delay);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We override the HW backlight delays to 1 because we do manual waits
|
2024-11-06 23:58:54 +02:00
|
|
|
* on them. For backlight_on, even BSpec recommends doing it. For
|
|
|
|
* backlight_off, if we don't do this, we'll end up waiting for the
|
|
|
|
* backlight off delay twice: once when we do the manual sleep, and
|
|
|
|
* once when we disable the panel and wait for the PP_STATUS bit to
|
|
|
|
* become zero.
|
2021-01-08 19:44:09 +02:00
|
|
|
*/
|
2024-11-06 23:58:54 +02:00
|
|
|
final->backlight_on = 1;
|
|
|
|
final->backlight_off = 1;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/*
|
2024-11-06 23:58:54 +02:00
|
|
|
* HW has only a 100msec granularity for power_cycle so round it up
|
2021-01-08 19:44:09 +02:00
|
|
|
* accordingly.
|
|
|
|
*/
|
2024-11-06 23:58:57 +02:00
|
|
|
final->power_cycle = roundup(final->power_cycle, msecs_to_pps_units(100));
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2021-01-08 19:44:21 +02:00
|
|
|
static void pps_init_registers(struct intel_dp *intel_dp, bool force_disable_vdd)
|
2021-01-08 19:44:09 +02:00
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:09 +02:00
|
|
|
u32 pp_on, pp_off, port_sel = 0;
|
2024-08-30 13:15:45 +03:00
|
|
|
int div = DISPLAY_RUNTIME_INFO(display)->rawclk_freq / 1000;
|
2021-01-08 19:44:09 +02:00
|
|
|
struct pps_registers regs;
|
|
|
|
enum port port = dp_to_dig_port(intel_dp)->base.port;
|
2024-11-06 23:58:53 +02:00
|
|
|
const struct intel_pps_delays *seq = &intel_dp->pps.pps_delays;
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
lockdep_assert_held(&display->pps.mutex);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
intel_pps_get_registers(intel_dp, ®s);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* On some VLV machines the BIOS can leave the VDD
|
|
|
|
* enabled even on power sequencers which aren't
|
|
|
|
* hooked up to any port. This would mess up the
|
|
|
|
* power domain tracking the first time we pick
|
|
|
|
* one of these power sequencers for use since
|
2021-01-08 19:44:13 +02:00
|
|
|
* intel_pps_vdd_on_unlocked() would notice that the VDD was
|
2021-01-08 19:44:09 +02:00
|
|
|
* already on and therefore wouldn't grab the power
|
|
|
|
* domain reference. Disable VDD first to avoid this.
|
|
|
|
* This also avoids spuriously turning the VDD on as
|
|
|
|
* soon as the new power sequencer gets initialized.
|
|
|
|
*/
|
|
|
|
if (force_disable_vdd) {
|
|
|
|
u32 pp = ilk_get_pp_control(intel_dp);
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_WARN(display->drm, pp & PANEL_POWER_ON,
|
2021-01-08 19:44:09 +02:00
|
|
|
"Panel power already on\n");
|
|
|
|
|
|
|
|
if (pp & EDP_FORCE_VDD)
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2021-01-08 19:44:09 +02:00
|
|
|
"VDD already on, disabling first\n");
|
|
|
|
|
|
|
|
pp &= ~EDP_FORCE_VDD;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_write(display, regs.pp_ctrl, pp);
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2024-11-06 23:58:54 +02:00
|
|
|
pp_on = REG_FIELD_PREP(PANEL_POWER_UP_DELAY_MASK, seq->power_up) |
|
|
|
|
REG_FIELD_PREP(PANEL_LIGHT_ON_DELAY_MASK, seq->backlight_on);
|
|
|
|
pp_off = REG_FIELD_PREP(PANEL_LIGHT_OFF_DELAY_MASK, seq->backlight_off) |
|
|
|
|
REG_FIELD_PREP(PANEL_POWER_DOWN_DELAY_MASK, seq->power_down);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/* Haswell doesn't have any port selection bits for the panel
|
|
|
|
* power sequencer any more. */
|
2024-10-28 21:48:45 +02:00
|
|
|
if (display->platform.valleyview || display->platform.cherryview) {
|
2021-01-08 19:44:09 +02:00
|
|
|
port_sel = PANEL_PORT_SELECT_VLV(port);
|
2025-04-17 12:10:36 +03:00
|
|
|
} else if (HAS_PCH_IBX(display) || HAS_PCH_CPT(display)) {
|
2021-01-08 19:44:09 +02:00
|
|
|
switch (port) {
|
|
|
|
case PORT_A:
|
|
|
|
port_sel = PANEL_PORT_SELECT_DPA;
|
|
|
|
break;
|
|
|
|
case PORT_C:
|
|
|
|
port_sel = PANEL_PORT_SELECT_DPC;
|
|
|
|
break;
|
|
|
|
case PORT_D:
|
|
|
|
port_sel = PANEL_PORT_SELECT_DPD;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MISSING_CASE(port);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pp_on |= port_sel;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_write(display, regs.pp_on, pp_on);
|
|
|
|
intel_de_write(display, regs.pp_off, pp_off);
|
2021-01-08 19:44:09 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Compute the divisor for the pp clock, simply match the Bspec formula.
|
|
|
|
*/
|
2023-01-05 14:10:44 +01:00
|
|
|
if (i915_mmio_reg_valid(regs.pp_div))
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_write(display, regs.pp_div,
|
2024-11-06 23:58:52 +02:00
|
|
|
REG_FIELD_PREP(PP_REFERENCE_DIVIDER_MASK,
|
|
|
|
(100 * div) / 2 - 1) |
|
|
|
|
REG_FIELD_PREP(PANEL_POWER_CYCLE_DELAY_MASK,
|
2024-11-06 23:58:54 +02:00
|
|
|
DIV_ROUND_UP(seq->power_cycle, 1000) + 1));
|
2023-01-05 14:10:44 +01:00
|
|
|
else
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_rmw(display, regs.pp_ctrl, BXT_POWER_CYCLE_DELAY_MASK,
|
2023-01-05 14:10:44 +01:00
|
|
|
REG_FIELD_PREP(BXT_POWER_CYCLE_DELAY_MASK,
|
2024-11-06 23:58:54 +02:00
|
|
|
DIV_ROUND_UP(seq->power_cycle, 1000) + 1));
|
2021-01-08 19:44:09 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_dbg_kms(display->drm,
|
2021-01-08 19:44:09 +02:00
|
|
|
"panel power sequencer register settings: PP_ON %#x, PP_OFF %#x, PP_DIV %#x\n",
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_read(display, regs.pp_on),
|
|
|
|
intel_de_read(display, regs.pp_off),
|
2021-01-08 19:44:09 +02:00
|
|
|
i915_mmio_reg_valid(regs.pp_div) ?
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_read(display, regs.pp_div) :
|
|
|
|
(intel_de_read(display, regs.pp_ctrl) & BXT_POWER_CYCLE_DELAY_MASK));
|
2021-01-08 19:44:09 +02:00
|
|
|
}
|
|
|
|
|
2021-01-08 19:44:16 +02:00
|
|
|
void intel_pps_encoder_reset(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2021-01-08 19:44:16 +02:00
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
|
|
|
|
if (!intel_dp_is_edp(intel_dp))
|
|
|
|
return;
|
|
|
|
|
|
|
|
with_intel_pps_lock(intel_dp, wakeref) {
|
|
|
|
/*
|
2021-01-20 12:18:31 +02:00
|
|
|
* Reinit the power sequencer also on the resume path, in case
|
|
|
|
* BIOS did something nasty with it.
|
2021-01-08 19:44:16 +02:00
|
|
|
*/
|
2024-10-28 21:48:45 +02:00
|
|
|
if (display->platform.valleyview || display->platform.cherryview)
|
2021-01-20 12:18:31 +02:00
|
|
|
vlv_initial_power_sequencer_setup(intel_dp);
|
|
|
|
|
|
|
|
pps_init_delays(intel_dp);
|
|
|
|
pps_init_registers(intel_dp, false);
|
2022-05-10 13:42:34 +03:00
|
|
|
pps_vdd_init(intel_dp);
|
2021-01-20 12:18:31 +02:00
|
|
|
|
2022-05-10 13:42:34 +03:00
|
|
|
if (edp_have_panel_vdd(intel_dp))
|
|
|
|
edp_panel_vdd_schedule_off(intel_dp);
|
2021-01-08 19:44:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-25 19:31:53 +02:00
|
|
|
bool intel_pps_init(struct intel_dp *intel_dp)
|
2021-01-08 19:44:15 +02:00
|
|
|
{
|
2022-05-10 13:42:34 +03:00
|
|
|
intel_wakeref_t wakeref;
|
2022-11-25 19:31:53 +02:00
|
|
|
bool ret;
|
2022-05-10 13:42:34 +03:00
|
|
|
|
2022-05-10 13:42:36 +03:00
|
|
|
intel_dp->pps.initializing = true;
|
2021-01-20 12:18:33 +02:00
|
|
|
INIT_DELAYED_WORK(&intel_dp->pps.panel_vdd_work, edp_panel_vdd_work);
|
2021-01-08 19:44:15 +02:00
|
|
|
|
2021-01-20 12:18:31 +02:00
|
|
|
pps_init_timestamps(intel_dp);
|
|
|
|
|
2022-05-10 13:42:34 +03:00
|
|
|
with_intel_pps_lock(intel_dp, wakeref) {
|
2022-11-25 19:31:53 +02:00
|
|
|
ret = pps_initial_setup(intel_dp);
|
2022-05-10 13:42:34 +03:00
|
|
|
|
|
|
|
pps_init_delays(intel_dp);
|
|
|
|
pps_init_registers(intel_dp, false);
|
|
|
|
pps_vdd_init(intel_dp);
|
|
|
|
}
|
2022-11-25 19:31:53 +02:00
|
|
|
|
|
|
|
return ret;
|
2022-05-10 13:42:34 +03:00
|
|
|
}
|
|
|
|
|
2022-11-25 19:31:51 +02:00
|
|
|
static void pps_init_late(struct intel_dp *intel_dp)
|
|
|
|
{
|
2024-08-30 13:15:45 +03:00
|
|
|
struct intel_display *display = to_intel_display(intel_dp);
|
2022-11-25 19:31:51 +02:00
|
|
|
struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
|
|
|
|
struct intel_connector *connector = intel_dp->attached_connector;
|
|
|
|
|
2024-10-28 21:48:45 +02:00
|
|
|
if (display->platform.valleyview || display->platform.cherryview)
|
2022-11-25 19:31:52 +02:00
|
|
|
return;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
if (intel_num_pps(display) < 2)
|
2022-11-25 19:31:51 +02:00
|
|
|
return;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_WARN(display->drm,
|
|
|
|
connector->panel.vbt.backlight.controller >= 0 &&
|
2022-11-25 19:31:51 +02:00
|
|
|
intel_dp->pps.pps_idx != connector->panel.vbt.backlight.controller,
|
|
|
|
"[ENCODER:%d:%s] power sequencer mismatch: %d (initial) vs. %d (VBT)\n",
|
|
|
|
encoder->base.base.id, encoder->base.name,
|
|
|
|
intel_dp->pps.pps_idx, connector->panel.vbt.backlight.controller);
|
|
|
|
|
|
|
|
if (connector->panel.vbt.backlight.controller >= 0)
|
|
|
|
intel_dp->pps.pps_idx = connector->panel.vbt.backlight.controller;
|
|
|
|
}
|
|
|
|
|
2022-05-10 13:42:34 +03:00
|
|
|
void intel_pps_init_late(struct intel_dp *intel_dp)
|
|
|
|
{
|
|
|
|
intel_wakeref_t wakeref;
|
|
|
|
|
|
|
|
with_intel_pps_lock(intel_dp, wakeref) {
|
2022-05-10 13:42:35 +03:00
|
|
|
/* Reinit delays after per-panel info has been parsed from VBT */
|
2022-11-25 19:31:51 +02:00
|
|
|
pps_init_late(intel_dp);
|
|
|
|
|
2022-05-10 13:42:35 +03:00
|
|
|
memset(&intel_dp->pps.pps_delays, 0, sizeof(intel_dp->pps.pps_delays));
|
|
|
|
pps_init_delays(intel_dp);
|
|
|
|
pps_init_registers(intel_dp, false);
|
|
|
|
|
2022-05-10 13:42:36 +03:00
|
|
|
intel_dp->pps.initializing = false;
|
|
|
|
|
2022-05-10 13:42:34 +03:00
|
|
|
if (edp_have_panel_vdd(intel_dp))
|
|
|
|
edp_panel_vdd_schedule_off(intel_dp);
|
|
|
|
}
|
2021-01-08 19:44:15 +02:00
|
|
|
}
|
2021-01-20 12:18:32 +02:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
void intel_pps_unlock_regs_wa(struct intel_display *display)
|
2021-01-20 12:18:32 +02:00
|
|
|
{
|
|
|
|
int pps_num;
|
|
|
|
int pps_idx;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
if (!HAS_DISPLAY(display) || HAS_DDI(display))
|
2021-01-20 12:18:32 +02:00
|
|
|
return;
|
|
|
|
/*
|
|
|
|
* This w/a is needed at least on CPT/PPT, but to be sure apply it
|
|
|
|
* everywhere where registers can be write protected.
|
|
|
|
*/
|
2024-08-30 13:15:45 +03:00
|
|
|
pps_num = intel_num_pps(display);
|
2021-01-20 12:18:32 +02:00
|
|
|
|
2023-04-17 11:57:42 +03:00
|
|
|
for (pps_idx = 0; pps_idx < pps_num; pps_idx++)
|
2024-08-30 13:15:45 +03:00
|
|
|
intel_de_rmw(display, PP_CONTROL(display, pps_idx),
|
2023-04-17 11:57:42 +03:00
|
|
|
PANEL_UNLOCK_MASK, PANEL_UNLOCK_REGS);
|
2021-01-20 12:18:32 +02:00
|
|
|
}
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
void intel_pps_setup(struct intel_display *display)
|
2021-01-20 12:18:32 +02:00
|
|
|
{
|
2025-04-17 12:10:36 +03:00
|
|
|
if (HAS_PCH_SPLIT(display) || display->platform.geminilake || display->platform.broxton)
|
2024-08-30 13:15:45 +03:00
|
|
|
display->pps.mmio_base = PCH_PPS_BASE;
|
2024-10-28 21:48:45 +02:00
|
|
|
else if (display->platform.valleyview || display->platform.cherryview)
|
2024-08-30 13:15:45 +03:00
|
|
|
display->pps.mmio_base = VLV_PPS_BASE;
|
2021-01-20 12:18:32 +02:00
|
|
|
else
|
2024-08-30 13:15:45 +03:00
|
|
|
display->pps.mmio_base = PPS_BASE;
|
2021-01-20 12:18:32 +02:00
|
|
|
}
|
2021-09-30 12:22:59 +03:00
|
|
|
|
2024-04-08 12:43:57 +03:00
|
|
|
static int intel_pps_show(struct seq_file *m, void *data)
|
|
|
|
{
|
|
|
|
struct intel_connector *connector = m->private;
|
|
|
|
struct intel_dp *intel_dp = intel_attached_dp(connector);
|
|
|
|
|
|
|
|
if (connector->base.status != connector_status_connected)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
seq_printf(m, "Panel power up delay: %d\n",
|
|
|
|
intel_dp->pps.panel_power_up_delay);
|
|
|
|
seq_printf(m, "Panel power down delay: %d\n",
|
|
|
|
intel_dp->pps.panel_power_down_delay);
|
2024-12-05 14:37:20 +02:00
|
|
|
seq_printf(m, "Panel power cycle delay: %d\n",
|
|
|
|
intel_dp->pps.panel_power_cycle_delay);
|
2024-04-08 12:43:57 +03:00
|
|
|
seq_printf(m, "Backlight on delay: %d\n",
|
|
|
|
intel_dp->pps.backlight_on_delay);
|
|
|
|
seq_printf(m, "Backlight off delay: %d\n",
|
|
|
|
intel_dp->pps.backlight_off_delay);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
DEFINE_SHOW_ATTRIBUTE(intel_pps);
|
|
|
|
|
|
|
|
void intel_pps_connector_debugfs_add(struct intel_connector *connector)
|
|
|
|
{
|
|
|
|
struct dentry *root = connector->base.debugfs_entry;
|
|
|
|
int connector_type = connector->base.connector_type;
|
|
|
|
|
|
|
|
if (connector_type == DRM_MODE_CONNECTOR_eDP)
|
|
|
|
debugfs_create_file("i915_panel_timings", 0444, root,
|
|
|
|
connector, &intel_pps_fops);
|
|
|
|
}
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
void assert_pps_unlocked(struct intel_display *display, enum pipe pipe)
|
2021-09-30 12:22:59 +03:00
|
|
|
{
|
|
|
|
i915_reg_t pp_reg;
|
|
|
|
u32 val;
|
|
|
|
enum pipe panel_pipe = INVALID_PIPE;
|
|
|
|
bool locked = true;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
if (drm_WARN_ON(display->drm, HAS_DDI(display)))
|
2021-09-30 12:22:59 +03:00
|
|
|
return;
|
|
|
|
|
2025-04-17 12:10:36 +03:00
|
|
|
if (HAS_PCH_SPLIT(display)) {
|
2021-09-30 12:22:59 +03:00
|
|
|
u32 port_sel;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
pp_reg = PP_CONTROL(display, 0);
|
|
|
|
port_sel = intel_de_read(display, PP_ON_DELAYS(display, 0)) &
|
|
|
|
PANEL_PORT_SELECT_MASK;
|
2021-09-30 12:22:59 +03:00
|
|
|
|
|
|
|
switch (port_sel) {
|
|
|
|
case PANEL_PORT_SELECT_LVDS:
|
2025-03-21 12:52:51 +02:00
|
|
|
intel_lvds_port_enabled(display, PCH_LVDS, &panel_pipe);
|
2021-09-30 12:22:59 +03:00
|
|
|
break;
|
|
|
|
case PANEL_PORT_SELECT_DPA:
|
2025-02-12 18:36:30 +02:00
|
|
|
g4x_dp_port_enabled(display, DP_A, PORT_A, &panel_pipe);
|
2021-09-30 12:22:59 +03:00
|
|
|
break;
|
|
|
|
case PANEL_PORT_SELECT_DPC:
|
2025-02-12 18:36:30 +02:00
|
|
|
g4x_dp_port_enabled(display, PCH_DP_C, PORT_C, &panel_pipe);
|
2021-09-30 12:22:59 +03:00
|
|
|
break;
|
|
|
|
case PANEL_PORT_SELECT_DPD:
|
2025-02-12 18:36:30 +02:00
|
|
|
g4x_dp_port_enabled(display, PCH_DP_D, PORT_D, &panel_pipe);
|
2021-09-30 12:22:59 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MISSING_CASE(port_sel);
|
|
|
|
break;
|
|
|
|
}
|
2024-10-28 21:48:45 +02:00
|
|
|
} else if (display->platform.valleyview || display->platform.cherryview) {
|
2021-09-30 12:22:59 +03:00
|
|
|
/* presumably write lock depends on pipe, not port select */
|
2024-08-30 13:15:45 +03:00
|
|
|
pp_reg = PP_CONTROL(display, pipe);
|
2021-09-30 12:22:59 +03:00
|
|
|
panel_pipe = pipe;
|
|
|
|
} else {
|
|
|
|
u32 port_sel;
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
pp_reg = PP_CONTROL(display, 0);
|
|
|
|
port_sel = intel_de_read(display, PP_ON_DELAYS(display, 0)) &
|
|
|
|
PANEL_PORT_SELECT_MASK;
|
2021-09-30 12:22:59 +03:00
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
drm_WARN_ON(display->drm,
|
2021-09-30 12:22:59 +03:00
|
|
|
port_sel != PANEL_PORT_SELECT_LVDS);
|
2025-03-21 12:52:51 +02:00
|
|
|
intel_lvds_port_enabled(display, LVDS, &panel_pipe);
|
2021-09-30 12:22:59 +03:00
|
|
|
}
|
|
|
|
|
2024-08-30 13:15:45 +03:00
|
|
|
val = intel_de_read(display, pp_reg);
|
2021-09-30 12:22:59 +03:00
|
|
|
if (!(val & PANEL_POWER_ON) ||
|
|
|
|
((val & PANEL_UNLOCK_MASK) == PANEL_UNLOCK_REGS))
|
|
|
|
locked = false;
|
|
|
|
|
2024-10-24 19:25:10 +03:00
|
|
|
INTEL_DISPLAY_STATE_WARN(display, panel_pipe == pipe && locked,
|
|
|
|
"panel assertion failure, pipe %c regs locked\n",
|
|
|
|
pipe_name(pipe));
|
2021-09-30 12:22:59 +03:00
|
|
|
}
|