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; 111f2db303SRob Herring struct drm_panel; 121f2db303SRob Herring struct drm_bridge; 137e435aadSRussell King struct device_node; 147e435aadSRussell King 157e435aadSRussell King #ifdef CONFIG_OF 1691faa047SDaniel Vetter uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, 177e435aadSRussell King struct device_node *port); 1891faa047SDaniel Vetter void drm_of_component_match_add(struct device *master, 1997ac0e47SRussell King struct component_match **matchptr, 2097ac0e47SRussell King int (*compare)(struct device *, void *), 2197ac0e47SRussell King struct device_node *node); 2291faa047SDaniel Vetter int drm_of_component_probe(struct device *dev, 23df785aa8SLiviu Dudau int (*compare_of)(struct device *, void *), 24df785aa8SLiviu Dudau const struct component_master_ops *m_ops); 2591faa047SDaniel Vetter int drm_of_encoder_active_endpoint(struct device_node *node, 264cacf91fSPhilipp Zabel struct drm_encoder *encoder, 274cacf91fSPhilipp Zabel struct of_endpoint *endpoint); 281f2db303SRob Herring int drm_of_find_panel_or_bridge(const struct device_node *np, 291f2db303SRob Herring int port, int endpoint, 301f2db303SRob Herring struct drm_panel **panel, 311f2db303SRob Herring struct drm_bridge **bridge); 32*c70087e8Sbenjamin.gaignard@linaro.org int drm_of_panel_bridge_remove(const struct device_node *np, 33*c70087e8Sbenjamin.gaignard@linaro.org int port, int endpoint); 347e435aadSRussell King #else 357e435aadSRussell King static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, 367e435aadSRussell King struct device_node *port) 377e435aadSRussell King { 387e435aadSRussell King return 0; 397e435aadSRussell King } 40df785aa8SLiviu Dudau 41329f4c81SArnd Bergmann static inline void 42329f4c81SArnd Bergmann drm_of_component_match_add(struct device *master, 4397ac0e47SRussell King struct component_match **matchptr, 4497ac0e47SRussell King int (*compare)(struct device *, void *), 4597ac0e47SRussell King struct device_node *node) 4697ac0e47SRussell King { 4797ac0e47SRussell King } 4897ac0e47SRussell King 49df785aa8SLiviu Dudau static inline int 50df785aa8SLiviu Dudau drm_of_component_probe(struct device *dev, 51df785aa8SLiviu Dudau int (*compare_of)(struct device *, void *), 52df785aa8SLiviu Dudau const struct component_master_ops *m_ops) 53df785aa8SLiviu Dudau { 54df785aa8SLiviu Dudau return -EINVAL; 55df785aa8SLiviu Dudau } 564cacf91fSPhilipp Zabel 574cacf91fSPhilipp Zabel static inline int drm_of_encoder_active_endpoint(struct device_node *node, 584cacf91fSPhilipp Zabel struct drm_encoder *encoder, 594cacf91fSPhilipp Zabel struct of_endpoint *endpoint) 604cacf91fSPhilipp Zabel { 614cacf91fSPhilipp Zabel return -EINVAL; 624cacf91fSPhilipp Zabel } 631f2db303SRob Herring static inline int drm_of_find_panel_or_bridge(const struct device_node *np, 641f2db303SRob Herring int port, int endpoint, 651f2db303SRob Herring struct drm_panel **panel, 661f2db303SRob Herring struct drm_bridge **bridge) 671f2db303SRob Herring { 681f2db303SRob Herring return -EINVAL; 691f2db303SRob Herring } 70*c70087e8Sbenjamin.gaignard@linaro.org 71*c70087e8Sbenjamin.gaignard@linaro.org static inline int drm_of_panel_bridge_remove(const struct device_node *np, 72*c70087e8Sbenjamin.gaignard@linaro.org int port, int endpoint) 73*c70087e8Sbenjamin.gaignard@linaro.org { 74*c70087e8Sbenjamin.gaignard@linaro.org return -EINVAL; 75*c70087e8Sbenjamin.gaignard@linaro.org } 767e435aadSRussell King #endif 777e435aadSRussell King 784cacf91fSPhilipp Zabel static inline int drm_of_encoder_active_endpoint_id(struct device_node *node, 794cacf91fSPhilipp Zabel struct drm_encoder *encoder) 804cacf91fSPhilipp Zabel { 814cacf91fSPhilipp Zabel struct of_endpoint endpoint; 824cacf91fSPhilipp Zabel int ret = drm_of_encoder_active_endpoint(node, encoder, 834cacf91fSPhilipp Zabel &endpoint); 844cacf91fSPhilipp Zabel 854cacf91fSPhilipp Zabel return ret ?: endpoint.id; 864cacf91fSPhilipp Zabel } 874cacf91fSPhilipp Zabel 884cacf91fSPhilipp Zabel static inline int drm_of_encoder_active_port_id(struct device_node *node, 894cacf91fSPhilipp Zabel struct drm_encoder *encoder) 904cacf91fSPhilipp Zabel { 914cacf91fSPhilipp Zabel struct of_endpoint endpoint; 924cacf91fSPhilipp Zabel int ret = drm_of_encoder_active_endpoint(node, encoder, 934cacf91fSPhilipp Zabel &endpoint); 944cacf91fSPhilipp Zabel 954cacf91fSPhilipp Zabel return ret ?: endpoint.port; 964cacf91fSPhilipp Zabel } 974cacf91fSPhilipp Zabel 987e435aadSRussell King #endif /* __DRM_OF_H__ */ 99