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 15 struct intel_display; 16 17 struct 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 32 void intel_dmc_wl_init(struct intel_display *display); 33 void intel_dmc_wl_enable(struct intel_display *display, u32 dc_state); 34 void intel_dmc_wl_disable(struct intel_display *display); 35 void intel_dmc_wl_flush_release_work(struct intel_display *display); 36 void intel_dmc_wl_get(struct intel_display *display, i915_reg_t reg); 37 void intel_dmc_wl_put(struct intel_display *display, i915_reg_t reg); 38 void intel_dmc_wl_get_noreg(struct intel_display *display); 39 void intel_dmc_wl_put_noreg(struct intel_display *display); 40 41 #endif /* __INTEL_WAKELOCK_H__ */ 42