2 * drivers/video/tegra/host/vi/vi.h
4 * Tegra Graphics Host VI
6 * Copyright (c) 2012-2016, NVIDIA CORPORATION. All rights reserved.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef __NVHOST_VI_H__
22 #define __NVHOST_VI_H__
24 #include <linux/platform/tegra/isomgr.h>
25 #include <linux/tegra-powergate.h>
26 #include <linux/clk/tegra.h>
28 #include "camera/mc_common.h"
29 #include "chip_support.h"
32 #define VI_CFG_INTERRUPT_MASK_0 0x8c
33 #define VI_CFG_INTERRUPT_STATUS_0 0x98
35 #define CSI_CSI_PIXEL_PARSER_A_INTERRUPT_MASK_0 0x850
36 #define CSI_CSI_PIXEL_PARSER_A_STATUS_0 0x854
37 #define PPA_FIFO_OVRF (1 << 5)
39 #define CSI_CSI_PIXEL_PARSER_B_INTERRUPT_MASK_0 0x884
40 #define CSI_CSI_PIXEL_PARSER_B_STATUS_0 0x888
41 #define PPB_FIFO_OVRF (1 << 5)
43 #define VI_CSI_0_ERROR_STATUS 0x184
44 #define VI_CSI_1_ERROR_STATUS 0x284
45 #define VI_CSI_0_WD_CTRL 0x18c
46 #define VI_CSI_1_WD_CTRL 0x28c
47 #define VI_CSI_0_ERROR_INT_MASK_0 0x188
48 #define VI_CSI_1_ERROR_INT_MASK_0 0x288
50 #ifdef TEGRA_21X_OR_HIGHER_CONFIG
51 #define VI_CSI_2_ERROR_STATUS 0x384
52 #define VI_CSI_3_ERROR_STATUS 0x484
53 #define VI_CSI_2_WD_CTRL 0x38c
54 #define VI_CSI_3_WD_CTRL 0x48c
55 #define VI_CSI_2_ERROR_INT_MASK_0 0x388
56 #define VI_CSI_3_ERROR_INT_MASK_0 0x488
57 #define VI_CSI_4_ERROR_STATUS 0x584
58 #define VI_CSI_5_ERROR_STATUS 0x684
59 #define VI_CSI_4_WD_CTRL 0x58c
60 #define VI_CSI_5_WD_CTRL 0x68c
61 #define VI_CSI_4_ERROR_INT_MASK_0 0x588
62 #define VI_CSI_5_ERROR_INT_MASK_0 0x688
64 #define CSI_PHY_CIL_COMMAND_0 0x908
65 #define CSI_A_PHY_CIL_ENABLE_SHIFT 0
66 #define CSI_B_PHY_CIL_ENABLE_SHIFT 8
67 #define CSI1_PHY_CIL_COMMAND_0 0x1108
68 #define CSI2_PHY_CIL_COMMAND_0 0x1908
70 #define CSI1_CSI_PIXEL_PARSER_A_INTERRUPT_MASK_0 0x1050
71 #define CSI1_CSI_PIXEL_PARSER_A_STATUS_0 0x1054
72 #define CSI1_CSI_PIXEL_PARSER_B_INTERRUPT_MASK_0 0x1084
73 #define CSI1_CSI_PIXEL_PARSER_B_STATUS_0 0x1088
74 #define CSI2_CSI_PIXEL_PARSER_A_INTERRUPT_MASK_0 0x1850
75 #define CSI2_CSI_PIXEL_PARSER_A_STATUS_0 0x1854
76 #define CSI2_CSI_PIXEL_PARSER_B_INTERRUPT_MASK_0 0x1884
77 #define CSI2_CSI_PIXEL_PARSER_B_STATUS_0 0x1888
79 #define NUM_VI_WATCHDOG 6
81 #define NUM_VI_WATCHDOG 2
84 typedef void (*callback)(void *);
86 struct tegra_vi_stats {
90 struct tegra_vi_fops {
91 int (*soc_power_on)(struct tegra_mc_vi *vi);
92 void (*soc_power_off)(struct tegra_mc_vi *vi);
95 struct tegra_vi_channel_fops {
96 void (*soc_channel_ec_init)(struct tegra_channel *chan);
97 void (*soc_channel_ec_recover)(struct tegra_channel *chan);
98 int (*soc_channel_capture_setup)(struct tegra_channel *chan);
99 void (*soc_channel_capture_frame_init)(struct tegra_channel *chan,
100 struct tegra_channel_buffer *buf, u32 *thresh);
101 void (*soc_channel_capture_frame_enable)(struct tegra_channel *chan);
102 int (*soc_channel_capture_frame)(struct tegra_channel *chan,
103 struct timespec *ts, u32 *thresh);
104 int (*soc_channel_capture_done)(struct tegra_channel *chan,
105 struct tegra_channel_buffer *buf,
106 struct timespec *ts);
107 int (*soc_channel_error_status)(struct tegra_channel *chan);
108 int (*soc_channel_stop_streaming)(struct tegra_channel *chan);
111 struct tegra_vi_data {
112 struct nvhost_device_data *info;
113 struct tegra_vi_fops *vi_fops;
114 struct tegra_vi_channel_fops *channel_fops;
115 struct tegra_csi_fops *csi_fops;
119 struct tegra_camera *camera;
120 struct platform_device *ndev;
122 struct tegra_vi_data *data;
123 struct tegra_mc_vi mc_vi;
124 struct tegra_csi_device csi;
126 struct regulator *reg;
127 struct dentry *debugdir;
128 struct tegra_vi_stats vi_out;
129 struct workqueue_struct *vi_workqueue;
130 struct work_struct stats_work;
131 struct work_struct mfi_cb_work;
132 #if defined(CONFIG_TEGRA_ISOMGR)
133 tegra_isomgr_handle isomgr_handle;
138 struct mutex update_la_lock;
139 bool master_deinitialized;
145 extern const struct file_operations tegra_vi_ctrl_ops;
146 int nvhost_vi_prepare_poweroff(struct platform_device *);
147 int nvhost_vi_finalize_poweron(struct platform_device *);
149 void nvhost_vi_reset_all(struct platform_device *);
150 struct vi *tegra_vi_get(void);
151 int vi_v4l2_set_la(struct vi *tegra_vi, u32 vi_bypass_bw, bool is_ioctl);
153 #ifdef CONFIG_VIDEO_TEGRA_VI
154 int tegra_vi_register_mfi_cb(callback cb, void *cb_arg);
155 int tegra_vi_unregister_mfi_cb(void);
157 static inline int tegra_vi_register_mfi_cb(callback cb, void *cb_arg)
161 static inline int tegra_vi_unregister_mfi_cb(void)