aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/platform/hisi/isp/isp.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/platform/hisi/isp/isp.h')
-rw-r--r--drivers/media/platform/hisi/isp/isp.h159
1 files changed, 159 insertions, 0 deletions
diff --git a/drivers/media/platform/hisi/isp/isp.h b/drivers/media/platform/hisi/isp/isp.h
new file mode 100644
index 000000000000..dc9aa590d615
--- /dev/null
+++ b/drivers/media/platform/hisi/isp/isp.h
@@ -0,0 +1,159 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2018 Linaro Ltd.
+ */
+
+#ifndef HISI_ISP_H
+#define HISI_ISP_H
+
+#include <linux/regulator/consumer.h>
+
+#include "isp-csiphy.h"
+#include "isp-sr.h"
+#include "isp-cvdr.h"
+
+#define MASK0(name) ((1<<(name##_LEN))-1)
+#define MASK1(name) (((1<<(name##_LEN))-1) << (name##_OFFSET))
+
+/* operation on the field of a variable */
+#define isp_readl_field(reg, name) \
+ (((reg) >> (name##_OFFSET)) & MASK0(name))
+
+#define isp_writel_field(reg, name, val) \
+ (reg = ((reg) & ~MASK1(name)) | \
+ (((val) & MASK0(name)) << (name##_OFFSET)))
+
+#define ISP_NUM_CLKS 2
+
+enum IRQ_MERGER_TYPE {
+ IRQ_MERGER_DEBUG_0 = 0x0,
+ IRQ_MERGER_DEBUG_1 = 0x20,
+ IRQ_MERGER_DEBUG_2 = 0x40,
+ IRQ_MERGER_DEBUG_3 = 0x60,
+ IRQ_MERGER_DEBUG_4 = 0x80,
+ IRQ_MERGER_ERROR_0 = 0xA0,
+ IRQ_MERGER_ERROR_1 = 0xC0,
+ IRQ_MERGER_FRPROC_0 = 0xE0,
+ IRQ_MERGER_FRPROC_1 = 0x100,
+ IRQ_MERGER_FRPROC_2 = 0x120,
+ IRQ_MERGER_COMBINED = 0x140,
+ IRQ_MERGER_IRQ_MAX = 0xFF,
+};
+
+enum IRQ_MERGER_FUNC_TYPE {
+ IRQ_MERGER_FUNC_IMS = 0x0,
+ IRQ_MERGER_FUNC_RIS = 0x4,
+ IRQ_MERGER_FUNC_MIS = 0x8,
+ IRQ_MERGER_FUNC_ICR = 0xC,
+ IRQ_MERGER_FUNC_ISR = 0x10,
+ IRQ_MERGER_FUNC_NO = 0x1F,
+};
+
+#define IRQ_MERGER_IMSC_DEBUG0 \
+ (IRQ_MERGER_DEBUG_0)
+#define IRQ_MERGER_IMSC_DEBUG1 \
+ (IRQ_MERGER_DEBUG_1)
+#define IRQ_MERGER_IMSC_DEBUG2 \
+ (IRQ_MERGER_DEBUG_2)
+#define IRQ_MERGER_IMSC_DEBUG3 \
+ (IRQ_MERGER_DEBUG_3)
+#define IRQ_MERGER_IMSC_ERROR0 \
+ (IRQ_MERGER_ERROR_0)
+#define IRQ_MERGER_IMSC_ERROR1 \
+ (IRQ_MERGER_ERROR_1)
+#define IRQ_MERGER_IMSC_FRPROC0 \
+ (IRQ_MERGER_FRPROC_0)
+#define IRQ_MERGER_IMSC_FRPROC1 \
+ (IRQ_MERGER_FRPROC_1)
+#define IRQ_MERGER_IMSC_FRPROC2 \
+ (IRQ_MERGER_FRPROC_2)
+
+#define IRQ_MERGER_ICR_DEBUG0 \
+ (IRQ_MERGER_DEBUG_0 + IRQ_MERGER_FUNC_ICR)
+#define IRQ_MERGER_ICR_DEBUG1 \
+ (IRQ_MERGER_DEBUG_1 + IRQ_MERGER_FUNC_ICR)
+#define IRQ_MERGER_ICR_DEBUG2 \
+ (IRQ_MERGER_DEBUG_2 + IRQ_MERGER_FUNC_ICR)
+#define IRQ_MERGER_ICR_DEBUG3 \
+ (IRQ_MERGER_DEBUG_3 + IRQ_MERGER_FUNC_ICR)
+#define IRQ_MERGER_ICR_ERROR0 \
+ (IRQ_MERGER_ERROR_0 + IRQ_MERGER_FUNC_ICR)
+#define IRQ_MERGER_ICR_ERROR1 \
+ (IRQ_MERGER_ERROR_1 + IRQ_MERGER_FUNC_ICR)
+#define IRQ_MERGER_ICR_FRPROC0 \
+ (IRQ_MERGER_FRPROC_0 + IRQ_MERGER_FUNC_ICR)
+#define IRQ_MERGER_ICR_FRPROC1 \
+ (IRQ_MERGER_FRPROC_1 + IRQ_MERGER_FUNC_ICR)
+#define IRQ_MERGER_ICR_FRPROC2 \
+ (IRQ_MERGER_FRPROC_2 + IRQ_MERGER_FUNC_ICR)
+
+#define IRQ_MERGER_SR_4_CVDR_RT_SOF_VPWR_23_OFFSET 17
+#define IRQ_MERGER_SR_4_CVDR_RT_EOF_VPWR_23_OFFSET 21
+
+#define YUV_DT_420_8BITS 0x18
+#define YUV_DT_420_10BITS 0x19
+#define YUV_DT_LEGACY_420_8BITS 0x1A
+#define YUV_DT_420_8BITS_C 0x1C
+#define YUV_DT_420_10BITS_C 0x1D
+#define YUV_DT_422_8BITS 0x1E
+#define YUV_DT_422_10BITS 0x1F
+
+#define RAW_DT_RAW6 0x28
+#define RAW_DT_RAW7 0x29
+#define RAW_DT_RAW8 0x2A
+#define RAW_DT_RAW10 0x2B
+#define RAW_DT_RAW12 0x2C
+#define RAW_DT_RAW14 0x2D
+
+struct resources {
+ char *reg;
+};
+
+struct isp_clock {
+ struct clk *clk;
+ const char *name;
+ u32 freq;
+};
+
+struct isp {
+ void __iomem *ispss_ctrl;
+ void __iomem *smmu_ctrl;
+ void __iomem *irq_merger2;
+ struct v4l2_device v4l2_dev;
+ struct v4l2_async_notifier notifier;
+ struct media_device media_dev;
+ struct device *dev;
+ struct csiphy_device *csiphy;
+ struct sr_device *sr;
+ struct cvdr_device *cvdr;
+ struct isp_clock clks[ISP_NUM_CLKS];
+ void *virt_addr;
+ dma_addr_t hw_addr;
+ int csiphy_num;
+ unsigned int pool_size;
+ unsigned int frame_size;
+ unsigned int frame_count;
+ unsigned int frame_num;
+};
+
+struct isp_camera_interface {
+ u8 csiphy_id;
+ struct csiphy_csi2_cfg csi2;
+};
+
+struct isp_async_subdev {
+ struct v4l2_async_subdev asd; /* must be first */
+ struct isp_camera_interface interface;
+};
+
+void isp_writel(void __iomem *base , u32 reg, u32 value);
+u32 isp_readl(void __iomem *base , u32 reg);
+int isp_enable_clocks(struct isp_clock *clks, struct device *dev);
+void isp_disable_clocks(struct isp_clock *clks);
+void isp_ispss_clear_irq_state(struct isp *isp);
+void isp_ispss_enable_irq(struct isp *isp);
+u32 isp_clear_irq(struct isp *isp, enum IRQ_MERGER_TYPE irq);
+int frame_num2Offset(struct isp *isp, int frame_num);
+void isp_config_smmu_bypass(struct isp *isp);
+
+#endif /* HISI_ISP_H */