tizen 2.4 release
[kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-tiger / sc8810_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 _SC8810_LCD_H_
18 #define _SC8810_LCD_H_
19
20 #include <linux/types.h>
21 #include <common.h>
22
23 #define LCD_DelayMS(ms)  udelay(1000*(ms))
24
25 #define LCD_REGISTER_TIMING 0
26 #define LCD_GRAM_TIMING     1
27
28 /* LCD mode */
29 #define LCD_MODE_RGB 0
30 #define LCD_MODE_MCU 1
31
32 /* bus mode */
33 #define LCD_BUS_8080 0
34 #define LCD_BUS_6800 1
35 #define LCD_BUS_SPI  2
36
37 /* lcd directions */
38 #define LCD_DIRECT_NORMAL  0
39 #define LCD_DIRECT_ROT_90  1
40 #define LCD_DIRECT_ROT_180 2
41 #define LCD_DIRECT_ROT_270 3
42 #define LCD_DIRECT_MIR_H   4
43 #define LCD_DIRECT_MIR_V   5
44 #define LCD_DIRECT_MIR_HV  6
45
46 #define PIN_PWM0_MOD_VALUE 0x20
47
48 #define SPRD_PWM_BASE                   0x88000000
49 #define SPRD_PWM_REG(off)               (SPRD_PWM_BASE + (off))
50 #define SPRD_PWM0_PRESCALE      SPRD_PWM_REG(0x0000)
51 #define SPRD_PWM0_CNT                   SPRD_PWM_REG(0x0004)
52 #define SPRD_PWM0_TONE_DIV      SPRD_PWM_REG(0x0008)
53 #define SPRD_PWM0_PAT_LOW       SPRD_PWM_REG(0x000C)
54 #define SPRD_PWM0_PAT_HIG       SPRD_PWM_REG(0x0010)
55
56 #define LCD_PWM_PRESCALE_VALUE  0x01
57 #define LCD_PWM_MOD_VALUE               0xFF
58 #define PWM_REG_MSK_VALUE                       0xFFFF
59
60 #define LCD_PWM0_EN BIT_8
61
62 struct lcd_spec;
63
64 /* LCD operations */
65 struct lcd_operations {
66         int32_t (*lcd_init)(struct lcd_spec *self);
67         int32_t (*lcd_close)(struct lcd_spec *self);
68         int32_t (*lcd_reset)(struct lcd_spec *self);
69         int32_t (*lcd_enter_sleep)(struct lcd_spec *self, uint8_t is_sleep);
70         int32_t (*lcd_set_contrast)(struct lcd_spec *self, uint16_t contrast);
71         int32_t (*lcd_set_brightness)(struct lcd_spec *self,
72                                 uint16_t brightness);
73         int32_t (*lcd_set_window)(struct lcd_spec *self,
74                                 uint16_t left, uint16_t top,
75                                 uint16_t right, uint16_t bottom);
76         int32_t (*lcd_invalidate)(struct lcd_spec *self);
77         int32_t (*lcd_invalidate_rect)(struct lcd_spec *self,
78                                 uint16_t left, uint16_t top,
79                                 uint16_t right, uint16_t bottom);
80         int32_t (*lcd_rotate_invalidate_rect)(struct lcd_spec *self,
81                                 uint16_t left, uint16_t top,
82                                 uint16_t right, uint16_t bottom,
83                                 uint16_t angle);
84         int32_t (*lcd_set_direction)(struct lcd_spec *self, uint16_t direction);
85         uint32_t (*lcd_readid)(struct lcd_spec *self);
86 };
87
88 /* RGB LCD specific properties */
89 struct timing_rgb {
90         uint16_t bfw;
91         uint16_t efw;
92         uint16_t vsw;
93         uint16_t blw;
94         uint16_t elw;
95         uint16_t hsw;
96 };
97
98 struct ops_rgb {
99         int32_t (*send_cmd)(uint32_t cmd);
100         int32_t (*send_cmd_data)(uint32_t cmd, uint32_t data);
101 };
102
103 struct info_rgb {
104         /* under construction... */
105         struct timing_rgb timing;
106         struct ops_rgb *ops;
107 };
108
109 /* MCU LCD specific properties */
110 struct timing_mcu {
111         uint16_t rcss;
112         uint16_t rlpw;
113         uint16_t rhpw;
114         uint16_t wcss;
115         uint16_t wlpw;
116         uint16_t whpw;
117 };
118
119 typedef int32_t (*Send_cmd)(uint32_t data);
120 typedef int32_t (*Send_data)(uint32_t data);
121 typedef int32_t (*Send_cmd_data)(uint32_t cmd, uint32_t data);
122 typedef uint32_t (*Read_data)(void);
123
124 struct ops_mcu {
125         int32_t (*send_cmd)(uint32_t cmd);
126         int32_t (*send_cmd_data)(uint32_t cmd, uint32_t data);
127         int32_t (*send_data)(uint32_t data);
128         uint32_t (*read_data)(void);
129 };
130
131 struct info_mcu {
132         uint16_t bus_mode;
133         uint16_t bus_width;
134         struct timing_mcu *timing;
135         struct ops_mcu *ops;
136 };
137
138 /* LCD abstraction */
139 struct lcd_spec {
140         uint16_t width;
141         uint16_t height;
142         uint16_t mode;
143         uint16_t direction;
144         union {
145                 struct info_rgb *rgb;
146                 struct info_mcu *mcu;
147         } info;
148         struct lcd_operations *ops;
149 };
150
151 extern void LCD_SetBackLightBrightness( unsigned long  value);
152 #endif
153