xref: /linux/drivers/gpu/drm/panthor/panthor_hw.h (revision fbf5df34a4dbcd09d433dd4f0916bf9b2ddb16de)
1 /* SPDX-License-Identifier: GPL-2.0 or MIT */
2 /* Copyright 2025 ARM Limited. All rights reserved. */
3 
4 #ifndef __PANTHOR_HW_H__
5 #define __PANTHOR_HW_H__
6 
7 #include "panthor_device.h"
8 #include "panthor_regs.h"
9 
10 /**
11  * struct panthor_hw_ops - HW operations that are specific to a GPU
12  */
13 struct panthor_hw_ops {
14 	/** @soft_reset: Soft reset function pointer */
15 	int (*soft_reset)(struct panthor_device *ptdev);
16 
17 	/** @l2_power_off: L2 power off function pointer */
18 	void (*l2_power_off)(struct panthor_device *ptdev);
19 
20 	/** @l2_power_on: L2 power on function pointer */
21 	int (*l2_power_on)(struct panthor_device *ptdev);
22 
23 	/** @power_changed_on: Start listening to power change IRQs */
24 	int (*power_changed_on)(struct panthor_device *ptdev);
25 
26 	/** @power_changed_off: Stop listening to power change IRQs */
27 	void (*power_changed_off)(struct panthor_device *ptdev);
28 };
29 
30 /**
31  * struct panthor_hw - GPU specific register mapping and functions
32  */
33 struct panthor_hw {
34 	/** @features: Bitmap containing panthor_hw_feature */
35 
36 	/** @ops: Panthor HW specific operations */
37 	struct panthor_hw_ops ops;
38 };
39 
40 int panthor_hw_init(struct panthor_device *ptdev);
41 int panthor_hw_power_status_register(void);
42 void panthor_hw_power_status_unregister(void);
43 
44 static inline int panthor_hw_soft_reset(struct panthor_device *ptdev)
45 {
46 	return ptdev->hw->ops.soft_reset(ptdev);
47 }
48 
49 static inline int panthor_hw_l2_power_on(struct panthor_device *ptdev)
50 {
51 	return ptdev->hw->ops.l2_power_on(ptdev);
52 }
53 
54 static inline void panthor_hw_l2_power_off(struct panthor_device *ptdev)
55 {
56 	ptdev->hw->ops.l2_power_off(ptdev);
57 }
58 
59 static inline bool panthor_hw_has_pwr_ctrl(struct panthor_device *ptdev)
60 {
61 	return GPU_ARCH_MAJOR(ptdev->gpu_info.gpu_id) >= 14;
62 }
63 
64 #endif /* __PANTHOR_HW_H__ */
65