Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 1 | /* Copyright (c) 2013, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * Redistribution and use in source and binary forms, with or without |
| 4 | * modification, are permitted provided that the following conditions |
| 5 | * are met: |
| 6 | * * Redistributions of source code must retain the above copyright |
| 7 | * notice, this list of conditions and the following disclaimer. |
| 8 | * * Redistributions in binary form must reproduce the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer in |
| 10 | * the documentation and/or other materials provided with the |
| 11 | * distribution. |
| 12 | * * Neither the name of The Linux Foundation nor the names of its |
| 13 | * contributors may be used to endorse or promote products derived |
| 14 | * from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 23 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 24 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 25 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 26 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 27 | * SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #include <debug.h> |
| 31 | #include <smem.h> |
| 32 | #include <msm_panel.h> |
| 33 | #include <pm8x41.h> |
| 34 | #include <pm8x41_wled.h> |
| 35 | #include <board.h> |
| 36 | #include <mdp5.h> |
| 37 | #include <platform/gpio.h> |
| 38 | #include <platform/iomap.h> |
| 39 | #include <target/display.h> |
| 40 | |
| 41 | static struct msm_fb_panel_data panel; |
| 42 | static uint8_t display_enable; |
| 43 | |
| 44 | extern int msm_display_init(struct msm_fb_panel_data *pdata); |
| 45 | extern int msm_display_off(); |
| 46 | extern int mdss_dsi_uniphy_pll_config(uint32_t ctl_base); |
| 47 | |
| 48 | static struct pm8x41_wled_data wled_ctrl = { |
| 49 | .mod_scheme = 0xC3, |
| 50 | .led1_brightness = (0x0F << 8) | 0xEF, |
| 51 | .led2_brightness = (0x0F << 8) | 0xEF, |
| 52 | .led3_brightness = (0x0F << 8) | 0xEF, |
| 53 | .max_duty_cycle = 0x01, |
| 54 | .ovp = 0x2, |
| 55 | .full_current_scale = 0x19 |
| 56 | }; |
| 57 | |
| 58 | static int msm8226_backlight_on() |
| 59 | { |
| 60 | pm8x41_wled_config(&wled_ctrl); |
| 61 | pm8x41_wled_sink_control(1); |
| 62 | pm8x41_wled_iled_sync_control(1); |
| 63 | pm8x41_wled_enable(1); |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | static int msm8226_mdss_dsi_panel_clock(uint8_t enable) |
| 69 | { |
| 70 | dprintf(SPEW, "msm8226_mdss_dsi_panel_clock, enable = %d\n", enable); |
| 71 | |
| 72 | if (enable) { |
| 73 | mdp_gdsc_ctrl(enable); |
| 74 | mdp_clock_init(); |
| 75 | mdss_dsi_uniphy_pll_config(MIPI_DSI0_BASE); |
| 76 | mmss_clock_init(0x100); |
| 77 | } else if(!target_cont_splash_screen()) { |
| 78 | /* Add here for non-continuous splash */ |
| 79 | /* FIXME:Need to disable the clocks. |
| 80 | * For now leave the clocks enabled until the kernel |
| 81 | * hang issue gets resolved |
| 82 | */ |
| 83 | } |
| 84 | |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | static void msm8226_mdss_mipi_panel_reset(int enable) |
| 89 | { |
| 90 | dprintf(SPEW, "msm8226_mdss_mipi_panel_reset, enable = %d\n", enable); |
| 91 | |
| 92 | if (enable) { |
| 93 | gpio_tlmm_config(25, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE); |
| 94 | gpio_set_dir(25, 2); //output |
| 95 | |
| 96 | /* reset */ |
| 97 | gpio_set_value(25, 1); |
| 98 | mdelay(20); |
| 99 | gpio_set_value(25, 0); |
| 100 | mdelay(20); |
| 101 | gpio_set_value(25, 1); |
| 102 | mdelay(20); |
| 103 | } else if(!target_cont_splash_screen()) { |
| 104 | gpio_set_value(25, 0); |
| 105 | } |
| 106 | |
| 107 | return; |
| 108 | } |
| 109 | |
| 110 | static int msm8226_mipi_panel_power(uint8_t enable) |
| 111 | { |
| 112 | struct pm8x41_ldo ldo4 = LDO(PM8x41_LDO4, NLDO_TYPE); |
| 113 | struct pm8x41_ldo ldo8 = LDO(PM8x41_LDO8, PLDO_TYPE); |
| 114 | struct pm8x41_ldo ldo15 = LDO(PM8x41_LDO15, PLDO_TYPE); |
| 115 | |
| 116 | dprintf(SPEW, "msm8226_mipi_panel_power, enable = %d\n", enable); |
| 117 | |
| 118 | if (enable) { |
| 119 | /* backlight */ |
| 120 | msm8226_backlight_on(); |
| 121 | |
| 122 | pm8x41_ldo_set_voltage(&ldo15, 2800000); |
| 123 | pm8x41_ldo_control(&ldo15, enable); |
| 124 | |
| 125 | pm8x41_ldo_set_voltage(&ldo8, 1800000); |
| 126 | pm8x41_ldo_control(&ldo8, enable); |
| 127 | |
| 128 | pm8x41_ldo_set_voltage(&ldo4, 1200000); |
| 129 | pm8x41_ldo_control(&ldo4, enable); |
| 130 | |
| 131 | /* reset */ |
| 132 | msm8226_mdss_mipi_panel_reset(enable); |
| 133 | } else if(!target_cont_splash_screen()) { |
| 134 | msm8226_mdss_mipi_panel_reset(enable); |
| 135 | pm8x41_wled_enable(enable); |
| 136 | pm8x41_ldo_control(&ldo4, enable); |
| 137 | pm8x41_ldo_control(&ldo15, enable); |
| 138 | } |
| 139 | |
| 140 | return 0; |
| 141 | } |
| 142 | |
| 143 | void display_init(void) |
| 144 | { |
| 145 | uint32_t hw_id = board_hardware_id(); |
| 146 | |
| 147 | dprintf(SPEW, "display_init(),target_id=%d.\n", hw_id); |
| 148 | |
| 149 | switch (hw_id) { |
| 150 | case HW_PLATFORM_QRD: |
| 151 | case HW_PLATFORM_MTP: |
| 152 | case HW_PLATFORM_SURF: |
rayzhang | bd616e8 | 2013-06-05 20:06:36 +0800 | [diff] [blame] | 153 | #if DISPLAY_TYPE_CMD_MODE |
| 154 | mipi_nt35590_cmd_720p_init(&(panel.panel_info)); |
| 155 | #else |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 156 | mipi_nt35590_video_720p_init(&(panel.panel_info)); |
rayzhang | bd616e8 | 2013-06-05 20:06:36 +0800 | [diff] [blame] | 157 | #endif |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 158 | panel.clk_func = msm8226_mdss_dsi_panel_clock; |
| 159 | panel.power_func = msm8226_mipi_panel_power; |
| 160 | panel.fb.base = MIPI_FB_ADDR; |
| 161 | panel.fb.width = panel.panel_info.xres; |
| 162 | panel.fb.height = panel.panel_info.yres; |
| 163 | panel.fb.stride = panel.panel_info.xres; |
| 164 | panel.fb.bpp = panel.panel_info.bpp; |
| 165 | panel.fb.format = FB_FORMAT_RGB888; |
| 166 | panel.mdp_rev = MDP_REV_50; |
| 167 | break; |
| 168 | default: |
| 169 | return; |
| 170 | }; |
| 171 | |
| 172 | if (msm_display_init(&panel)) { |
| 173 | dprintf(CRITICAL, "Display init failed!\n"); |
| 174 | return; |
| 175 | } |
| 176 | |
| 177 | display_enable = 1; |
| 178 | } |
| 179 | |
| 180 | void display_shutdown(void) |
| 181 | { |
| 182 | if (display_enable) |
| 183 | msm_display_off(); |
| 184 | } |