Home | History | Annotate | Line # | Download | only in fdt
fdt_port.h revision 1.1
      1  1.1  bouyer /*	$NetBSD: fdt_port.h,v 1.1 2018/04/03 12:40:20 bouyer 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.1  bouyer struct fdt_port;
     48  1.1  bouyer struct fdt_endpoint;
     49  1.1  bouyer 
     50  1.1  bouyer struct fdt_device_ports {
     51  1.1  bouyer 	struct fdt_port *dp_port; /* this device's ports */
     52  1.1  bouyer 	int		dp_nports; /* number of ports for this device */
     53  1.1  bouyer 	device_t	dp_dev;
     54  1.1  bouyer 	/* callbacks to device drivers owning endpoints */
     55  1.1  bouyer 	void		(*dp_ep_connect)(device_t, struct fdt_endpoint *, bool);
     56  1.1  bouyer 	int		(*dp_ep_activate)(device_t, struct fdt_endpoint *, bool);
     57  1.1  bouyer 	int		(*dp_ep_enable)(device_t, struct fdt_endpoint *, bool);
     58  1.1  bouyer 	void *		(*dp_ep_get_data)(device_t, struct fdt_endpoint *);
     59  1.1  bouyer 	SLIST_ENTRY(fdt_device_ports) dp_list;
     60  1.1  bouyer };
     61  1.1  bouyer 
     62  1.1  bouyer enum endpoint_type {
     63  1.1  bouyer 	EP_OTHER = 0,
     64  1.1  bouyer 	EP_CONNECTOR,
     65  1.1  bouyer 	EP_PANEL,
     66  1.1  bouyer };
     67  1.1  bouyer 
     68  1.1  bouyer 
     69  1.1  bouyer /*
     70  1.1  bouyer  * register a device's ports and enpoints into the provided fdt_device_ports.
     71  1.1  bouyer  * when and endpoint is connected to a remote endpoint, dp_ep_connect
     72  1.1  bouyer  * is called for the devices associated to both endpoints
     73  1.1  bouyer  */
     74  1.1  bouyer int fdt_ports_register(struct fdt_device_ports *, device_t,
     75  1.1  bouyer 					int, enum endpoint_type);
     76  1.1  bouyer 
     77  1.1  bouyer /* various methods to retrive an enpoint descriptor */
     78  1.1  bouyer struct fdt_endpoint *fdt_endpoint_get_from_phandle(int);
     79  1.1  bouyer struct fdt_endpoint *fdt_endpoint_get_from_index(struct fdt_device_ports *,
     80  1.1  bouyer 							int, int);
     81  1.1  bouyer struct fdt_endpoint *fdt_endpoint_remote(struct fdt_endpoint *);
     82  1.1  bouyer 
     83  1.1  bouyer /*
     84  1.1  bouyer  * get informations/data for a given endpoint
     85  1.1  bouyer  */
     86  1.1  bouyer int fdt_endpoint_port_index(struct fdt_endpoint *);
     87  1.1  bouyer int fdt_endpoint_index(struct fdt_endpoint *);
     88  1.1  bouyer device_t fdt_endpoint_device(struct fdt_endpoint *);
     89  1.1  bouyer bool fdt_endpoint_is_active(struct fdt_endpoint *);
     90  1.1  bouyer bool fdt_endpoint_is_enabled(struct fdt_endpoint *);
     91  1.1  bouyer /*
     92  1.1  bouyer  * call dp_ep_get_data() for the endpoint. The returned pointer is
     93  1.1  bouyer  * type of driver-specific.
     94  1.1  bouyer  */
     95  1.1  bouyer void * fdt_endpoint_get_data(struct fdt_endpoint *);
     96  1.1  bouyer 
     97  1.1  bouyer /*
     98  1.1  bouyer  * Activate/deactivate an endpoint. This causes dp_ep_activate() to be
     99  1.1  bouyer  * called for the remote endpoint
    100  1.1  bouyer  */
    101  1.1  bouyer int fdt_endpoint_activate(struct fdt_endpoint *, bool);
    102  1.1  bouyer /*
    103  1.1  bouyer  * Enable/disable an endpoint. This causes dp_ep_enable() to be called for
    104  1.1  bouyer  * the remote endpoint
    105  1.1  bouyer  */
    106  1.1  bouyer int fdt_endpoint_enable(struct fdt_endpoint *, bool);
    107  1.1  bouyer 
    108  1.1  bouyer #endif /* _DEV_FDT_FDT_PORT_H_ */
    109