blob: f5d336cc7cdc705ac55aa7531d0ad15ac77bcc83 [file] [log] [blame]
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +05301/*
2 * * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials provided
12 * with the distribution.
13 * * Neither the name of Code Aurora Forum, Inc. nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29#include <debug.h>
30#include <reg.h>
31#include <mdp3.h>
32#include <mipi_dsi.h>
33#include <platform/iomap.h>
34#include <platform/clock.h>
35#include <target/display.h>
36
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +053037void config_renesas_dsi_video_mode(void)
38{
39
Ajay Dudanib01e5062011-12-03 23:23:42 -080040 unsigned char dst_format = 3; /* RGB888 */
41 unsigned char traffic_mode = 2; /* non burst mode with sync start events */
42 unsigned char lane_en = 3; /* 3 Lanes -- Enables Data Lane0, 1, 2 */
43 unsigned long low_pwr_stop_mode = 1;
44 unsigned char eof_bllp_pwr = 0x9; /* Needed or else will have blank line at top of display */
45 unsigned char interleav = 0;
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +053046
Ajay Dudanib01e5062011-12-03 23:23:42 -080047 unsigned short display_wd = REN_MIPI_FB_WIDTH;
48 unsigned short display_ht = REN_MIPI_FB_HEIGHT;
49 unsigned short image_wd = REN_MIPI_FB_WIDTH;
50 unsigned short image_ht = REN_MIPI_FB_HEIGHT;
51 unsigned short hsync_porch_fp = MIPI_HSYNC_FRONT_PORCH_DCLK;
52 unsigned short hsync_porch_bp = MIPI_HSYNC_BACK_PORCH_DCLK;
53 unsigned short vsync_porch_fp = MIPI_VSYNC_FRONT_PORCH_LINES;
54 unsigned short vsync_porch_bp = MIPI_VSYNC_BACK_PORCH_LINES;
55 unsigned short hsync_width = MIPI_HSYNC_PULSE_WIDTH;
56 unsigned short vsync_width = MIPI_VSYNC_PULSE_WIDTH;
Aparna Mallavarapu45869c32011-08-05 13:22:35 +053057
Ajay Dudanib01e5062011-12-03 23:23:42 -080058 dprintf(SPEW, "DSI_Video_Mode - Dst Format: RGB888\n");
59 dprintf(SPEW, "Traffic mode: burst mode\n");
60 if (machine_is_7x25a()) {
61 dprintf(CRITICAL,
62 "Entered 7x25A in config_renesas_dsi_video_mode\n");
63 dprintf(SPEW, "Data Lane: 1 lane\n");
64 display_wd = REN_MIPI_FB_WIDTH_HVGA;
65 display_ht = REN_MIPI_FB_HEIGHT_HVGA;
66 image_wd = REN_MIPI_FB_WIDTH_HVGA;
67 image_ht = REN_MIPI_FB_HEIGHT_HVGA;
68 hsync_porch_fp = MIPI_HSYNC_FRONT_PORCH_DCLK_HVGA;
69 hsync_porch_bp = MIPI_HSYNC_BACK_PORCH_DCLK_HVGA;
70 vsync_porch_fp = MIPI_VSYNC_FRONT_PORCH_LINES_HVGA;
71 vsync_porch_bp = MIPI_VSYNC_BACK_PORCH_LINES_HVGA;
72 hsync_width = MIPI_HSYNC_PULSE_WIDTH_HVGA;
73 vsync_width = MIPI_VSYNC_PULSE_WIDTH_HVGA;
74 lane_en = 1;
75 } else {
76 dprintf(SPEW, "Data Lane: 2 lane\n");
77 }
Aparna Mallavarapu45869c32011-08-05 13:22:35 +053078
Ajay Dudanib01e5062011-12-03 23:23:42 -080079 writel(0x00000000, MDP_DSI_VIDEO_EN);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +053080
Ajay Dudanib01e5062011-12-03 23:23:42 -080081 writel(0x00000000, DSI_CLK_CTRL);
82 writel(0x00000000, DSI_CLK_CTRL);
83 writel(0x00000000, DSI_CLK_CTRL);
84 writel(0x00000000, DSI_CLK_CTRL);
85 writel(0x00000002, DSI_CLK_CTRL);
86 writel(0x00000006, DSI_CLK_CTRL);
87 writel(0x0000000e, DSI_CLK_CTRL);
88 writel(0x0000001e, DSI_CLK_CTRL);
89 writel(0x0000003e, DSI_CLK_CTRL);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +053090
Ajay Dudanib01e5062011-12-03 23:23:42 -080091 writel(0, DSI_CTRL);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +053092
Ajay Dudanib01e5062011-12-03 23:23:42 -080093 writel(0, DSI_ERR_INT_MASK0);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +053094
Ajay Dudanib01e5062011-12-03 23:23:42 -080095 writel(0x02020202, DSI_INT_CTRL);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +053096
Ajay Dudanib01e5062011-12-03 23:23:42 -080097 writel(((hsync_porch_bp + display_wd) << 16) | hsync_porch_bp,
98 DSI_VIDEO_MODE_ACTIVE_H);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +053099
Ajay Dudanib01e5062011-12-03 23:23:42 -0800100 writel(((vsync_porch_bp + display_ht) << 16) | vsync_porch_bp,
101 DSI_VIDEO_MODE_ACTIVE_V);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530102
Ajay Dudanib01e5062011-12-03 23:23:42 -0800103 writel(((display_ht + vsync_porch_fp + vsync_porch_bp) << 16) |
104 (display_wd + hsync_porch_fp + hsync_porch_bp),
105 DSI_VIDEO_MODE_TOTAL);
106 writel((hsync_width) << 16 | 0, DSI_VIDEO_MODE_HSYNC);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530107
Ajay Dudanib01e5062011-12-03 23:23:42 -0800108 writel(0 << 16 | 0, DSI_VIDEO_MODE_VSYNC);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530109
Ajay Dudanib01e5062011-12-03 23:23:42 -0800110 writel(vsync_width << 16 | 0, DSI_VIDEO_MODE_VSYNC_VPOS);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530111
Ajay Dudanib01e5062011-12-03 23:23:42 -0800112 writel(1, DSI_EOT_PACKET_CTRL);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530113
Ajay Dudanib01e5062011-12-03 23:23:42 -0800114 writel(0x00000100, DSI_MISR_VIDEO_CTRL);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530115
Ajay Dudanib01e5062011-12-03 23:23:42 -0800116 writel(1 << 28 | 1 << 24 | 1 << 20 | low_pwr_stop_mode << 16 |
117 eof_bllp_pwr << 12 | traffic_mode << 8 | dst_format << 4 | 0x0,
118 DSI_VIDEO_MODE_CTRL);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530119
Ajay Dudanib01e5062011-12-03 23:23:42 -0800120 writel(0x67, DSI_CAL_STRENGTH_CTRL);
121 writel(0x80006711, DSI_CAL_CTRL);
122 writel(0x00010100, DSI_MISR_VIDEO_CTRL);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530123
Ajay Dudanib01e5062011-12-03 23:23:42 -0800124 writel(0x00010100, DSI_INT_CTRL);
125 writel(0x02010202, DSI_INT_CTRL);
126 writel(0x02030303, DSI_INT_CTRL);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530127
Ajay Dudanib01e5062011-12-03 23:23:42 -0800128 writel(interleav << 30 | 0 << 24 | 0 << 20 | lane_en << 4
129 | 0x103, DSI_CTRL);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530130}