Kuogee Hsieh | 7c3982a | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 2 | * |
| 3 | * Redistribution and use in source and binary forms, with or without |
| 4 | * modification, are permitted provided that the following conditions are |
| 5 | * 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 |
| 9 | * copyright notice, this list of conditions and the following |
| 10 | * disclaimer in the documentation and/or other materials provided |
| 11 | * with the 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 "AS IS" AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | * |
| 28 | */ |
| 29 | |
| 30 | #include <debug.h> |
| 31 | #include <smem.h> |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 32 | #include <err.h> |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 33 | #include <msm_panel.h> |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 34 | #include <mipi_dsi.h> |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 35 | #include <pm8x41.h> |
| 36 | #include <pm8x41_wled.h> |
| 37 | #include <board.h> |
| 38 | #include <platform/gpio.h> |
| 39 | #include <platform/iomap.h> |
Xu Kai | df04b16 | 2013-12-04 23:30:04 +0800 | [diff] [blame] | 40 | #include <platform/pm_pwm.h> |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 41 | #include <target/display.h> |
| 42 | |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 43 | #include "include/panel.h" |
| 44 | #include "include/display_resource.h" |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 45 | |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 46 | #define MODE_GPIO_STATE_ENABLE 1 |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 47 | |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 48 | #define MODE_GPIO_STATE_DISABLE 2 |
Dhaval Patel | 42bd43c | 2013-10-04 10:36:33 -0700 | [diff] [blame] | 49 | #define GPIO_STATE_LOW 0 |
| 50 | #define GPIO_STATE_HIGH 2 |
| 51 | #define RESET_GPIO_SEQ_LEN 3 |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 52 | |
Xu Kai | df04b16 | 2013-12-04 23:30:04 +0800 | [diff] [blame] | 53 | #define PWM_DUTY_US 13 |
| 54 | #define PWM_PERIOD_US 27 |
| 55 | |
Kuogee Hsieh | 7c3982a | 2013-12-18 14:13:45 -0800 | [diff] [blame] | 56 | int target_backlight_ctrl(struct backlight *bl, uint8_t enable) |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 57 | { |
| 58 | struct pm8x41_mpp mpp; |
Xu Kai | df04b16 | 2013-12-04 23:30:04 +0800 | [diff] [blame] | 59 | int rc; |
| 60 | |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 61 | mpp.base = PM8x41_MMP3_BASE; |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 62 | mpp.vin = MPP_VIN3; |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 63 | if (enable) { |
Xu Kai | df04b16 | 2013-12-04 23:30:04 +0800 | [diff] [blame] | 64 | pm_pwm_enable(false); |
| 65 | rc = pm_pwm_config(PWM_DUTY_US, PWM_PERIOD_US); |
| 66 | if (rc < 0) |
| 67 | mpp.mode = MPP_HIGH; |
| 68 | else { |
| 69 | mpp.mode = MPP_DTEST1; |
| 70 | pm_pwm_enable(true); |
| 71 | } |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 72 | pm8x41_config_output_mpp(&mpp); |
| 73 | pm8x41_enable_mpp(&mpp, MPP_ENABLE); |
| 74 | } else { |
Xu Kai | df04b16 | 2013-12-04 23:30:04 +0800 | [diff] [blame] | 75 | pm_pwm_enable(false); |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 76 | pm8x41_enable_mpp(&mpp, MPP_DISABLE); |
| 77 | } |
| 78 | /* Need delay before power on regulators */ |
| 79 | mdelay(20); |
| 80 | return 0; |
| 81 | } |
| 82 | |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 83 | int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo) |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 84 | { |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 85 | struct mdss_dsi_pll_config *pll_data; |
| 86 | dprintf(SPEW, "target_panel_clock\n"); |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 87 | |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 88 | pll_data = pinfo->mipi.dsi_pll_config; |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 89 | |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 90 | if (enable) { |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 91 | mdp_clock_enable(); |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 92 | dsi_clock_enable( |
| 93 | pll_data->byte_clock * pinfo->mipi.num_of_lanes, |
| 94 | pll_data->byte_clock); |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 95 | } else if(!target_cont_splash_screen()) { |
| 96 | dsi_clock_disable(); |
| 97 | mdp_clock_disable(); |
| 98 | } |
| 99 | |
| 100 | return 0; |
| 101 | } |
| 102 | |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 103 | int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq, |
| 104 | struct msm_panel_info *pinfo) |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 105 | { |
Dhaval Patel | 42bd43c | 2013-10-04 10:36:33 -0700 | [diff] [blame] | 106 | uint8_t i = 0; |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 107 | dprintf(SPEW, "msm8610_mdss_mipi_panel_reset, enable = %d\n", enable); |
| 108 | |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 109 | if (enable) { |
| 110 | gpio_tlmm_config(reset_gpio.pin_id, 0, |
| 111 | reset_gpio.pin_direction, reset_gpio.pin_pull, |
| 112 | reset_gpio.pin_strength, reset_gpio.pin_state); |
| 113 | |
| 114 | gpio_tlmm_config(mode_gpio.pin_id, 0, |
| 115 | mode_gpio.pin_direction, mode_gpio.pin_pull, |
| 116 | mode_gpio.pin_strength, mode_gpio.pin_state); |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 117 | |
| 118 | /* reset */ |
Dhaval Patel | 42bd43c | 2013-10-04 10:36:33 -0700 | [diff] [blame] | 119 | for (i = 0; i < RESET_GPIO_SEQ_LEN; i++) { |
| 120 | if (resetseq->pin_state[i] == GPIO_STATE_LOW) |
| 121 | gpio_set(reset_gpio.pin_id, GPIO_STATE_LOW); |
| 122 | else |
| 123 | gpio_set(reset_gpio.pin_id, GPIO_STATE_HIGH); |
| 124 | mdelay(resetseq->sleep[i]); |
| 125 | } |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 126 | |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 127 | if (pinfo->mipi.mode_gpio_state == MODE_GPIO_STATE_ENABLE) |
| 128 | gpio_set(mode_gpio.pin_id, 2); |
| 129 | else if (pinfo->mipi.mode_gpio_state == MODE_GPIO_STATE_DISABLE) |
| 130 | gpio_set(mode_gpio.pin_id, 0); |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 131 | } else if(!target_cont_splash_screen()) { |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 132 | gpio_set(reset_gpio.pin_id, 0); |
| 133 | gpio_set(mode_gpio.pin_id, 0); |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 134 | } |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 135 | return 0; |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 136 | } |
| 137 | |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 138 | int target_ldo_ctrl(uint8_t enable) |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 139 | { |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 140 | uint32_t ldocounter = 0; |
| 141 | uint32_t pm8x41_ldo_base = 0x13F00; |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 142 | |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 143 | while (ldocounter < TOTAL_LDO_DEFINED) { |
| 144 | struct pm8x41_ldo ldo_entry = LDO((pm8x41_ldo_base + |
| 145 | 0x100 * ldo_entry_array[ldocounter].ldo_id), |
| 146 | ldo_entry_array[ldocounter].ldo_type); |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 147 | |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 148 | dprintf(SPEW, "Setting %s\n", |
| 149 | ldo_entry_array[ldocounter].ldo_id); |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 150 | |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 151 | /* Set voltage during power on */ |
| 152 | if (enable) { |
| 153 | pm8x41_ldo_set_voltage(&ldo_entry, |
| 154 | ldo_entry_array[ldocounter].ldo_voltage); |
| 155 | pm8x41_ldo_control(&ldo_entry, enable); |
| 156 | } else if(!target_cont_splash_screen()) { |
| 157 | pm8x41_ldo_control(&ldo_entry, enable); |
| 158 | } |
| 159 | ldocounter++; |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 160 | } |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 161 | |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 162 | return 0; |
| 163 | } |
| 164 | |
Aravind Venkateswaran | 35d110b | 2014-02-25 16:45:11 -0800 | [diff] [blame] | 165 | void target_display_init(const char *panel_name) |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 166 | { |
Justin Philip | d4b293a | 2014-09-17 12:26:49 +0530 | [diff] [blame] | 167 | uint32_t ret = 0; |
| 168 | |
| 169 | ret = gcdb_display_init(panel_name, MDP_REV_304, MIPI_FB_ADDR); |
| 170 | if(ret) { |
| 171 | /* Panel signature did not match, turn off the display */ |
| 172 | target_force_cont_splash_disable(true); |
| 173 | msm_display_off(); |
| 174 | } |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 175 | } |
| 176 | |
Aravind Venkateswaran | 497653f | 2014-02-25 14:42:43 -0800 | [diff] [blame] | 177 | void target_display_shutdown(void) |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 178 | { |
Dhaval Patel | 8ae0bbd | 2013-08-15 15:45:01 -0700 | [diff] [blame] | 179 | gcdb_display_shutdown(); |
Terence Hampson | afded26 | 2013-06-18 14:48:18 -0400 | [diff] [blame] | 180 | } |