18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: MIT */ 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci#ifndef _INTEL_SIDEBAND_H_ 48c2ecf20Sopenharmony_ci#define _INTEL_SIDEBAND_H_ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <linux/bitops.h> 78c2ecf20Sopenharmony_ci#include <linux/types.h> 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_cistruct drm_i915_private; 108c2ecf20Sopenharmony_cienum pipe; 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_cienum intel_sbi_destination { 138c2ecf20Sopenharmony_ci SBI_ICLK, 148c2ecf20Sopenharmony_ci SBI_MPHY, 158c2ecf20Sopenharmony_ci}; 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cienum { 188c2ecf20Sopenharmony_ci VLV_IOSF_SB_BUNIT, 198c2ecf20Sopenharmony_ci VLV_IOSF_SB_CCK, 208c2ecf20Sopenharmony_ci VLV_IOSF_SB_CCU, 218c2ecf20Sopenharmony_ci VLV_IOSF_SB_DPIO, 228c2ecf20Sopenharmony_ci VLV_IOSF_SB_FLISDSI, 238c2ecf20Sopenharmony_ci VLV_IOSF_SB_GPIO, 248c2ecf20Sopenharmony_ci VLV_IOSF_SB_NC, 258c2ecf20Sopenharmony_ci VLV_IOSF_SB_PUNIT, 268c2ecf20Sopenharmony_ci}; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_civoid vlv_iosf_sb_get(struct drm_i915_private *i915, unsigned long ports); 298c2ecf20Sopenharmony_ciu32 vlv_iosf_sb_read(struct drm_i915_private *i915, u8 port, u32 reg); 308c2ecf20Sopenharmony_civoid vlv_iosf_sb_write(struct drm_i915_private *i915, 318c2ecf20Sopenharmony_ci u8 port, u32 reg, u32 val); 328c2ecf20Sopenharmony_civoid vlv_iosf_sb_put(struct drm_i915_private *i915, unsigned long ports); 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistatic inline void vlv_bunit_get(struct drm_i915_private *i915) 358c2ecf20Sopenharmony_ci{ 368c2ecf20Sopenharmony_ci vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_BUNIT)); 378c2ecf20Sopenharmony_ci} 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ciu32 vlv_bunit_read(struct drm_i915_private *i915, u32 reg); 408c2ecf20Sopenharmony_civoid vlv_bunit_write(struct drm_i915_private *i915, u32 reg, u32 val); 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistatic inline void vlv_bunit_put(struct drm_i915_private *i915) 438c2ecf20Sopenharmony_ci{ 448c2ecf20Sopenharmony_ci vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_BUNIT)); 458c2ecf20Sopenharmony_ci} 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_cistatic inline void vlv_cck_get(struct drm_i915_private *i915) 488c2ecf20Sopenharmony_ci{ 498c2ecf20Sopenharmony_ci vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_CCK)); 508c2ecf20Sopenharmony_ci} 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ciu32 vlv_cck_read(struct drm_i915_private *i915, u32 reg); 538c2ecf20Sopenharmony_civoid vlv_cck_write(struct drm_i915_private *i915, u32 reg, u32 val); 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_cistatic inline void vlv_cck_put(struct drm_i915_private *i915) 568c2ecf20Sopenharmony_ci{ 578c2ecf20Sopenharmony_ci vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_CCK)); 588c2ecf20Sopenharmony_ci} 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic inline void vlv_ccu_get(struct drm_i915_private *i915) 618c2ecf20Sopenharmony_ci{ 628c2ecf20Sopenharmony_ci vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_CCU)); 638c2ecf20Sopenharmony_ci} 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ciu32 vlv_ccu_read(struct drm_i915_private *i915, u32 reg); 668c2ecf20Sopenharmony_civoid vlv_ccu_write(struct drm_i915_private *i915, u32 reg, u32 val); 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cistatic inline void vlv_ccu_put(struct drm_i915_private *i915) 698c2ecf20Sopenharmony_ci{ 708c2ecf20Sopenharmony_ci vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_CCU)); 718c2ecf20Sopenharmony_ci} 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_cistatic inline void vlv_dpio_get(struct drm_i915_private *i915) 748c2ecf20Sopenharmony_ci{ 758c2ecf20Sopenharmony_ci vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_DPIO)); 768c2ecf20Sopenharmony_ci} 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ciu32 vlv_dpio_read(struct drm_i915_private *i915, enum pipe pipe, int reg); 798c2ecf20Sopenharmony_civoid vlv_dpio_write(struct drm_i915_private *i915, 808c2ecf20Sopenharmony_ci enum pipe pipe, int reg, u32 val); 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_cistatic inline void vlv_dpio_put(struct drm_i915_private *i915) 838c2ecf20Sopenharmony_ci{ 848c2ecf20Sopenharmony_ci vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_DPIO)); 858c2ecf20Sopenharmony_ci} 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_cistatic inline void vlv_flisdsi_get(struct drm_i915_private *i915) 888c2ecf20Sopenharmony_ci{ 898c2ecf20Sopenharmony_ci vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_FLISDSI)); 908c2ecf20Sopenharmony_ci} 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ciu32 vlv_flisdsi_read(struct drm_i915_private *i915, u32 reg); 938c2ecf20Sopenharmony_civoid vlv_flisdsi_write(struct drm_i915_private *i915, u32 reg, u32 val); 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_cistatic inline void vlv_flisdsi_put(struct drm_i915_private *i915) 968c2ecf20Sopenharmony_ci{ 978c2ecf20Sopenharmony_ci vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_FLISDSI)); 988c2ecf20Sopenharmony_ci} 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_cistatic inline void vlv_nc_get(struct drm_i915_private *i915) 1018c2ecf20Sopenharmony_ci{ 1028c2ecf20Sopenharmony_ci vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_NC)); 1038c2ecf20Sopenharmony_ci} 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ciu32 vlv_nc_read(struct drm_i915_private *i915, u8 addr); 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_cistatic inline void vlv_nc_put(struct drm_i915_private *i915) 1088c2ecf20Sopenharmony_ci{ 1098c2ecf20Sopenharmony_ci vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_NC)); 1108c2ecf20Sopenharmony_ci} 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_cistatic inline void vlv_punit_get(struct drm_i915_private *i915) 1138c2ecf20Sopenharmony_ci{ 1148c2ecf20Sopenharmony_ci vlv_iosf_sb_get(i915, BIT(VLV_IOSF_SB_PUNIT)); 1158c2ecf20Sopenharmony_ci} 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ciu32 vlv_punit_read(struct drm_i915_private *i915, u32 addr); 1188c2ecf20Sopenharmony_ciint vlv_punit_write(struct drm_i915_private *i915, u32 addr, u32 val); 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_cistatic inline void vlv_punit_put(struct drm_i915_private *i915) 1218c2ecf20Sopenharmony_ci{ 1228c2ecf20Sopenharmony_ci vlv_iosf_sb_put(i915, BIT(VLV_IOSF_SB_PUNIT)); 1238c2ecf20Sopenharmony_ci} 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ciu32 intel_sbi_read(struct drm_i915_private *i915, u16 reg, 1268c2ecf20Sopenharmony_ci enum intel_sbi_destination destination); 1278c2ecf20Sopenharmony_civoid intel_sbi_write(struct drm_i915_private *i915, u16 reg, u32 value, 1288c2ecf20Sopenharmony_ci enum intel_sbi_destination destination); 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ciint sandybridge_pcode_read(struct drm_i915_private *i915, u32 mbox, 1318c2ecf20Sopenharmony_ci u32 *val, u32 *val1); 1328c2ecf20Sopenharmony_ciint sandybridge_pcode_write_timeout(struct drm_i915_private *i915, u32 mbox, 1338c2ecf20Sopenharmony_ci u32 val, int fast_timeout_us, 1348c2ecf20Sopenharmony_ci int slow_timeout_ms); 1358c2ecf20Sopenharmony_ci#define sandybridge_pcode_write(i915, mbox, val) \ 1368c2ecf20Sopenharmony_ci sandybridge_pcode_write_timeout(i915, mbox, val, 500, 0) 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ciint skl_pcode_request(struct drm_i915_private *i915, u32 mbox, u32 request, 1398c2ecf20Sopenharmony_ci u32 reply_mask, u32 reply, int timeout_base_ms); 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_civoid intel_pcode_init(struct drm_i915_private *i915); 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci#endif /* _INTEL_SIDEBAND_H */ 144