1 // SPDX-License-Identifier: MIT
3 * Copyright © 2013-2021 Intel Corporation
5 * LPT/WPT IOSF sideband.
12 static int intel_sbi_rw(struct drm_i915_private *i915, u16 reg,
13 enum intel_sbi_destination destination,
14 u32 *val, bool is_read)
16 struct intel_uncore *uncore = &i915->uncore;
19 lockdep_assert_held(&i915->sb_lock);
21 if (intel_wait_for_register_fw(uncore,
22 SBI_CTL_STAT, SBI_BUSY, 0,
25 "timeout waiting for SBI to become ready\n");
29 intel_uncore_write_fw(uncore, SBI_ADDR, (u32)reg << 16);
30 intel_uncore_write_fw(uncore, SBI_DATA, is_read ? 0 : *val);
32 if (destination == SBI_ICLK)
33 cmd = SBI_CTL_DEST_ICLK | SBI_CTL_OP_CRRD;
35 cmd = SBI_CTL_DEST_MPHY | SBI_CTL_OP_IORD;
38 intel_uncore_write_fw(uncore, SBI_CTL_STAT, cmd | SBI_BUSY);
40 if (__intel_wait_for_register_fw(uncore,
41 SBI_CTL_STAT, SBI_BUSY, 0,
44 "timeout waiting for SBI to complete read\n");
48 if (cmd & SBI_RESPONSE_FAIL) {
49 drm_err(&i915->drm, "error during SBI read of reg %x\n", reg);
54 *val = intel_uncore_read_fw(uncore, SBI_DATA);
59 u32 intel_sbi_read(struct drm_i915_private *i915, u16 reg,
60 enum intel_sbi_destination destination)
64 intel_sbi_rw(i915, reg, destination, &result, true);
69 void intel_sbi_write(struct drm_i915_private *i915, u16 reg, u32 value,
70 enum intel_sbi_destination destination)
72 intel_sbi_rw(i915, reg, destination, &value, false);