1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 27e435aadSRussell King #ifndef __DRM_OF_H__ 37e435aadSRussell King #define __DRM_OF_H__ 47e435aadSRussell King 54cacf91fSPhilipp Zabel #include <linux/of_graph.h> 64cacf91fSPhilipp Zabel 7df785aa8SLiviu Dudau struct component_master_ops; 897ac0e47SRussell King struct component_match; 9df785aa8SLiviu Dudau struct device; 107e435aadSRussell King struct drm_device; 114cacf91fSPhilipp Zabel struct drm_encoder; 121f2db303SRob Herring struct drm_panel; 131f2db303SRob Herring struct drm_bridge; 147e435aadSRussell King struct device_node; 157e435aadSRussell King 167e435aadSRussell King #ifdef CONFIG_OF 1791faa047SDaniel Vetter uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, 187e435aadSRussell King struct device_node *port); 1991faa047SDaniel Vetter void drm_of_component_match_add(struct device *master, 2097ac0e47SRussell King struct component_match **matchptr, 2197ac0e47SRussell King int (*compare)(struct device *, void *), 2297ac0e47SRussell King struct device_node *node); 2391faa047SDaniel Vetter int drm_of_component_probe(struct device *dev, 24df785aa8SLiviu Dudau int (*compare_of)(struct device *, void *), 25df785aa8SLiviu Dudau const struct component_master_ops *m_ops); 2691faa047SDaniel Vetter int drm_of_encoder_active_endpoint(struct device_node *node, 274cacf91fSPhilipp Zabel struct drm_encoder *encoder, 284cacf91fSPhilipp Zabel struct of_endpoint *endpoint); 291f2db303SRob Herring int drm_of_find_panel_or_bridge(const struct device_node *np, 301f2db303SRob Herring int port, int endpoint, 311f2db303SRob Herring struct drm_panel **panel, 321f2db303SRob Herring struct drm_bridge **bridge); 337e435aadSRussell King #else 347e435aadSRussell King static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, 357e435aadSRussell King struct device_node *port) 367e435aadSRussell King { 377e435aadSRussell King return 0; 387e435aadSRussell King } 39df785aa8SLiviu Dudau 40329f4c81SArnd Bergmann static inline void 41329f4c81SArnd Bergmann drm_of_component_match_add(struct device *master, 4297ac0e47SRussell King struct component_match **matchptr, 4397ac0e47SRussell King int (*compare)(struct device *, void *), 4497ac0e47SRussell King struct device_node *node) 4597ac0e47SRussell King { 4697ac0e47SRussell King } 4797ac0e47SRussell King 48df785aa8SLiviu Dudau static inline int 49df785aa8SLiviu Dudau drm_of_component_probe(struct device *dev, 50df785aa8SLiviu Dudau int (*compare_of)(struct device *, void *), 51df785aa8SLiviu Dudau const struct component_master_ops *m_ops) 52df785aa8SLiviu Dudau { 53df785aa8SLiviu Dudau return -EINVAL; 54df785aa8SLiviu Dudau } 554cacf91fSPhilipp Zabel 564cacf91fSPhilipp Zabel static inline int drm_of_encoder_active_endpoint(struct device_node *node, 574cacf91fSPhilipp Zabel struct drm_encoder *encoder, 584cacf91fSPhilipp Zabel struct of_endpoint *endpoint) 594cacf91fSPhilipp Zabel { 604cacf91fSPhilipp Zabel return -EINVAL; 614cacf91fSPhilipp Zabel } 621f2db303SRob Herring static inline int drm_of_find_panel_or_bridge(const struct device_node *np, 631f2db303SRob Herring int port, int endpoint, 641f2db303SRob Herring struct drm_panel **panel, 651f2db303SRob Herring struct drm_bridge **bridge) 661f2db303SRob Herring { 671f2db303SRob Herring return -EINVAL; 681f2db303SRob Herring } 697e435aadSRussell King #endif 707e435aadSRussell King 714cacf91fSPhilipp Zabel static inline int drm_of_encoder_active_endpoint_id(struct device_node *node, 724cacf91fSPhilipp Zabel struct drm_encoder *encoder) 734cacf91fSPhilipp Zabel { 744cacf91fSPhilipp Zabel struct of_endpoint endpoint; 754cacf91fSPhilipp Zabel int ret = drm_of_encoder_active_endpoint(node, encoder, 764cacf91fSPhilipp Zabel &endpoint); 774cacf91fSPhilipp Zabel 784cacf91fSPhilipp Zabel return ret ?: endpoint.id; 794cacf91fSPhilipp Zabel } 804cacf91fSPhilipp Zabel 814cacf91fSPhilipp Zabel static inline int drm_of_encoder_active_port_id(struct device_node *node, 824cacf91fSPhilipp Zabel struct drm_encoder *encoder) 834cacf91fSPhilipp Zabel { 844cacf91fSPhilipp Zabel struct of_endpoint endpoint; 854cacf91fSPhilipp Zabel int ret = drm_of_encoder_active_endpoint(node, encoder, 864cacf91fSPhilipp Zabel &endpoint); 874cacf91fSPhilipp Zabel 884cacf91fSPhilipp Zabel return ret ?: endpoint.port; 894cacf91fSPhilipp Zabel } 904cacf91fSPhilipp Zabel 917e435aadSRussell King #endif /* __DRM_OF_H__ */ 92