1/* SPDX-License-Identifier: MIT */
2/*
3 * Copyright (C) 2024 Intel Corporation
4 */
5
6#ifndef __INTEL_WAKELOCK_H__
7#define __INTEL_WAKELOCK_H__
8
9#include <linux/types.h>
10#include <linux/workqueue.h>
11#include <linux/refcount.h>
12
13#include "i915_reg_defs.h"
14
15struct intel_display;
16
17struct intel_dmc_wl {
18 spinlock_t lock; /* protects enabled, taken, dc_state and refcount */
19 bool enabled;
20 bool taken;
21 refcount_t refcount;
22 /*
23 * We are keeping a copy of the enabled DC state because
24 * intel_display.power.domains is protected by a mutex and we do
25 * not want call mutex_lock() in atomic context, where some of
26 * the tracked MMIO operations happen.
27 */
28 u32 dc_state;
29 struct delayed_work work;
30};
31
32void intel_dmc_wl_init(struct intel_display *display);
33void intel_dmc_wl_enable(struct intel_display *display, u32 dc_state);
34void intel_dmc_wl_disable(struct intel_display *display);
35void intel_dmc_wl_flush_release_work(struct intel_display *display);
36void intel_dmc_wl_get(struct intel_display *display, i915_reg_t reg);
37void intel_dmc_wl_put(struct intel_display *display, i915_reg_t reg);
38void intel_dmc_wl_get_noreg(struct intel_display *display);
39void intel_dmc_wl_put_noreg(struct intel_display *display);
40
41#endif /* __INTEL_WAKELOCK_H__ */
42