1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright 2018 Marty E. Plummer <hanetzer@startmail.com> */
3 /* Copyright 2019 Linaro, Ltd, Rob Herring <robh@kernel.org> */
5 #ifndef __PANFROST_DEVICE_H__
6 #define __PANFROST_DEVICE_H__
8 #include <linux/spinlock.h>
9 #include <drm/drm_device.h>
10 #include <drm/drm_mm.h>
11 #include <drm/gpu_scheduler.h>
13 struct panfrost_device
;
15 struct panfrost_job_slot
;
18 #define NUM_JOB_SLOTS 3
20 struct panfrost_features
{
38 u32 thread_max_workgroup_sz
;
39 u32 thread_max_barrier_sz
;
40 u32 coherency_features
;
41 u32 texture_features
[4];
46 unsigned long hw_features
[64 / BITS_PER_LONG
];
47 unsigned long hw_issues
[64 / BITS_PER_LONG
];
50 struct panfrost_devfreq_slot
{
53 ktime_t time_last_update
;
57 struct panfrost_device
{
59 struct drm_device
*ddev
;
60 struct platform_device
*pdev
;
62 spinlock_t hwaccess_lock
;
69 struct clk
*bus_clock
;
70 struct regulator
*regulator
;
71 struct reset_control
*rstc
;
73 struct panfrost_features features
;
75 struct panfrost_mmu
*mmu
;
76 struct panfrost_job_slot
*js
;
78 struct panfrost_job
*jobs
[NUM_JOB_SLOTS
];
79 struct list_head scheduled_jobs
;
81 struct mutex sched_lock
;
82 struct mutex reset_lock
;
85 struct devfreq
*devfreq
;
86 struct thermal_cooling_device
*cooling
;
87 unsigned long cur_freq
;
88 unsigned long cur_volt
;
89 struct panfrost_devfreq_slot slot
[NUM_JOB_SLOTS
];
93 struct panfrost_file_priv
{
94 struct panfrost_device
*pfdev
;
96 struct drm_sched_entity sched_entity
[NUM_JOB_SLOTS
];
99 static inline struct panfrost_device
*to_panfrost_device(struct drm_device
*ddev
)
101 return ddev
->dev_private
;
104 static inline int panfrost_model_cmp(struct panfrost_device
*pfdev
, s32 id
)
106 s32 match_id
= pfdev
->features
.id
;
108 if (match_id
& 0xf000)
110 return match_id
- id
;
113 static inline bool panfrost_model_eq(struct panfrost_device
*pfdev
, s32 id
)
115 return !panfrost_model_cmp(pfdev
, id
);
118 int panfrost_unstable_ioctl_check(void);
120 int panfrost_device_init(struct panfrost_device
*pfdev
);
121 void panfrost_device_fini(struct panfrost_device
*pfdev
);
123 int panfrost_device_resume(struct device
*dev
);
124 int panfrost_device_suspend(struct device
*dev
);
126 const char *panfrost_exception_name(struct panfrost_device
*pfdev
, u32 exception_code
);