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> |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 32 | #include <err.h> |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 33 | #include <msm_panel.h> |
Arpita Banerjee | 0906ffd | 2013-05-24 16:25:38 -0700 | [diff] [blame^] | 34 | #include <mipi_dsi.h> |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 35 | #include <pm8x41.h> |
| 36 | #include <pm8x41_wled.h> |
| 37 | #include <board.h> |
| 38 | #include <mdp5.h> |
| 39 | #include <platform/gpio.h> |
| 40 | #include <platform/iomap.h> |
| 41 | #include <target/display.h> |
| 42 | |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 43 | #include "include/display_resource.h" |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 44 | |
| 45 | static struct pm8x41_wled_data wled_ctrl = { |
| 46 | .mod_scheme = 0xC3, |
| 47 | .led1_brightness = (0x0F << 8) | 0xEF, |
| 48 | .led2_brightness = (0x0F << 8) | 0xEF, |
| 49 | .led3_brightness = (0x0F << 8) | 0xEF, |
| 50 | .max_duty_cycle = 0x01, |
| 51 | .ovp = 0x2, |
| 52 | .full_current_scale = 0x19 |
| 53 | }; |
| 54 | |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 55 | int target_backlight_ctrl(uint8_t enable) |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 56 | { |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 57 | dprintf(SPEW, "target_backlight_ctrl\n"); |
| 58 | |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 59 | pm8x41_wled_config(&wled_ctrl); |
| 60 | pm8x41_wled_sink_control(1); |
| 61 | pm8x41_wled_iled_sync_control(1); |
| 62 | pm8x41_wled_enable(1); |
| 63 | |
| 64 | return 0; |
| 65 | } |
| 66 | |
Arpita Banerjee | 0906ffd | 2013-05-24 16:25:38 -0700 | [diff] [blame^] | 67 | int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo) |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 68 | { |
Arpita Banerjee | 0906ffd | 2013-05-24 16:25:38 -0700 | [diff] [blame^] | 69 | struct mdss_dsi_pll_config *pll_data; |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 70 | dprintf(SPEW, "target_panel_clock\n"); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 71 | |
Arpita Banerjee | 0906ffd | 2013-05-24 16:25:38 -0700 | [diff] [blame^] | 72 | pll_data = pinfo->mipi.dsi_pll_config; |
| 73 | |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 74 | if (enable) { |
| 75 | mdp_gdsc_ctrl(enable); |
| 76 | mdp_clock_init(); |
Arpita Banerjee | 0906ffd | 2013-05-24 16:25:38 -0700 | [diff] [blame^] | 77 | mdss_dsi_auto_pll_config(pll_data); |
| 78 | mmss_clock_auto_pll_init(pll_data->pclk_m, |
| 79 | pll_data->pclk_n, |
| 80 | pll_data->pclk_d); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 81 | } else if(!target_cont_splash_screen()) { |
| 82 | /* Add here for non-continuous splash */ |
| 83 | /* FIXME:Need to disable the clocks. |
| 84 | * For now leave the clocks enabled until the kernel |
| 85 | * hang issue gets resolved |
| 86 | */ |
| 87 | } |
| 88 | |
| 89 | return 0; |
| 90 | } |
| 91 | |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 92 | int target_panel_reset(uint8_t enable, |
| 93 | struct gpio_pin *resetgpio, |
| 94 | struct gpio_pin *enablegpio, |
| 95 | struct panel_reset_sequence *resetseq) |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 96 | { |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 97 | int ret = NO_ERROR; |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 98 | if (enable) { |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 99 | gpio_tlmm_config(resetgpio->pin_id, 0, |
| 100 | resetgpio->pin_direction, resetgpio->pin_pull, |
| 101 | resetgpio->pin_strength, resetgpio->pin_state); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 102 | |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 103 | gpio_set_dir(resetgpio->pin_id, 2); |
| 104 | |
| 105 | gpio_set_value(resetgpio->pin_id, resetseq->pin_state[0]); |
| 106 | mdelay(resetseq->sleep[0]); |
| 107 | gpio_set_value(resetgpio->pin_id, resetseq->pin_state[1]); |
| 108 | mdelay(resetseq->sleep[1]); |
| 109 | gpio_set_value(resetgpio->pin_id, resetseq->pin_state[2]); |
| 110 | mdelay(resetseq->sleep[2]); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 111 | } else if(!target_cont_splash_screen()) { |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 112 | gpio_set_value(resetgpio->pin_id, 0); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 113 | } |
| 114 | |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 115 | return ret; |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 116 | } |
| 117 | |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 118 | int target_ldo_ctrl(uint8_t enable, struct ldo_entry ldo_entry_array[], |
| 119 | uint8_t ldo_array_size) |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 120 | { |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 121 | uint32_t ret = NO_ERROR; |
| 122 | uint32_t ldocounter = 0; |
| 123 | uint32_t pm8x41_ldo_base = 0x13F00; |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 124 | |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 125 | while (ldocounter < ldo_array_size) { |
| 126 | struct pm8x41_ldo ldo_entry = LDO((pm8x41_ldo_base + |
| 127 | 0x100 * ldo_entry_array[ldocounter].ldo_id), |
| 128 | ldo_entry_array[ldocounter].ldo_type); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 129 | |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 130 | dprintf(SPEW, "Setting %s\n", |
| 131 | ldo_entry_array[ldocounter].ldo_id); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 132 | |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 133 | /* Set voltage during power on */ |
| 134 | if (enable == 1) { |
| 135 | pm8x41_ldo_set_voltage(&ldo_entry, |
| 136 | ldo_entry_array[ldocounter].ldo_voltage); |
| 137 | } |
| 138 | pm8x41_ldo_control(&ldo_entry, enable); |
| 139 | ldocounter++; |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 140 | } |
| 141 | |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 142 | return ret; |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | void display_init(void) |
| 146 | { |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 147 | gcdb_display_init(MDP_REV_50, MIPI_FB_ADDR); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | void display_shutdown(void) |
| 151 | { |
Arpita Banerjee | c5f78df | 2013-05-24 15:43:40 -0700 | [diff] [blame] | 152 | gcdb_display_shutdown(); |
Ray Zhang | 743e503 | 2013-05-25 23:25:39 +0800 | [diff] [blame] | 153 | } |