Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 1 | /* |
| 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 | |
| 37 | int mipi_dsi_phy_init(struct mipi_dsi_panel_config *pinfo){ |
| 38 | struct mipi_dsi_phy_ctrl *pd; |
| 39 | uint32_t i, off = 0; |
| 40 | |
| 41 | writel(0x00000001, DSI_PHY_SW_RESET); |
| 42 | mdelay(50); |
| 43 | writel(0x00000000, DSI_PHY_SW_RESET); |
| 44 | |
| 45 | pd = (pinfo->dsi_phy_config); |
| 46 | |
| 47 | off = 0x02cc; /* regulator ctrl 0 */ |
| 48 | for (i = 0; i < 4; i++) { |
| 49 | writel(pd->strength[i], MIPI_DSI_BASE + off); |
| 50 | off += 4; |
| 51 | } |
| 52 | |
| 53 | off = 0x0260; /* phy timig ctrl 0 */ |
| 54 | for (i = 0; i < 11; i++) { |
| 55 | writel(pd->timing[i], MIPI_DSI_BASE + off); |
| 56 | off += 4; |
| 57 | } |
| 58 | writel(0x202f, DSI_CLKOUT_TIMING_CTRL); |
| 59 | |
| 60 | off = 0x0290; /* ctrl 0 */ |
| 61 | for (i = 0; i < 4; i++) { |
| 62 | writel(pd->ctrl[i], MIPI_DSI_BASE + off); |
| 63 | off += 4; |
| 64 | } |
| 65 | |
| 66 | off = 0x02a0; /* strength 0 */ |
| 67 | for (i = 0; i < 4; i++) { |
| 68 | writel(pd->strength[i], MIPI_DSI_BASE + off); |
| 69 | off += 4; |
| 70 | } |
| 71 | |
| 72 | /* calibration ctrl */ |
| 73 | writel(0x67, MIPI_DSI_BASE + 0x100); |
| 74 | |
| 75 | /* pll ctrl 0 */ |
| 76 | writel(pd->pll[0], MIPI_DSI_BASE + 0x200); |
| 77 | writel((pd->pll[0] | 0x01), MIPI_DSI_BASE + 0x200); |
| 78 | |
| 79 | /* lane swap ctrl */ |
| 80 | writel(0x1, MIPI_DSI_BASE + 0xac); |
| 81 | return 0; |
| 82 | } |
| 83 | |
| 84 | void config_renesas_dsi_video_mode(void) |
| 85 | { |
| 86 | |
| 87 | unsigned char dst_format = 3; /* RGB888 */ |
| 88 | unsigned char traffic_mode = 2; /* non burst mode with sync start events */ |
| 89 | unsigned char lane_en = 3; /* 3 Lanes -- Enables Data Lane0, 1, 2 */ |
| 90 | unsigned long low_pwr_stop_mode = 1; |
| 91 | unsigned char eof_bllp_pwr = 0x9; /* Needed or else will have blank line at top of display */ |
| 92 | unsigned char interleav = 0; |
| 93 | |
Aparna Mallavarapu | 45869c3 | 2011-08-05 13:22:35 +0530 | [diff] [blame^] | 94 | unsigned short display_wd = REN_MIPI_FB_WIDTH; |
| 95 | unsigned short display_ht = REN_MIPI_FB_HEIGHT; |
| 96 | unsigned short image_wd = REN_MIPI_FB_WIDTH; |
| 97 | unsigned short image_ht = REN_MIPI_FB_HEIGHT; |
| 98 | unsigned short hsync_porch_fp = MIPI_HSYNC_FRONT_PORCH_DCLK; |
| 99 | unsigned short hsync_porch_bp = MIPI_HSYNC_BACK_PORCH_DCLK; |
| 100 | unsigned short vsync_porch_fp = MIPI_VSYNC_FRONT_PORCH_LINES; |
| 101 | unsigned short vsync_porch_bp = MIPI_VSYNC_BACK_PORCH_LINES; |
| 102 | unsigned short hsync_width = MIPI_HSYNC_PULSE_WIDTH; |
| 103 | unsigned short vsync_width = MIPI_VSYNC_PULSE_WIDTH; |
| 104 | |
| 105 | |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 106 | dprintf(SPEW, "DSI_Video_Mode - Dst Format: RGB888\n"); |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 107 | dprintf(SPEW, "Traffic mode: burst mode\n"); |
Aparna Mallavarapu | 45869c3 | 2011-08-05 13:22:35 +0530 | [diff] [blame^] | 108 | if(machine_is_7x25a()) { |
| 109 | dprintf(CRITICAL, "Entered 7x25A in config_renesas_dsi_video_mode\n"); |
| 110 | dprintf(SPEW, "Data Lane: 1 lane\n"); |
| 111 | display_wd = REN_MIPI_FB_WIDTH_HVGA; |
| 112 | display_ht = REN_MIPI_FB_HEIGHT_HVGA; |
| 113 | image_wd = REN_MIPI_FB_WIDTH_HVGA; |
| 114 | image_ht = REN_MIPI_FB_HEIGHT_HVGA; |
| 115 | hsync_porch_fp = MIPI_HSYNC_FRONT_PORCH_DCLK_HVGA; |
| 116 | hsync_porch_bp = MIPI_HSYNC_BACK_PORCH_DCLK_HVGA; |
| 117 | vsync_porch_fp = MIPI_VSYNC_FRONT_PORCH_LINES_HVGA; |
| 118 | vsync_porch_bp = MIPI_VSYNC_BACK_PORCH_LINES_HVGA; |
| 119 | hsync_width = MIPI_HSYNC_PULSE_WIDTH_HVGA; |
| 120 | vsync_width = MIPI_VSYNC_PULSE_WIDTH_HVGA; |
| 121 | lane_en = 1; |
| 122 | } else { |
| 123 | dprintf(SPEW, "Data Lane: 2 lane\n"); |
| 124 | } |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 125 | |
| 126 | writel(0x00000000, MDP_DSI_VIDEO_EN); |
| 127 | |
| 128 | writel(0x00000000, DSI_CLK_CTRL); |
| 129 | writel(0x00000000, DSI_CLK_CTRL); |
| 130 | writel(0x00000000, DSI_CLK_CTRL); |
| 131 | writel(0x00000000, DSI_CLK_CTRL); |
| 132 | writel(0x00000002, DSI_CLK_CTRL); |
| 133 | writel(0x00000006, DSI_CLK_CTRL); |
| 134 | writel(0x0000000e, DSI_CLK_CTRL); |
| 135 | writel(0x0000001e, DSI_CLK_CTRL); |
| 136 | writel(0x0000003e, DSI_CLK_CTRL); |
| 137 | |
| 138 | writel(0, DSI_CTRL); |
| 139 | |
| 140 | writel(0, DSI_ERR_INT_MASK0); |
| 141 | |
| 142 | writel(0x02020202, DSI_INT_CTRL); |
| 143 | |
Aparna Mallavarapu | 45869c3 | 2011-08-05 13:22:35 +0530 | [diff] [blame^] | 144 | writel(((hsync_porch_bp + display_wd)<<16) | hsync_porch_bp, |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 145 | DSI_VIDEO_MODE_ACTIVE_H); |
| 146 | |
Aparna Mallavarapu | 45869c3 | 2011-08-05 13:22:35 +0530 | [diff] [blame^] | 147 | writel(((vsync_porch_bp + display_ht)<<16) | vsync_porch_bp, |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 148 | DSI_VIDEO_MODE_ACTIVE_V); |
| 149 | |
Aparna Mallavarapu | 45869c3 | 2011-08-05 13:22:35 +0530 | [diff] [blame^] | 150 | writel(((display_ht + vsync_porch_fp + vsync_porch_bp)<< 16) | |
| 151 | (display_wd + hsync_porch_fp + hsync_porch_bp ), |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 152 | DSI_VIDEO_MODE_TOTAL ); |
Aparna Mallavarapu | 45869c3 | 2011-08-05 13:22:35 +0530 | [diff] [blame^] | 153 | writel((hsync_width)<<16 | 0, DSI_VIDEO_MODE_HSYNC); |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 154 | |
| 155 | writel(0<<16 | 0, DSI_VIDEO_MODE_VSYNC); |
| 156 | |
Aparna Mallavarapu | 45869c3 | 2011-08-05 13:22:35 +0530 | [diff] [blame^] | 157 | writel(vsync_width<<16 | 0, DSI_VIDEO_MODE_VSYNC_VPOS); |
Aparna Mallavarapu | f712f5e | 2011-08-04 21:11:00 +0530 | [diff] [blame] | 158 | |
| 159 | writel(1, DSI_EOT_PACKET_CTRL); |
| 160 | |
| 161 | writel(0x00000100, DSI_MISR_VIDEO_CTRL); |
| 162 | |
| 163 | writel(1 << 28 | 1 << 24 | 1 << 20 | low_pwr_stop_mode << 16 | eof_bllp_pwr << 12 | traffic_mode << 8 |
| 164 | | dst_format << 4 | 0x0, DSI_VIDEO_MODE_CTRL); |
| 165 | |
| 166 | writel(0x67, DSI_CAL_STRENGTH_CTRL); |
| 167 | writel(0x80006711, DSI_CAL_CTRL); |
| 168 | writel(0x00010100, DSI_MISR_VIDEO_CTRL); |
| 169 | |
| 170 | writel(0x00010100, DSI_INT_CTRL); |
| 171 | writel(0x02010202, DSI_INT_CTRL); |
| 172 | writel(0x02030303, DSI_INT_CTRL); |
| 173 | |
| 174 | writel(interleav << 30 | 0 << 24 | 0 << 20 | lane_en << 4 |
| 175 | | 0x103, DSI_CTRL); |
| 176 | } |