1 /* 2 * Copyright (c) 2023 HPMicro 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 */ 7 8 #ifndef HPM_MIPI_CSI_DRV_H 9 #define HPM_MIPI_CSI_DRV_H 10 11 /** 12 * @brief MIPI_CSI APIs 13 * @defgroup mipi_csi_interface MIPI_CSI driver APIs 14 * @ingroup mipi_csi_interfaces 15 * @{ 16 */ 17 18 #include "hpm_common.h" 19 #include "hpm_soc.h" 20 #include "hpm_mipi_csi_regs.h" 21 22 #define MIPI_CSI_PHY_STOP_MASK_CLK_LANE (0x01u<<16) 23 #define MIPI_CSI_PHY_STOP_MASK_DATA1_LANE (0x01u<<1) 24 #define MIPI_CSI_PHY_STOP_MASK_DATA0_LANE (0x01u<<0) 25 26 27 typedef enum mipi_csi_data_type { 28 mipi_csi_data_type_yuv420_8bit = 0x18, 29 mipi_csi_data_type_yuv422_8bit = 0x1e, 30 mipi_csi_data_type_rgb565 = 0x22, 31 mipi_csi_data_type_rgb666 = 0x23, 32 mipi_csi_data_type_rgb888 = 0x24, 33 } mipi_csi_data_type_t; 34 35 typedef struct mipi_csi_config { 36 uint8_t lanes; /* !< max: 2. number of lane*/ 37 mipi_csi_data_type_t data_type; 38 } mipi_csi_config_t; 39 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 /** 46 * @brief get MIPI_CSI default config 47 * 48 * @cfg: MIPI_CSI default config 49 */ 50 void mipi_csi_get_defconfig(mipi_csi_config_t *cfg); 51 52 /** 53 * @brief MIPI_CSI init 54 * 55 * @param ptr MIPI_CSI base address 56 * @param cfg config of MIPI_CSI 57 */ 58 void mipi_csi_init(MIPI_CSI_Type *ptr, mipi_csi_config_t *cfg); 59 60 /** 61 * @brief MIPI_CSI phy interface power on 62 * 63 * @param ptr MIPI_DCI base address 64 */ 65 void mipi_csi_phy_poweron(MIPI_CSI_Type *ptr); 66 67 /** 68 * @brief MIPI_CSI phy interface power down 69 * 70 * @param ptr MIPI_CSI base address 71 */ 72 void mipi_csi_phy_powerdown(MIPI_CSI_Type *ptr); 73 74 /* 75 * @brief MIPI_CSI check clklane whether on HS state 76 * 77 * @param ptr MIPI_DCI base address 78 * @return: true on HS or false not on HS. 79 */ mipi_csi_clklane_is_entry_hs(MIPI_CSI_Type * ptr)80static inline bool mipi_csi_clklane_is_entry_hs(MIPI_CSI_Type *ptr) 81 { 82 return !!(ptr->PHY_RX & MIPI_CSI_PHY_RX_PHY_RXCLKACTIVEHS_MASK); 83 } 84 85 86 #ifdef __cplusplus 87 } 88 #endif 89 90 /** 91 * @} 92 */ 93 #endif /* HPM_MIPI_CSI_DRV_H */ 94