1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
2 /* Copyright 2018-2019 Qiang Yu <yuq825@gmail.com> */
4 #ifndef __LIMA_DEVICE_H__
5 #define __LIMA_DEVICE_H__
7 #include <drm/drm_device.h>
8 #include <linux/delay.h>
9 #include <linux/list.h>
10 #include <linux/mutex.h>
12 #include "lima_sched.h"
13 #include "lima_dump.h"
14 #include "lima_devfreq.h"
55 struct lima_device
*dev
;
80 struct drm_device
*ddev
;
90 struct reset_control
*reset
;
91 struct regulator
*regulator
;
93 struct lima_ip ip
[lima_ip_num
];
94 struct lima_sched_pipe pipe
[lima_pipe_num
];
96 struct lima_vm
*empty_vm
;
103 struct lima_devfreq devfreq
;
106 struct lima_dump_head dump
;
107 struct list_head error_task_list
;
108 struct mutex error_task_list_lock
;
111 static inline struct lima_device
*
112 to_lima_dev(struct drm_device
*dev
)
114 return dev
->dev_private
;
117 int lima_device_init(struct lima_device
*ldev
);
118 void lima_device_fini(struct lima_device
*ldev
);
120 const char *lima_ip_name(struct lima_ip
*ip
);
122 typedef int (*lima_poll_func_t
)(struct lima_ip
*);
124 static inline int lima_poll_timeout(struct lima_ip
*ip
, lima_poll_func_t func
,
125 int sleep_us
, int timeout_us
)
127 ktime_t timeout
= ktime_add_us(ktime_get(), timeout_us
);
129 might_sleep_if(sleep_us
);
134 if (timeout_us
&& ktime_compare(ktime_get(), timeout
) > 0)
138 usleep_range((sleep_us
>> 2) + 1, sleep_us
);
143 int lima_device_suspend(struct device
*dev
);
144 int lima_device_resume(struct device
*dev
);