struct intel_dpll_mgr {
        const struct dpll_info *dpll_info;
 
+       int (*compute_dplls)(struct intel_atomic_state *state,
+                            struct intel_crtc *crtc,
+                            struct intel_encoder *encoder);
        int (*get_dplls)(struct intel_atomic_state *state,
                         struct intel_crtc *crtc,
                         struct intel_encoder *encoder);
        udelay(200);
 }
 
+static int ibx_compute_dpll(struct intel_atomic_state *state,
+                           struct intel_crtc *crtc,
+                           struct intel_encoder *encoder)
+{
+       return 0;
+}
+
 static int ibx_get_dpll(struct intel_atomic_state *state,
                        struct intel_crtc *crtc,
                        struct intel_encoder *encoder)
 
 static const struct intel_dpll_mgr pch_pll_mgr = {
        .dpll_info = pch_plls,
+       .compute_dplls = ibx_compute_dpll,
        .get_dplls = ibx_get_dpll,
        .put_dplls = intel_put_dpll,
        .dump_hw_state = ibx_dump_hw_state,
        *r2_out = best.r2;
 }
 
-static struct intel_shared_dpll *
-hsw_ddi_wrpll_get_dpll(struct intel_atomic_state *state,
-                      struct intel_crtc *crtc)
+static int
+hsw_ddi_wrpll_compute_dpll(struct intel_atomic_state *state,
+                          struct intel_crtc *crtc)
 {
        struct intel_crtc_state *crtc_state =
                intel_atomic_get_new_crtc_state(state, crtc);
-       struct intel_shared_dpll *pll;
-       u32 val;
        unsigned int p, n2, r2;
 
        hsw_ddi_calculate_wrpll(crtc_state->port_clock * 1000, &r2, &n2, &p);
 
-       val = WRPLL_PLL_ENABLE | WRPLL_REF_LCPLL |
-             WRPLL_DIVIDER_REFERENCE(r2) | WRPLL_DIVIDER_FEEDBACK(n2) |
-             WRPLL_DIVIDER_POST(p);
-
-       crtc_state->dpll_hw_state.wrpll = val;
+       crtc_state->dpll_hw_state.wrpll =
+               WRPLL_PLL_ENABLE | WRPLL_REF_LCPLL |
+               WRPLL_DIVIDER_REFERENCE(r2) | WRPLL_DIVIDER_FEEDBACK(n2) |
+               WRPLL_DIVIDER_POST(p);
 
-       pll = intel_find_shared_dpll(state, crtc,
-                                    &crtc_state->dpll_hw_state,
-                                    BIT(DPLL_ID_WRPLL2) |
-                                    BIT(DPLL_ID_WRPLL1));
+       return 0;
+}
 
-       if (!pll)
-               return NULL;
+static struct intel_shared_dpll *
+hsw_ddi_wrpll_get_dpll(struct intel_atomic_state *state,
+                      struct intel_crtc *crtc)
+{
+       struct intel_crtc_state *crtc_state =
+               intel_atomic_get_new_crtc_state(state, crtc);
 
-       return pll;
+       return intel_find_shared_dpll(state, crtc,
+                                     &crtc_state->dpll_hw_state,
+                                     BIT(DPLL_ID_WRPLL2) |
+                                     BIT(DPLL_ID_WRPLL1));
 }
 
 static int hsw_ddi_wrpll_get_freq(struct drm_i915_private *dev_priv,
        return (refclk * n / 10) / (p * r) * 2;
 }
 
