1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2020 Rockchip Electronics Co. Ltd.
4 *
5 * Author: Zorro Liu <zorro.liu@rock-chips.com>
6 */
7
8 #ifndef _EBC_TCON_H_
9 #define _EBC_TCON_H_
10
11 #include "../ebc_panel.h"
12
13 //update mode define
14 #define NORMAL_UPDATE 0
15 #define DIFF_UPDATE 1
16
17 //display mode define
18 #define DIRECT_MODE 0
19 #define LUT_MODE 1
20 #define THREE_WIN_MODE 1
21 #define EINK_MODE 1
22
23 struct ebc_tcon {
24 struct device *dev;
25 void __iomem *regs;
26 unsigned int len;
27 int irq;
28
29 struct clk *hclk;
30 struct clk *dclk;
31 struct regmap *regmap_base;
32
33 int (*enable)(struct ebc_tcon *tcon, struct ebc_panel *panel);
34 void (*disable)(struct ebc_tcon *tcon);
35 void (*dsp_mode_set)(struct ebc_tcon *tcon, int update_mode, int display_mode, int three_win_mode, int eink_mode);
36 void (*image_addr_set)(struct ebc_tcon *tcon, u32 pre_image_addr, u32 cur_image_addr);
37 void (*frame_addr_set)(struct ebc_tcon *tcon, u32 frame_addr);
38 int (*lut_data_set)(struct ebc_tcon *tcon, unsigned int *lut_data, int frame_count, int lut_32);
39 void (*frame_start)(struct ebc_tcon *tcon, int frame_total);
40
41 void (*dsp_end_callback)(void);
42 };
43
ebc_tcon_enable(struct ebc_tcon * tcon,struct ebc_panel * panel)44 static inline int ebc_tcon_enable(struct ebc_tcon *tcon, struct ebc_panel *panel)
45 {
46 return tcon->enable(tcon, panel);
47 }
48
ebc_tcon_disable(struct ebc_tcon * tcon)49 static inline void ebc_tcon_disable(struct ebc_tcon *tcon)
50 {
51 tcon->disable(tcon);
52 }
53
ebc_tcon_dsp_mode_set(struct ebc_tcon * tcon,int update_mode,int display_mode,int three_win_mode,int eink_mode)54 static inline void ebc_tcon_dsp_mode_set(struct ebc_tcon *tcon, int update_mode,
55 int display_mode, int three_win_mode, int eink_mode)
56 {
57 return tcon->dsp_mode_set(tcon, update_mode, display_mode, three_win_mode, eink_mode);
58 }
59
ebc_tcon_image_addr_set(struct ebc_tcon * tcon,u32 pre_image_addr,u32 cur_image_addr)60 static inline void ebc_tcon_image_addr_set(struct ebc_tcon *tcon, u32 pre_image_addr, u32 cur_image_addr)
61 {
62 tcon->image_addr_set(tcon, pre_image_addr, cur_image_addr);
63 }
64
ebc_tcon_frame_addr_set(struct ebc_tcon * tcon,u32 frame_addr)65 static inline void ebc_tcon_frame_addr_set(struct ebc_tcon *tcon, u32 frame_addr)
66 {
67 tcon->frame_addr_set(tcon, frame_addr);
68 }
69
ebc_tcon_lut_data_set(struct ebc_tcon * tcon,unsigned int * lut_data,int frame_count,int lut_32)70 static inline int ebc_tcon_lut_data_set(struct ebc_tcon *tcon, unsigned int *lut_data, int frame_count, int lut_32)
71 {
72 return tcon->lut_data_set(tcon, lut_data, frame_count, lut_32);
73 }
74
ebc_tcon_frame_start(struct ebc_tcon * tcon,int frame_total)75 static inline void ebc_tcon_frame_start(struct ebc_tcon *tcon, int frame_total)
76 {
77 tcon->frame_start(tcon, frame_total);
78 }
79
80 struct eink_tcon {
81 struct device *dev;
82 void __iomem *regs;
83 unsigned int len;
84 int irq;
85
86 struct clk *hclk;
87 struct clk *pclk;
88 struct regmap *regmap_base;
89
90 int (*enable)(struct eink_tcon *tcon, struct ebc_panel *panel);
91 void (*disable)(struct eink_tcon *tcon);
92 void (*image_addr_set)(struct eink_tcon *tcon, u32 pre_image_buf_addr,
93 u32 cur_image_buf_addr, u32 image_process_buf_addr);
94 void (*frame_start)(struct eink_tcon *tcon);
95
96 void (*dsp_end_callback)(void);
97 };
98
eink_tcon_enable(struct eink_tcon * tcon,struct ebc_panel * panel)99 static inline int eink_tcon_enable(struct eink_tcon *tcon, struct ebc_panel *panel)
100 {
101 return tcon->enable(tcon, panel);
102 }
103
eink_tcon_disable(struct eink_tcon * tcon)104 static inline void eink_tcon_disable(struct eink_tcon *tcon)
105 {
106 tcon->disable(tcon);
107 }
108
eink_tcon_image_addr_set(struct eink_tcon * tcon,u32 pre_image_buf_addr,u32 cur_image_buf_addr,u32 image_process_buf_addr)109 static inline void eink_tcon_image_addr_set(struct eink_tcon *tcon, u32 pre_image_buf_addr,
110 u32 cur_image_buf_addr, u32 image_process_buf_addr)
111 {
112 tcon->image_addr_set(tcon, pre_image_buf_addr, cur_image_buf_addr, image_process_buf_addr);
113 }
114
eink_tcon_frame_start(struct eink_tcon * tcon)115 static inline void eink_tcon_frame_start(struct eink_tcon *tcon)
116 {
117 tcon->frame_start(tcon);
118 }
119 #endif
120