| 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 | |
| 12 | int pvr_watchdog_init(struct pvr_device *pvr_dev); |
| 13 | void pvr_watchdog_fini(struct pvr_device *pvr_dev); |
| 14 | |
| 15 | void pvr_device_lost(struct pvr_device *pvr_dev); |
| 16 | |
| 17 | bool pvr_power_is_idle(struct pvr_device *pvr_dev); |
| 18 | |
| 19 | int pvr_power_device_suspend(struct device *dev); |
| 20 | int pvr_power_device_resume(struct device *dev); |
| 21 | int pvr_power_device_idle(struct device *dev); |
| 22 | |
| 23 | int pvr_power_reset(struct pvr_device *pvr_dev, bool hard_reset); |
| 24 | |
| 25 | static __always_inline int |
| 26 | pvr_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 | |
| 33 | static __always_inline int |
| 34 | pvr_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 | |
| 41 | int pvr_power_domains_init(struct pvr_device *pvr_dev); |
| 42 | void 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 | */ |
| 50 | struct 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 | |
| 56 | extern const struct pvr_power_sequence_ops pvr_power_sequence_ops_manual; |
| 57 | extern const struct pvr_power_sequence_ops pvr_power_sequence_ops_pwrseq; |
| 58 | |
| 59 | #endif /* PVR_POWER_H */ |
| 60 |