+static int
+hsw_ddi_lcpll_compute_dpll(struct intel_crtc_state *crtc_state)
+{
+       struct drm_i915_private *dev_priv = to_i915(crtc_state->uapi.crtc->dev);
+       int clock = crtc_state->port_clock;
+
+       switch (clock / 2) {
+       case 81000:
+       case 135000:
+       case 270000:
+               return 0;
+       default:
+               drm_dbg_kms(&dev_priv->drm, "Invalid clock for DP: %d\n",
+                           clock);
+               return -EINVAL;
+       }
+}
+
 static struct intel_shared_dpll *
 hsw_ddi_lcpll_get_dpll(struct intel_crtc_state *crtc_state)
 {
                pll_id = DPLL_ID_LCPLL_2700;
                break;
        default:
-               drm_dbg_kms(&dev_priv->drm, "Invalid clock for DP: %d\n",
-                           clock);
+               MISSING_CASE(clock / 2);
                return NULL;
        }
 
        return link_clock * 2;
 }
 
-static struct intel_shared_dpll *
-hsw_ddi_spll_get_dpll(struct intel_atomic_state *state,
-                     struct intel_crtc *crtc)
+static int
+hsw_ddi_spll_compute_dpll(struct intel_atomic_state *state,
+                         struct intel_crtc *crtc)
 {
        struct intel_crtc_state *crtc_state =
                intel_atomic_get_new_crtc_state(state, crtc);
 
        if (drm_WARN_ON(crtc->base.dev, crtc_state->port_clock / 2 != 135000))
-               return NULL;
+               return -EINVAL;
+
+       crtc_state->dpll_hw_state.spll =
+               SPLL_PLL_ENABLE | SPLL_FREQ_1350MHz | SPLL_REF_MUXED_SSC;
 
-       crtc_state->dpll_hw_state.spll = SPLL_PLL_ENABLE | SPLL_FREQ_1350MHz |
-                                        SPLL_REF_MUXED_SSC;
+       return 0;
+}
+
+static struct intel_shared_dpll *
+hsw_ddi_spll_get_dpll(struct intel_atomic_state *state,
+                     struct intel_crtc *crtc)
+{
+       struct intel_crtc_state *crtc_state =
+               intel_atomic_get_new_crtc_state(state, crtc);
 
        return intel_find_shared_dpll(state, crtc, &crtc_state->dpll_hw_state,
                                      BIT(DPLL_ID_SPLL));
        return link_clock * 2;
 }
 
+static int hsw_compute_dpll(struct intel_atomic_state *state,
+                           struct intel_crtc *crtc,
+                           struct intel_encoder *encoder)
+{
+       struct intel_crtc_state *crtc_state =
+               intel_atomic_get_new_crtc_state(state, crtc);
+
+       if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
+               return hsw_ddi_wrpll_compute_dpll(state, crtc);
+       else if (intel_crtc_has_dp_encoder(crtc_state))
+               return hsw_ddi_lcpll_compute_dpll(crtc_state);
+       else if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_ANALOG))
+               return hsw_ddi_spll_compute_dpll(state, crtc);
+       else
+               return -EINVAL;
+}
+
 static int hsw_get_dpll(struct intel_atomic_state *state,
                        struct intel_crtc *crtc,
                        struct intel_encoder *encoder)
 
 static const struct intel_dpll_mgr hsw_pll_mgr = {
        .dpll_info = hsw_plls,
+       .compute_dplls = hsw_compute_dpll,
        .get_dplls = hsw_get_dpll,
        .put_dplls = intel_put_dpll,
        .update_ref_clks = hsw_update_dpll_ref_clks,
        return link_clock * 2;
 }
 
