Guennadi Liakhovetski | 99fd133 | 2012-09-26 05:24:03 -0300 | [diff] [blame] | 1 | /* |
| 2 | * V4L2 OF binding parsing library |
| 3 | * |
Sylwester Nawrocki | c6e8d96 | 2013-04-02 11:41:19 -0300 | [diff] [blame] | 4 | * Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd. |
| 5 | * Author: Sylwester Nawrocki <s.nawrocki@samsung.com> |
| 6 | * |
Guennadi Liakhovetski | 99fd133 | 2012-09-26 05:24:03 -0300 | [diff] [blame] | 7 | * Copyright (C) 2012 Renesas Electronics Corp. |
| 8 | * Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de> |
| 9 | * |
Guennadi Liakhovetski | 99fd133 | 2012-09-26 05:24:03 -0300 | [diff] [blame] | 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of version 2 of the GNU General Public License as |
| 12 | * published by the Free Software Foundation. |
| 13 | */ |
| 14 | #ifndef _V4L2_OF_H |
| 15 | #define _V4L2_OF_H |
| 16 | |
| 17 | #include <linux/list.h> |
| 18 | #include <linux/types.h> |
| 19 | #include <linux/errno.h> |
Philipp Zabel | fd9fdb7 | 2014-02-10 22:01:48 +0100 | [diff] [blame] | 20 | #include <linux/of_graph.h> |
Guennadi Liakhovetski | 99fd133 | 2012-09-26 05:24:03 -0300 | [diff] [blame] | 21 | |
| 22 | #include <media/v4l2-mediabus.h> |
| 23 | |
| 24 | struct device_node; |
| 25 | |
| 26 | /** |
| 27 | * struct v4l2_of_bus_mipi_csi2 - MIPI CSI-2 bus data structure |
| 28 | * @flags: media bus (V4L2_MBUS_*) flags |
| 29 | * @data_lanes: an array of physical data lane indexes |
| 30 | * @clock_lane: physical lane index of the clock lane |
| 31 | * @num_data_lanes: number of data lanes |
Sakari Ailus | b6eec1c | 2015-03-25 19:57:37 -0300 | [diff] [blame] | 32 | * @lane_polarities: polarity of the lanes. The order is the same of |
| 33 | * the physical lanes. |
Guennadi Liakhovetski | 99fd133 | 2012-09-26 05:24:03 -0300 | [diff] [blame] | 34 | */ |
| 35 | struct v4l2_of_bus_mipi_csi2 { |
| 36 | unsigned int flags; |
| 37 | unsigned char data_lanes[4]; |
| 38 | unsigned char clock_lane; |
| 39 | unsigned short num_data_lanes; |
Sakari Ailus | b6eec1c | 2015-03-25 19:57:37 -0300 | [diff] [blame] | 40 | bool lane_polarities[5]; |
Guennadi Liakhovetski | 99fd133 | 2012-09-26 05:24:03 -0300 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | /** |
| 44 | * struct v4l2_of_bus_parallel - parallel data bus data structure |
| 45 | * @flags: media bus (V4L2_MBUS_*) flags |
| 46 | * @bus_width: bus width in bits |
| 47 | * @data_shift: data shift in bits |
| 48 | */ |
| 49 | struct v4l2_of_bus_parallel { |
| 50 | unsigned int flags; |
| 51 | unsigned char bus_width; |
| 52 | unsigned char data_shift; |
| 53 | }; |
| 54 | |
| 55 | /** |
| 56 | * struct v4l2_of_endpoint - the endpoint data structure |
Philipp Zabel | f2a575f | 2014-02-14 11:53:56 +0100 | [diff] [blame] | 57 | * @base: struct of_endpoint containing port, id, and local of_node |
Guennadi Liakhovetski | 99fd133 | 2012-09-26 05:24:03 -0300 | [diff] [blame] | 58 | * @bus_type: bus type |
| 59 | * @bus: bus configuration data structure |
Sakari Ailus | 698da18 | 2015-03-22 17:48:26 -0300 | [diff] [blame] | 60 | * @link_frequencies: array of supported link frequencies |
| 61 | * @nr_of_link_frequencies: number of elements in link_frequenccies array |
Guennadi Liakhovetski | 99fd133 | 2012-09-26 05:24:03 -0300 | [diff] [blame] | 62 | */ |
| 63 | struct v4l2_of_endpoint { |
Philipp Zabel | f2a575f | 2014-02-14 11:53:56 +0100 | [diff] [blame] | 64 | struct of_endpoint base; |
Sakari Ailus | 161aada | 2015-03-22 17:42:31 -0300 | [diff] [blame] | 65 | /* Fields below this line will be zeroed by v4l2_of_parse_endpoint() */ |
Guennadi Liakhovetski | 99fd133 | 2012-09-26 05:24:03 -0300 | [diff] [blame] | 66 | enum v4l2_mbus_type bus_type; |
| 67 | union { |
| 68 | struct v4l2_of_bus_parallel parallel; |
| 69 | struct v4l2_of_bus_mipi_csi2 mipi_csi2; |
| 70 | } bus; |
Sakari Ailus | 698da18 | 2015-03-22 17:48:26 -0300 | [diff] [blame] | 71 | u64 *link_frequencies; |
| 72 | unsigned int nr_of_link_frequencies; |
Guennadi Liakhovetski | 99fd133 | 2012-09-26 05:24:03 -0300 | [diff] [blame] | 73 | }; |
| 74 | |
Laurent Pinchart | c9bca8b | 2013-05-17 07:31:04 -0300 | [diff] [blame] | 75 | /** |
| 76 | * struct v4l2_of_link - a link between two endpoints |
| 77 | * @local_node: pointer to device_node of this endpoint |
| 78 | * @local_port: identifier of the port this endpoint belongs to |
| 79 | * @remote_node: pointer to device_node of the remote endpoint |
| 80 | * @remote_port: identifier of the port the remote endpoint belongs to |
| 81 | */ |
| 82 | struct v4l2_of_link { |
| 83 | struct device_node *local_node; |
| 84 | unsigned int local_port; |
| 85 | struct device_node *remote_node; |
| 86 | unsigned int remote_port; |
| 87 | }; |
| 88 | |
Guennadi Liakhovetski | 99fd133 | 2012-09-26 05:24:03 -0300 | [diff] [blame] | 89 | #ifdef CONFIG_OF |
Laurent Pinchart | 9ff889b | 2013-05-17 07:31:04 -0300 | [diff] [blame] | 90 | int v4l2_of_parse_endpoint(const struct device_node *node, |
| 91 | struct v4l2_of_endpoint *endpoint); |
Sakari Ailus | 698da18 | 2015-03-22 17:48:26 -0300 | [diff] [blame] | 92 | struct v4l2_of_endpoint *v4l2_of_alloc_parse_endpoint( |
| 93 | const struct device_node *node); |
| 94 | void v4l2_of_free_endpoint(struct v4l2_of_endpoint *endpoint); |
Laurent Pinchart | c9bca8b | 2013-05-17 07:31:04 -0300 | [diff] [blame] | 95 | int v4l2_of_parse_link(const struct device_node *node, |
| 96 | struct v4l2_of_link *link); |
| 97 | void v4l2_of_put_link(struct v4l2_of_link *link); |
Guennadi Liakhovetski | 99fd133 | 2012-09-26 05:24:03 -0300 | [diff] [blame] | 98 | #else /* CONFIG_OF */ |
| 99 | |
| 100 | static inline int v4l2_of_parse_endpoint(const struct device_node *node, |
| 101 | struct v4l2_of_endpoint *link) |
| 102 | { |
| 103 | return -ENOSYS; |
| 104 | } |
| 105 | |
Hans Verkuil | 480856f | 2015-04-28 03:41:00 -0300 | [diff] [blame] | 106 | static inline struct v4l2_of_endpoint *v4l2_of_alloc_parse_endpoint( |
Sakari Ailus | 698da18 | 2015-03-22 17:48:26 -0300 | [diff] [blame] | 107 | const struct device_node *node) |
| 108 | { |
| 109 | return NULL; |
| 110 | } |
| 111 | |
Hans Verkuil | 480856f | 2015-04-28 03:41:00 -0300 | [diff] [blame] | 112 | static inline void v4l2_of_free_endpoint(struct v4l2_of_endpoint *endpoint) |
Sakari Ailus | 698da18 | 2015-03-22 17:48:26 -0300 | [diff] [blame] | 113 | { |
| 114 | } |
| 115 | |
Laurent Pinchart | c9bca8b | 2013-05-17 07:31:04 -0300 | [diff] [blame] | 116 | static inline int v4l2_of_parse_link(const struct device_node *node, |
| 117 | struct v4l2_of_link *link) |
| 118 | { |
| 119 | return -ENOSYS; |
| 120 | } |
| 121 | |
| 122 | static inline void v4l2_of_put_link(struct v4l2_of_link *link) |
| 123 | { |
| 124 | } |
| 125 | |
Guennadi Liakhovetski | 99fd133 | 2012-09-26 05:24:03 -0300 | [diff] [blame] | 126 | #endif /* CONFIG_OF */ |
| 127 | |
| 128 | #endif /* _V4L2_OF_H */ |