[media] v4l: fwnode: Support generic fwnode for parsing standardised properties
[linux-2.6-block.git] / include / media / v4l2-fwnode.h
CommitLineData
ca50c197
SA
1/*
2 * V4L2 fwnode binding parsing library
3 *
4 * Copyright (c) 2016 Intel Corporation.
5 * Author: Sakari Ailus <sakari.ailus@linux.intel.com>
6 *
7 * Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd.
8 * Author: Sylwester Nawrocki <s.nawrocki@samsung.com>
9 *
10 * Copyright (C) 2012 Renesas Electronics Corp.
11 * Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of version 2 of the GNU General Public License as
15 * published by the Free Software Foundation.
16 */
17#ifndef _V4L2_FWNODE_H
18#define _V4L2_FWNODE_H
19
20#include <linux/errno.h>
21#include <linux/fwnode.h>
22#include <linux/list.h>
23#include <linux/types.h>
24
25#include <media/v4l2-mediabus.h>
26
27struct fwnode_handle;
28
29/**
30 * struct v4l2_fwnode_bus_mipi_csi2 - MIPI CSI-2 bus data structure
31 * @flags: media bus (V4L2_MBUS_*) flags
32 * @data_lanes: an array of physical data lane indexes
33 * @clock_lane: physical lane index of the clock lane
34 * @num_data_lanes: number of data lanes
35 * @lane_polarities: polarity of the lanes. The order is the same of
36 * the physical lanes.
37 */
38struct v4l2_fwnode_bus_mipi_csi2 {
39 unsigned int flags;
40 unsigned char data_lanes[4];
41 unsigned char clock_lane;
42 unsigned short num_data_lanes;
43 bool lane_polarities[5];
44};
45
46/**
47 * struct v4l2_fwnode_bus_parallel - parallel data bus data structure
48 * @flags: media bus (V4L2_MBUS_*) flags
49 * @bus_width: bus width in bits
50 * @data_shift: data shift in bits
51 */
52struct v4l2_fwnode_bus_parallel {
53 unsigned int flags;
54 unsigned char bus_width;
55 unsigned char data_shift;
56};
57
58/**
59 * struct v4l2_fwnode_endpoint - the endpoint data structure
60 * @base: fwnode endpoint of the v4l2_fwnode
61 * @bus_type: bus type
62 * @bus: bus configuration data structure
63 * @link_frequencies: array of supported link frequencies
64 * @nr_of_link_frequencies: number of elements in link_frequenccies array
65 */
66struct v4l2_fwnode_endpoint {
67 struct fwnode_endpoint base;
68 /*
69 * Fields below this line will be zeroed by
70 * v4l2_fwnode_parse_endpoint()
71 */
72 enum v4l2_mbus_type bus_type;
73 union {
74 struct v4l2_fwnode_bus_parallel parallel;
75 struct v4l2_fwnode_bus_mipi_csi2 mipi_csi2;
76 } bus;
77 u64 *link_frequencies;
78 unsigned int nr_of_link_frequencies;
79};
80
81/**
82 * struct v4l2_fwnode_link - a link between two endpoints
83 * @local_node: pointer to device_node of this endpoint
84 * @local_port: identifier of the port this endpoint belongs to
85 * @remote_node: pointer to device_node of the remote endpoint
86 * @remote_port: identifier of the port the remote endpoint belongs to
87 */
88struct v4l2_fwnode_link {
89 struct fwnode_handle *local_node;
90 unsigned int local_port;
91 struct fwnode_handle *remote_node;
92 unsigned int remote_port;
93};
94
95int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
96 struct v4l2_fwnode_endpoint *vep);
97struct v4l2_fwnode_endpoint *v4l2_fwnode_endpoint_alloc_parse(
98 struct fwnode_handle *fwnode);
99void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep);
100int v4l2_fwnode_parse_link(struct fwnode_handle *fwnode,
101 struct v4l2_fwnode_link *link);
102void v4l2_fwnode_put_link(struct v4l2_fwnode_link *link);
103
104#endif /* _V4L2_FWNODE_H */