xref: /linux/drivers/gpu/drm/i915/vlv_sideband.h (revision f4fee216df7d28b87d1c9cc60bcebfecb51c1a05)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2013-2021 Intel Corporation
4  */
5 
6 #ifndef _VLV_SIDEBAND_H_
7 #define _VLV_SIDEBAND_H_
8 
9 #include <linux/bitops.h>
10 #include <linux/types.h>
11 
12 #include "vlv_sideband_reg.h"
13 
14 enum dpio_phy;
15 struct drm_i915_private;
16 
17 enum {
18 	VLV_IOSF_SB_BUNIT,
19 	VLV_IOSF_SB_CCK,
20 	VLV_IOSF_SB_CCU,
21 	VLV_IOSF_SB_DPIO,
22 	VLV_IOSF_SB_FLISDSI,
23 	VLV_IOSF_SB_GPIO,
24 	VLV_IOSF_SB_NC,
25 	VLV_IOSF_SB_PUNIT,
26 };
27 
28 void vlv_iosf_sb_get(struct drm_i915_private *i915, unsigned long ports);
29 void vlv_iosf_sb_put(struct drm_i915_private *i915, unsigned long ports);
30 
31 static inline void vlv_bunit_get(struct drm_i915_private *i915)
32 {
33 	vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_BUNIT));
34 }
35 
36 u32 vlv_bunit_read(struct drm_i915_private *i915, u32 reg);
37 void vlv_bunit_write(struct drm_i915_private *i915, u32 reg, u32 val);
38 
39 static inline void vlv_bunit_put(struct drm_i915_private *i915)
40 {
41 	vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_BUNIT));
42 }
43 
44 static inline void vlv_cck_get(struct drm_i915_private *i915)
45 {
46 	vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_CCK));
47 }
48 
49 u32 vlv_cck_read(struct drm_i915_private *i915, u32 reg);
50 void vlv_cck_write(struct drm_i915_private *i915, u32 reg, u32 val);
51 
52 static inline void vlv_cck_put(struct drm_i915_private *i915)
53 {
54 	vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_CCK));
55 }
56 
57 static inline void vlv_ccu_get(struct drm_i915_private *i915)
58 {
59 	vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_CCU));
60 }
61 
62 u32 vlv_ccu_read(struct drm_i915_private *i915, u32 reg);
63 void vlv_ccu_write(struct drm_i915_private *i915, u32 reg, u32 val);
64 
65 static inline void vlv_ccu_put(struct drm_i915_private *i915)
66 {
67 	vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_CCU));
68 }
69 
70 static inline void vlv_dpio_get(struct drm_i915_private *i915)
71 {
72 	vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_DPIO));
73 }
74 
75 u32 vlv_dpio_read(struct drm_i915_private *i915, enum dpio_phy phy, int reg);
76 void vlv_dpio_write(struct drm_i915_private *i915,
77 		    enum dpio_phy phy, int reg, u32 val);
78 
79 static inline void vlv_dpio_put(struct drm_i915_private *i915)
80 {
81 	vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_DPIO));
82 }
83 
84 static inline void vlv_flisdsi_get(struct drm_i915_private *i915)
85 {
86 	vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_FLISDSI));
87 }
88 
89 u32 vlv_flisdsi_read(struct drm_i915_private *i915, u32 reg);
90 void vlv_flisdsi_write(struct drm_i915_private *i915, u32 reg, u32 val);
91 
92 static inline void vlv_flisdsi_put(struct drm_i915_private *i915)
93 {
94 	vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_FLISDSI));
95 }
96 
97 static inline void vlv_nc_get(struct drm_i915_private *i915)
98 {
99 	vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_NC));
100 }
101 
102 u32 vlv_nc_read(struct drm_i915_private *i915, u8 addr);
103 
104 static inline void vlv_nc_put(struct drm_i915_private *i915)
105 {
106 	vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_NC));
107 }
108 
109 static inline void vlv_punit_get(struct drm_i915_private *i915)
110 {
111 	vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_PUNIT));
112 }
113 
114 u32 vlv_punit_read(struct drm_i915_private *i915, u32 addr);
115 int vlv_punit_write(struct drm_i915_private *i915, u32 addr, u32 val);
116 
117 static inline void vlv_punit_put(struct drm_i915_private *i915)
118 {
119 	vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_PUNIT));
120 }
121 
122 #endif /* _VLV_SIDEBAND_H_ */
123