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