2 * Copyright (C) 2012 Spreadtrum Communications Inc.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include <linux/uaccess.h>
15 #include <linux/sprd_mm.h>
16 #include <video/sprd_isp.h>
17 #include <linux/delay.h>
21 #define ISP_TIME_OUT_MAX (500)
23 int32_t isp_get_int_num(struct isp_node *node)
26 node->irq_val1 = REG_RD(ISP_INT_INT0);
27 node->irq_val2 = REG_RD(ISP_INT_INT1);
28 node->irq_val3 = REG_RD(ISP_INT_INT2);
30 if ((0 == node->irq_val1)
31 && (0 == node->irq_val2)
32 && (0 == node->irq_val3)) {
33 printk("isp_get_int_num: int error.\n");
37 REG_WR(ISP_INT_CLR0, ISP_IRQ_HW_MASK);
38 REG_WR(ISP_INT_CLR1, ISP_IRQ_HW_MASK);
39 REG_WR(ISP_INT_CLR2, ISP_IRQ_HW_MASK);
44 void isp_clr_int(void)
46 REG_WR(ISP_INT_CLR0, ISP_IRQ_HW_MASK);
47 REG_WR(ISP_INT_CLR1, ISP_IRQ_HW_MASK);
48 REG_WR(ISP_INT_CLR2, ISP_IRQ_HW_MASK);
51 void isp_en_irq(uint32_t irq_mode)
53 REG_WR(ISP_INT_CLR0, ISP_IRQ_HW_MASK);
54 REG_WR(ISP_INT_CLR1, ISP_IRQ_HW_MASK);
55 REG_WR(ISP_INT_CLR2, ISP_IRQ_HW_MASK);
58 case ISP_INT_VIDEO_MODE:
59 REG_WR(ISP_INT_EN0, ISP_INT_DCAMERA_SOF | ISP_INT_AEM_DONE | ISP_INT_AFM_RGB_DONE | ISP_INT_AFL_DONE);
60 REG_WR(ISP_INT_EN1, 0);
61 REG_WR(ISP_INT_EN2, 0);
63 case ISP_INT_CAPTURE_MODE:
64 REG_WR(ISP_INT_EN0, ISP_INT_STORE_DONE);
65 REG_WR(ISP_INT_EN1, 0);
66 REG_WR(ISP_INT_EN2, 0);
68 case ISP_INT_CLEAR_MODE:
69 REG_WR(ISP_INT_EN0, 0);
70 REG_WR(ISP_INT_EN1, 0);
71 REG_WR(ISP_INT_EN2, 0);
74 printk("isp_en_irq: irq_mode error.\n");
79 int32_t isp_axi_bus_waiting(void)
82 uint32_t reg_value = 0;
83 uint32_t time_out_cnt = 0;
85 REG_OWR(ISP_AXI_ITI2AXIM_CTRL, BIT_18);
87 reg_value = REG_RD(ISP_INT_STATUS);
88 while ((0x00 == (reg_value & BIT_3))
89 && (time_out_cnt < ISP_TIME_OUT_MAX)) {
92 reg_value = REG_RD(ISP_INT_STATUS);
95 if (time_out_cnt >= ISP_TIME_OUT_MAX) {
97 printk("isp_axi_bus_waiting: time out.\n");