2 * Support for Intel Camera Imaging ISP subsystem.
3 * Copyright (c) 2015, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 #ifndef __CSI_RX_PRIVATE_H_INCLUDED__
16 #define __CSI_RX_PRIVATE_H_INCLUDED__
18 #include "rx_csi_defs.h"
19 #include "mipi_backend_defs.h"
22 #include "device_access.h" /* ia_css_device_load_uint32 */
24 #include "assert_support.h" /* assert */
25 #include "print_support.h" /* print */
27 /*****************************************************
29 * Device level interface (DLI).
31 *****************************************************/
33 * @brief Load the register value.
34 * Refer to "csi_rx_public.h" for details.
36 static inline hrt_data csi_rx_fe_ctrl_reg_load(
37 const csi_rx_frontend_ID_t ID,
38 const hrt_address reg)
40 assert(ID < N_CSI_RX_FRONTEND_ID);
41 assert(CSI_RX_FE_CTRL_BASE[ID] != (hrt_address)-1);
42 return ia_css_device_load_uint32(CSI_RX_FE_CTRL_BASE[ID] + reg * sizeof(
47 * @brief Store a value to the register.
48 * Refer to "ibuf_ctrl_public.h" for details.
50 static inline void csi_rx_fe_ctrl_reg_store(
51 const csi_rx_frontend_ID_t ID,
52 const hrt_address reg,
55 assert(ID < N_CSI_RX_FRONTEND_ID);
56 assert(CSI_RX_FE_CTRL_BASE[ID] != (hrt_address)-1);
58 ia_css_device_store_uint32(CSI_RX_FE_CTRL_BASE[ID] + reg * sizeof(hrt_data),
63 * @brief Load the register value.
64 * Refer to "csi_rx_public.h" for details.
66 static inline hrt_data csi_rx_be_ctrl_reg_load(
67 const csi_rx_backend_ID_t ID,
68 const hrt_address reg)
70 assert(ID < N_CSI_RX_BACKEND_ID);
71 assert(CSI_RX_BE_CTRL_BASE[ID] != (hrt_address)-1);
72 return ia_css_device_load_uint32(CSI_RX_BE_CTRL_BASE[ID] + reg * sizeof(
77 * @brief Store a value to the register.
78 * Refer to "ibuf_ctrl_public.h" for details.
80 static inline void csi_rx_be_ctrl_reg_store(
81 const csi_rx_backend_ID_t ID,
82 const hrt_address reg,
85 assert(ID < N_CSI_RX_BACKEND_ID);
86 assert(CSI_RX_BE_CTRL_BASE[ID] != (hrt_address)-1);
88 ia_css_device_store_uint32(CSI_RX_BE_CTRL_BASE[ID] + reg * sizeof(hrt_data),
94 /*****************************************************
96 * Native command interface (NCI).
98 *****************************************************/
100 * @brief Get the state of the csi rx fe dlane process.
101 * Refer to "csi_rx_public.h" for details.
103 static inline void csi_rx_fe_ctrl_get_dlane_state(
104 const csi_rx_frontend_ID_t ID,
106 csi_rx_fe_ctrl_lane_t *dlane_state)
108 dlane_state->termen =
109 csi_rx_fe_ctrl_reg_load(ID, _HRT_CSI_RX_DLY_CNT_TERMEN_DLANE_REG_IDX(lane));
110 dlane_state->settle =
111 csi_rx_fe_ctrl_reg_load(ID, _HRT_CSI_RX_DLY_CNT_SETTLE_DLANE_REG_IDX(lane));
115 * @brief Get the csi rx fe state.
116 * Refer to "csi_rx_public.h" for details.
118 static inline void csi_rx_fe_ctrl_get_state(
119 const csi_rx_frontend_ID_t ID,
120 csi_rx_fe_ctrl_state_t *state)
125 csi_rx_fe_ctrl_reg_load(ID, _HRT_CSI_RX_ENABLE_REG_IDX);
126 state->nof_enable_lanes =
127 csi_rx_fe_ctrl_reg_load(ID, _HRT_CSI_RX_NOF_ENABLED_LANES_REG_IDX);
128 state->error_handling =
129 csi_rx_fe_ctrl_reg_load(ID, _HRT_CSI_RX_ERROR_HANDLING_REG_IDX);
131 csi_rx_fe_ctrl_reg_load(ID, _HRT_CSI_RX_STATUS_REG_IDX);
132 state->status_dlane_hs =
133 csi_rx_fe_ctrl_reg_load(ID, _HRT_CSI_RX_STATUS_DLANE_HS_REG_IDX);
134 state->status_dlane_lp =
135 csi_rx_fe_ctrl_reg_load(ID, _HRT_CSI_RX_STATUS_DLANE_LP_REG_IDX);
136 state->clane.termen =
137 csi_rx_fe_ctrl_reg_load(ID, _HRT_CSI_RX_DLY_CNT_TERMEN_CLANE_REG_IDX);
138 state->clane.settle =
139 csi_rx_fe_ctrl_reg_load(ID, _HRT_CSI_RX_DLY_CNT_SETTLE_CLANE_REG_IDX);
142 * Get the values of the register-set per
145 for (i = 0; i < N_CSI_RX_FE_CTRL_DLANES[ID]; i++) {
146 csi_rx_fe_ctrl_get_dlane_state(
154 * @brief dump the csi rx fe state.
155 * Refer to "csi_rx_public.h" for details.
157 static inline void csi_rx_fe_ctrl_dump_state(
158 const csi_rx_frontend_ID_t ID,
159 csi_rx_fe_ctrl_state_t *state)
163 ia_css_print("CSI RX FE STATE Controller %d Enable state 0x%x\n", ID,
165 ia_css_print("CSI RX FE STATE Controller %d No Of enable lanes 0x%x\n", ID,
166 state->nof_enable_lanes);
167 ia_css_print("CSI RX FE STATE Controller %d Error handling 0x%x\n", ID,
168 state->error_handling);
169 ia_css_print("CSI RX FE STATE Controller %d Status 0x%x\n", ID, state->status);
170 ia_css_print("CSI RX FE STATE Controller %d Status Dlane HS 0x%x\n", ID,
171 state->status_dlane_hs);
172 ia_css_print("CSI RX FE STATE Controller %d Status Dlane LP 0x%x\n", ID,
173 state->status_dlane_lp);
174 ia_css_print("CSI RX FE STATE Controller %d Status term enable LP 0x%x\n", ID,
175 state->clane.termen);
176 ia_css_print("CSI RX FE STATE Controller %d Status term settle LP 0x%x\n", ID,
177 state->clane.settle);
180 * Get the values of the register-set per
183 for (i = 0; i < N_CSI_RX_FE_CTRL_DLANES[ID]; i++) {
184 ia_css_print("CSI RX FE STATE Controller %d DLANE ID %d termen 0x%x\n", ID, i,
185 state->dlane[i].termen);
186 ia_css_print("CSI RX FE STATE Controller %d DLANE ID %d settle 0x%x\n", ID, i,
187 state->dlane[i].settle);
192 * @brief Get the csi rx be state.
193 * Refer to "csi_rx_public.h" for details.
195 static inline void csi_rx_be_ctrl_get_state(
196 const csi_rx_backend_ID_t ID,
197 csi_rx_be_ctrl_state_t *state)
202 csi_rx_be_ctrl_reg_load(ID, _HRT_MIPI_BACKEND_ENABLE_REG_IDX);
205 csi_rx_be_ctrl_reg_load(ID, _HRT_MIPI_BACKEND_STATUS_REG_IDX);
207 for (i = 0; i < N_CSI_RX_BE_MIPI_COMP_FMT_REG ; i++) {
208 state->comp_format_reg[i] =
209 csi_rx_be_ctrl_reg_load(ID,
210 _HRT_MIPI_BACKEND_COMP_FORMAT_REG0_IDX + i);
214 csi_rx_be_ctrl_reg_load(ID, _HRT_MIPI_BACKEND_RAW16_CONFIG_REG_IDX);
217 csi_rx_be_ctrl_reg_load(ID, _HRT_MIPI_BACKEND_RAW18_CONFIG_REG_IDX);
219 csi_rx_be_ctrl_reg_load(ID, _HRT_MIPI_BACKEND_FORCE_RAW8_REG_IDX);
221 csi_rx_be_ctrl_reg_load(ID, _HRT_MIPI_BACKEND_IRQ_STATUS_REG_IDX);
222 #if 0 /* device access error for these registers */
223 /* ToDo: rootcause this failure */
224 state->custom_mode_enable =
225 csi_rx_be_ctrl_reg_load(ID, _HRT_MIPI_BACKEND_CUST_EN_REG_IDX);
227 state->custom_mode_data_state =
228 csi_rx_be_ctrl_reg_load(ID, _HRT_MIPI_BACKEND_CUST_DATA_STATE_REG_IDX);
229 for (i = 0; i < N_CSI_RX_BE_MIPI_CUSTOM_PEC ; i++) {
231 csi_rx_be_ctrl_reg_load(ID, _HRT_MIPI_BACKEND_CUST_PIX_EXT_S0P0_REG_IDX + i);
233 state->custom_mode_valid_eop_config =
234 csi_rx_be_ctrl_reg_load(ID, _HRT_MIPI_BACKEND_CUST_PIX_VALID_EOP_REG_IDX);
236 state->global_lut_disregard_reg =
237 csi_rx_be_ctrl_reg_load(ID, _HRT_MIPI_BACKEND_GLOBAL_LUT_DISREGARD_REG_IDX);
238 state->packet_status_stall =
239 csi_rx_be_ctrl_reg_load(ID, _HRT_MIPI_BACKEND_PKT_STALL_STATUS_REG_IDX);
241 * Get the values of the register-set per
244 for (i = 0; i < N_SHORT_PACKET_LUT_ENTRIES[ID]; i++) {
245 state->short_packet_lut_entry[i] =
246 csi_rx_be_ctrl_reg_load(ID, _HRT_MIPI_BACKEND_SP_LUT_ENTRY_0_REG_IDX + i);
248 for (i = 0; i < N_LONG_PACKET_LUT_ENTRIES[ID]; i++) {
249 state->long_packet_lut_entry[i] =
250 csi_rx_be_ctrl_reg_load(ID, _HRT_MIPI_BACKEND_LP_LUT_ENTRY_0_REG_IDX + i);
255 * @brief Dump the csi rx be state.
256 * Refer to "csi_rx_public.h" for details.
258 static inline void csi_rx_be_ctrl_dump_state(
259 const csi_rx_backend_ID_t ID,
260 csi_rx_be_ctrl_state_t *state)
264 ia_css_print("CSI RX BE STATE Controller %d Enable 0x%x\n", ID, state->enable);
265 ia_css_print("CSI RX BE STATE Controller %d Status 0x%x\n", ID, state->status);
267 for (i = 0; i < N_CSI_RX_BE_MIPI_COMP_FMT_REG ; i++) {
268 ia_css_print("CSI RX BE STATE Controller %d comp format reg vc%d value 0x%x\n",
269 ID, i, state->status);
271 ia_css_print("CSI RX BE STATE Controller %d RAW16 0x%x\n", ID, state->raw16);
272 ia_css_print("CSI RX BE STATE Controller %d RAW18 0x%x\n", ID, state->raw18);
273 ia_css_print("CSI RX BE STATE Controller %d Force RAW8 0x%x\n", ID,
275 ia_css_print("CSI RX BE STATE Controller %d IRQ state 0x%x\n", ID,
277 #if 0 /* ToDo:Getting device access error for this register */
278 for (i = 0; i < N_CSI_RX_BE_MIPI_CUSTOM_PEC ; i++) {
279 ia_css_print("CSI RX BE STATE Controller %d PEC ID %d custom pec 0x%x\n", ID, i,
283 ia_css_print("CSI RX BE STATE Controller %d Global LUT disregard reg 0x%x\n",
284 ID, state->global_lut_disregard_reg);
285 ia_css_print("CSI RX BE STATE Controller %d packet stall reg 0x%x\n", ID,
286 state->packet_status_stall);
288 * Get the values of the register-set per
291 for (i = 0; i < N_SHORT_PACKET_LUT_ENTRIES[ID]; i++) {
292 ia_css_print("CSI RX BE STATE Controller ID %d Short packat entry %d shart packet lut id 0x%x\n",
294 state->short_packet_lut_entry[i]);
296 for (i = 0; i < N_LONG_PACKET_LUT_ENTRIES[ID]; i++) {
297 ia_css_print("CSI RX BE STATE Controller ID %d Long packat entry %d Long packet lut id 0x%x\n",
299 state->long_packet_lut_entry[i]);
305 #endif /* __CSI_RX_PRIVATE_H_INCLUDED__ */