1 // SPDX-License-Identifier: MIT
2 /*
3  * Copyright © 2022 Intel Corporation
4  */
5 
6 #include "i915_drv.h"
7 #include "intel_de.h"
8 #include "intel_display.h"
9 #include "intel_hti.h"
10 #include "intel_hti_regs.h"
11 
12 void intel_hti_init(struct drm_i915_private *i915)
13 {
14 	/*
15 	 * If the platform has HTI, we need to find out whether it has reserved
16 	 * any display resources before we create our display outputs.
17 	 */
18 	if (DISPLAY_INFO(i915)->has_hti)
19 		i915->display.hti.state = intel_de_read(i915, HDPORT_STATE);
20 }
21 
22 bool intel_hti_uses_phy(struct drm_i915_private *i915, enum phy phy)
23 {
24 	if (drm_WARN_ON(&i915->drm, phy == PHY_NONE))
25 		return false;
26 
27 	return i915->display.hti.state & HDPORT_ENABLED &&
28 		i915->display.hti.state & HDPORT_DDI_USED(phy);
29 }
30 
31 u32 intel_hti_dpll_mask(struct drm_i915_private *i915)
32 {
33 	if (!(i915->display.hti.state & HDPORT_ENABLED))
34 		return 0;
35 
36 	/*
37 	 * Note: This is subtle. The values must coincide with what's defined
38 	 * for the platform.
39 	 */
40 	return REG_FIELD_GET(HDPORT_DPLL_USED_MASK, i915->display.hti.state);
41 }
42