xref: /openbmc/linux/include/drm/drm_of.h (revision 91faa0478b5921c638853db54c89a3859c742556)
17e435aadSRussell King #ifndef __DRM_OF_H__
27e435aadSRussell King #define __DRM_OF_H__
37e435aadSRussell King 
44cacf91fSPhilipp Zabel #include <linux/of_graph.h>
54cacf91fSPhilipp Zabel 
6df785aa8SLiviu Dudau struct component_master_ops;
797ac0e47SRussell King struct component_match;
8df785aa8SLiviu Dudau struct device;
97e435aadSRussell King struct drm_device;
104cacf91fSPhilipp Zabel struct drm_encoder;
117e435aadSRussell King struct device_node;
127e435aadSRussell King 
137e435aadSRussell King #ifdef CONFIG_OF
14*91faa047SDaniel Vetter uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
157e435aadSRussell King 				    struct device_node *port);
16*91faa047SDaniel Vetter void drm_of_component_match_add(struct device *master,
1797ac0e47SRussell King 				struct component_match **matchptr,
1897ac0e47SRussell King 				int (*compare)(struct device *, void *),
1997ac0e47SRussell King 				struct device_node *node);
20*91faa047SDaniel Vetter int drm_of_component_probe(struct device *dev,
21df785aa8SLiviu Dudau 			   int (*compare_of)(struct device *, void *),
22df785aa8SLiviu Dudau 			   const struct component_master_ops *m_ops);
23*91faa047SDaniel Vetter int drm_of_encoder_active_endpoint(struct device_node *node,
244cacf91fSPhilipp Zabel 				   struct drm_encoder *encoder,
254cacf91fSPhilipp Zabel 				   struct of_endpoint *endpoint);
267e435aadSRussell King #else
277e435aadSRussell King static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
287e435aadSRussell King 						  struct device_node *port)
297e435aadSRussell King {
307e435aadSRussell King 	return 0;
317e435aadSRussell King }
32df785aa8SLiviu Dudau 
33329f4c81SArnd Bergmann static inline void
34329f4c81SArnd Bergmann drm_of_component_match_add(struct device *master,
3597ac0e47SRussell King 			   struct component_match **matchptr,
3697ac0e47SRussell King 			   int (*compare)(struct device *, void *),
3797ac0e47SRussell King 			   struct device_node *node)
3897ac0e47SRussell King {
3997ac0e47SRussell King }
4097ac0e47SRussell King 
41df785aa8SLiviu Dudau static inline int
42df785aa8SLiviu Dudau drm_of_component_probe(struct device *dev,
43df785aa8SLiviu Dudau 		       int (*compare_of)(struct device *, void *),
44df785aa8SLiviu Dudau 		       const struct component_master_ops *m_ops)
45df785aa8SLiviu Dudau {
46df785aa8SLiviu Dudau 	return -EINVAL;
47df785aa8SLiviu Dudau }
484cacf91fSPhilipp Zabel 
494cacf91fSPhilipp Zabel static inline int drm_of_encoder_active_endpoint(struct device_node *node,
504cacf91fSPhilipp Zabel 						 struct drm_encoder *encoder,
514cacf91fSPhilipp Zabel 						 struct of_endpoint *endpoint)
524cacf91fSPhilipp Zabel {
534cacf91fSPhilipp Zabel 	return -EINVAL;
544cacf91fSPhilipp Zabel }
557e435aadSRussell King #endif
567e435aadSRussell King 
574cacf91fSPhilipp Zabel static inline int drm_of_encoder_active_endpoint_id(struct device_node *node,
584cacf91fSPhilipp Zabel 						    struct drm_encoder *encoder)
594cacf91fSPhilipp Zabel {
604cacf91fSPhilipp Zabel 	struct of_endpoint endpoint;
614cacf91fSPhilipp Zabel 	int ret = drm_of_encoder_active_endpoint(node, encoder,
624cacf91fSPhilipp Zabel 						 &endpoint);
634cacf91fSPhilipp Zabel 
644cacf91fSPhilipp Zabel 	return ret ?: endpoint.id;
654cacf91fSPhilipp Zabel }
664cacf91fSPhilipp Zabel 
674cacf91fSPhilipp Zabel static inline int drm_of_encoder_active_port_id(struct device_node *node,
684cacf91fSPhilipp Zabel 						struct drm_encoder *encoder)
694cacf91fSPhilipp Zabel {
704cacf91fSPhilipp Zabel 	struct of_endpoint endpoint;
714cacf91fSPhilipp Zabel 	int ret = drm_of_encoder_active_endpoint(node, encoder,
724cacf91fSPhilipp Zabel 						 &endpoint);
734cacf91fSPhilipp Zabel 
744cacf91fSPhilipp Zabel 	return ret ?: endpoint.port;
754cacf91fSPhilipp Zabel }
764cacf91fSPhilipp Zabel 
777e435aadSRussell King #endif /* __DRM_OF_H__ */
78