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