GNU Linux-libre 4.14.332-gnu1
[releases.git] / drivers / media / platform / qcom / camss-8x16 / camss-csiphy.h
1 /*
2  * camss-csiphy.h
3  *
4  * Qualcomm MSM Camera Subsystem - CSIPHY Module
5  *
6  * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
7  * Copyright (C) 2016-2017 Linaro Ltd.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 and
11  * only version 2 as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  */
18 #ifndef QC_MSM_CAMSS_CSIPHY_H
19 #define QC_MSM_CAMSS_CSIPHY_H
20
21 #include <linux/clk.h>
22 #include <media/media-entity.h>
23 #include <media/v4l2-device.h>
24 #include <media/v4l2-mediabus.h>
25 #include <media/v4l2-subdev.h>
26
27 #define MSM_CSIPHY_PAD_SINK 0
28 #define MSM_CSIPHY_PAD_SRC 1
29 #define MSM_CSIPHY_PADS_NUM 2
30
31 struct csiphy_lane {
32         u8 pos;
33         u8 pol;
34 };
35
36 struct csiphy_lanes_cfg {
37         int num_data;
38         struct csiphy_lane *data;
39         struct csiphy_lane clk;
40 };
41
42 struct csiphy_csi2_cfg {
43         struct csiphy_lanes_cfg lane_cfg;
44 };
45
46 struct csiphy_config {
47         u8 combo_mode;
48         u8 csid_id;
49         struct csiphy_csi2_cfg *csi2;
50 };
51
52 struct csiphy_device {
53         u8 id;
54         struct v4l2_subdev subdev;
55         struct media_pad pads[MSM_CSIPHY_PADS_NUM];
56         void __iomem *base;
57         void __iomem *base_clk_mux;
58         u32 irq;
59         char irq_name[30];
60         struct camss_clock *clock;
61         int nclocks;
62         u32 timer_clk_rate;
63         struct csiphy_config cfg;
64         struct v4l2_mbus_framefmt fmt[MSM_CSIPHY_PADS_NUM];
65 };
66
67 struct resources;
68
69 int msm_csiphy_subdev_init(struct csiphy_device *csiphy,
70                            const struct resources *res, u8 id);
71
72 int msm_csiphy_register_entity(struct csiphy_device *csiphy,
73                                struct v4l2_device *v4l2_dev);
74
75 void msm_csiphy_unregister_entity(struct csiphy_device *csiphy);
76
77 #endif /* QC_MSM_CAMSS_CSIPHY_H */