blob: 6c85c079544f4f8dff366d63386caa13ce8034ef [file] [log] [blame]
Guennadi Liakhovetski99fd1332012-09-26 05:24:03 -03001/*
2 * V4L2 OF binding parsing library
3 *
Sylwester Nawrockic6e8d962013-04-02 11:41:19 -03004 * Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd.
5 * Author: Sylwester Nawrocki <s.nawrocki@samsung.com>
6 *
Guennadi Liakhovetski99fd1332012-09-26 05:24:03 -03007 * Copyright (C) 2012 Renesas Electronics Corp.
8 * Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
9 *
Guennadi Liakhovetski99fd1332012-09-26 05:24:03 -030010 * 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 Zabelfd9fdb72014-02-10 22:01:48 +010020#include <linux/of_graph.h>
Guennadi Liakhovetski99fd1332012-09-26 05:24:03 -030021
22#include <media/v4l2-mediabus.h>
23
24struct 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 Ailusb6eec1c2015-03-25 19:57:37 -030032 * @lane_polarities: polarity of the lanes. The order is the same of
33 * the physical lanes.
Guennadi Liakhovetski99fd1332012-09-26 05:24:03 -030034 */
35struct 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 Ailusb6eec1c2015-03-25 19:57:37 -030040 bool lane_polarities[5];
Guennadi Liakhovetski99fd1332012-09-26 05:24:03 -030041};
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 */
49struct 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 Zabelf2a575f2014-02-14 11:53:56 +010057 * @base: struct of_endpoint containing port, id, and local of_node
Guennadi Liakhovetski99fd1332012-09-26 05:24:03 -030058 * @bus_type: bus type
59 * @bus: bus configuration data structure
Guennadi Liakhovetski99fd1332012-09-26 05:24:03 -030060 */
61struct v4l2_of_endpoint {
Philipp Zabelf2a575f2014-02-14 11:53:56 +010062 struct of_endpoint base;
Sakari Ailus161aada2015-03-22 17:42:31 -030063 /* Fields below this line will be zeroed by v4l2_of_parse_endpoint() */
Guennadi Liakhovetski99fd1332012-09-26 05:24:03 -030064 enum v4l2_mbus_type bus_type;
65 union {
66 struct v4l2_of_bus_parallel parallel;
67 struct v4l2_of_bus_mipi_csi2 mipi_csi2;
68 } bus;
Guennadi Liakhovetski99fd1332012-09-26 05:24:03 -030069};
70
Laurent Pinchartc9bca8b2013-05-17 07:31:04 -030071/**
72 * struct v4l2_of_link - a link between two endpoints
73 * @local_node: pointer to device_node of this endpoint
74 * @local_port: identifier of the port this endpoint belongs to
75 * @remote_node: pointer to device_node of the remote endpoint
76 * @remote_port: identifier of the port the remote endpoint belongs to
77 */
78struct v4l2_of_link {
79 struct device_node *local_node;
80 unsigned int local_port;
81 struct device_node *remote_node;
82 unsigned int remote_port;
83};
84
Guennadi Liakhovetski99fd1332012-09-26 05:24:03 -030085#ifdef CONFIG_OF
Laurent Pinchart9ff889b2013-05-17 07:31:04 -030086int v4l2_of_parse_endpoint(const struct device_node *node,
87 struct v4l2_of_endpoint *endpoint);
Laurent Pinchartc9bca8b2013-05-17 07:31:04 -030088int v4l2_of_parse_link(const struct device_node *node,
89 struct v4l2_of_link *link);
90void v4l2_of_put_link(struct v4l2_of_link *link);
Guennadi Liakhovetski99fd1332012-09-26 05:24:03 -030091#else /* CONFIG_OF */
92
93static inline int v4l2_of_parse_endpoint(const struct device_node *node,
94 struct v4l2_of_endpoint *link)
95{
96 return -ENOSYS;
97}
98
Laurent Pinchartc9bca8b2013-05-17 07:31:04 -030099static inline int v4l2_of_parse_link(const struct device_node *node,
100 struct v4l2_of_link *link)
101{
102 return -ENOSYS;
103}
104
105static inline void v4l2_of_put_link(struct v4l2_of_link *link)
106{
107}
108
Guennadi Liakhovetski99fd1332012-09-26 05:24:03 -0300109#endif /* CONFIG_OF */
110
111#endif /* _V4L2_OF_H */