1/* SPDX-License-Identifier: GPL-2.0-only OR MIT */
2/* Copyright (c) 2023 Imagination Technologies Ltd. */
3
4#ifndef PVR_POWER_H
5#define PVR_POWER_H
6
7#include "pvr_device.h"
8
9#include <linux/mutex.h>
10#include <linux/pm_runtime.h>
11
12int pvr_watchdog_init(struct pvr_device *pvr_dev);
13void pvr_watchdog_fini(struct pvr_device *pvr_dev);
14
15void pvr_device_lost(struct pvr_device *pvr_dev);
16
17bool pvr_power_is_idle(struct pvr_device *pvr_dev);
18
19int pvr_power_device_suspend(struct device *dev);
20int pvr_power_device_resume(struct device *dev);
21int pvr_power_device_idle(struct device *dev);
22
23int pvr_power_reset(struct pvr_device *pvr_dev, bool hard_reset);
24
25static __always_inline int
26pvr_power_get(struct pvr_device *pvr_dev)
27{
28 struct drm_device *drm_dev = from_pvr_device(pvr_dev);
29
30 return pm_runtime_resume_and_get(dev: drm_dev->dev);
31}
32
33static __always_inline int
34pvr_power_put(struct pvr_device *pvr_dev)
35{
36 struct drm_device *drm_dev = from_pvr_device(pvr_dev);
37
38 return pm_runtime_put(dev: drm_dev->dev);
39}
40
41int pvr_power_domains_init(struct pvr_device *pvr_dev);
42void pvr_power_domains_fini(struct pvr_device *pvr_dev);
43
44/**
45 * struct pvr_power_sequence_ops - Platform specific power sequence operations.
46 * @init: Pointer to the platform-specific initialization function.
47 * @power_on: Pointer to the platform-specific power on function.
48 * @power_off: Pointer to the platform-specific power off function.
49 */
50struct pvr_power_sequence_ops {
51 int (*init)(struct pvr_device *pvr_dev);
52 int (*power_on)(struct pvr_device *pvr_dev);
53 int (*power_off)(struct pvr_device *pvr_dev);
54};
55
56extern const struct pvr_power_sequence_ops pvr_power_sequence_ops_manual;
57extern const struct pvr_power_sequence_ops pvr_power_sequence_ops_pwrseq;
58
59#endif /* PVR_POWER_H */
60

source code of linux/drivers/gpu/drm/imagination/pvr_power.h