-static int skl_get_dpll(struct intel_atomic_state *state,
-                       struct intel_crtc *crtc,
-                       struct intel_encoder *encoder)
+static int skl_compute_dpll(struct intel_atomic_state *state,
+                           struct intel_crtc *crtc,
+                           struct intel_encoder *encoder)
 {
        struct intel_crtc_state *crtc_state =
                intel_atomic_get_new_crtc_state(state, crtc);
-       struct intel_shared_dpll *pll;
-       int ret;
 
        if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
-               ret = skl_ddi_hdmi_pll_dividers(crtc_state);
+               return skl_ddi_hdmi_pll_dividers(crtc_state);
        else if (intel_crtc_has_dp_encoder(crtc_state))
-               ret = skl_ddi_dp_set_dpll_hw_state(crtc_state);
+               return skl_ddi_dp_set_dpll_hw_state(crtc_state);
        else
-               ret = -EINVAL;
-       if (ret)
-               return ret;
+               return -EINVAL;
+}
+
+static int skl_get_dpll(struct intel_atomic_state *state,
+                       struct intel_crtc *crtc,
+                       struct intel_encoder *encoder)
+{
+       struct intel_crtc_state *crtc_state =
+               intel_atomic_get_new_crtc_state(state, crtc);
+       struct intel_shared_dpll *pll;
 
        if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_EDP))
                pll = intel_find_shared_dpll(state, crtc,
 
 static const struct intel_dpll_mgr skl_pll_mgr = {
        .dpll_info = skl_plls,
+       .compute_dplls = skl_compute_dpll,
        .get_dplls = skl_get_dpll,
        .put_dplls = intel_put_dpll,
        .update_ref_clks = skl_update_dpll_ref_clks,
        return chv_calc_dpll_params(i915->dpll.ref_clks.nssc, &clock);
 }
 
+static int bxt_compute_dpll(struct intel_atomic_state *state,
+                           struct intel_crtc *crtc,
+                           struct intel_encoder *encoder)
+{
+       struct intel_crtc_state *crtc_state =
+               intel_atomic_get_new_crtc_state(state, crtc);
+
+       if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
+               return bxt_ddi_hdmi_set_dpll_hw_state(crtc_state);
+       else if (intel_crtc_has_dp_encoder(crtc_state))
+               return bxt_ddi_dp_set_dpll_hw_state(crtc_state);
+       else
+               return -EINVAL;
+}
+
 static int bxt_get_dpll(struct intel_atomic_state *state,
                        struct intel_crtc *crtc,
                        struct intel_encoder *encoder)
        struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
        struct intel_shared_dpll *pll;
        enum intel_dpll_id id;
-       int ret;
-
-       if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
-               ret = bxt_ddi_hdmi_set_dpll_hw_state(crtc_state);
-       else if (intel_crtc_has_dp_encoder(crtc_state))
-               ret = bxt_ddi_dp_set_dpll_hw_state(crtc_state);
-       else
-               ret = -EINVAL;
-       if (ret)
-               return ret;
 
        /* 1:1 mapping between ports and PLLs */
        id = (enum intel_dpll_id) encoder->port;
 
 static const struct intel_dpll_mgr bxt_pll_mgr = {
        .dpll_info = bxt_plls,
+       .compute_dplls = bxt_compute_dpll,
        .get_dplls = bxt_get_dpll,
        .put_dplls = intel_put_dpll,
        .update_ref_clks = bxt_update_dpll_ref_clks,
        return REG_FIELD_GET(HDPORT_DPLL_USED_MASK, i915->hti_state);
 }
 
-static int icl_get_combo_phy_dpll(struct intel_atomic_state *state,
-                                 struct intel_crtc *crtc,
-                                 struct intel_encoder *encoder)
+static int icl_compute_combo_phy_dpll(struct intel_atomic_state *state,
+                                     struct intel_crtc *crtc)
 {
+       struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
        struct intel_crtc_state *crtc_state =
                intel_atomic_get_new_crtc_state(state, crtc);
-       struct skl_wrpll_params pll_params = { };
        struct icl_port_dpll *port_dpll =
                &crtc_state->icl_port_dplls[ICL_PORT_DPLL_DEFAULT];
-       struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
-       enum port port = encoder->port;
-       unsigned long dpll_mask;
-       int ret;
+       struct skl_wrpll_params pll_params = {};
+       bool ret;
 
        if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI) ||
            intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DSI))
 
        icl_calc_dpll_state(dev_priv, &pll_params, &port_dpll->hw_state);
 
