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) {
96 struct mipi_dsi_ops *ops = NULL;
98 if(id > (MAX_DSI_CHIPS - 1))
105 id = ops->get_id(ops->dsi);
107 printk("load mipi dsi chip:%s id:%08x\n", ops->name, ops->id);
108 printk("%s\n", MIPI_DSI_VERSION_AND_TIME);
110 printk("mipi dsi chip is not found, read id:%08x, but %08x is correct\n", id, ops->id);
116 #ifdef CONFIG_MIPI_DSI
117 EXPORT_SYMBOL(dsi_probe_current_chip);
119 int dsi_power_up(unsigned int id) {
121 struct mipi_dsi_ops *ops = NULL;
123 if(id > (MAX_DSI_CHIPS - 1))
131 ops->power_up(ops->dsi);
134 #ifdef CONFIG_MIPI_DSI
135 EXPORT_SYMBOL(dsi_power_up);
138 int dsi_power_off(unsigned int id) {
140 struct mipi_dsi_ops *ops = NULL;
142 if(id > (MAX_DSI_CHIPS - 1))
151 ops->power_down(ops->dsi);
155 #ifdef CONFIG_MIPI_DSI
156 EXPORT_SYMBOL(dsi_power_off);
158 int dsi_set_regs(unsigned int id, void *array, u32 n) {
160 struct mipi_dsi_ops *ops = NULL;
162 if(id > (MAX_DSI_CHIPS - 1))
170 if(ops->dsi_set_regs)
171 ops->dsi_set_regs(ops->dsi, array, n);
175 #ifdef CONFIG_MIPI_DSI
176 EXPORT_SYMBOL(dsi_set_regs);
178 int dsi_init(unsigned int id, u32 n) {
180 struct mipi_dsi_ops *ops = NULL;
182 if(id > (MAX_DSI_CHIPS - 1))
191 ops->dsi_init(ops->dsi, n);
195 #ifdef CONFIG_MIPI_DSI
196 EXPORT_SYMBOL(dsi_init);
198 int dsi_enable_video_mode(unsigned int id, u32 enable) {
200 struct mipi_dsi_ops *ops = NULL;
202 if(id > (MAX_DSI_CHIPS - 1))
210 if(ops->dsi_enable_video_mode)
211 ops->dsi_enable_video_mode(ops->dsi, enable);
216 #ifdef CONFIG_MIPI_DSI
217 EXPORT_SYMBOL(dsi_enable_video_mode);
219 int dsi_enable_command_mode(unsigned int id, u32 enable) {
221 struct mipi_dsi_ops *ops = NULL;
223 if(id > (MAX_DSI_CHIPS - 1))
231 if(ops->dsi_enable_command_mode)
232 ops->dsi_enable_command_mode(ops->dsi, enable);
237 #ifdef CONFIG_MIPI_DSI
238 EXPORT_SYMBOL(dsi_enable_command_mode);
240 int dsi_enable_hs_clk(unsigned int id, u32 enable) {
242 struct mipi_dsi_ops *ops = NULL;
244 if(id > (MAX_DSI_CHIPS - 1))
252 if(ops->dsi_enable_hs_clk)
253 ops->dsi_enable_hs_clk(ops->dsi, enable);
258 #ifdef CONFIG_MIPI_DSI
259 EXPORT_SYMBOL(dsi_enable_hs_clk);
261 int dsi_is_active(unsigned int id) {
263 struct mipi_dsi_ops *ops = NULL;
265 if(id > (MAX_DSI_CHIPS - 1))
273 if(ops->dsi_is_active)
274 return ops->dsi_is_active(ops->dsi);
278 #ifdef CONFIG_MIPI_DSI
279 EXPORT_SYMBOL(dsi_is_active);
281 int dsi_is_enable(unsigned int id, u32 enable){
283 struct mipi_dsi_ops *ops = NULL;
285 if(id > (MAX_DSI_CHIPS - 1))
293 if(ops->dsi_is_enable)
294 ops->dsi_is_enable(ops->dsi, enable);
299 #ifdef CONFIG_MIPI_DSI
300 EXPORT_SYMBOL(dsi_is_enable);
302 int dsi_send_dcs_packet(unsigned int id, unsigned char *packet, u32 n) {
304 struct mipi_dsi_ops *ops = NULL;
306 //printk("dsi_send_dcs_packet-------id=%d\n",id);
307 if(id > (MAX_DSI_CHIPS - 1))
315 if(ops->dsi_send_dcs_packet)
316 ops->dsi_send_dcs_packet(ops->dsi, packet, n);
319 #ifdef CONFIG_MIPI_DSI
320 EXPORT_SYMBOL(dsi_send_dcs_packet);
323 int dsi_read_dcs_packet(unsigned int id, unsigned char *packet, u32 n) {
325 struct mipi_dsi_ops *ops = NULL;
327 if(id > (MAX_DSI_CHIPS - 1))
335 if(ops->dsi_read_dcs_packet)
336 ops->dsi_read_dcs_packet(ops->dsi, packet, n);
339 #ifdef CONFIG_MIPI_DSI
340 EXPORT_SYMBOL(dsi_read_dcs_packet);
343 int dsi_send_packet(unsigned int id, unsigned char *packet, u32 n) {
345 struct mipi_dsi_ops *ops = NULL;
347 if(id > (MAX_DSI_CHIPS - 1))
355 if(ops->dsi_send_packet)
356 ops->dsi_send_packet(ops->dsi, packet, n);
360 #ifdef CONFIG_MIPI_DSI
361 EXPORT_SYMBOL(dsi_send_packet);