1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright 2020 Kévin L'hôpital <kevin.lhopital@bootlin.com>
4  * Copyright 2020-2022 Bootlin
5  * Author: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
6  */
7 
8 #ifndef _SUN8I_A83T_MIPI_CSI2_H_
9 #define _SUN8I_A83T_MIPI_CSI2_H_
10 
11 #include <linux/phy/phy.h>
12 #include <linux/regmap.h>
13 #include <linux/reset.h>
14 #include <media/v4l2-device.h>
15 #include <media/v4l2-fwnode.h>
16 
17 #define SUN8I_A83T_MIPI_CSI2_NAME	"sun8i-a83t-mipi-csi2"
18 
19 enum sun8i_a83t_mipi_csi2_pad {
20 	SUN8I_A83T_MIPI_CSI2_PAD_SINK	= 0,
21 	SUN8I_A83T_MIPI_CSI2_PAD_SOURCE	= 1,
22 	SUN8I_A83T_MIPI_CSI2_PAD_COUNT	= 2,
23 };
24 
25 struct sun8i_a83t_mipi_csi2_format {
26 	u32	mbus_code;
27 	u8	data_type;
28 	u32	bpp;
29 };
30 
31 struct sun8i_a83t_mipi_csi2_bridge {
32 	struct v4l2_subdev		subdev;
33 	struct media_pad		pads[SUN8I_A83T_MIPI_CSI2_PAD_COUNT];
34 	struct v4l2_fwnode_endpoint	endpoint;
35 	struct v4l2_async_notifier	notifier;
36 	struct v4l2_mbus_framefmt	mbus_format;
37 	struct mutex			lock; /* Mbus format lock. */
38 
39 	struct v4l2_subdev		*source_subdev;
40 };
41 
42 struct sun8i_a83t_mipi_csi2_device {
43 	struct device				*dev;
44 
45 	struct regmap				*regmap;
46 	struct clk				*clock_mod;
47 	struct clk				*clock_mipi;
48 	struct clk				*clock_misc;
49 	struct reset_control			*reset;
50 	struct phy				*dphy;
51 
52 	struct sun8i_a83t_mipi_csi2_bridge	bridge;
53 };
54 
55 #endif
56