2 * Copyright (C) 2013 ROCKCHIP, Inc.
3 * drivers/video/display/transmitter/mipi_dsi.c
4 * author: hhb@rock-chips.com
5 * create date: 2013-01-17
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 #ifndef CONFIG_MIPI_DSI
18 #ifdef CONFIG_RK_3288_DSI_UBOOT
25 #include <asm/arch/rkplat.h>
29 #include <linux/module.h>
30 #include <linux/init.h>
31 /* #include <asm/system.h> */
33 #include <linux/delay.h>
34 #include <linux/rk_fb.h>
35 #include <linux/rk_screen.h>
36 #include <linux/ktime.h>
41 #define MAX_DSI_CHIPS 5
46 *v1.0 : this driver is a top level architecture of mipi dsi driver;
47 *v1.1 : add struct mipi_dsi_screen
48 *v1.2 : add id argument to identify different dsi
49 *v1.3 : fix send commad's methods
51 #define MIPI_DSI_VERSION_AND_TIME "mipi_dsi v1.3 2014-04-17"
52 #ifdef CONFIG_RK_3288_DSI_UBOOT
53 #define printk(x...) printf(x)
57 static struct mipi_dsi_ops *dsi_ops[MAX_DSI_CHIPS] = {NULL};
58 //static struct mipi_dsi_ops *cur_dsi_ops;
60 int register_dsi_ops(unsigned int id, struct mipi_dsi_ops *ops) {
63 if(id > (MAX_DSI_CHIPS - 1))
69 #ifdef CONFIG_MIPI_DSI
70 EXPORT_SYMBOL(register_dsi_ops);
73 int del_dsi_ops(struct mipi_dsi_ops *ops) {
77 for(i = 0; i < MAX_DSI_CHIPS; i++) {
78 if(dsi_ops[i] == ops) {
84 if(i == MAX_DSI_CHIPS) {
85 printk("dsi ops not found\n");
90 #ifdef CONFIG_MIPI_DSI
91 EXPORT_SYMBOL(del_dsi_ops);
94 int dsi_probe_current_chip(unsigned int id) {
95 struct mipi_dsi_ops *ops = NULL;
97 if(id > (MAX_DSI_CHIPS - 1))
104 id = ops->get_id(ops->dsi);
108 #ifdef CONFIG_MIPI_DSI
109 EXPORT_SYMBOL(dsi_probe_current_chip);
111 int dsi_power_up(unsigned int id) {
113 struct mipi_dsi_ops *ops = NULL;
115 if(id > (MAX_DSI_CHIPS - 1))
123 ops->power_up(ops->dsi);
126 #ifdef CONFIG_MIPI_DSI
127 EXPORT_SYMBOL(dsi_power_up);
130 int dsi_power_off(unsigned int id) {
132 struct mipi_dsi_ops *ops = NULL;
134 if(id > (MAX_DSI_CHIPS - 1))
143 ops->power_down(ops->dsi);
147 #ifdef CONFIG_MIPI_DSI
148 EXPORT_SYMBOL(dsi_power_off);
150 int dsi_set_regs(unsigned int id, void *array, u32 n) {
152 struct mipi_dsi_ops *ops = NULL;
154 if(id > (MAX_DSI_CHIPS - 1))
162 if(ops->dsi_set_regs)
163 ops->dsi_set_regs(ops->dsi, array, n);
167 #ifdef CONFIG_MIPI_DSI
168 EXPORT_SYMBOL(dsi_set_regs);
170 int dsi_init(unsigned int id, u32 n) {
172 struct mipi_dsi_ops *ops = NULL;
174 if(id > (MAX_DSI_CHIPS - 1))
183 ops->dsi_init(ops->dsi, n);
187 #ifdef CONFIG_MIPI_DSI
188 EXPORT_SYMBOL(dsi_init);
190 int dsi_enable_video_mode(unsigned int id, u32 enable) {
192 struct mipi_dsi_ops *ops = NULL;
194 if(id > (MAX_DSI_CHIPS - 1))
202 if(ops->dsi_enable_video_mode)
203 ops->dsi_enable_video_mode(ops->dsi, enable);
208 #ifdef CONFIG_MIPI_DSI
209 EXPORT_SYMBOL(dsi_enable_video_mode);
211 int dsi_enable_command_mode(unsigned int id, u32 enable) {
213 struct mipi_dsi_ops *ops = NULL;
215 if(id > (MAX_DSI_CHIPS - 1))
223 if(ops->dsi_enable_command_mode)
224 ops->dsi_enable_command_mode(ops->dsi, enable);
229 #ifdef CONFIG_MIPI_DSI
230 EXPORT_SYMBOL(dsi_enable_command_mode);
232 int dsi_enable_hs_clk(unsigned int id, u32 enable) {
234 struct mipi_dsi_ops *ops = NULL;
236 if(id > (MAX_DSI_CHIPS - 1))
244 if(ops->dsi_enable_hs_clk)
245 ops->dsi_enable_hs_clk(ops->dsi, enable);
250 #ifdef CONFIG_MIPI_DSI
251 EXPORT_SYMBOL(dsi_enable_hs_clk);
253 int dsi_is_active(unsigned int id) {
255 struct mipi_dsi_ops *ops = NULL;
257 if(id > (MAX_DSI_CHIPS - 1))
265 if(ops->dsi_is_active)
266 return ops->dsi_is_active(ops->dsi);
270 #ifdef CONFIG_MIPI_DSI
271 EXPORT_SYMBOL(dsi_is_active);
273 int dsi_is_enable(unsigned int id, u32 enable){
275 struct mipi_dsi_ops *ops = NULL;
277 if(id > (MAX_DSI_CHIPS - 1))
285 if(ops->dsi_is_enable)
286 ops->dsi_is_enable(ops->dsi, enable);
291 #ifdef CONFIG_MIPI_DSI
292 EXPORT_SYMBOL(dsi_is_enable);
294 int dsi_send_dcs_packet(unsigned int id, unsigned char *packet, u32 n) {
296 struct mipi_dsi_ops *ops = NULL;
298 //printk("dsi_send_dcs_packet-------id=%d\n",id);
299 if(id > (MAX_DSI_CHIPS - 1))
307 if(ops->dsi_send_dcs_packet)
308 ops->dsi_send_dcs_packet(ops->dsi, packet, n);
311 #ifdef CONFIG_MIPI_DSI
312 EXPORT_SYMBOL(dsi_send_dcs_packet);
315 int dsi_read_dcs_packet(unsigned int id, unsigned char *packet, u32 n) {
317 struct mipi_dsi_ops *ops = NULL;
319 if(id > (MAX_DSI_CHIPS - 1))
327 if(ops->dsi_read_dcs_packet)
328 ops->dsi_read_dcs_packet(ops->dsi, packet, n);
331 #ifdef CONFIG_MIPI_DSI
332 EXPORT_SYMBOL(dsi_read_dcs_packet);
335 int dsi_send_packet(unsigned int id, unsigned char *packet, u32 n) {
337 struct mipi_dsi_ops *ops = NULL;
339 if(id > (MAX_DSI_CHIPS - 1))
347 if(ops->dsi_send_packet)
348 ops->dsi_send_packet(ops->dsi, packet, n);
352 #ifdef CONFIG_MIPI_DSI
353 EXPORT_SYMBOL(dsi_send_packet);