1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2019 Intel Corporation
4  */
5 
6 #ifndef __INTEL_DE_H__
7 #define __INTEL_DE_H__
8 
9 #include "i915_drv.h"
10 #include "i915_reg.h"
11 #include "intel_uncore.h"
12 
13 static inline u32
intel_de_read(struct drm_i915_private * i915,i915_reg_t reg)14 intel_de_read(struct drm_i915_private *i915, i915_reg_t reg)
15 {
16 	return intel_uncore_read(&i915->uncore, reg);
17 }
18 
19 static inline void
intel_de_posting_read(struct drm_i915_private * i915,i915_reg_t reg)20 intel_de_posting_read(struct drm_i915_private *i915, i915_reg_t reg)
21 {
22 	intel_uncore_posting_read(&i915->uncore, reg);
23 }
24 
25 /* Note: read the warnings for intel_uncore_*_fw() functions! */
26 static inline u32
intel_de_read_fw(struct drm_i915_private * i915,i915_reg_t reg)27 intel_de_read_fw(struct drm_i915_private *i915, i915_reg_t reg)
28 {
29 	return intel_uncore_read_fw(&i915->uncore, reg);
30 }
31 
32 static inline void
intel_de_write(struct drm_i915_private * i915,i915_reg_t reg,u32 val)33 intel_de_write(struct drm_i915_private *i915, i915_reg_t reg, u32 val)
34 {
35 	intel_uncore_write(&i915->uncore, reg, val);
36 }
37 
38 /* Note: read the warnings for intel_uncore_*_fw() functions! */
39 static inline void
intel_de_write_fw(struct drm_i915_private * i915,i915_reg_t reg,u32 val)40 intel_de_write_fw(struct drm_i915_private *i915, i915_reg_t reg, u32 val)
41 {
42 	intel_uncore_write_fw(&i915->uncore, reg, val);
43 }
44 
45 static inline void
intel_de_rmw(struct drm_i915_private * i915,i915_reg_t reg,u32 clear,u32 set)46 intel_de_rmw(struct drm_i915_private *i915, i915_reg_t reg, u32 clear, u32 set)
47 {
48 	intel_uncore_rmw(&i915->uncore, reg, clear, set);
49 }
50 
51 static inline int
intel_de_wait_for_register(struct drm_i915_private * i915,i915_reg_t reg,u32 mask,u32 value,unsigned int timeout)52 intel_de_wait_for_register(struct drm_i915_private *i915, i915_reg_t reg,
53 			   u32 mask, u32 value, unsigned int timeout)
54 {
55 	return intel_wait_for_register(&i915->uncore, reg, mask, value, timeout);
56 }
57 
58 static inline int
intel_de_wait_for_set(struct drm_i915_private * i915,i915_reg_t reg,u32 mask,unsigned int timeout)59 intel_de_wait_for_set(struct drm_i915_private *i915, i915_reg_t reg,
60 		      u32 mask, unsigned int timeout)
61 {
62 	return intel_de_wait_for_register(i915, reg, mask, mask, timeout);
63 }
64 
65 static inline int
intel_de_wait_for_clear(struct drm_i915_private * i915,i915_reg_t reg,u32 mask,unsigned int timeout)66 intel_de_wait_for_clear(struct drm_i915_private *i915, i915_reg_t reg,
67 			u32 mask, unsigned int timeout)
68 {
69 	return intel_de_wait_for_register(i915, reg, mask, 0, timeout);
70 }
71 
72 #endif /* __INTEL_DE_H__ */
73