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 pipe;
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 u32 vlv_iosf_sb_read(struct drm_i915_private *i915, u8 port, u32 reg);
30 void vlv_iosf_sb_write(struct drm_i915_private *i915,
31 		       u8 port, u32 reg, u32 val);
32 void vlv_iosf_sb_put(struct drm_i915_private *i915, unsigned long ports);
33 
vlv_bunit_get(struct drm_i915_private * i915)34 static inline void vlv_bunit_get(struct drm_i915_private *i915)
35 {
36 	vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_BUNIT));
37 }
38 
39 u32 vlv_bunit_read(struct drm_i915_private *i915, u32 reg);
40 void vlv_bunit_write(struct drm_i915_private *i915, u32 reg, u32 val);
41 
vlv_bunit_put(struct drm_i915_private * i915)42 static inline void vlv_bunit_put(struct drm_i915_private *i915)
43 {
44 	vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_BUNIT));
45 }
46 
vlv_cck_get(struct drm_i915_private * i915)47 static inline void vlv_cck_get(struct drm_i915_private *i915)
48 {
49 	vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_CCK));
50 }
51 
52 u32 vlv_cck_read(struct drm_i915_private *i915, u32 reg);
53 void vlv_cck_write(struct drm_i915_private *i915, u32 reg, u32 val);
54 
vlv_cck_put(struct drm_i915_private * i915)55 static inline void vlv_cck_put(struct drm_i915_private *i915)
56 {
57 	vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_CCK));
58 }
59 
vlv_ccu_get(struct drm_i915_private * i915)60 static inline void vlv_ccu_get(struct drm_i915_private *i915)
61 {
62 	vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_CCU));
63 }
64 
65 u32 vlv_ccu_read(struct drm_i915_private *i915, u32 reg);
66 void vlv_ccu_write(struct drm_i915_private *i915, u32 reg, u32 val);
67 
vlv_ccu_put(struct drm_i915_private * i915)68 static inline void vlv_ccu_put(struct drm_i915_private *i915)
69 {
70 	vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_CCU));
71 }
72 
vlv_dpio_get(struct drm_i915_private * i915)73 static inline void vlv_dpio_get(struct drm_i915_private *i915)
74 {
75 	vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_DPIO));
76 }
77 
78 u32 vlv_dpio_read(struct drm_i915_private *i915, enum pipe pipe, int reg);
79 void vlv_dpio_write(struct drm_i915_private *i915,
80 		    enum pipe pipe, int reg, u32 val);
81 
vlv_dpio_put(struct drm_i915_private * i915)82 static inline void vlv_dpio_put(struct drm_i915_private *i915)
83 {
84 	vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_DPIO));
85 }
86 
vlv_flisdsi_get(struct drm_i915_private * i915)87 static inline void vlv_flisdsi_get(struct drm_i915_private *i915)
88 {
89 	vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_FLISDSI));
90 }
91 
92 u32 vlv_flisdsi_read(struct drm_i915_private *i915, u32 reg);
93 void vlv_flisdsi_write(struct drm_i915_private *i915, u32 reg, u32 val);
94 
vlv_flisdsi_put(struct drm_i915_private * i915)95 static inline void vlv_flisdsi_put(struct drm_i915_private *i915)
96 {
97 	vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_FLISDSI));
98 }
99 
vlv_nc_get(struct drm_i915_private * i915)100 static inline void vlv_nc_get(struct drm_i915_private *i915)
101 {
102 	vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_NC));
103 }
104 
105 u32 vlv_nc_read(struct drm_i915_private *i915, u8 addr);
106 
vlv_nc_put(struct drm_i915_private * i915)107 static inline void vlv_nc_put(struct drm_i915_private *i915)
108 {
109 	vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_NC));
110 }
111 
vlv_punit_get(struct drm_i915_private * i915)112 static inline void vlv_punit_get(struct drm_i915_private *i915)
113 {
114 	vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_PUNIT));
115 }
116 
117 u32 vlv_punit_read(struct drm_i915_private *i915, u32 addr);
118 int vlv_punit_write(struct drm_i915_private *i915, u32 addr, u32 val);
119 
vlv_punit_put(struct drm_i915_private * i915)120 static inline void vlv_punit_put(struct drm_i915_private *i915)
121 {
122 	vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_PUNIT));
123 }
124 
125 #endif /* _VLV_SIDEBAND_H_ */
126