xref: /linux/drivers/gpu/drm/panthor/panthor_gpu.h (revision 7f71507851fc7764b36a3221839607d3a45c2025)
1 /* SPDX-License-Identifier: GPL-2.0 or MIT */
2 /* Copyright 2018 Marty E. Plummer <hanetzer@startmail.com> */
3 /* Copyright 2019 Collabora ltd. */
4 
5 #ifndef __PANTHOR_GPU_H__
6 #define __PANTHOR_GPU_H__
7 
8 #include <linux/types.h>
9 
10 struct panthor_device;
11 
12 int panthor_gpu_init(struct panthor_device *ptdev);
13 void panthor_gpu_unplug(struct panthor_device *ptdev);
14 void panthor_gpu_suspend(struct panthor_device *ptdev);
15 void panthor_gpu_resume(struct panthor_device *ptdev);
16 
17 int panthor_gpu_block_power_on(struct panthor_device *ptdev,
18 			       const char *blk_name,
19 			       u32 pwron_reg, u32 pwrtrans_reg,
20 			       u32 rdy_reg, u64 mask, u32 timeout_us);
21 int panthor_gpu_block_power_off(struct panthor_device *ptdev,
22 				const char *blk_name,
23 				u32 pwroff_reg, u32 pwrtrans_reg,
24 				u64 mask, u32 timeout_us);
25 
26 /**
27  * panthor_gpu_power_on() - Power on the GPU block.
28  *
29  * Return: 0 on success, a negative error code otherwise.
30  */
31 #define panthor_gpu_power_on(ptdev, type, mask, timeout_us) \
32 	panthor_gpu_block_power_on(ptdev, #type, \
33 				  type ## _PWRON_LO, \
34 				  type ## _PWRTRANS_LO, \
35 				  type ## _READY_LO, \
36 				  mask, timeout_us)
37 
38 /**
39  * panthor_gpu_power_off() - Power off the GPU block.
40  *
41  * Return: 0 on success, a negative error code otherwise.
42  */
43 #define panthor_gpu_power_off(ptdev, type, mask, timeout_us) \
44 	panthor_gpu_block_power_off(ptdev, #type, \
45 				   type ## _PWROFF_LO, \
46 				   type ## _PWRTRANS_LO, \
47 				   mask, timeout_us)
48 
49 int panthor_gpu_l2_power_on(struct panthor_device *ptdev);
50 int panthor_gpu_flush_caches(struct panthor_device *ptdev,
51 			     u32 l2, u32 lsc, u32 other);
52 int panthor_gpu_soft_reset(struct panthor_device *ptdev);
53 u64 panthor_gpu_read_timestamp(struct panthor_device *ptdev);
54 u64 panthor_gpu_read_timestamp_offset(struct panthor_device *ptdev);
55 
56 #endif
57