tizen 2.4 release
[kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-tiger / tiger_lcd.h
1 /* drivers/video/sc8810/sc8810_lcd.h
2  *
3  * Spreadtrum LCD abstraction
4  *
5  * Copyright (C) 2010 Spreadtrum.com
6  *
7  * This software is licensed under the terms of the GNU General Public
8  * License version 2, as published by the Free Software Foundation, and
9  * may be copied, distributed, and modified under those terms.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  */
16
17 #ifndef _TIGER_LCD_H_
18 #define _TIGER_LCD_H_
19
20 #include <linux/types.h>
21 #include <common.h>
22
23 #define LCD_DelayMS(ms)  udelay(1000*(ms))
24
25 /* LCD mode */
26 #define SPRDFB_I2C_WRITE_DELAY 0xffff
27
28
29 /* LCD mode */
30 #define LCD_MODE_MCU                    0
31 #define LCD_MODE_RGB                    1
32 #define LCD_MODE_DSI                    2
33
34 /* bus mode */
35 #define LCD_BUS_8080                    0
36 #define LCD_BUS_6800                    1
37 #define LCD_BUS_SPI                     2
38
39 /* lcd directions */
40 #define LCD_DIRECT_NORMAL               0
41 #define LCD_DIRECT_ROT_90               1
42 #define LCD_DIRECT_ROT_180              2
43 #define LCD_DIRECT_ROT_270              3
44 #define LCD_DIRECT_MIR_H                4
45 #define LCD_DIRECT_MIR_V                5
46 #define LCD_DIRECT_MIR_HV               6
47
48 #define PIN_PWM0_MOD_VALUE 0x20
49
50 #define SPRD_PWM_BASE                   0x88000000
51 #define SPRD_PWM_REG(off)               (SPRD_PWM_BASE + (off))
52 #define SPRD_PWM0_PRESCALE      SPRD_PWM_REG(0x0000)
53 #define SPRD_PWM0_CNT                   SPRD_PWM_REG(0x0004)
54 #define SPRD_PWM0_TONE_DIV      SPRD_PWM_REG(0x0008)
55 #define SPRD_PWM0_PAT_LOW       SPRD_PWM_REG(0x000C)
56 #define SPRD_PWM0_PAT_HIG       SPRD_PWM_REG(0x0010)
57
58 #define LCD_PWM_PRESCALE_VALUE  0x01
59 #define LCD_PWM_MOD_VALUE               0xFF
60 #define PWM_REG_MSK_VALUE                       0xFFFF
61
62 #define LCD_PWM0_EN BIT_8
63
64 enum{
65         SPRDFB_PANEL_TYPE_MCU = 0,
66         SPRDFB_PANEL_TYPE_RGB,
67         SPRDFB_PANEL_TYPE_MIPI,
68         SPRDFB_PANEL_TYPE_LIMIT
69 };
70
71 enum{
72         SPRDFB_POLARITY_POS = 0,
73         SPRDFB_POLARITY_NEG,
74         SPRDFB_POLARITY_LIMIT
75 };
76
77 enum{
78         SPRDFB_RGB_BUS_TYPE_I2C = 0,
79         SPRDFB_RGB_BUS_TYPE_SPI,
80         SPRDFB_RGB_BUG_TYPE_LIMIT
81 };
82
83 enum{
84         SPRDFB_MIPI_MODE_CMD = 0,
85         SPRDFB_MIPI_MODE_VIDEO,
86         SPRDFB_MIPI_MODE_LIMIT
87 };
88
89 struct panel_spec;
90
91 typedef int32_t (*send_cmd_t)(uint32_t data);
92 typedef int32_t (*send_data_t)(uint32_t data);
93 typedef int32_t (*send_cmd_data_t)(uint32_t cmd, uint32_t data);
94 typedef uint32_t (*read_data_t)(void);
95
96
97 /* LCD operations */
98 struct panel_operations {
99         int32_t (*panel_init)(struct panel_spec *self);
100         int32_t (*panel_close)(struct panel_spec *self);
101         int32_t (*panel_reset)(struct panel_spec *self);
102         int32_t (*panel_enter_sleep)(struct panel_spec *self, uint8_t is_sleep);
103         int32_t (*panel_set_contrast)(struct panel_spec *self, uint16_t contrast);
104         int32_t (*panel_set_brightness)(struct panel_spec *self,
105                                 uint16_t brightness);
106         int32_t (*panel_set_window)(struct panel_spec *self,
107                                 uint16_t left, uint16_t top,
108                                 uint16_t right, uint16_t bottom);
109         int32_t (*panel_invalidate)(struct panel_spec *self);
110         int32_t (*panel_invalidate_rect)(struct panel_spec *self,
111                                 uint16_t left, uint16_t top,
112                                 uint16_t right, uint16_t bottom);
113         int32_t (*panel_rotate_invalidate_rect)(struct panel_spec *self,
114                                 uint16_t left, uint16_t top,
115                                 uint16_t right, uint16_t bottom,
116                                 uint16_t angle);
117         int32_t (*panel_set_direction)(struct panel_spec *self, uint16_t direction);
118         uint32_t (*panel_readid)(struct panel_spec *self);
119 };
120
121 /* MCU LCD specific properties */
122 struct timing_mcu {
123         uint16_t rcss;
124         uint16_t rlpw;
125         uint16_t rhpw;
126         uint16_t wcss;
127         uint16_t wlpw;
128         uint16_t whpw;
129 };
130
131 /* RGB LCD specific properties */
132 struct timing_rgb {
133         uint16_t hfp;
134         uint16_t hbp;
135         uint16_t hsync;
136         uint16_t vfp;
137         uint16_t vbp;
138         uint16_t vsync;
139 };
140
141 struct ops_mcu {
142         int32_t (*send_cmd)(uint32_t cmd);
143         int32_t (*send_cmd_data)(uint32_t cmd, uint32_t data);
144         int32_t (*send_data)(uint32_t data);
145         uint32_t (*read_data)(void);
146 };
147
148 struct ops_i2c {
149         int32_t (*i2c_write_8bits)(uint8_t reg, uint8_t val);
150         int32_t (*i2c_read_8bits)(uint8_t reg, uint8_t *val);
151         int32_t (*i2c_write_16bits)(uint16_t reg, uint16_t reg_is_8bit, uint16_t val, uint16_t val_is_8bit);
152         int32_t (*i2c_read_16bits)(uint16_t reg, uint16_t reg_is_8bit, uint16_t *val, uint16_t val_is_8bit);
153         int32_t (*i2c_write_burst)(uint8_t* buf, int num);
154 };
155
156 struct ops_spi{
157         int32_t (*spi_send_cmd)(uint32_t cmd);
158         int32_t (*spi_send_data)(uint32_t cmd, uint32_t data);
159         int32_t (*spi_read)(uint32_t cmd, uint32_t *data);
160 };
161
162 struct ops_mipi{
163         int32_t (*mipi_set_cmd_mode)(void);
164         int32_t (*mipi_set_video_mode)(void);
165         int32_t (*mipi_gen_write)(uint8_t *param, uint16_t param_length);
166         int32_t (*mipi_gen_read)(uint8_t *param, uint16_t param_length, uint8_t bytes_to_read, uint8_t *read_buffer);
167         int32_t (*mipi_dcs_write)(uint8_t *param, uint16_t param_length);
168         int32_t (*mipi_dcs_read)(uint8_t command, uint8_t bytes_to_read, uint8_t *read_buffer);
169 };
170
171 struct i2c_info{
172         uint32_t i2c_addr;
173         struct ops_i2c *ops;
174 };
175
176 struct spi_info{
177         struct ops_spi *ops;
178 };
179
180
181 struct info_mipi {
182         uint16_t work_mode; /*command_mode, video_mode*/
183         uint16_t video_bus_width;
184         uint32_t lan_number;
185         uint32_t phy_feq;
186         uint16_t h_sync_pol;
187         uint16_t v_sync_pol;
188         uint16_t de_pol;
189         uint16_t te_pol; /*only for command_mode*/
190         uint16_t color_mode_pol;
191         uint16_t shut_down_pol;
192         struct timing_rgb *timing;
193         struct ops_mipi *ops;
194 };
195
196 struct info_rgb {
197         uint16_t cmd_bus_mode; /*spi, i2c*/
198         uint16_t video_bus_width;
199         uint16_t h_sync_pol;
200         uint16_t v_sync_pol;
201         uint16_t de_pol;
202         struct timing_rgb *timing;
203         union{
204                 struct i2c_info *i2c;
205                 struct spi_info *spi;
206         }bus_info;
207 };
208
209 struct info_mcu {
210         uint16_t bus_mode; /*8080, 6800*/
211         uint16_t bus_width;
212         uint16_t bpp;
213         uint16_t te_pol;
214         uint32_t te_sync_delay;
215         struct timing_mcu *timing;
216         struct ops_mcu *ops;
217 };
218
219
220 /* LCD abstraction */
221 struct panel_spec {
222         uint16_t width;
223         uint16_t height;
224         uint32_t fps;
225         uint16_t type; /*mcu, rgb, mipi*/
226         uint16_t direction;
227         union {
228                 struct info_mcu *mcu;
229                 struct info_rgb *rgb;
230                 struct info_mipi * mipi;
231         } info;
232         struct panel_operations *ops;
233 };
234
235 struct panel_cfg {
236         uint32_t lcd_id;
237         struct panel_spec *panel;
238 };
239
240 extern void LCD_SetBackLightBrightness( unsigned long  value);
241 #endif
242