0001
0002
0003
0004
0005
0006 #ifndef __SPRD_DPU_H__
0007 #define __SPRD_DPU_H__
0008
0009 #include <linux/bug.h>
0010 #include <linux/delay.h>
0011 #include <linux/device.h>
0012 #include <linux/kernel.h>
0013 #include <linux/platform_device.h>
0014 #include <linux/string.h>
0015 #include <video/videomode.h>
0016
0017 #include <drm/drm_crtc.h>
0018 #include <drm/drm_fourcc.h>
0019 #include <drm/drm_print.h>
0020 #include <drm/drm_vblank.h>
0021 #include <uapi/drm/drm_mode.h>
0022
0023
0024 #define DPU_LAY_REG_OFFSET 0x30
0025
0026 enum {
0027 SPRD_DPU_IF_DPI,
0028 SPRD_DPU_IF_EDPI,
0029 SPRD_DPU_IF_LIMIT
0030 };
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 struct dpu_context {
0046 void __iomem *base;
0047 int irq;
0048 u8 if_type;
0049 struct videomode vm;
0050 bool stopped;
0051 wait_queue_head_t wait_queue;
0052 bool evt_update;
0053 bool evt_stop;
0054 };
0055
0056
0057
0058
0059
0060
0061
0062
0063 struct sprd_dpu {
0064 struct drm_crtc base;
0065 struct drm_device *drm;
0066 struct dpu_context ctx;
0067 };
0068
0069 static inline struct sprd_dpu *to_sprd_crtc(struct drm_crtc *crtc)
0070 {
0071 return container_of(crtc, struct sprd_dpu, base);
0072 }
0073
0074 static inline void
0075 dpu_reg_set(struct dpu_context *ctx, u32 offset, u32 set_bits)
0076 {
0077 u32 bits = readl_relaxed(ctx->base + offset);
0078
0079 writel(bits | set_bits, ctx->base + offset);
0080 }
0081
0082 static inline void
0083 dpu_reg_clr(struct dpu_context *ctx, u32 offset, u32 clr_bits)
0084 {
0085 u32 bits = readl_relaxed(ctx->base + offset);
0086
0087 writel(bits & ~clr_bits, ctx->base + offset);
0088 }
0089
0090 static inline u32
0091 layer_reg_rd(struct dpu_context *ctx, u32 offset, int index)
0092 {
0093 u32 layer_offset = offset + index * DPU_LAY_REG_OFFSET;
0094
0095 return readl(ctx->base + layer_offset);
0096 }
0097
0098 static inline void
0099 layer_reg_wr(struct dpu_context *ctx, u32 offset, u32 cfg_bits, int index)
0100 {
0101 u32 layer_offset = offset + index * DPU_LAY_REG_OFFSET;
0102
0103 writel(cfg_bits, ctx->base + layer_offset);
0104 }
0105
0106 void sprd_dpu_run(struct sprd_dpu *dpu);
0107 void sprd_dpu_stop(struct sprd_dpu *dpu);
0108
0109 #endif