2 * Copyright © 2017 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 #ifndef __INTEL_UNCORE_H__
26 #define __INTEL_UNCORE_H__
28 #include <linux/spinlock.h>
29 #include <linux/notifier.h>
30 #include <linux/hrtimer.h>
34 struct drm_i915_private
;
36 enum forcewake_domain_id
{
37 FW_DOMAIN_ID_RENDER
= 0,
44 enum forcewake_domains
{
45 FORCEWAKE_RENDER
= BIT(FW_DOMAIN_ID_RENDER
),
46 FORCEWAKE_BLITTER
= BIT(FW_DOMAIN_ID_BLITTER
),
47 FORCEWAKE_MEDIA
= BIT(FW_DOMAIN_ID_MEDIA
),
48 FORCEWAKE_ALL
= (FORCEWAKE_RENDER
|
53 struct intel_uncore_funcs
{
54 void (*force_wake_get
)(struct drm_i915_private
*dev_priv
,
55 enum forcewake_domains domains
);
56 void (*force_wake_put
)(struct drm_i915_private
*dev_priv
,
57 enum forcewake_domains domains
);
59 uint8_t (*mmio_readb
)(struct drm_i915_private
*dev_priv
,
60 i915_reg_t r
, bool trace
);
61 uint16_t (*mmio_readw
)(struct drm_i915_private
*dev_priv
,
62 i915_reg_t r
, bool trace
);
63 uint32_t (*mmio_readl
)(struct drm_i915_private
*dev_priv
,
64 i915_reg_t r
, bool trace
);
65 uint64_t (*mmio_readq
)(struct drm_i915_private
*dev_priv
,
66 i915_reg_t r
, bool trace
);
68 void (*mmio_writeb
)(struct drm_i915_private
*dev_priv
,
69 i915_reg_t r
, uint8_t val
, bool trace
);
70 void (*mmio_writew
)(struct drm_i915_private
*dev_priv
,
71 i915_reg_t r
, uint16_t val
, bool trace
);
72 void (*mmio_writel
)(struct drm_i915_private
*dev_priv
,
73 i915_reg_t r
, uint32_t val
, bool trace
);
76 struct intel_forcewake_range
{
80 enum forcewake_domains domains
;
84 spinlock_t lock
; /** lock is also taken in irq contexts. */
86 const struct intel_forcewake_range
*fw_domains_table
;
87 unsigned int fw_domains_table_entries
;
89 struct notifier_block pmic_bus_access_nb
;
90 struct intel_uncore_funcs funcs
;
92 unsigned int fifo_count
;
94 enum forcewake_domains fw_domains
;
95 enum forcewake_domains fw_domains_active
;
101 struct intel_uncore_forcewake_domain
{
102 enum forcewake_domain_id id
;
103 enum forcewake_domains mask
;
104 unsigned int wake_count
;
106 struct hrtimer timer
;
109 } fw_domain
[FW_DOMAIN_ID_COUNT
];
114 int saved_mmio_check
;
115 int saved_mmio_debug
;
118 int unclaimed_mmio_check
;
121 /* Iterate over initialised fw domains */
122 #define for_each_fw_domain_masked(domain__, mask__, dev_priv__, tmp__) \
123 for (tmp__ = (mask__); \
124 tmp__ ? (domain__ = &(dev_priv__)->uncore.fw_domain[__mask_next_bit(tmp__)]), 1 : 0;)
126 #define for_each_fw_domain(domain__, dev_priv__, tmp__) \
127 for_each_fw_domain_masked(domain__, (dev_priv__)->uncore.fw_domains, dev_priv__, tmp__)
130 void intel_uncore_sanitize(struct drm_i915_private
*dev_priv
);
131 void intel_uncore_init(struct drm_i915_private
*dev_priv
);
132 bool intel_uncore_unclaimed_mmio(struct drm_i915_private
*dev_priv
);
133 bool intel_uncore_arm_unclaimed_mmio_detection(struct drm_i915_private
*dev_priv
);
134 void intel_uncore_fini(struct drm_i915_private
*dev_priv
);
135 void intel_uncore_suspend(struct drm_i915_private
*dev_priv
);
136 void intel_uncore_resume_early(struct drm_i915_private
*dev_priv
);
137 void intel_uncore_runtime_resume(struct drm_i915_private
*dev_priv
);
139 u64
intel_uncore_edram_size(struct drm_i915_private
*dev_priv
);
140 void assert_forcewakes_inactive(struct drm_i915_private
*dev_priv
);
141 void assert_forcewakes_active(struct drm_i915_private
*dev_priv
,
142 enum forcewake_domains fw_domains
);
143 const char *intel_uncore_forcewake_domain_to_str(const enum forcewake_domain_id id
);
145 enum forcewake_domains
146 intel_uncore_forcewake_for_reg(struct drm_i915_private
*dev_priv
,
147 i915_reg_t reg
, unsigned int op
);
148 #define FW_REG_READ (1)
149 #define FW_REG_WRITE (2)
151 void intel_uncore_forcewake_get(struct drm_i915_private
*dev_priv
,
152 enum forcewake_domains domains
);
153 void intel_uncore_forcewake_put(struct drm_i915_private
*dev_priv
,
154 enum forcewake_domains domains
);
155 /* Like above but the caller must manage the uncore.lock itself.
156 * Must be used with I915_READ_FW and friends.
158 void intel_uncore_forcewake_get__locked(struct drm_i915_private
*dev_priv
,
159 enum forcewake_domains domains
);
160 void intel_uncore_forcewake_put__locked(struct drm_i915_private
*dev_priv
,
161 enum forcewake_domains domains
);
163 void intel_uncore_forcewake_user_get(struct drm_i915_private
*dev_priv
);
164 void intel_uncore_forcewake_user_put(struct drm_i915_private
*dev_priv
);
166 int intel_wait_for_register(struct drm_i915_private
*dev_priv
,
170 unsigned int timeout_ms
);
171 int __intel_wait_for_register_fw(struct drm_i915_private
*dev_priv
,
175 unsigned int fast_timeout_us
,
176 unsigned int slow_timeout_ms
,
179 int intel_wait_for_register_fw(struct drm_i915_private
*dev_priv
,
183 unsigned int timeout_ms
)
185 return __intel_wait_for_register_fw(dev_priv
, reg
, mask
, value
,
186 2, timeout_ms
, NULL
);
189 #endif /* !__INTEL_UNCORE_H__ */