• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 Allwinnertech Co.Ltd
3  * Authors: zhengwanyu
4  *
5  * This program is free software; you can redistribute  it and/or modify it
6  * under  the terms of  the GNU General  Public License as published by the
7  * Free Software Foundation;  either version 2 of the  License, or (at your
8  * option) any later version.
9  *
10  */
11 #ifndef _SUNXI_TCON_H_
12 #define _SUNXI_TCON_H_
13 
14 #include <linux/clk.h>
15 #include "sunxi_config.h"
16 #include "de/include.h"
17 #include "sunxi_common.h"
18 
19 #define TCON_NUM_MAX      4
20 
21 #if defined(CONFIG_ARCH_SUN8IW12)
22 #define DISP2_TCON_TV_SYNC_POL_ISSUE
23 #endif
24 
25 enum tcon_type {
26 	TCON_LCD = 0,
27 	TCON_TV = 1,
28 };
29 struct lcd_clk_info;
30 
31 struct sunxi_tcon_funcs {
32 	bool (*is_use_irq)(unsigned int enc_id);
33 	unsigned int (*get_irq_no)(unsigned int enc_id);
34 
35 	bool (*conn_is_support)(int enc_id, int conn_type_id);
36 	int (*set)(unsigned int de_id,
37 		   unsigned int enc_id,
38 		   unsigned int conn_type_id,
39 		   struct disp_video_timings *video_info,
40 		   struct sunxi_connector_work_mode *conn_work_mode);
41 	int (*sw_set)(unsigned int enc_id, unsigned int conn_type_id);
42 	void (*unset)(unsigned int enc_id);
43 };
44 
45 struct sunxi_tcon {
46 	/*id(or number) of this tcon*/
47 	int			id;
48 	bool			is_enabled;
49 
50 	/*register base*/
51 	uintptr_t		reg_base;
52 
53 	/*0:tcon_lcd  1:tcon_tv*/
54 	enum tcon_type		type;
55 
56 	/*
57 	 * for example, typde_id = 1, type = TCON_LCD,
58 	 * it means that this sunxi_tcon is TCON_LCD1
59 	 */
60 	int			type_id;
61 
62 	/*clock resource*/
63 	struct clk 		*mclk;/*module clk*/
64 	struct clk      *mclk_bus;/*module clk bus*/
65 	unsigned long long	tcon_div;
66 
67 	/*interrupt resource*/
68 	unsigned int 		irq_no;
69 	/*judge_line for start delay, used to judge if there is enough time
70 	 *to update and sync DE register
71 	 */
72 	unsigned int	judge_line;
73 
74 	/*indicate that this tcon has been designed to a connector
75 	 *and can NOT be assigned to others
76 	 */
77 	bool 			is_assigned;
78 
79 	/*Attached connector type id*/
80 	int				conn_type_id;
81 
82 	struct sunxi_tcon_funcs *funcs;
83 	struct reset_control *rst_bus_tcon;
84 };
85 
86 #if defined(HAVE_DEVICE_COMMON_MODULE)
87 /*disp_if_top module*/
88 struct sunxi_top_if {
89 	uintptr_t               reg_base;
90 	struct clk              *mclk;/*module clk*/
91 	struct reset_control 	*rst_bus_if_top;
92 };
93 #endif
94 
95 struct sunxi_tcon_drv {
96 	struct platform_device *pdev;
97 	struct drv_model_info  drv_model;
98 
99 #if defined(HAVE_DEVICE_COMMON_MODULE)
100 	struct sunxi_top_if hwtopif;
101 #endif
102 	/*total counts of tcon*/
103 	unsigned int tcon_cnt;
104 	unsigned int tcon_lcd_cnt;
105 	unsigned int tcon_tv_cnt;
106 	struct sunxi_tcon hwtcon[TCON_NUM_MAX];
107 };
108 
109 int sunxi_tcon_lcd_enable(int nr, int lcd_id);
110 int sunxi_tcon_lcd_disable(int nr, int lcd_id);
111 
112 unsigned int sunxi_tcon_mode(unsigned int id);
113 unsigned int sunxi_tcon_slave_num(unsigned int id);
114 unsigned int sunxi_tcon_port_num(unsigned int id);
115 
116 
117 struct sunxi_tcon_funcs *
118 sunxi_tcon_attach_connector_type(int enc_id, int conn_type);
119 void sunxi_tcon_unattach_connector_type(int enc_id);
120 
121 
122 enum disp_tv_output sunxi_tv_get_interface_type(int tv_id);
123 int sunxi_tcon_query_irq(int nr);
124 int sunxi_tcon_lcd_get_tcon_id(unsigned int lcd_id);
125 bool sunxi_tcon_sync_time_is_enough(unsigned int nr);
126 int sunxi_tcon_get_count(void);
127 
128 int sunxi_tcon_module_init(void);
129 void sunxi_tcon_module_exit(void);
130 int sunxi_tcon_get_clk_info(int lcd_id, struct lcd_clk_info *info);
131 
132 #endif
133