1 /* drivers/video/sc8810/sc8810_lcd.h
3 * Spreadtrum LCD abstraction
5 * Copyright (C) 2010 Spreadtrum.com
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.
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.
20 #include <linux/types.h>
23 #define LCD_DelayMS(ms) udelay(1000*(ms))
26 #define SPRDFB_I2C_WRITE_DELAY 0xffff
30 #define LCD_MODE_MCU 0
31 #define LCD_MODE_RGB 1
32 #define LCD_MODE_DSI 2
35 #define LCD_BUS_8080 0
36 #define LCD_BUS_6800 1
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
48 #define PIN_PWM0_MOD_VALUE 0x20
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)
58 #define LCD_PWM_PRESCALE_VALUE 0x01
59 #define LCD_PWM_MOD_VALUE 0xFF
60 #define PWM_REG_MSK_VALUE 0xFFFF
62 #define LCD_PWM0_EN BIT_8
65 SPRDFB_PANEL_TYPE_MCU = 0,
66 SPRDFB_PANEL_TYPE_RGB,
67 SPRDFB_PANEL_TYPE_MIPI,
68 SPRDFB_PANEL_TYPE_LIMIT
72 SPRDFB_POLARITY_POS = 0,
78 SPRDFB_RGB_BUS_TYPE_I2C = 0,
79 SPRDFB_RGB_BUS_TYPE_SPI,
80 SPRDFB_RGB_BUG_TYPE_LIMIT
84 SPRDFB_MIPI_MODE_CMD = 0,
85 SPRDFB_MIPI_MODE_VIDEO,
86 SPRDFB_MIPI_MODE_LIMIT
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);
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,
117 int32_t (*panel_set_direction)(struct panel_spec *self, uint16_t direction);
118 uint32_t (*panel_readid)(struct panel_spec *self);
121 /* MCU LCD specific properties */
131 /* RGB LCD specific properties */
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);
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);
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);
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);
182 uint16_t work_mode; /*command_mode, video_mode*/
183 uint16_t video_bus_width;
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;
197 uint16_t cmd_bus_mode; /*spi, i2c*/
198 uint16_t video_bus_width;
202 struct timing_rgb *timing;
204 struct i2c_info *i2c;
205 struct spi_info *spi;
210 uint16_t bus_mode; /*8080, 6800*/
214 uint32_t te_sync_delay;
215 struct timing_mcu *timing;
220 /* LCD abstraction */
225 uint16_t type; /*mcu, rgb, mipi*/
228 struct info_mcu *mcu;
229 struct info_rgb *rgb;
230 struct info_mipi * mipi;
232 struct panel_operations *ops;
237 struct panel_spec *panel;
240 extern void LCD_SetBackLightBrightness( unsigned long value);