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>
10 #include "lima_sched.h"
51 struct lima_device
*dev
;
74 struct drm_device
*ddev
;
75 struct platform_device
*pdev
;
85 struct reset_control
*reset
;
86 struct regulator
*regulator
;
88 struct lima_ip ip
[lima_ip_num
];
89 struct lima_sched_pipe pipe
[lima_pipe_num
];
91 struct lima_vm
*empty_vm
;
99 static inline struct lima_device
*
100 to_lima_dev(struct drm_device
*dev
)
102 return dev
->dev_private
;
105 int lima_device_init(struct lima_device
*ldev
);
106 void lima_device_fini(struct lima_device
*ldev
);
108 const char *lima_ip_name(struct lima_ip
*ip
);
110 typedef int (*lima_poll_func_t
)(struct lima_ip
*);
112 static inline int lima_poll_timeout(struct lima_ip
*ip
, lima_poll_func_t func
,
113 int sleep_us
, int timeout_us
)
115 ktime_t timeout
= ktime_add_us(ktime_get(), timeout_us
);
117 might_sleep_if(sleep_us
);
122 if (timeout_us
&& ktime_compare(ktime_get(), timeout
) > 0)
126 usleep_range((sleep_us
>> 2) + 1, sleep_us
);