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