xref: /openbmc/linux/include/drm/drm_of.h (revision 4cacf91fcb1d7118e93caf9cb6651d7f7b56e58d)
17e435aadSRussell King #ifndef __DRM_OF_H__
27e435aadSRussell King #define __DRM_OF_H__
37e435aadSRussell King 
4*4cacf91fSPhilipp Zabel #include <linux/of_graph.h>
5*4cacf91fSPhilipp Zabel 
6df785aa8SLiviu Dudau struct component_master_ops;
7df785aa8SLiviu Dudau struct device;
87e435aadSRussell King struct drm_device;
9*4cacf91fSPhilipp Zabel struct drm_encoder;
107e435aadSRussell King struct device_node;
117e435aadSRussell King 
127e435aadSRussell King #ifdef CONFIG_OF
137e435aadSRussell King extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
147e435aadSRussell King 					   struct device_node *port);
15df785aa8SLiviu Dudau extern int drm_of_component_probe(struct device *dev,
16df785aa8SLiviu Dudau 				  int (*compare_of)(struct device *, void *),
17df785aa8SLiviu Dudau 				  const struct component_master_ops *m_ops);
18*4cacf91fSPhilipp Zabel extern int drm_of_encoder_active_endpoint(struct device_node *node,
19*4cacf91fSPhilipp Zabel 					  struct drm_encoder *encoder,
20*4cacf91fSPhilipp Zabel 					  struct of_endpoint *endpoint);
217e435aadSRussell King #else
227e435aadSRussell King static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
237e435aadSRussell King 						  struct device_node *port)
247e435aadSRussell King {
257e435aadSRussell King 	return 0;
267e435aadSRussell King }
27df785aa8SLiviu Dudau 
28df785aa8SLiviu Dudau static inline int
29df785aa8SLiviu Dudau drm_of_component_probe(struct device *dev,
30df785aa8SLiviu Dudau 		       int (*compare_of)(struct device *, void *),
31df785aa8SLiviu Dudau 		       const struct component_master_ops *m_ops)
32df785aa8SLiviu Dudau {
33df785aa8SLiviu Dudau 	return -EINVAL;
34df785aa8SLiviu Dudau }
35*4cacf91fSPhilipp Zabel 
36*4cacf91fSPhilipp Zabel static inline int drm_of_encoder_active_endpoint(struct device_node *node,
37*4cacf91fSPhilipp Zabel 						 struct drm_encoder *encoder,
38*4cacf91fSPhilipp Zabel 						 struct of_endpoint *endpoint)
39*4cacf91fSPhilipp Zabel {
40*4cacf91fSPhilipp Zabel 	return -EINVAL;
41*4cacf91fSPhilipp Zabel }
427e435aadSRussell King #endif
437e435aadSRussell King 
44*4cacf91fSPhilipp Zabel static inline int drm_of_encoder_active_endpoint_id(struct device_node *node,
45*4cacf91fSPhilipp Zabel 						    struct drm_encoder *encoder)
46*4cacf91fSPhilipp Zabel {
47*4cacf91fSPhilipp Zabel 	struct of_endpoint endpoint;
48*4cacf91fSPhilipp Zabel 	int ret = drm_of_encoder_active_endpoint(node, encoder,
49*4cacf91fSPhilipp Zabel 						 &endpoint);
50*4cacf91fSPhilipp Zabel 
51*4cacf91fSPhilipp Zabel 	return ret ?: endpoint.id;
52*4cacf91fSPhilipp Zabel }
53*4cacf91fSPhilipp Zabel 
54*4cacf91fSPhilipp Zabel static inline int drm_of_encoder_active_port_id(struct device_node *node,
55*4cacf91fSPhilipp Zabel 						struct drm_encoder *encoder)
56*4cacf91fSPhilipp Zabel {
57*4cacf91fSPhilipp Zabel 	struct of_endpoint endpoint;
58*4cacf91fSPhilipp Zabel 	int ret = drm_of_encoder_active_endpoint(node, encoder,
59*4cacf91fSPhilipp Zabel 						 &endpoint);
60*4cacf91fSPhilipp Zabel 
61*4cacf91fSPhilipp Zabel 	return ret ?: endpoint.port;
62*4cacf91fSPhilipp Zabel }
63*4cacf91fSPhilipp Zabel 
647e435aadSRussell King #endif /* __DRM_OF_H__ */
65