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