1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* Copyright (C) 2013--2024 Intel Corporation */ 3 4 #ifndef IPU6_ISYS_CSI2_H 5 #define IPU6_ISYS_CSI2_H 6 7 #include <linux/container_of.h> 8 9 #include "ipu6-isys-subdev.h" 10 #include "ipu6-isys-video.h" 11 12 struct media_entity; 13 struct v4l2_mbus_frame_desc_entry; 14 15 struct ipu6_isys_video; 16 struct ipu6_isys; 17 struct ipu6_isys_csi2_pdata; 18 struct ipu6_isys_stream; 19 20 #define NR_OF_CSI2_VC 16 21 #define INVALID_VC_ID -1 22 #define NR_OF_CSI2_SINK_PADS 1 23 #define CSI2_PAD_SINK 0 24 #define NR_OF_CSI2_SRC_PADS 8 25 #define CSI2_PAD_SRC 1 26 #define NR_OF_CSI2_PADS (NR_OF_CSI2_SINK_PADS + NR_OF_CSI2_SRC_PADS) 27 28 #define CSI2_CSI_RX_DLY_CNT_TERMEN_CLANE_A 0 29 #define CSI2_CSI_RX_DLY_CNT_TERMEN_CLANE_B 0 30 #define CSI2_CSI_RX_DLY_CNT_SETTLE_CLANE_A 95 31 #define CSI2_CSI_RX_DLY_CNT_SETTLE_CLANE_B -8 32 33 #define CSI2_CSI_RX_DLY_CNT_TERMEN_DLANE_A 0 34 #define CSI2_CSI_RX_DLY_CNT_TERMEN_DLANE_B 0 35 #define CSI2_CSI_RX_DLY_CNT_SETTLE_DLANE_A 85 36 #define CSI2_CSI_RX_DLY_CNT_SETTLE_DLANE_B -2 37 38 struct ipu6_isys_csi2 { 39 struct ipu6_isys_subdev asd; 40 struct ipu6_isys_csi2_pdata *pdata; 41 struct ipu6_isys *isys; 42 struct ipu6_isys_video av[NR_OF_CSI2_SRC_PADS]; 43 44 void __iomem *base; 45 u32 receiver_errors; 46 unsigned int nlanes; 47 unsigned int port; 48 unsigned int stream_count; 49 }; 50 51 struct ipu6_isys_csi2_timing { 52 u32 ctermen; 53 u32 csettle; 54 u32 dtermen; 55 u32 dsettle; 56 }; 57 58 struct ipu6_csi2_error { 59 const char *error_string; 60 bool is_info_only; 61 }; 62 63 #define ipu6_isys_subdev_to_csi2(__sd) \ 64 container_of(__sd, struct ipu6_isys_csi2, asd) 65 66 #define to_ipu6_isys_csi2(__asd) container_of(__asd, struct ipu6_isys_csi2, asd) 67 68 s64 ipu6_isys_csi2_get_link_freq(struct ipu6_isys_csi2 *csi2); 69 int ipu6_isys_csi2_init(struct ipu6_isys_csi2 *csi2, struct ipu6_isys *isys, 70 void __iomem *base, unsigned int index); 71 void ipu6_isys_csi2_cleanup(struct ipu6_isys_csi2 *csi2); 72 void ipu6_isys_csi2_sof_event_by_stream(struct ipu6_isys_stream *stream); 73 void ipu6_isys_csi2_eof_event_by_stream(struct ipu6_isys_stream *stream); 74 void ipu6_isys_register_errors(struct ipu6_isys_csi2 *csi2); 75 void ipu6_isys_csi2_error(struct ipu6_isys_csi2 *csi2); 76 int ipu6_isys_csi2_get_remote_desc(u32 source_stream, 77 struct ipu6_isys_csi2 *csi2, 78 struct media_entity *source_entity, 79 struct v4l2_mbus_frame_desc_entry *entry); 80 void ipu6_isys_set_csi2_streams_status(struct ipu6_isys_video *av, bool status); 81 82 #endif /* IPU6_ISYS_CSI2_H */ 83