1 1.7 andvar /* $NetBSD: fdt_port.h,v 1.7 2024/02/10 09:21:52 andvar Exp $ */ 2 1.1 bouyer 3 1.1 bouyer /*- 4 1.1 bouyer * Copyright (c) 2018 The NetBSD Foundation, Inc. 5 1.1 bouyer * All rights reserved. 6 1.1 bouyer * 7 1.1 bouyer * This code is derived from software contributed to The NetBSD Foundation 8 1.1 bouyer * by Manuel Bouyer. 9 1.1 bouyer * 10 1.1 bouyer * Redistribution and use in source and binary forms, with or without 11 1.1 bouyer * modification, are permitted provided that the following conditions 12 1.1 bouyer * are met: 13 1.1 bouyer * 1. Redistributions of source code must retain the above copyright 14 1.1 bouyer * notice, this list of conditions and the following disclaimer. 15 1.1 bouyer * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 bouyer * notice, this list of conditions and the following disclaimer in the 17 1.1 bouyer * documentation and/or other materials provided with the distribution. 18 1.1 bouyer * 19 1.1 bouyer * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.1 bouyer * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.1 bouyer * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.1 bouyer * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.1 bouyer * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.1 bouyer * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.1 bouyer * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 bouyer * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.1 bouyer * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.1 bouyer * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.1 bouyer * POSSIBILITY OF SUCH DAMAGE. 30 1.1 bouyer */ 31 1.1 bouyer 32 1.1 bouyer /* 33 1.1 bouyer * ports and endpoints management. from 34 1.1 bouyer * linux/Documentation/devicetree/bindings/graph.txt 35 1.1 bouyer * 2 endpoints can be connected together in the device tree. In this case 36 1.1 bouyer * an endpoint will have a remote endpoint. 37 1.1 bouyer * A pair of connected endpoints can be activated by a driver; when it choose 38 1.1 bouyer * to use this path. 39 1.1 bouyer * A pair of active endpoints can be enabled; when a driver starts to send 40 1.1 bouyer * a signal. Disabling a pair of endpoints can cause appropriate actions 41 1.1 bouyer * to save power (stop clocks, disable output buffers, turn on/off power, ...) 42 1.1 bouyer */ 43 1.1 bouyer 44 1.1 bouyer #ifndef _DEV_FDT_FDT_PORT_H_ 45 1.1 bouyer #define _DEV_FDT_FDT_PORT_H_ 46 1.1 bouyer 47 1.2 jmcneill struct drm_device; 48 1.2 jmcneill 49 1.1 bouyer struct fdt_port; 50 1.1 bouyer struct fdt_endpoint; 51 1.1 bouyer 52 1.1 bouyer struct fdt_device_ports { 53 1.1 bouyer struct fdt_port *dp_port; /* this device's ports */ 54 1.1 bouyer int dp_nports; /* number of ports for this device */ 55 1.1 bouyer device_t dp_dev; 56 1.1 bouyer /* callbacks to device drivers owning endpoints */ 57 1.1 bouyer void (*dp_ep_connect)(device_t, struct fdt_endpoint *, bool); 58 1.1 bouyer int (*dp_ep_activate)(device_t, struct fdt_endpoint *, bool); 59 1.1 bouyer int (*dp_ep_enable)(device_t, struct fdt_endpoint *, bool); 60 1.1 bouyer void * (*dp_ep_get_data)(device_t, struct fdt_endpoint *); 61 1.1 bouyer SLIST_ENTRY(fdt_device_ports) dp_list; 62 1.1 bouyer }; 63 1.1 bouyer 64 1.1 bouyer enum endpoint_type { 65 1.1 bouyer EP_OTHER = 0, 66 1.1 bouyer EP_CONNECTOR, 67 1.1 bouyer EP_PANEL, 68 1.2 jmcneill 69 1.2 jmcneill EP_DRM_BRIDGE, /* struct drm_bridge */ 70 1.2 jmcneill EP_DRM_CONNECTOR, /* struct drm_connector */ 71 1.2 jmcneill EP_DRM_CRTC, /* struct drm_crtc */ 72 1.2 jmcneill EP_DRM_ENCODER, /* struct drm_encoder */ 73 1.3 jmcneill EP_DRM_PANEL, /* struct drm_panel */ 74 1.1 bouyer }; 75 1.1 bouyer 76 1.1 bouyer 77 1.1 bouyer /* 78 1.7 andvar * register a device's ports and endpoints into the provided fdt_device_ports. 79 1.1 bouyer * when and endpoint is connected to a remote endpoint, dp_ep_connect 80 1.1 bouyer * is called for the devices associated to both endpoints 81 1.1 bouyer */ 82 1.1 bouyer int fdt_ports_register(struct fdt_device_ports *, device_t, 83 1.1 bouyer int, enum endpoint_type); 84 1.1 bouyer 85 1.7 andvar /* various methods to retrieve an endpoint descriptor */ 86 1.1 bouyer struct fdt_endpoint *fdt_endpoint_get_from_phandle(int); 87 1.1 bouyer struct fdt_endpoint *fdt_endpoint_get_from_index(struct fdt_device_ports *, 88 1.1 bouyer int, int); 89 1.1 bouyer struct fdt_endpoint *fdt_endpoint_remote(struct fdt_endpoint *); 90 1.2 jmcneill struct fdt_endpoint *fdt_endpoint_remote_from_index(struct fdt_device_ports *, 91 1.2 jmcneill int, int); 92 1.1 bouyer 93 1.1 bouyer /* 94 1.1 bouyer * get informations/data for a given endpoint 95 1.1 bouyer */ 96 1.1 bouyer int fdt_endpoint_port_index(struct fdt_endpoint *); 97 1.1 bouyer int fdt_endpoint_index(struct fdt_endpoint *); 98 1.2 jmcneill int fdt_endpoint_phandle(struct fdt_endpoint *); 99 1.1 bouyer device_t fdt_endpoint_device(struct fdt_endpoint *); 100 1.1 bouyer bool fdt_endpoint_is_active(struct fdt_endpoint *); 101 1.1 bouyer bool fdt_endpoint_is_enabled(struct fdt_endpoint *); 102 1.2 jmcneill enum endpoint_type fdt_endpoint_type(struct fdt_endpoint *); 103 1.1 bouyer /* 104 1.1 bouyer * call dp_ep_get_data() for the endpoint. The returned pointer is 105 1.1 bouyer * type of driver-specific. 106 1.1 bouyer */ 107 1.1 bouyer void * fdt_endpoint_get_data(struct fdt_endpoint *); 108 1.1 bouyer 109 1.1 bouyer /* 110 1.1 bouyer * Activate/deactivate an endpoint. This causes dp_ep_activate() to be 111 1.1 bouyer * called for the remote endpoint 112 1.1 bouyer */ 113 1.1 bouyer int fdt_endpoint_activate(struct fdt_endpoint *, bool); 114 1.2 jmcneill 115 1.2 jmcneill /* 116 1.6 andvar * Activate/deactivate an endpoint by direct reference. 117 1.2 jmcneill */ 118 1.2 jmcneill int fdt_endpoint_activate_direct(struct fdt_endpoint *, bool); 119 1.2 jmcneill 120 1.1 bouyer /* 121 1.1 bouyer * Enable/disable an endpoint. This causes dp_ep_enable() to be called for 122 1.1 bouyer * the remote endpoint 123 1.1 bouyer */ 124 1.1 bouyer int fdt_endpoint_enable(struct fdt_endpoint *, bool); 125 1.1 bouyer 126 1.4 skrll #endif /* _DEV_FDT_FDT_PORT_H */ 127