1 /* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
13 #include <linux/module.h>
14 #include <linux/ratelimit.h>
16 #include "msm_isp44.h"
17 #include "msm_isp_util.h"
18 #include "msm_isp_axi_util.h"
19 #include "msm_isp_stats_util.h"
22 #include "msm_camera_io_util.h"
23 #include "msm_isp47.h"
24 #include "linux/iopoll.h"
27 #define CDBG(fmt, args...) pr_debug(fmt, ##args)
29 #define STATS_IDX_BF_SCALE 0
30 #define STATS_IDX_BE 1
31 #define STATS_IDX_BG 2
32 #define STATS_IDX_BF 3
33 #define STATS_IDX_AWB 4
34 #define STATS_IDX_RS 5
35 #define STATS_IDX_CS 6
36 #define STATS_IDX_IHIST 7
37 #define STATS_IDX_BHIST 8
39 #define VFE44_8084V1_VERSION 0x4000000A
41 #define VFE44_BURST_LEN 3
42 #define VFE44_FETCH_BURST_LEN 3
43 #define VFE44_STATS_BURST_LEN 2
44 #define VFE44_UB_SIZE 2048
45 #define MSM_ISP44_TOTAL_IMAGE_UB 1528
46 #define VFE44_WM_BASE(idx) (0x6C + 0x24 * idx)
47 #define VFE44_RDI_BASE(idx) (0x2E8 + 0x4 * idx)
48 #define VFE44_XBAR_BASE(idx) (0x58 + 0x4 * (idx / 2))
49 #define VFE44_XBAR_SHIFT(idx) ((idx%2) ? 16 : 0)
50 #define VFE44_PING_PONG_BASE(wm, ping_pong) \
51 (VFE44_WM_BASE(wm) + 0x4 * (1 + ((~ping_pong) & 0x1)))
53 #define VFE44_BUS_RD_CGC_OVERRIDE_BIT 16
55 static uint8_t stats_pingpong_offset_map[] = {
56 7, 8, 9, 10, 11, 12, 13, 14, 15};
58 #define SHIFT_BF_SCALE_BIT 1
59 #define VFE44_NUM_STATS_COMP 2
60 #define VFE44_NUM_STATS_TYPE 9
61 #define VFE44_STATS_BASE(idx) \
62 ((idx) == STATS_IDX_BF_SCALE ? 0xA0C : (0x168 + 0x18 * (idx-1)))
63 #define VFE44_STATS_PING_PONG_BASE(idx, ping_pong) \
64 (VFE44_STATS_BASE(idx) + 0x4 * \
65 (~(ping_pong >> (stats_pingpong_offset_map[idx])) & 0x1))
67 #define VFE44_CLK_IDX 2
69 static uint32_t msm_vfe44_ub_reg_offset(struct vfe_device *vfe_dev, int wm_idx)
71 return (VFE44_WM_BASE(wm_idx) + 0x10);
74 static uint32_t msm_vfe44_get_ub_size(struct vfe_device *vfe_dev)
76 return MSM_ISP44_TOTAL_IMAGE_UB;
79 static void msm_vfe44_config_irq(struct vfe_device *vfe_dev,
80 uint32_t irq0_mask, uint32_t irq1_mask,
81 enum msm_isp_irq_operation oper)
84 case MSM_ISP_IRQ_ENABLE:
85 vfe_dev->irq0_mask |= irq0_mask;
86 vfe_dev->irq1_mask |= irq1_mask;
87 msm_camera_io_w(irq0_mask, vfe_dev->vfe_base + 0x30);
88 msm_camera_io_w(irq1_mask, vfe_dev->vfe_base + 0x34);
89 msm_camera_io_w(0x1, vfe_dev->vfe_base + 0x24);
91 case MSM_ISP_IRQ_DISABLE:
92 vfe_dev->irq0_mask &= ~irq0_mask;
93 vfe_dev->irq1_mask &= ~irq1_mask;
96 vfe_dev->irq0_mask = irq0_mask;
97 vfe_dev->irq1_mask = irq1_mask;
98 msm_camera_io_w(irq0_mask, vfe_dev->vfe_base + 0x30);
99 msm_camera_io_w(irq1_mask, vfe_dev->vfe_base + 0x34);
100 msm_camera_io_w(0x1, vfe_dev->vfe_base + 0x24);
103 msm_camera_io_w_mb(irq0_mask, vfe_dev->vfe_base + 0x28);
104 msm_camera_io_w_mb(irq1_mask, vfe_dev->vfe_base + 0x2C);
107 static int32_t msm_vfe44_init_dt_parms(struct vfe_device *vfe_dev,
108 struct msm_vfe_hw_init_parms *dt_parms)
110 void __iomem *vfebase = vfe_dev->vfe_base;
111 struct device_node *of_node;
112 int32_t i = 0 , rc = 0;
113 uint32_t *dt_settings = NULL, *dt_regs = NULL, dt_entries = 0;
115 of_node = vfe_dev->pdev->dev.of_node;
117 rc = of_property_read_u32(of_node, dt_parms->entries,
119 if (rc < 0 || !dt_entries) {
120 pr_err("%s: NO QOS entries found\n", __func__);
123 dt_settings = kzalloc(sizeof(uint32_t) * dt_entries,
126 pr_err("%s:%d No memory\n", __func__, __LINE__);
129 dt_regs = kzalloc(sizeof(uint32_t) * dt_entries,
132 pr_err("%s:%d No memory\n", __func__, __LINE__);
136 rc = of_property_read_u32_array(of_node, dt_parms->regs,
137 dt_regs, dt_entries);
139 pr_err("%s: NO QOS BUS BDG info\n", __func__);
144 if (dt_parms->settings) {
145 rc = of_property_read_u32_array(of_node,
147 dt_settings, dt_entries);
149 pr_err("%s: NO QOS settings\n",
154 for (i = 0; i < dt_entries; i++) {
155 msm_camera_io_w(dt_settings[i],
156 vfebase + dt_regs[i]);
170 static void msm_vfe44_init_hardware_reg(struct vfe_device *vfe_dev)
172 struct msm_vfe_hw_init_parms qos_parms;
173 struct msm_vfe_hw_init_parms vbif_parms;
174 struct msm_vfe_hw_init_parms ds_parms;
176 qos_parms.entries = "qos-entries";
177 qos_parms.regs = "qos-regs";
178 qos_parms.settings = "qos-settings";
179 vbif_parms.entries = "vbif-entries";
180 vbif_parms.regs = "vbif-regs";
181 vbif_parms.settings = "vbif-settings";
182 ds_parms.entries = "ds-entries";
183 ds_parms.regs = "ds-regs";
184 ds_parms.settings = "ds-settings";
186 msm_vfe44_init_dt_parms(vfe_dev, &qos_parms);
187 msm_vfe44_init_dt_parms(vfe_dev, &ds_parms);
188 msm_vfe44_init_dt_parms(vfe_dev, &vbif_parms);
191 msm_camera_io_w(0x10000001, vfe_dev->vfe_base + 0x50);
192 msm_vfe44_config_irq(vfe_dev, 0x800000E0, 0xFFFFFF7E,
197 static void msm_vfe44_clear_status_reg(struct vfe_device *vfe_dev)
199 msm_vfe44_config_irq(vfe_dev, 0x80000000, 0,
201 msm_camera_io_w(0xFFFFFFFF, vfe_dev->vfe_base + 0x30);
202 msm_camera_io_w_mb(0xFFFFFFFF, vfe_dev->vfe_base + 0x34);
203 msm_camera_io_w_mb(0x1, vfe_dev->vfe_base + 0x24);
206 static void msm_vfe44_process_reset_irq(struct vfe_device *vfe_dev,
207 uint32_t irq_status0, uint32_t irq_status1)
209 if (irq_status0 & (1 << 31)) {
210 complete(&vfe_dev->reset_complete);
211 vfe_dev->reset_pending = 0;
215 static void msm_vfe44_process_halt_irq(struct vfe_device *vfe_dev,
216 uint32_t irq_status0, uint32_t irq_status1)
218 if (irq_status1 & (1 << 8)) {
219 complete(&vfe_dev->halt_complete);
220 msm_camera_io_w(0x0, vfe_dev->vfe_base + 0x2C0);
224 static void msm_vfe44_process_input_irq(struct vfe_device *vfe_dev,
225 uint32_t irq_status0, uint32_t irq_status1,
226 struct msm_isp_timestamp *ts)
228 if (!(irq_status0 & 0x1000003))
231 if (irq_status0 & (1 << 0)) {
232 ISP_DBG("%s: SOF IRQ\n", __func__);
233 msm_isp_increment_frame_id(vfe_dev, VFE_PIX_0, ts);
236 if (irq_status0 & (1 << 24)) {
237 ISP_DBG("%s: Fetch Engine Read IRQ\n", __func__);
238 msm_isp_fetch_engine_done_notify(vfe_dev,
239 &vfe_dev->fetch_engine_info);
242 if (irq_status0 & (1 << 1))
243 ISP_DBG("%s: EOF IRQ\n", __func__);
246 static void msm_vfe44_process_violation_status(
247 struct vfe_device *vfe_dev)
249 uint32_t violation_status = vfe_dev->error_info.violation_status;
250 if (!violation_status)
253 if (violation_status & (1 << 0))
254 pr_err("%s: camif violation\n", __func__);
255 if (violation_status & (1 << 1))
256 pr_err("%s: black violation\n", __func__);
257 if (violation_status & (1 << 2))
258 pr_err("%s: rolloff violation\n", __func__);
259 if (violation_status & (1 << 3))
260 pr_err("%s: demux violation\n", __func__);
261 if (violation_status & (1 << 4))
262 pr_err("%s: demosaic violation\n", __func__);
263 if (violation_status & (1 << 5))
264 pr_err("%s: wb violation\n", __func__);
265 if (violation_status & (1 << 6))
266 pr_err("%s: clf violation\n", __func__);
267 if (violation_status & (1 << 7))
268 pr_err("%s: color correct violation\n", __func__);
269 if (violation_status & (1 << 8))
270 pr_err("%s: rgb lut violation\n", __func__);
271 if (violation_status & (1 << 9))
272 pr_err("%s: la violation\n", __func__);
273 if (violation_status & (1 << 10))
274 pr_err("%s: chroma enhance violation\n", __func__);
275 if (violation_status & (1 << 11))
276 pr_err("%s: chroma supress mce violation\n", __func__);
277 if (violation_status & (1 << 12))
278 pr_err("%s: skin enhance violation\n", __func__);
279 if (violation_status & (1 << 13))
280 pr_err("%s: color tranform enc violation\n", __func__);
281 if (violation_status & (1 << 14))
282 pr_err("%s: color tranform view violation\n", __func__);
283 if (violation_status & (1 << 15))
284 pr_err("%s: scale enc y violation\n", __func__);
285 if (violation_status & (1 << 16))
286 pr_err("%s: scale enc cbcr violation\n", __func__);
287 if (violation_status & (1 << 17))
288 pr_err("%s: scale view y violation\n", __func__);
289 if (violation_status & (1 << 18))
290 pr_err("%s: scale view cbcr violation\n", __func__);
291 if (violation_status & (1 << 21))
292 pr_err("%s: crop enc y violation\n", __func__);
293 if (violation_status & (1 << 22))
294 pr_err("%s: crop enc cbcr violation\n", __func__);
295 if (violation_status & (1 << 23))
296 pr_err("%s: crop view y violation\n", __func__);
297 if (violation_status & (1 << 24))
298 pr_err("%s: crop view cbcr violation\n", __func__);
299 if (violation_status & (1 << 25))
300 pr_err("%s: realign buf y violation\n", __func__);
301 if (violation_status & (1 << 26))
302 pr_err("%s: realign buf cb violation\n", __func__);
303 if (violation_status & (1 << 27))
304 pr_err("%s: realign buf cr violation\n", __func__);
305 if (violation_status & (1 << 28))
306 pr_err("%s: ltm violation\n", __func__);
307 if (violation_status & (1 << 29))
308 pr_err("%s: ltm cov violation\n", __func__);
309 if (violation_status & (1 << 30))
310 pr_err("%s: abf violation\n", __func__);
311 if (violation_status & (1 << 31))
312 pr_err("%s: bpc violation\n", __func__);
315 static void msm_vfe44_process_error_status(struct vfe_device *vfe_dev)
317 uint32_t error_status1 = vfe_dev->error_info.error_mask1;
318 if (error_status1 & (1 << 0)) {
319 pr_err("%s: camif error status: 0x%x\n",
320 __func__, vfe_dev->error_info.camif_status);
321 msm_camera_io_dump(vfe_dev->vfe_base + 0x2f4, 0x30, 1);
323 if (error_status1 & (1 << 1))
324 pr_err("%s: stats bhist overwrite\n", __func__);
325 if (error_status1 & (1 << 2))
326 pr_err("%s: stats cs overwrite\n", __func__);
327 if (error_status1 & (1 << 3))
328 pr_err("%s: stats ihist overwrite\n", __func__);
329 if (error_status1 & (1 << 4))
330 pr_err("%s: realign buf y overflow\n", __func__);
331 if (error_status1 & (1 << 5))
332 pr_err("%s: realign buf cb overflow\n", __func__);
333 if (error_status1 & (1 << 6))
334 pr_err("%s: realign buf cr overflow\n", __func__);
335 if (error_status1 & (1 << 7)) {
336 msm_vfe44_process_violation_status(vfe_dev);
338 if (error_status1 & (1 << 9)) {
339 vfe_dev->stats->imagemaster0_overflow++;
340 pr_err("%s: image master 0 bus overflow\n", __func__);
342 if (error_status1 & (1 << 10)) {
343 vfe_dev->stats->imagemaster1_overflow++;
344 pr_err("%s: image master 1 bus overflow\n", __func__);
346 if (error_status1 & (1 << 11)) {
347 vfe_dev->stats->imagemaster2_overflow++;
348 pr_err("%s: image master 2 bus overflow\n", __func__);
350 if (error_status1 & (1 << 12)) {
351 vfe_dev->stats->imagemaster3_overflow++;
352 pr_err("%s: image master 3 bus overflow\n", __func__);
354 if (error_status1 & (1 << 13)) {
355 vfe_dev->stats->imagemaster4_overflow++;
356 pr_err("%s: image master 4 bus overflow\n", __func__);
358 if (error_status1 & (1 << 14)) {
359 vfe_dev->stats->imagemaster5_overflow++;
360 pr_err("%s: image master 5 bus overflow\n", __func__);
362 if (error_status1 & (1 << 15)) {
363 vfe_dev->stats->imagemaster6_overflow++;
364 pr_err("%s: image master 6 bus overflow\n", __func__);
366 if (error_status1 & (1 << 16)) {
367 vfe_dev->stats->be_overflow++;
368 pr_err("%s: status be bus overflow\n", __func__);
370 if (error_status1 & (1 << 17)) {
371 vfe_dev->stats->bg_overflow++;
372 pr_err("%s: status bg bus overflow\n", __func__);
374 if (error_status1 & (1 << 18)) {
375 vfe_dev->stats->bf_overflow++;
376 pr_err("%s: status bf bus overflow\n", __func__);
378 if (error_status1 & (1 << 19)) {
379 vfe_dev->stats->awb_overflow++;
380 pr_err("%s: status awb bus overflow\n", __func__);
382 if (error_status1 & (1 << 20)) {
383 vfe_dev->stats->rs_overflow++;
384 pr_err("%s: status rs bus overflow\n", __func__);
386 if (error_status1 & (1 << 21)) {
387 vfe_dev->stats->cs_overflow++;
388 pr_err("%s: status cs bus overflow\n", __func__);
390 if (error_status1 & (1 << 22)) {
391 vfe_dev->stats->ihist_overflow++;
392 pr_err("%s: status ihist bus overflow\n", __func__);
394 if (error_status1 & (1 << 23)) {
395 vfe_dev->stats->skinbhist_overflow++;
396 pr_err("%s: status skin bhist bus overflow\n", __func__);
398 if (error_status1 & (1 << 24)) {
399 vfe_dev->stats->bfscale_overflow++;
400 pr_err("%s: status bf scale bus overflow\n", __func__);
404 static void msm_vfe44_read_and_clear_irq_status(struct vfe_device *vfe_dev,
405 uint32_t *irq_status0, uint32_t *irq_status1)
407 *irq_status0 = msm_camera_io_r(vfe_dev->vfe_base + 0x38);
408 *irq_status1 = msm_camera_io_r(vfe_dev->vfe_base + 0x3C);
410 msm_camera_io_w(*irq_status0, vfe_dev->vfe_base + 0x30);
411 msm_camera_io_w(*irq_status1, vfe_dev->vfe_base + 0x34);
412 msm_camera_io_w_mb(1, vfe_dev->vfe_base + 0x24);
413 *irq_status0 &= vfe_dev->irq0_mask;
414 *irq_status1 &= vfe_dev->irq1_mask;
415 if (*irq_status0 & 0x10000000) {
416 pr_err_ratelimited("%s: Protection triggered\n", __func__);
417 *irq_status0 &= ~(0x10000000);
420 if (*irq_status1 & (1 << 0)) {
421 vfe_dev->error_info.camif_status =
422 msm_camera_io_r(vfe_dev->vfe_base + 0x31C);
423 msm_vfe44_config_irq(vfe_dev, 0, (1 << 0), MSM_ISP_IRQ_DISABLE);
426 if (*irq_status1 & (1 << 7))
427 vfe_dev->error_info.violation_status =
428 msm_camera_io_r(vfe_dev->vfe_base + 0x48);
432 static void msm_vfe44_read_irq_status(struct vfe_device *vfe_dev,
433 uint32_t *irq_status0, uint32_t *irq_status1)
435 *irq_status0 = msm_camera_io_r(vfe_dev->vfe_base + 0x38);
436 *irq_status1 = msm_camera_io_r(vfe_dev->vfe_base + 0x3C);
439 static void msm_vfe44_process_reg_update(struct vfe_device *vfe_dev,
440 uint32_t irq_status0, uint32_t irq_status1,
441 struct msm_isp_timestamp *ts)
443 enum msm_vfe_input_src i;
445 uint8_t reg_updated = 0;
448 if (!(irq_status0 & 0xF0))
450 /* Shift status bits so that PIX SOF is 1st bit */
451 shift_irq = ((irq_status0 & 0xF0) >> 4);
453 for (i = VFE_PIX_0; i <= VFE_RAW_2; i++) {
454 if (shift_irq & BIT(i)) {
455 reg_updated |= BIT(i);
456 ISP_DBG("%s REG_UPDATE IRQ %x\n", __func__,
460 msm_isp_notify(vfe_dev, ISP_EVENT_REG_UPDATE,
462 msm_isp_process_reg_upd_epoch_irq(vfe_dev, i,
463 MSM_ISP_COMP_IRQ_REG_UPD, ts);
464 msm_isp_process_stats_reg_upd_epoch_irq(vfe_dev,
465 MSM_ISP_COMP_IRQ_REG_UPD);
466 if (vfe_dev->axi_data.src_info[i].stream_count
468 vfe_dev->axi_data.src_info[i].
469 raw_stream_count == 0 &&
470 vfe_dev->axi_data.src_info[i].active)
471 vfe_dev->hw_info->vfe_ops.core_ops.
472 reg_update(vfe_dev, i);
477 msm_isp_increment_frame_id(vfe_dev, i, ts);
478 msm_isp_notify(vfe_dev, ISP_EVENT_SOF, i, ts);
479 msm_isp_process_reg_upd_epoch_irq(vfe_dev, i,
480 MSM_ISP_COMP_IRQ_REG_UPD, ts);
482 * Reg Update is pseudo SOF for RDI,
483 * so request every frame
485 vfe_dev->hw_info->vfe_ops.core_ops.reg_update(
487 /* reg upd is epoch for rdi */
488 msm_isp_process_reg_upd_epoch_irq(vfe_dev, i,
489 MSM_ISP_COMP_IRQ_EPOCH, ts);
492 pr_err("%s: Error case\n", __func__);
498 spin_lock_irqsave(&vfe_dev->reg_update_lock, flags);
499 if (reg_updated & BIT(VFE_PIX_0))
500 vfe_dev->reg_updated = 1;
502 vfe_dev->reg_update_requested &= ~reg_updated;
503 spin_unlock_irqrestore(&vfe_dev->reg_update_lock, flags);
506 static void msm_vfe44_process_epoch_irq(struct vfe_device *vfe_dev,
507 uint32_t irq_status0, uint32_t irq_status1,
508 struct msm_isp_timestamp *ts)
510 if (!(irq_status0 & 0xc))
513 if (irq_status0 & BIT(2)) {
514 msm_isp_notify(vfe_dev, ISP_EVENT_SOF, VFE_PIX_0, ts);
515 ISP_DBG("%s: EPOCH0 IRQ\n", __func__);
516 msm_isp_process_reg_upd_epoch_irq(vfe_dev, VFE_PIX_0,
517 MSM_ISP_COMP_IRQ_EPOCH, ts);
518 msm_isp_process_stats_reg_upd_epoch_irq(vfe_dev,
519 MSM_ISP_COMP_IRQ_EPOCH);
520 msm_isp_update_error_frame_count(vfe_dev);
521 if (vfe_dev->axi_data.src_info[VFE_PIX_0].raw_stream_count > 0
522 && vfe_dev->axi_data.src_info[VFE_PIX_0].
524 ISP_DBG("%s: SOF IRQ\n", __func__);
525 msm_isp_notify(vfe_dev, ISP_EVENT_SOF, VFE_PIX_0, ts);
526 msm_isp_process_reg_upd_epoch_irq(vfe_dev, VFE_PIX_0,
527 MSM_ISP_COMP_IRQ_REG_UPD, ts);
528 vfe_dev->hw_info->vfe_ops.core_ops.reg_update(
534 static void msm_vfe44_reg_update(struct vfe_device *vfe_dev,
535 enum msm_vfe_input_src frame_src)
537 uint32_t update_mask = 0;
540 /* This HW supports upto VFE_RAW_2 */
541 if (frame_src > VFE_RAW_2 && frame_src != VFE_SRC_MAX) {
542 pr_err("%s Error case\n", __func__);
547 * If frame_src == VFE_SRC_MAX request reg_update on
550 if (frame_src == VFE_SRC_MAX)
553 update_mask = BIT((uint32_t)frame_src);
555 spin_lock_irqsave(&vfe_dev->reg_update_lock, flags);
556 vfe_dev->axi_data.src_info[VFE_PIX_0].reg_update_frame_id =
557 vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id;
558 vfe_dev->reg_update_requested |= update_mask;
559 vfe_dev->common_data->dual_vfe_res->reg_update_mask[vfe_dev->pdev->id] =
560 vfe_dev->reg_update_requested;
561 if ((vfe_dev->is_split && vfe_dev->pdev->id == ISP_VFE1) &&
562 ((frame_src == VFE_PIX_0) || (frame_src == VFE_SRC_MAX))) {
563 if (!vfe_dev->common_data->dual_vfe_res->vfe_base[ISP_VFE0]) {
564 pr_err("%s vfe_base for ISP_VFE0 is NULL\n", __func__);
565 spin_unlock_irqrestore(&vfe_dev->reg_update_lock,
569 msm_camera_io_w_mb(update_mask,
570 vfe_dev->common_data->dual_vfe_res->vfe_base[ISP_VFE0]
572 msm_camera_io_w_mb(update_mask,
573 vfe_dev->vfe_base + 0x378);
574 } else if (!vfe_dev->is_split ||
575 ((frame_src == VFE_PIX_0) &&
576 (vfe_dev->axi_data.src_info[VFE_PIX_0].stream_count == 0) &&
577 (vfe_dev->axi_data.src_info[VFE_PIX_0].
578 raw_stream_count == 0)) ||
579 (frame_src >= VFE_RAW_0 && frame_src <= VFE_SRC_MAX)) {
580 msm_camera_io_w_mb(update_mask,
581 vfe_dev->vfe_base + 0x378);
583 spin_unlock_irqrestore(&vfe_dev->reg_update_lock, flags);
586 static long msm_vfe44_reset_hardware(struct vfe_device *vfe_dev,
587 uint32_t first_start, uint32_t blocking_call)
590 init_completion(&vfe_dev->reset_complete);
593 vfe_dev->reset_pending = 1;
596 msm_camera_io_w_mb(0x1FF, vfe_dev->vfe_base + 0xC);
598 msm_camera_io_w_mb(0x1EF, vfe_dev->vfe_base + 0xC);
599 msm_camera_io_w(0x7FFFFFFF, vfe_dev->vfe_base + 0x30);
600 msm_camera_io_w(0xFEFFFEFF, vfe_dev->vfe_base + 0x34);
601 msm_camera_io_w(0x1, vfe_dev->vfe_base + 0x24);
602 vfe_dev->hw_info->vfe_ops.axi_ops.
603 reload_wm(vfe_dev, vfe_dev->vfe_base, 0x0031FFFF);
607 rc = wait_for_completion_timeout(
608 &vfe_dev->reset_complete, msecs_to_jiffies(50));
610 pr_err("%s:%d failed: reset timeout\n", __func__,
612 vfe_dev->reset_pending = 0;
619 static void msm_vfe44_axi_reload_wm(struct vfe_device *vfe_dev,
620 void __iomem *vfe_base, uint32_t reload_mask)
622 msm_camera_io_w_mb(reload_mask, vfe_base + 0x4C);
625 static void msm_vfe44_axi_enable_wm(void __iomem *vfe_base,
626 uint8_t wm_idx, uint8_t enable)
629 val = msm_camera_io_r(vfe_base + VFE44_WM_BASE(wm_idx));
634 msm_camera_io_w_mb(val,
635 vfe_base + VFE44_WM_BASE(wm_idx));
638 static void msm_vfe44_axi_update_cgc_override(struct vfe_device *vfe_dev,
639 uint8_t wm_idx, uint8_t cgc_override)
643 /* Change CGC override */
644 val = msm_camera_io_r(vfe_dev->vfe_base + 0x974);
646 val |= (1 << wm_idx);
648 val &= ~(1 << wm_idx);
649 msm_camera_io_w_mb(val, vfe_dev->vfe_base + 0x974);
652 static void msm_vfe44_axi_cfg_comp_mask(struct vfe_device *vfe_dev,
653 struct msm_vfe_axi_stream *stream_info)
655 struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
656 int vfe_idx = msm_isp_get_vfe_idx_for_stream(vfe_dev, stream_info);
657 uint32_t comp_mask, comp_mask_index;
659 comp_mask_index = stream_info->comp_mask_index[vfe_idx];
661 comp_mask = msm_camera_io_r(vfe_dev->vfe_base + 0x40);
662 comp_mask &= ~(0x7F << (comp_mask_index * 8));
663 comp_mask |= (axi_data->composite_info[comp_mask_index].
664 stream_composite_mask << (comp_mask_index * 8));
665 msm_camera_io_w(comp_mask, vfe_dev->vfe_base + 0x40);
667 msm_vfe44_config_irq(vfe_dev, 1 << (comp_mask_index + 25), 0,
671 static void msm_vfe44_axi_clear_comp_mask(struct vfe_device *vfe_dev,
672 struct msm_vfe_axi_stream *stream_info)
674 int vfe_idx = msm_isp_get_vfe_idx_for_stream(vfe_dev, stream_info);
675 uint32_t comp_mask, comp_mask_index;
677 comp_mask_index = stream_info->comp_mask_index[vfe_idx];
679 comp_mask = msm_camera_io_r(vfe_dev->vfe_base + 0x40);
680 comp_mask &= ~(0x7F << (comp_mask_index * 8));
681 msm_camera_io_w(comp_mask, vfe_dev->vfe_base + 0x40);
683 msm_vfe44_config_irq(vfe_dev, (1 << (comp_mask_index + 25)), 0,
684 MSM_ISP_IRQ_DISABLE);
687 static void msm_vfe44_axi_cfg_wm_irq_mask(struct vfe_device *vfe_dev,
688 struct msm_vfe_axi_stream *stream_info)
690 int vfe_idx = msm_isp_get_vfe_idx_for_stream(vfe_dev, stream_info);
692 msm_vfe44_config_irq(vfe_dev, 1 << (stream_info->wm[vfe_idx][0] + 8), 0,
696 static void msm_vfe44_axi_clear_wm_irq_mask(struct vfe_device *vfe_dev,
697 struct msm_vfe_axi_stream *stream_info)
699 int vfe_idx = msm_isp_get_vfe_idx_for_stream(vfe_dev, stream_info);
701 msm_vfe44_config_irq(vfe_dev, (1 << (stream_info->wm[vfe_idx][0] + 8)),
702 0, MSM_ISP_IRQ_DISABLE);
705 static void msm_vfe44_cfg_framedrop(struct vfe_device *vfe_dev,
706 struct msm_vfe_axi_stream *stream_info, uint32_t framedrop_pattern,
707 uint32_t framedrop_period)
709 void __iomem *vfe_base = vfe_dev->vfe_base;
711 int vfe_idx = msm_isp_get_vfe_idx_for_stream(vfe_dev, stream_info);
713 for (i = 0; i < stream_info->num_planes; i++) {
714 msm_camera_io_w(framedrop_pattern, vfe_base +
715 VFE44_WM_BASE(stream_info->wm[vfe_idx][i]) + 0x1C);
716 temp = msm_camera_io_r(vfe_base +
717 VFE44_WM_BASE(stream_info->wm[vfe_idx][i]) + 0xC);
719 msm_camera_io_w(temp | (framedrop_period - 1) << 2,
721 VFE44_WM_BASE(stream_info->wm[vfe_idx][i]) + 0xC);
725 static void msm_vfe44_clear_framedrop(struct vfe_device *vfe_dev,
726 struct msm_vfe_axi_stream *stream_info)
729 int vfe_idx = msm_isp_get_vfe_idx_for_stream(vfe_dev, stream_info);
731 for (i = 0; i < stream_info->num_planes; i++)
732 msm_camera_io_w(0, vfe_dev->vfe_base +
733 VFE44_WM_BASE(stream_info->wm[vfe_idx][i]) + 0x1C);
736 static int32_t msm_vfe44_convert_bpp_to_reg(int32_t bpp, uint32_t *bpp_reg)
750 pr_err("%s:%d invalid bpp %d", __func__, __LINE__, bpp);
757 static int32_t msm_vfe44_convert_io_fmt_to_reg(
758 enum msm_isp_pack_fmt pack_format, uint32_t *pack_reg)
762 switch (pack_format) {
782 pr_err("%s: invalid pack fmt %d!\n", __func__, pack_format);
789 static int32_t msm_vfe44_cfg_io_format(struct vfe_device *vfe_dev,
790 enum msm_vfe_axi_stream_src stream_src, uint32_t io_format)
793 int bpp = 0, read_bpp = 0;
794 enum msm_isp_pack_fmt pack_fmt = 0, read_pack_fmt = 0;
795 uint32_t bpp_reg = 0, pack_reg = 0;
796 uint32_t read_bpp_reg = 0, read_pack_reg = 0;
797 uint32_t io_format_reg = 0; /*io format register bit*/
799 io_format_reg = msm_camera_io_r(vfe_dev->vfe_base + 0x54);
802 if ((stream_src < RDI_INTF_0) &&
803 (vfe_dev->axi_data.src_info[VFE_PIX_0].input_mux ==
805 read_bpp = msm_isp_get_bit_per_pixel(
806 vfe_dev->axi_data.src_info[VFE_PIX_0].input_format);
807 rc = msm_vfe44_convert_bpp_to_reg(read_bpp, &read_bpp_reg);
809 pr_err("%s: convert_bpp_to_reg err! in_bpp %d rc %d\n",
810 __func__, read_bpp, rc);
814 read_pack_fmt = msm_isp_get_pack_format(
815 vfe_dev->axi_data.src_info[VFE_PIX_0].input_format);
816 rc = msm_vfe44_convert_io_fmt_to_reg(
817 read_pack_fmt, &read_pack_reg);
819 pr_err("%s: convert_io_fmt_to_reg err! rc = %d\n",
823 /*use input format(v4l2_pix_fmt) to get pack format*/
824 io_format_reg &= 0xFFC8FFFF;
825 io_format_reg |= (read_bpp_reg << 20 | read_pack_reg << 16);
828 bpp = msm_isp_get_bit_per_pixel(io_format);
829 rc = msm_vfe44_convert_bpp_to_reg(bpp, &bpp_reg);
831 pr_err("%s: convert_bpp_to_reg err! bpp %d rc = %d\n",
836 switch (stream_src) {
840 io_format_reg &= 0xFFFFCFFF;
841 io_format_reg |= bpp_reg << 12;
844 /*use output format(v4l2_pix_fmt) to get pack format*/
845 pack_fmt = msm_isp_get_pack_format(io_format);
846 rc = msm_vfe44_convert_io_fmt_to_reg(pack_fmt, &pack_reg);
848 pr_err("%s: convert_io_fmt_to_reg err! rc = %d\n",
852 io_format_reg &= 0xFFFFFFC8;
853 io_format_reg |= bpp_reg << 4 | pack_reg;
859 pr_err("%s: Invalid stream source\n", __func__);
863 msm_camera_io_w(io_format_reg, vfe_dev->vfe_base + 0x54);
867 static int msm_vfe44_fetch_engine_start(struct vfe_device *vfe_dev,
871 uint32_t bufq_handle;
872 struct msm_isp_buffer *buf = NULL;
873 struct msm_vfe_fetch_eng_start *fe_cfg = arg;
874 struct msm_isp_buffer_mapped_info mapped_info;
876 if (vfe_dev->fetch_engine_info.is_busy == 1) {
877 pr_err("%s: fetch engine busy\n", __func__);
881 memset(&mapped_info, 0, sizeof(struct msm_isp_buffer_mapped_info));
882 /* There is other option of passing buffer address from user,
883 in such case, driver needs to map the buffer and use it*/
884 vfe_dev->fetch_engine_info.session_id = fe_cfg->session_id;
885 vfe_dev->fetch_engine_info.stream_id = fe_cfg->stream_id;
886 vfe_dev->fetch_engine_info.offline_mode = fe_cfg->offline_mode;
887 vfe_dev->fetch_engine_info.fd = fe_cfg->fd;
889 if (!fe_cfg->offline_mode) {
890 bufq_handle = vfe_dev->buf_mgr->ops->get_bufq_handle(
891 vfe_dev->buf_mgr, fe_cfg->session_id,
893 vfe_dev->fetch_engine_info.bufq_handle = bufq_handle;
895 mutex_lock(&vfe_dev->buf_mgr->lock);
896 rc = vfe_dev->buf_mgr->ops->get_buf_by_index(
897 vfe_dev->buf_mgr, bufq_handle, fe_cfg->buf_idx, &buf);
899 pr_err("%s: No fetch buffer\n", __func__);
900 mutex_unlock(&vfe_dev->buf_mgr->lock);
903 mapped_info = buf->mapped_info[0];
904 buf->state = MSM_ISP_BUFFER_STATE_DISPATCHED;
905 mutex_unlock(&vfe_dev->buf_mgr->lock);
907 rc = vfe_dev->buf_mgr->ops->map_buf(vfe_dev->buf_mgr,
908 &mapped_info, fe_cfg->fd);
910 pr_err("%s: can not map buffer\n", __func__);
914 vfe_dev->fetch_engine_info.buf_idx = fe_cfg->buf_idx;
915 vfe_dev->fetch_engine_info.is_busy = 1;
917 msm_camera_io_w(mapped_info.paddr, vfe_dev->vfe_base + 0x228);
919 msm_camera_io_w_mb(0x10000, vfe_dev->vfe_base + 0x4C);
920 msm_camera_io_w_mb(0x20000, vfe_dev->vfe_base + 0x4C);
922 ISP_DBG("%s: Fetch Engine ready\n", __func__);
926 static void msm_vfe44_cfg_fetch_engine(struct vfe_device *vfe_dev,
927 struct msm_vfe_pix_cfg *pix_cfg)
929 uint32_t x_size_word;
930 struct msm_vfe_fetch_engine_cfg *fe_cfg = NULL;
933 if (pix_cfg->input_mux == EXTERNAL_READ) {
934 fe_cfg = &pix_cfg->fetch_engine_cfg;
935 pr_debug("%s: fetch_dbg wd x ht buf = %d x %d, fe = %d x %d\n",
936 __func__, fe_cfg->buf_width, fe_cfg->buf_height,
937 fe_cfg->fetch_width, fe_cfg->fetch_height);
939 vfe_dev->hw_info->vfe_ops.axi_ops.update_cgc_override(vfe_dev,
940 VFE44_BUS_RD_CGC_OVERRIDE_BIT, 1);
942 temp = msm_camera_io_r(vfe_dev->vfe_base + 0x50);
945 msm_camera_io_w(temp, vfe_dev->vfe_base + 0x50);
947 msm_vfe44_config_irq(vfe_dev, (1 << 24), 0,
949 msm_camera_io_w((fe_cfg->fetch_height - 1) & 0xFFF,
950 vfe_dev->vfe_base + 0x238);
952 x_size_word = msm_isp_cal_word_per_line(
953 vfe_dev->axi_data.src_info[VFE_PIX_0].input_format,
954 fe_cfg->fetch_width);
955 msm_camera_io_w((x_size_word - 1) << 16,
956 vfe_dev->vfe_base + 0x23C);
958 msm_camera_io_w(x_size_word << 16 |
959 (fe_cfg->buf_height - 1) << 4 | VFE44_FETCH_BURST_LEN,
960 vfe_dev->vfe_base + 0x240);
962 msm_camera_io_w(0 << 28 | 2 << 25 |
963 ((fe_cfg->buf_width - 1) & 0x1FFF) << 12 |
964 ((fe_cfg->buf_height - 1) & 0xFFF), vfe_dev->vfe_base + 0x244);
966 /* need to use formulae to calculate MAIN_UNPACK_PATTERN*/
967 msm_camera_io_w(0xF6543210, vfe_dev->vfe_base + 0x248);
968 msm_camera_io_w(0xF, vfe_dev->vfe_base + 0x264);
970 temp = msm_camera_io_r(vfe_dev->vfe_base + 0x1C);
971 temp |= 2 << 16 | pix_cfg->pixel_pattern;
972 msm_camera_io_w(temp, vfe_dev->vfe_base + 0x1C);
975 pr_err("%s: Invalid mux configuration - mux: %d", __func__,
983 static void msm_vfe44_cfg_camif(struct vfe_device *vfe_dev,
984 struct msm_vfe_pix_cfg *pix_cfg)
986 uint16_t first_pixel, last_pixel, first_line, last_line;
987 struct msm_vfe_camif_cfg *camif_cfg = &pix_cfg->camif_cfg;
988 uint32_t val, subsample_period, subsample_pattern;
989 struct msm_vfe_camif_subsample_cfg *subsample_cfg =
990 &pix_cfg->camif_cfg.subsample_cfg;
991 uint16_t bus_sub_en = 0;
993 vfe_dev->dual_vfe_enable = camif_cfg->is_split;
995 msm_camera_io_w(pix_cfg->input_mux << 16 | pix_cfg->pixel_pattern,
996 vfe_dev->vfe_base + 0x1C);
998 if (subsample_cfg->pixel_skip || subsample_cfg->line_skip) {
1000 val = msm_camera_io_r(vfe_dev->vfe_base + 0x2F8);
1002 val = val | bus_sub_en << 5;
1003 msm_camera_io_w(val, vfe_dev->vfe_base + 0x2F8);
1004 subsample_cfg->pixel_skip &= 0x0000FFFF;
1005 subsample_cfg->line_skip &= 0x0000FFFF;
1006 msm_camera_io_w((subsample_cfg->line_skip << 16) |
1007 subsample_cfg->pixel_skip,
1008 vfe_dev->vfe_base + 0x30C);
1011 first_pixel = camif_cfg->first_pixel;
1012 last_pixel = camif_cfg->last_pixel;
1013 first_line = camif_cfg->first_line;
1014 last_line = camif_cfg->last_line;
1015 subsample_period = camif_cfg->subsample_cfg.irq_subsample_period;
1016 subsample_pattern = camif_cfg->subsample_cfg.irq_subsample_pattern;
1018 msm_camera_io_w(camif_cfg->lines_per_frame << 16 |
1019 camif_cfg->pixels_per_line, vfe_dev->vfe_base + 0x300);
1021 msm_camera_io_w(first_pixel << 16 | last_pixel,
1022 vfe_dev->vfe_base + 0x304);
1024 msm_camera_io_w(first_line << 16 | last_line,
1025 vfe_dev->vfe_base + 0x308);
1026 if (subsample_period && subsample_pattern) {
1027 val = msm_camera_io_r(vfe_dev->vfe_base + 0x2F8);
1029 val = (subsample_period - 1) << 16;
1030 msm_camera_io_w(val, vfe_dev->vfe_base + 0x2F8);
1031 ISP_DBG("%s:camif PERIOD %x PATTERN %x\n",
1032 __func__, subsample_period, subsample_pattern);
1034 val = subsample_pattern;
1035 msm_camera_io_w(val, vfe_dev->vfe_base + 0x314);
1037 msm_camera_io_w(0xFFFFFFFF, vfe_dev->vfe_base + 0x314);
1039 val = msm_camera_io_r(vfe_dev->vfe_base + 0x2E8);
1040 val |= camif_cfg->camif_input;
1041 msm_camera_io_w(val, vfe_dev->vfe_base + 0x2E8);
1045 static void msm_vfe44_cfg_input_mux(struct vfe_device *vfe_dev,
1046 struct msm_vfe_pix_cfg *pix_cfg)
1048 switch (pix_cfg->input_mux) {
1050 msm_vfe44_cfg_camif(vfe_dev, pix_cfg);
1053 msm_vfe44_cfg_fetch_engine(vfe_dev, pix_cfg);
1056 pr_err("%s: Unsupported input mux %d\n",
1057 __func__, pix_cfg->input_mux);
1062 static void msm_vfe44_update_camif_state(struct vfe_device *vfe_dev,
1063 enum msm_isp_camif_update_state update_state)
1066 bool bus_en, vfe_en;
1068 if (update_state == NO_UPDATE)
1071 if (update_state == ENABLE_CAMIF) {
1072 msm_camera_io_w(0x0, vfe_dev->vfe_base + 0x30);
1073 msm_camera_io_w_mb(0x81, vfe_dev->vfe_base + 0x34);
1074 msm_camera_io_w_mb(0x1, vfe_dev->vfe_base + 0x24);
1076 msm_vfe44_config_irq(vfe_dev, 0xF7, 0x81,
1077 MSM_ISP_IRQ_ENABLE);
1078 msm_camera_io_w_mb(0x140000, vfe_dev->vfe_base + 0x318);
1081 ((vfe_dev->axi_data.
1082 src_info[VFE_PIX_0].raw_stream_count > 0) ? 1 : 0);
1084 ((vfe_dev->axi_data.
1085 src_info[VFE_PIX_0].stream_count > 0) ? 1 : 0);
1086 val = msm_camera_io_r(vfe_dev->vfe_base + 0x2F8);
1088 val = val | bus_en << 7 | vfe_en << 6;
1089 msm_camera_io_w(val, vfe_dev->vfe_base + 0x2F8);
1090 msm_camera_io_w_mb(0x4, vfe_dev->vfe_base + 0x2F4);
1091 msm_camera_io_w_mb(0x1, vfe_dev->vfe_base + 0x2F4);
1093 vfe_dev->axi_data.src_info[VFE_PIX_0].active = 1;
1094 } else if (update_state == DISABLE_CAMIF ||
1095 DISABLE_CAMIF_IMMEDIATELY == update_state) {
1098 if (vfe_dev->axi_data.src_info[VFE_PIX_0].input_mux == TESTGEN)
1099 update_state = DISABLE_CAMIF;
1100 msm_vfe44_config_irq(vfe_dev, 0,
1101 0x81, MSM_ISP_IRQ_DISABLE);
1102 val = msm_camera_io_r(vfe_dev->vfe_base + 0xC18);
1103 /* disable danger signal */
1104 msm_camera_io_w_mb(val & ~(1 << 8), vfe_dev->vfe_base + 0xC18);
1105 msm_camera_io_w_mb((update_state == DISABLE_CAMIF ? 0x0 : 0x6),
1106 vfe_dev->vfe_base + 0x2F4);
1107 if (readl_poll_timeout_atomic(vfe_dev->vfe_base + 0x31C,
1108 poll_val, poll_val & 0x80000000, 1000, 2000000))
1109 pr_err("%s: camif disable failed %x\n",
1110 __func__, poll_val);
1111 vfe_dev->axi_data.src_info[VFE_PIX_0].active = 0;
1112 msm_camera_io_w(0, vfe_dev->vfe_base + 0x30);
1113 msm_camera_io_w((1 << 0), vfe_dev->vfe_base + 0x34);
1114 msm_camera_io_w_mb(1, vfe_dev->vfe_base + 0x24);
1115 msm_vfe44_config_irq(vfe_dev, vfe_dev->irq0_mask,
1116 vfe_dev->irq1_mask, MSM_ISP_IRQ_SET);
1120 static void msm_vfe44_cfg_rdi_reg(
1121 struct vfe_device *vfe_dev, struct msm_vfe_rdi_cfg *rdi_cfg,
1122 enum msm_vfe_input_src input_src)
1124 uint8_t rdi = input_src - VFE_RAW_0;
1125 uint32_t rdi_reg_cfg;
1126 rdi_reg_cfg = msm_camera_io_r(
1127 vfe_dev->vfe_base + VFE44_RDI_BASE(0));
1128 rdi_reg_cfg &= ~(BIT(16 + rdi));
1129 rdi_reg_cfg |= rdi_cfg->frame_based << (16 + rdi);
1130 msm_camera_io_w(rdi_reg_cfg,
1131 vfe_dev->vfe_base + VFE44_RDI_BASE(0));
1133 rdi_reg_cfg = msm_camera_io_r(
1134 vfe_dev->vfe_base + VFE44_RDI_BASE(rdi));
1135 rdi_reg_cfg &= 0x70003;
1136 rdi_reg_cfg |= (rdi * 3) << 28 | rdi_cfg->cid << 4 | 0x4;
1138 rdi_reg_cfg, vfe_dev->vfe_base + VFE44_RDI_BASE(rdi));
1141 static void msm_vfe44_axi_cfg_wm_reg(
1142 struct vfe_device *vfe_dev,
1143 struct msm_vfe_axi_stream *stream_info,
1147 int vfe_idx = msm_isp_get_vfe_idx_for_stream(vfe_dev, stream_info);
1150 wm_base = VFE44_WM_BASE(stream_info->wm[vfe_idx][plane_idx]);
1152 if (!stream_info->frame_based) {
1153 msm_camera_io_w(0x0, vfe_dev->vfe_base + wm_base);
1156 ((msm_isp_cal_word_per_line(
1157 stream_info->output_format,
1158 stream_info->plane_cfg[vfe_idx][plane_idx].
1159 output_width)+1)/2 - 1) << 16 |
1160 (stream_info->plane_cfg[vfe_idx][plane_idx].
1162 msm_camera_io_w(val, vfe_dev->vfe_base + wm_base + 0x14);
1165 val = (stream_info->plane_cfg[vfe_idx][plane_idx].
1167 val = (((val & 0xfff) << 2) | ((val >> 12) & 0x3));
1169 msm_isp_cal_word_per_line(stream_info->output_format,
1170 stream_info->plane_cfg[vfe_idx][
1171 plane_idx].output_stride) << 16 |
1173 msm_camera_io_w(val, vfe_dev->vfe_base + wm_base + 0x18);
1175 msm_camera_io_w(0x2, vfe_dev->vfe_base + wm_base);
1176 val = (stream_info->plane_cfg[vfe_idx][plane_idx].
1178 val = (((val & 0xfff) << 2) | ((val >> 12) & 0x3));
1180 msm_isp_cal_word_per_line(stream_info->output_format,
1181 stream_info->plane_cfg[vfe_idx][
1182 plane_idx].output_width) << 16 |
1184 msm_camera_io_w(val, vfe_dev->vfe_base + wm_base + 0x18);
1187 /*WR_IRQ_SUBSAMPLE_PATTERN*/
1188 msm_camera_io_w(0xFFFFFFFF,
1189 vfe_dev->vfe_base + wm_base + 0x20);
1190 /* TD: Add IRQ subsample pattern */
1193 static void msm_vfe44_axi_clear_wm_reg(
1194 struct vfe_device *vfe_dev,
1195 struct msm_vfe_axi_stream *stream_info, uint8_t plane_idx)
1198 int vfe_idx = msm_isp_get_vfe_idx_for_stream(vfe_dev, stream_info);
1201 wm_base = VFE44_WM_BASE(stream_info->wm[vfe_idx][plane_idx]);
1203 msm_camera_io_w(val, vfe_dev->vfe_base + wm_base + 0xC);
1205 msm_camera_io_w(val, vfe_dev->vfe_base + wm_base + 0x14);
1207 msm_camera_io_w(val, vfe_dev->vfe_base + wm_base + 0x18);
1208 /*WR_IRQ_SUBSAMPLE_PATTERN*/
1209 msm_camera_io_w(val, vfe_dev->vfe_base + wm_base + 0x20);
1212 static void msm_vfe44_axi_cfg_wm_xbar_reg(
1213 struct vfe_device *vfe_dev,
1214 struct msm_vfe_axi_stream *stream_info,
1217 int vfe_idx = msm_isp_get_vfe_idx_for_stream(vfe_dev, stream_info);
1218 struct msm_vfe_axi_plane_cfg *plane_cfg;
1220 uint32_t xbar_cfg = 0;
1221 uint32_t xbar_reg_cfg = 0;
1223 plane_cfg = &stream_info->plane_cfg[vfe_idx][plane_idx];
1224 wm = stream_info->wm[vfe_idx][plane_idx];
1226 switch (stream_info->stream_src) {
1228 case PIX_VIEWFINDER: {
1229 if (plane_cfg->output_plane_format != CRCB_PLANE &&
1230 plane_cfg->output_plane_format != CBCR_PLANE) {
1231 /*SINGLE_STREAM_SEL*/
1232 xbar_cfg |= plane_cfg->output_plane_format << 8;
1234 switch (stream_info->output_format) {
1235 case V4L2_PIX_FMT_NV12:
1236 case V4L2_PIX_FMT_NV14:
1237 case V4L2_PIX_FMT_NV16:
1238 case V4L2_PIX_FMT_NV24:
1239 xbar_cfg |= 0x3 << 4; /*PAIR_STREAM_SWAP_CTRL*/
1242 xbar_cfg |= 0x1 << 1; /*PAIR_STREAM_EN*/
1244 if (stream_info->stream_src == PIX_VIEWFINDER)
1245 xbar_cfg |= 0x1; /*VIEW_STREAM_EN*/
1264 pr_err("%s: Invalid stream src\n", __func__);
1268 msm_camera_io_r(vfe_dev->vfe_base + VFE44_XBAR_BASE(wm));
1269 xbar_reg_cfg &= ~(0xFFFF << VFE44_XBAR_SHIFT(wm));
1270 xbar_reg_cfg |= (xbar_cfg << VFE44_XBAR_SHIFT(wm));
1271 msm_camera_io_w(xbar_reg_cfg,
1272 vfe_dev->vfe_base + VFE44_XBAR_BASE(wm));
1275 static void msm_vfe44_axi_clear_wm_xbar_reg(
1276 struct vfe_device *vfe_dev,
1277 struct msm_vfe_axi_stream *stream_info, uint8_t plane_idx)
1279 int vfe_idx = msm_isp_get_vfe_idx_for_stream(vfe_dev, stream_info);
1281 uint32_t xbar_reg_cfg = 0;
1283 wm = stream_info->wm[vfe_idx][plane_idx];
1286 msm_camera_io_r(vfe_dev->vfe_base + VFE44_XBAR_BASE(wm));
1287 xbar_reg_cfg &= ~(0xFFFF << VFE44_XBAR_SHIFT(wm));
1288 msm_camera_io_w(xbar_reg_cfg,
1289 vfe_dev->vfe_base + VFE44_XBAR_BASE(wm));
1292 static void msm_vfe44_read_wm_ping_pong_addr(
1293 struct vfe_device *vfe_dev)
1295 msm_camera_io_dump(vfe_dev->vfe_base +
1296 (VFE44_WM_BASE(0) & 0xFFFFFFF0), 0x200, 1);
1299 static void msm_vfe44_update_ping_pong_addr(
1300 void __iomem *vfe_base,
1301 uint8_t wm_idx, uint32_t pingpong_bit, dma_addr_t paddr,
1304 uint32_t paddr32 = (paddr & 0xFFFFFFFF);
1305 msm_camera_io_w(paddr32, vfe_base +
1306 VFE44_PING_PONG_BASE(wm_idx, pingpong_bit));
1309 static void msm_vfe44_set_halt_restart_mask(struct vfe_device *vfe_dev)
1311 msm_vfe44_config_irq(vfe_dev, BIT(31), BIT(8), MSM_ISP_IRQ_SET);
1315 static int msm_vfe44_axi_halt(struct vfe_device *vfe_dev,
1319 enum msm_vfe_input_src i;
1320 struct msm_isp_timestamp ts;
1322 /* Keep only halt and restart mask */
1323 msm_vfe44_config_irq(vfe_dev, (1 << 31), (1 << 8),
1326 if (atomic_read(&vfe_dev->error_info.overflow_state)
1327 == OVERFLOW_DETECTED)
1328 pr_err_ratelimited("%s: VFE%d halt for recovery, blocking %d\n",
1329 __func__, vfe_dev->pdev->id, blocking);
1332 init_completion(&vfe_dev->halt_complete);
1333 /* Halt AXI Bus Bridge */
1334 msm_camera_io_w_mb(0x1, vfe_dev->vfe_base + 0x2C0);
1335 rc = wait_for_completion_timeout(
1336 &vfe_dev->halt_complete, msecs_to_jiffies(500));
1338 pr_err("%s:VFE%d halt timeout rc=%d\n", __func__,
1339 vfe_dev->pdev->id, rc);
1341 /* Halt AXI Bus Bridge */
1342 msm_camera_io_w_mb(0x1, vfe_dev->vfe_base + 0x2C0);
1345 msm_isp_get_timestamp(&ts, vfe_dev);
1346 for (i = VFE_PIX_0; i <= VFE_RAW_2; i++) {
1347 /* if any stream is waiting for update, signal complete */
1348 msm_isp_axi_stream_update(vfe_dev, i, &ts);
1349 msm_isp_axi_stream_update(vfe_dev, i, &ts);
1352 msm_isp_stats_stream_update(vfe_dev);
1353 msm_isp_stats_stream_update(vfe_dev);
1358 static void msm_vfe44_axi_restart(struct vfe_device *vfe_dev,
1359 uint32_t blocking, uint32_t enable_camif)
1361 msm_vfe44_config_irq(vfe_dev, vfe_dev->recovery_irq0_mask,
1362 vfe_dev->recovery_irq1_mask, MSM_ISP_IRQ_ENABLE);
1363 msm_camera_io_w_mb(0x140000, vfe_dev->vfe_base + 0x318);
1366 msm_camera_io_w(0x0, vfe_dev->vfe_base + 0x2C0);
1368 vfe_dev->hw_info->vfe_ops.core_ops.reg_update(vfe_dev, VFE_SRC_MAX);
1369 memset(&vfe_dev->error_info, 0, sizeof(vfe_dev->error_info));
1370 atomic_set(&vfe_dev->error_info.overflow_state, NO_OVERFLOW);
1372 vfe_dev->hw_info->vfe_ops.core_ops.
1373 update_camif_state(vfe_dev, ENABLE_CAMIF);
1376 static uint32_t msm_vfe44_get_wm_mask(
1377 uint32_t irq_status0, uint32_t irq_status1)
1379 return (irq_status0 >> 8) & 0x7F;
1382 static uint32_t msm_vfe44_get_comp_mask(
1383 uint32_t irq_status0, uint32_t irq_status1)
1385 return (irq_status0 >> 25) & 0xF;
1388 static uint32_t msm_vfe44_get_pingpong_status(
1389 struct vfe_device *vfe_dev)
1391 return msm_camera_io_r(vfe_dev->vfe_base + 0x268);
1394 static int msm_vfe44_get_stats_idx(enum msm_isp_stats_type stats_type)
1396 switch (stats_type) {
1397 case MSM_ISP_STATS_BE:
1398 return STATS_IDX_BE;
1399 case MSM_ISP_STATS_BG:
1400 return STATS_IDX_BG;
1401 case MSM_ISP_STATS_BF:
1402 return STATS_IDX_BF;
1403 case MSM_ISP_STATS_AWB:
1404 return STATS_IDX_AWB;
1405 case MSM_ISP_STATS_RS:
1406 return STATS_IDX_RS;
1407 case MSM_ISP_STATS_CS:
1408 return STATS_IDX_CS;
1409 case MSM_ISP_STATS_IHIST:
1410 return STATS_IDX_IHIST;
1411 case MSM_ISP_STATS_BHIST:
1412 return STATS_IDX_BHIST;
1413 case MSM_ISP_STATS_BF_SCALE:
1414 return STATS_IDX_BF_SCALE;
1416 pr_err("%s: Invalid stats type\n", __func__);
1421 static int msm_vfe44_stats_check_streams(
1422 struct msm_vfe_stats_stream *stream_info)
1424 if (stream_info[STATS_IDX_BF].state ==
1426 stream_info[STATS_IDX_BF_SCALE].state !=
1428 pr_err("%s: does not support BF_SCALE while BF is disabled\n",
1432 if (stream_info[STATS_IDX_BF].state != STATS_AVAILABLE &&
1433 stream_info[STATS_IDX_BF_SCALE].state != STATS_AVAILABLE &&
1434 stream_info[STATS_IDX_BF].composite_flag !=
1435 stream_info[STATS_IDX_BF_SCALE].composite_flag) {
1436 pr_err("%s: Different composite flag for BF and BF_SCALE\n",
1443 static void msm_vfe44_stats_cfg_comp_mask(
1444 struct vfe_device *vfe_dev,
1445 uint32_t stats_mask, uint8_t request_comp_index, uint8_t enable)
1447 uint32_t comp_mask_reg, mask_bf_scale;
1448 atomic_t *stats_comp_mask;
1449 struct msm_vfe_stats_shared_data *stats_data = &vfe_dev->stats_data;
1451 if (vfe_dev->hw_info->stats_hw_info->num_stats_comp_mask < 1)
1454 if (request_comp_index >= MAX_NUM_STATS_COMP_MASK) {
1455 pr_err("%s: num of comp masks %d exceed max %d\n",
1456 __func__, request_comp_index,
1457 MAX_NUM_STATS_COMP_MASK);
1461 if (vfe_dev->hw_info->stats_hw_info->num_stats_comp_mask >
1462 MAX_NUM_STATS_COMP_MASK) {
1463 pr_err("%s: num of comp masks %d exceed max %d\n",
1465 vfe_dev->hw_info->stats_hw_info->num_stats_comp_mask,
1466 MAX_NUM_STATS_COMP_MASK);
1470 /* BF scale is controlled by BF also so ignore bit 0 of BF scale */
1471 stats_mask = stats_mask & 0x1FF;
1472 mask_bf_scale = stats_mask >> SHIFT_BF_SCALE_BIT;
1474 stats_comp_mask = &stats_data->stats_comp_mask[request_comp_index];
1475 comp_mask_reg = msm_camera_io_r(vfe_dev->vfe_base + 0x44);
1478 comp_mask_reg |= mask_bf_scale << (16 + request_comp_index * 8);
1479 atomic_set(stats_comp_mask, stats_mask |
1480 atomic_read(stats_comp_mask));
1481 msm_vfe44_config_irq(vfe_dev,
1482 1 << (request_comp_index + 29), 0,
1483 MSM_ISP_IRQ_ENABLE);
1485 if (!(atomic_read(stats_comp_mask) & stats_mask))
1487 if (stats_mask & (1 << STATS_IDX_BF_SCALE) &&
1488 atomic_read(stats_comp_mask) &
1489 (1 << STATS_IDX_BF_SCALE))
1490 atomic_set(stats_comp_mask,
1491 ~(1 << STATS_IDX_BF_SCALE) &
1492 atomic_read(stats_comp_mask));
1494 atomic_set(stats_comp_mask,
1495 ~stats_mask & atomic_read(stats_comp_mask));
1496 comp_mask_reg &= ~(mask_bf_scale <<
1497 (16 + request_comp_index * 8));
1498 msm_vfe44_config_irq(vfe_dev,
1499 1 << (request_comp_index + 29), 0,
1500 MSM_ISP_IRQ_DISABLE);
1502 msm_camera_io_w(comp_mask_reg, vfe_dev->vfe_base + 0x44);
1504 ISP_DBG("%s: comp_mask_reg: %x comp mask0 %x mask1: %x\n",
1505 __func__, comp_mask_reg,
1506 atomic_read(&stats_data->stats_comp_mask[0]),
1507 atomic_read(&stats_data->stats_comp_mask[1]));
1512 static void msm_vfe44_stats_cfg_wm_irq_mask(
1513 struct vfe_device *vfe_dev,
1514 struct msm_vfe_stats_stream *stream_info)
1516 int vfe_idx = msm_isp_get_vfe_idx_for_stats_stream(vfe_dev,
1519 msm_vfe44_config_irq(vfe_dev,
1520 1 << (STATS_IDX(stream_info->stream_handle[vfe_idx]) + 15), 0,
1521 MSM_ISP_IRQ_ENABLE);
1524 static void msm_vfe44_stats_clear_wm_irq_mask(
1525 struct vfe_device *vfe_dev,
1526 struct msm_vfe_stats_stream *stream_info)
1528 int vfe_idx = msm_isp_get_vfe_idx_for_stats_stream(vfe_dev,
1531 msm_vfe44_config_irq(vfe_dev,
1532 (1 << (STATS_IDX(stream_info->stream_handle[vfe_idx]) + 15)), 0,
1533 MSM_ISP_IRQ_DISABLE);
1536 static void msm_vfe44_stats_cfg_wm_reg(
1537 struct vfe_device *vfe_dev,
1538 struct msm_vfe_stats_stream *stream_info)
1540 int vfe_idx = msm_isp_get_vfe_idx_for_stats_stream(vfe_dev,
1543 uint32_t stats_base;
1545 stats_idx = STATS_IDX(stream_info->stream_handle[vfe_idx]);
1546 stats_base = VFE44_STATS_BASE(stats_idx);
1547 /* BF_SCALE does not have its own WR_ADDR_CFG,
1548 * IRQ_FRAMEDROP_PATTERN and IRQ_SUBSAMPLE_PATTERN;
1549 * it's using the same from BF */
1550 if (stats_idx == STATS_IDX_BF_SCALE)
1553 msm_camera_io_w((stream_info->framedrop_period - 1) << 2,
1554 vfe_dev->vfe_base + stats_base + 0x8);
1555 /*WR_IRQ_FRAMEDROP_PATTERN*/
1556 msm_camera_io_w(stream_info->framedrop_pattern,
1557 vfe_dev->vfe_base + stats_base + 0x10);
1558 /*WR_IRQ_SUBSAMPLE_PATTERN*/
1559 msm_camera_io_w(0xFFFFFFFF,
1560 vfe_dev->vfe_base + stats_base + 0x14);
1563 static void msm_vfe44_stats_clear_wm_reg(
1564 struct vfe_device *vfe_dev,
1565 struct msm_vfe_stats_stream *stream_info)
1567 int vfe_idx = msm_isp_get_vfe_idx_for_stats_stream(vfe_dev,
1571 uint32_t stats_base;
1573 stats_idx = STATS_IDX(stream_info->stream_handle[vfe_idx]);
1574 stats_base = VFE44_STATS_BASE(stats_idx);
1575 /* BF_SCALE does not have its own WR_ADDR_CFG,
1576 * IRQ_FRAMEDROP_PATTERN and IRQ_SUBSAMPLE_PATTERN;
1577 * it's using the same from BF */
1578 if (stats_idx == STATS_IDX_BF_SCALE)
1582 msm_camera_io_w(val, vfe_dev->vfe_base + stats_base + 0x8);
1583 /*WR_IRQ_FRAMEDROP_PATTERN*/
1584 msm_camera_io_w(val, vfe_dev->vfe_base + stats_base + 0x10);
1585 /*WR_IRQ_SUBSAMPLE_PATTERN*/
1586 msm_camera_io_w(val, vfe_dev->vfe_base + stats_base + 0x14);
1589 static void msm_vfe44_stats_cfg_ub(struct vfe_device *vfe_dev)
1592 uint32_t ub_offset = VFE44_UB_SIZE;
1593 uint32_t ub_size[VFE44_NUM_STATS_TYPE] = {
1594 128, /*MSM_ISP_STATS_BF_SCALE*/
1595 64, /*MSM_ISP_STATS_BE*/
1596 128, /*MSM_ISP_STATS_BG*/
1597 128, /*MSM_ISP_STATS_BF*/
1598 16, /*MSM_ISP_STATS_AWB*/
1599 8, /*MSM_ISP_STATS_RS*/
1600 16, /*MSM_ISP_STATS_CS*/
1601 16, /*MSM_ISP_STATS_IHIST*/
1602 16, /*MSM_ISP_STATS_BHIST*/
1605 for (i = 0; i < VFE44_NUM_STATS_TYPE; i++) {
1606 ub_offset -= ub_size[i];
1607 msm_camera_io_w(VFE44_STATS_BURST_LEN << 30 |
1608 ub_offset << 16 | (ub_size[i] - 1),
1609 vfe_dev->vfe_base + VFE44_STATS_BASE(i) +
1610 ((i == STATS_IDX_BF_SCALE) ? 0x8 : 0xC));
1614 static bool msm_vfe44_is_module_cfg_lock_needed(
1615 uint32_t reg_offset)
1617 if (reg_offset == 0x18)
1623 static void msm_vfe44_stats_enable_module(struct vfe_device *vfe_dev,
1624 uint32_t stats_mask, uint8_t enable)
1627 uint32_t module_cfg, module_cfg_mask = 0;
1628 uint32_t stats_cfg, stats_cfg_mask = 0;
1629 unsigned long flags;
1631 for (i = 0; i < VFE44_NUM_STATS_TYPE; i++) {
1632 if ((stats_mask >> i) & 0x1) {
1640 module_cfg_mask |= 1 << (4 + i);
1642 case STATS_IDX_IHIST:
1643 module_cfg_mask |= 1 << 15;
1645 case STATS_IDX_BHIST:
1646 module_cfg_mask |= 1 << 18;
1648 case STATS_IDX_BF_SCALE:
1649 stats_cfg_mask |= 1 << 2;
1652 pr_err("%s: Invalid stats mask\n", __func__);
1659 * For vfe44 stats and other modules share module_cfg register.
1660 * Hence need to Grab lock.
1662 spin_lock_irqsave(&vfe_dev->shared_data_lock, flags);
1663 module_cfg = msm_camera_io_r(vfe_dev->vfe_base + 0x18);
1665 module_cfg |= module_cfg_mask;
1667 module_cfg &= ~module_cfg_mask;
1668 msm_camera_io_w(module_cfg, vfe_dev->vfe_base + 0x18);
1669 spin_unlock_irqrestore(&vfe_dev->shared_data_lock, flags);
1671 stats_cfg = msm_camera_io_r(vfe_dev->vfe_base + 0x888);
1673 stats_cfg |= stats_cfg_mask;
1675 stats_cfg &= ~stats_cfg_mask;
1676 msm_camera_io_w(stats_cfg, vfe_dev->vfe_base + 0x888);
1679 static void msm_vfe44_stats_update_cgc_override(struct vfe_device *vfe_dev,
1680 uint32_t stats_mask, uint8_t cgc_override)
1683 uint32_t val = 0, cgc_mask = 0;
1685 for (i = 0; i < VFE44_NUM_STATS_TYPE; i++) {
1686 if ((stats_mask >> i) & 0x1) {
1689 cgc_mask |= (1 << 8);
1692 cgc_mask |= (1 << 9);
1695 cgc_mask |= (1 << 10);
1698 cgc_mask |= (1 << 11);
1701 cgc_mask |= (1 << 12);
1704 cgc_mask |= (1 << 13);
1706 case STATS_IDX_IHIST:
1707 cgc_mask |= (1 << 14);
1709 case STATS_IDX_BHIST:
1710 cgc_mask |= (1 << 15);
1712 case STATS_IDX_BF_SCALE:
1713 cgc_mask |= (1 << 10);
1716 pr_err("%s: Invalid stats mask\n", __func__);
1723 val = msm_camera_io_r(vfe_dev->vfe_base + 0x974);
1728 msm_camera_io_w(val, vfe_dev->vfe_base + 0x974);
1731 static void msm_vfe44_stats_update_ping_pong_addr(
1732 struct vfe_device *vfe_dev, struct msm_vfe_stats_stream *stream_info,
1733 uint32_t pingpong_status, dma_addr_t paddr, uint32_t buf_sz)
1735 void __iomem *vfe_base = vfe_dev->vfe_base;
1736 int vfe_idx = msm_isp_get_vfe_idx_for_stats_stream(vfe_dev,
1738 uint32_t paddr32 = (paddr & 0xFFFFFFFF);
1741 stats_idx = STATS_IDX(stream_info->stream_handle[vfe_idx]);
1742 msm_camera_io_w(paddr32, vfe_base +
1743 VFE44_STATS_PING_PONG_BASE(stats_idx, pingpong_status));
1746 static uint32_t msm_vfe44_stats_get_wm_mask(
1747 uint32_t irq_status0, uint32_t irq_status1)
1749 return (irq_status0 >> 15) & 0x1FF;
1752 static uint32_t msm_vfe44_stats_get_comp_mask(
1753 uint32_t irq_status0, uint32_t irq_status1)
1755 return (irq_status0 >> 29) & 0x3;
1758 static uint32_t msm_vfe44_stats_get_frame_id(
1759 struct vfe_device *vfe_dev)
1761 return vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id;
1764 static void msm_vfe44_get_error_mask(
1765 uint32_t *error_mask0, uint32_t *error_mask1)
1767 *error_mask0 = 0x00000000;
1768 *error_mask1 = 0x01FFFEFF;
1771 static void msm_vfe44_get_overflow_mask(uint32_t *overflow_mask)
1773 *overflow_mask = 0x00FFFE7E;
1776 static void msm_vfe44_get_rdi_wm_mask(struct vfe_device *vfe_dev,
1777 uint32_t *rdi_wm_mask)
1779 *rdi_wm_mask = vfe_dev->axi_data.rdi_wm_mask;
1782 static void msm_vfe44_get_irq_mask(struct vfe_device *vfe_dev,
1783 uint32_t *irq0_mask, uint32_t *irq1_mask)
1785 *irq0_mask = vfe_dev->irq0_mask;
1786 *irq1_mask = vfe_dev->irq1_mask;
1789 static void msm_vfe44_get_halt_restart_mask(uint32_t *irq0_mask,
1790 uint32_t *irq1_mask)
1792 *irq0_mask = BIT(31);
1793 *irq1_mask = BIT(8);
1796 static struct msm_vfe_axi_hardware_info msm_vfe44_axi_hw_info = {
1800 .num_rdi_master = 3,
1802 .scratch_buf_range = SZ_32M + SZ_4M,
1805 static struct msm_vfe_stats_hardware_info msm_vfe44_stats_hw_info = {
1806 .stats_capability_mask =
1807 1 << MSM_ISP_STATS_BE | 1 << MSM_ISP_STATS_BF |
1808 1 << MSM_ISP_STATS_BG | 1 << MSM_ISP_STATS_BHIST |
1809 1 << MSM_ISP_STATS_AWB | 1 << MSM_ISP_STATS_IHIST |
1810 1 << MSM_ISP_STATS_RS | 1 << MSM_ISP_STATS_CS |
1811 1 << MSM_ISP_STATS_BF_SCALE,
1812 .stats_ping_pong_offset = stats_pingpong_offset_map,
1813 .num_stats_type = VFE44_NUM_STATS_TYPE,
1814 .num_stats_comp_mask = VFE44_NUM_STATS_COMP,
1817 struct msm_vfe_hardware_info vfe44_hw_info = {
1819 .num_iommu_secure_ctx = 1,
1820 .vfe_clk_idx = VFE44_CLK_IDX,
1821 .runtime_axi_update = 0,
1822 .min_ab = 100000000,
1823 .min_ib = 100000000,
1826 .read_and_clear_irq_status =
1827 msm_vfe44_read_and_clear_irq_status,
1828 .read_irq_status = msm_vfe44_read_irq_status,
1829 .process_camif_irq = msm_vfe44_process_input_irq,
1830 .process_reset_irq = msm_vfe44_process_reset_irq,
1831 .process_halt_irq = msm_vfe44_process_halt_irq,
1832 .process_reset_irq = msm_vfe44_process_reset_irq,
1833 .process_reg_update = msm_vfe44_process_reg_update,
1834 .process_axi_irq = msm_isp_process_axi_irq,
1835 .process_stats_irq = msm_isp_process_stats_irq,
1836 .process_epoch_irq = msm_vfe44_process_epoch_irq,
1837 .config_irq = msm_vfe44_config_irq,
1838 .preprocess_camif_irq = msm_isp47_preprocess_camif_irq,
1841 .reload_wm = msm_vfe44_axi_reload_wm,
1842 .enable_wm = msm_vfe44_axi_enable_wm,
1843 .cfg_io_format = msm_vfe44_cfg_io_format,
1844 .cfg_comp_mask = msm_vfe44_axi_cfg_comp_mask,
1845 .clear_comp_mask = msm_vfe44_axi_clear_comp_mask,
1846 .cfg_wm_irq_mask = msm_vfe44_axi_cfg_wm_irq_mask,
1847 .clear_wm_irq_mask = msm_vfe44_axi_clear_wm_irq_mask,
1848 .cfg_framedrop = msm_vfe44_cfg_framedrop,
1849 .clear_framedrop = msm_vfe44_clear_framedrop,
1850 .cfg_wm_reg = msm_vfe44_axi_cfg_wm_reg,
1851 .clear_wm_reg = msm_vfe44_axi_clear_wm_reg,
1852 .cfg_wm_xbar_reg = msm_vfe44_axi_cfg_wm_xbar_reg,
1853 .clear_wm_xbar_reg = msm_vfe44_axi_clear_wm_xbar_reg,
1854 .cfg_ub = msm_vfe47_cfg_axi_ub,
1855 .read_wm_ping_pong_addr =
1856 msm_vfe44_read_wm_ping_pong_addr,
1857 .update_ping_pong_addr =
1858 msm_vfe44_update_ping_pong_addr,
1859 .get_comp_mask = msm_vfe44_get_comp_mask,
1860 .get_wm_mask = msm_vfe44_get_wm_mask,
1861 .get_pingpong_status = msm_vfe44_get_pingpong_status,
1862 .halt = msm_vfe44_axi_halt,
1863 .restart = msm_vfe44_axi_restart,
1864 .update_cgc_override =
1865 msm_vfe44_axi_update_cgc_override,
1866 .ub_reg_offset = msm_vfe44_ub_reg_offset,
1867 .get_ub_size = msm_vfe44_get_ub_size,
1870 .reg_update = msm_vfe44_reg_update,
1871 .cfg_input_mux = msm_vfe44_cfg_input_mux,
1872 .update_camif_state = msm_vfe44_update_camif_state,
1873 .start_fetch_eng = msm_vfe44_fetch_engine_start,
1874 .cfg_rdi_reg = msm_vfe44_cfg_rdi_reg,
1875 .reset_hw = msm_vfe44_reset_hardware,
1876 .init_hw = msm_vfe47_init_hardware,
1877 .init_hw_reg = msm_vfe44_init_hardware_reg,
1878 .clear_status_reg = msm_vfe44_clear_status_reg,
1879 .release_hw = msm_vfe47_release_hardware,
1880 .get_error_mask = msm_vfe44_get_error_mask,
1881 .get_overflow_mask = msm_vfe44_get_overflow_mask,
1882 .get_rdi_wm_mask = msm_vfe44_get_rdi_wm_mask,
1883 .get_irq_mask = msm_vfe44_get_irq_mask,
1884 .get_halt_restart_mask =
1885 msm_vfe44_get_halt_restart_mask,
1886 .process_error_status = msm_vfe44_process_error_status,
1887 .is_module_cfg_lock_needed =
1888 msm_vfe44_is_module_cfg_lock_needed,
1889 .ahb_clk_cfg = NULL,
1890 .set_halt_restart_mask =
1891 msm_vfe44_set_halt_restart_mask,
1892 .set_bus_err_ign_mask = NULL,
1893 .get_bus_err_mask = NULL,
1896 .get_stats_idx = msm_vfe44_get_stats_idx,
1897 .check_streams = msm_vfe44_stats_check_streams,
1898 .cfg_comp_mask = msm_vfe44_stats_cfg_comp_mask,
1899 .cfg_wm_irq_mask = msm_vfe44_stats_cfg_wm_irq_mask,
1900 .clear_wm_irq_mask = msm_vfe44_stats_clear_wm_irq_mask,
1901 .cfg_wm_reg = msm_vfe44_stats_cfg_wm_reg,
1902 .clear_wm_reg = msm_vfe44_stats_clear_wm_reg,
1903 .cfg_ub = msm_vfe44_stats_cfg_ub,
1904 .enable_module = msm_vfe44_stats_enable_module,
1905 .update_ping_pong_addr =
1906 msm_vfe44_stats_update_ping_pong_addr,
1907 .get_comp_mask = msm_vfe44_stats_get_comp_mask,
1908 .get_wm_mask = msm_vfe44_stats_get_wm_mask,
1909 .get_frame_id = msm_vfe44_stats_get_frame_id,
1910 .get_pingpong_status = msm_vfe44_get_pingpong_status,
1911 .update_cgc_override =
1912 msm_vfe44_stats_update_cgc_override,
1913 .enable_stats_wm = NULL,
1916 .get_platform_data = msm_vfe47_get_platform_data,
1917 .enable_regulators = msm_vfe47_enable_regulators,
1918 .get_regulators = msm_vfe47_get_regulators,
1919 .put_regulators = msm_vfe47_put_regulators,
1920 .enable_clks = msm_vfe47_enable_clks,
1921 .get_clks = msm_vfe47_get_clks,
1922 .put_clks = msm_vfe47_put_clks,
1923 .get_clk_rates = msm_vfe47_get_clk_rates,
1924 .get_max_clk_rate = msm_vfe47_get_max_clk_rate,
1925 .set_clk_rate = msm_vfe47_set_clk_rate,
1926 .init_bw_mgr = msm_vfe47_init_bandwidth_mgr,
1927 .deinit_bw_mgr = msm_vfe47_deinit_bandwidth_mgr,
1928 .update_bw = msm_vfe47_update_bandwidth,
1931 .dmi_reg_offset = 0x918,
1932 .axi_hw_info = &msm_vfe44_axi_hw_info,
1933 .stats_hw_info = &msm_vfe44_stats_hw_info,
1934 .regulator_names = {"vdd"},
1936 EXPORT_SYMBOL(vfe44_hw_info);
1938 static const struct of_device_id msm_vfe44_dt_match[] = {
1940 .compatible = "qcom,vfe44",
1941 .data = &vfe44_hw_info,
1946 MODULE_DEVICE_TABLE(of, msm_vfe44_dt_match);
1948 static struct platform_driver vfe44_driver = {
1949 .probe = vfe_hw_probe,
1951 .name = "msm_vfe44",
1952 .owner = THIS_MODULE,
1953 .of_match_table = msm_vfe44_dt_match,
1957 static int __init msm_vfe44_init_module(void)
1959 return platform_driver_register(&vfe44_driver);
1962 static void __exit msm_vfe44_exit_module(void)
1964 platform_driver_unregister(&vfe44_driver);
1967 module_init(msm_vfe44_init_module);
1968 module_exit(msm_vfe44_exit_module);
1969 MODULE_DESCRIPTION("MSM VFE44 driver");
1970 MODULE_LICENSE("GPL v2");