+       return 0;
+}
+
+static int icl_get_combo_phy_dpll(struct intel_atomic_state *state,
+                                 struct intel_crtc *crtc,
+                                 struct intel_encoder *encoder)
+{
+       struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
+       struct intel_crtc_state *crtc_state =
+               intel_atomic_get_new_crtc_state(state, crtc);
+       struct icl_port_dpll *port_dpll =
+               &crtc_state->icl_port_dplls[ICL_PORT_DPLL_DEFAULT];
+       enum port port = encoder->port;
+       unsigned long dpll_mask;
+
        if (IS_ALDERLAKE_S(dev_priv)) {
                dpll_mask =
                        BIT(DPLL_ID_DG1_DPLL3) |
        return 0;
 }
 
-static int icl_get_tc_phy_dplls(struct intel_atomic_state *state,
-                               struct intel_crtc *crtc,
-                               struct intel_encoder *encoder)
+static int icl_compute_tc_phy_dplls(struct intel_atomic_state *state,
+                                   struct intel_crtc *crtc)
 {
        struct drm_i915_private *dev_priv = to_i915(state->base.dev);
        struct intel_crtc_state *crtc_state =
                intel_atomic_get_new_crtc_state(state, crtc);
-       struct skl_wrpll_params pll_params = { };
-       struct icl_port_dpll *port_dpll;
-       enum intel_dpll_id dpll_id;
+       struct icl_port_dpll *port_dpll =
+               &crtc_state->icl_port_dplls[ICL_PORT_DPLL_DEFAULT];
+       struct skl_wrpll_params pll_params = {};
        int ret;
 
        port_dpll = &crtc_state->icl_port_dplls[ICL_PORT_DPLL_DEFAULT];
 
        icl_calc_dpll_state(dev_priv, &pll_params, &port_dpll->hw_state);
 
+       port_dpll = &crtc_state->icl_port_dplls[ICL_PORT_DPLL_MG_PHY];
+       ret = icl_calc_mg_pll_state(crtc_state, &port_dpll->hw_state);
+       if (ret) {
+               drm_dbg_kms(&dev_priv->drm,
+                           "Could not calculate MG PHY PLL state.\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+static int icl_get_tc_phy_dplls(struct intel_atomic_state *state,
+                               struct intel_crtc *crtc,
+                               struct intel_encoder *encoder)
+{
+       struct drm_i915_private *dev_priv = to_i915(state->base.dev);
+       struct intel_crtc_state *crtc_state =
+               intel_atomic_get_new_crtc_state(state, crtc);
+       struct icl_port_dpll *port_dpll =
+               &crtc_state->icl_port_dplls[ICL_PORT_DPLL_DEFAULT];
+       enum intel_dpll_id dpll_id;
+       int ret;
+
+       port_dpll = &crtc_state->icl_port_dplls[ICL_PORT_DPLL_DEFAULT];
        port_dpll->pll = intel_find_shared_dpll(state, crtc,
                                                &port_dpll->hw_state,
                                                BIT(DPLL_ID_ICL_TBTPLL));
 
 
        port_dpll = &crtc_state->icl_port_dplls[ICL_PORT_DPLL_MG_PHY];
-       ret = icl_calc_mg_pll_state(crtc_state, &port_dpll->hw_state);
-       if (ret) {
-               drm_dbg_kms(&dev_priv->drm,
-                           "Could not calculate MG PHY PLL state.\n");
-               goto err_unreference_tbt_pll;
-       }
-
        dpll_id = icl_tc_port_to_pll_id(intel_port_to_tc(dev_priv,
                                                         encoder->port));
        port_dpll->pll = intel_find_shared_dpll(state, crtc,
        return ret;
 }
 
+static int icl_compute_dplls(struct intel_atomic_state *state,
+                            struct intel_crtc *crtc,
+                            struct intel_encoder *encoder)
+{
+       struct drm_i915_private *dev_priv = to_i915(state->base.dev);
+       enum phy phy = intel_port_to_phy(dev_priv, encoder->port);
+
+       if (intel_phy_is_combo(dev_priv, phy))
+               return icl_compute_combo_phy_dpll(state, crtc);
+       else if (intel_phy_is_tc(dev_priv, phy))
+               return icl_compute_tc_phy_dplls(state, crtc);
+
+       MISSING_CASE(phy);
+
+       return 0;
+}
+
 static int icl_get_dplls(struct intel_atomic_state *state,
                         struct intel_crtc *crtc,
                         struct intel_encoder *encoder)
 
 static const struct intel_dpll_mgr icl_pll_mgr = {
        .dpll_info = icl_plls,
+       .compute_dplls = icl_compute_dplls,
        .get_dplls = icl_get_dplls,
        .put_dplls = icl_put_dplls,
        .update_active_dpll = icl_update_active_dpll,
 
 static const struct intel_dpll_mgr ehl_pll_mgr = {
        .dpll_info = ehl_plls,
+       .compute_dplls = icl_compute_dplls,
        .get_dplls = icl_get_dplls,
        .put_dplls = icl_put_dplls,
        .update_ref_clks = icl_update_dpll_ref_clks,
 
 static const struct intel_dpll_mgr tgl_pll_mgr = {
        .dpll_info = tgl_plls,
+       .compute_dplls = icl_compute_dplls,
        .get_dplls = icl_get_dplls,
        .put_dplls = icl_put_dplls,
        .update_active_dpll = icl_update_active_dpll,
 
 static const struct intel_dpll_mgr rkl_pll_mgr = {
        .dpll_info = rkl_plls,
+       .compute_dplls = icl_compute_dplls,
        .get_dplls = icl_get_dplls,
        .put_dplls = icl_put_dplls,
        .update_ref_clks = icl_update_dpll_ref_clks,
 
 static const struct intel_dpll_mgr dg1_pll_mgr = {
        .dpll_info = dg1_plls,
+       .compute_dplls = icl_compute_dplls,
        .get_dplls = icl_get_dplls,
        .put_dplls = icl_put_dplls,
        .update_ref_clks = icl_update_dpll_ref_clks,
 
 static const struct intel_dpll_mgr adls_pll_mgr = {
        .dpll_info = adls_plls,
+       .compute_dplls = icl_compute_dplls,
        .get_dplls = icl_get_dplls,
        .put_dplls = icl_put_dplls,
        .update_ref_clks = icl_update_dpll_ref_clks,
 
 static const struct intel_dpll_mgr adlp_pll_mgr = {
        .dpll_info = adlp_plls,
+       .compute_dplls = icl_compute_dplls,
        .get_dplls = icl_get_dplls,
        .put_dplls = icl_put_dplls,
        .update_active_dpll = icl_update_active_dpll,
        BUG_ON(dev_priv->dpll.num_shared_dpll > I915_NUM_PLLS);
 }
 
+/**
+ * intel_compute_shared_dplls - compute DPLL state CRTC and encoder combination
+ * @state: atomic state
+ * @crtc: CRTC to compute DPLLs for
+ * @encoder: encoder
+ *
+ * This function computes the DPLL state for the given CRTC and encoder.
+ *
+ * The new configuration in the atomic commit @state is made effective by
+ * calling intel_shared_dpll_swap_state().
+ *
+ * Returns:
+ * 0 on success, negative error code on falure.
+ */
+int intel_compute_shared_dplls(struct intel_atomic_state *state,
+                              struct intel_crtc *crtc,
+                              struct intel_encoder *encoder)
+{
+       struct drm_i915_private *dev_priv = to_i915(state->base.dev);
+       const struct intel_dpll_mgr *dpll_mgr = dev_priv->dpll.mgr;
+
+       if (drm_WARN_ON(&dev_priv->drm, !dpll_mgr))
+               return -EINVAL;
+
+       return dpll_mgr->compute_dplls(state, crtc, encoder);
+}
+
 /**
  * intel_reserve_shared_dplls - reserve DPLLs for CRTC and encoder combination
  * @state: atomic state