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 }; 49 50 struct ipu6_isys_csi2_timing { 51 u32 ctermen; 52 u32 csettle; 53 u32 dtermen; 54 u32 dsettle; 55 }; 56 57 struct ipu6_csi2_error { 58 const char *error_string; 59 bool is_info_only; 60 }; 61 62 #define ipu6_isys_subdev_to_csi2(__sd) \ 63 container_of(__sd, struct ipu6_isys_csi2, asd) 64 65 #define to_ipu6_isys_csi2(__asd) container_of(__asd, struct ipu6_isys_csi2, asd) 66 67 s64 ipu6_isys_csi2_get_link_freq(struct ipu6_isys_csi2 *csi2); 68 int ipu6_isys_csi2_init(struct ipu6_isys_csi2 *csi2, struct ipu6_isys *isys, 69 void __iomem *base, unsigned int index); 70 void ipu6_isys_csi2_cleanup(struct ipu6_isys_csi2 *csi2); 71 void ipu6_isys_csi2_sof_event_by_stream(struct ipu6_isys_stream *stream); 72 void ipu6_isys_csi2_eof_event_by_stream(struct ipu6_isys_stream *stream); 73 void ipu6_isys_register_errors(struct ipu6_isys_csi2 *csi2); 74 void ipu6_isys_csi2_error(struct ipu6_isys_csi2 *csi2); 75 int ipu6_isys_csi2_get_remote_desc(u32 source_stream, 76 struct ipu6_isys_csi2 *csi2, 77 struct media_entity *source_entity, 78 struct v4l2_mbus_frame_desc_entry *entry); 79 80 #endif /* IPU6_ISYS_CSI2_H */ 81