blob: fde805af7f0632a34c7500df43f6229bcc1f0e14 [file] [log] [blame]
Kuogee Hsieh7c3982a2013-12-18 14:13:45 -08001/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
Terence Hampsonafded262013-06-18 14:48:18 -04002 *
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 Patel8ae0bbd2013-08-15 15:45:01 -070032#include <err.h>
Terence Hampsonafded262013-06-18 14:48:18 -040033#include <msm_panel.h>
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -070034#include <mipi_dsi.h>
Terence Hampsonafded262013-06-18 14:48:18 -040035#include <pm8x41.h>
36#include <pm8x41_wled.h>
37#include <board.h>
38#include <platform/gpio.h>
39#include <platform/iomap.h>
Xu Kaidf04b162013-12-04 23:30:04 +080040#include <platform/pm_pwm.h>
Terence Hampsonafded262013-06-18 14:48:18 -040041#include <target/display.h>
42
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -070043#include "include/panel.h"
44#include "include/display_resource.h"
Terence Hampsonafded262013-06-18 14:48:18 -040045
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -070046#define MODE_GPIO_STATE_ENABLE 1
Terence Hampsonafded262013-06-18 14:48:18 -040047
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -070048#define MODE_GPIO_STATE_DISABLE 2
Dhaval Patel42bd43c2013-10-04 10:36:33 -070049#define GPIO_STATE_LOW 0
50#define GPIO_STATE_HIGH 2
51#define RESET_GPIO_SEQ_LEN 3
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -070052
Xu Kaidf04b162013-12-04 23:30:04 +080053#define PWM_DUTY_US 13
54#define PWM_PERIOD_US 27
55
Kuogee Hsieh7c3982a2013-12-18 14:13:45 -080056int target_backlight_ctrl(struct backlight *bl, uint8_t enable)
Terence Hampsonafded262013-06-18 14:48:18 -040057{
58 struct pm8x41_mpp mpp;
Xu Kaidf04b162013-12-04 23:30:04 +080059 int rc;
60
Terence Hampsonafded262013-06-18 14:48:18 -040061 mpp.base = PM8x41_MMP3_BASE;
Terence Hampsonafded262013-06-18 14:48:18 -040062 mpp.vin = MPP_VIN3;
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -070063 if (enable) {
Xu Kaidf04b162013-12-04 23:30:04 +080064 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 Hampsonafded262013-06-18 14:48:18 -040072 pm8x41_config_output_mpp(&mpp);
73 pm8x41_enable_mpp(&mpp, MPP_ENABLE);
74 } else {
Xu Kaidf04b162013-12-04 23:30:04 +080075 pm_pwm_enable(false);
Terence Hampsonafded262013-06-18 14:48:18 -040076 pm8x41_enable_mpp(&mpp, MPP_DISABLE);
77 }
78 /* Need delay before power on regulators */
79 mdelay(20);
80 return 0;
81}
82
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -070083int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
Terence Hampsonafded262013-06-18 14:48:18 -040084{
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -070085 struct mdss_dsi_pll_config *pll_data;
86 dprintf(SPEW, "target_panel_clock\n");
Terence Hampsonafded262013-06-18 14:48:18 -040087
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -070088 pll_data = pinfo->mipi.dsi_pll_config;
Terence Hampsonafded262013-06-18 14:48:18 -040089
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -070090 if (enable) {
Terence Hampsonafded262013-06-18 14:48:18 -040091 mdp_clock_enable();
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -070092 dsi_clock_enable(
93 pll_data->byte_clock * pinfo->mipi.num_of_lanes,
94 pll_data->byte_clock);
Terence Hampsonafded262013-06-18 14:48:18 -040095 } else if(!target_cont_splash_screen()) {
96 dsi_clock_disable();
97 mdp_clock_disable();
98 }
99
100 return 0;
101}
102
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700103int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq,
104 struct msm_panel_info *pinfo)
Terence Hampsonafded262013-06-18 14:48:18 -0400105{
Dhaval Patel42bd43c2013-10-04 10:36:33 -0700106 uint8_t i = 0;
Terence Hampsonafded262013-06-18 14:48:18 -0400107 dprintf(SPEW, "msm8610_mdss_mipi_panel_reset, enable = %d\n", enable);
108
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700109 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 Hampsonafded262013-06-18 14:48:18 -0400117
118 /* reset */
Dhaval Patel42bd43c2013-10-04 10:36:33 -0700119 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 Hampsonafded262013-06-18 14:48:18 -0400126
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700127 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 Hampsonafded262013-06-18 14:48:18 -0400131 } else if(!target_cont_splash_screen()) {
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700132 gpio_set(reset_gpio.pin_id, 0);
133 gpio_set(mode_gpio.pin_id, 0);
Terence Hampsonafded262013-06-18 14:48:18 -0400134 }
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700135 return 0;
Terence Hampsonafded262013-06-18 14:48:18 -0400136}
137
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700138int target_ldo_ctrl(uint8_t enable)
Terence Hampsonafded262013-06-18 14:48:18 -0400139{
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700140 uint32_t ldocounter = 0;
141 uint32_t pm8x41_ldo_base = 0x13F00;
Terence Hampsonafded262013-06-18 14:48:18 -0400142
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700143 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 Hampsonafded262013-06-18 14:48:18 -0400147
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700148 dprintf(SPEW, "Setting %s\n",
149 ldo_entry_array[ldocounter].ldo_id);
Terence Hampsonafded262013-06-18 14:48:18 -0400150
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700151 /* 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 Hampsonafded262013-06-18 14:48:18 -0400160 }
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700161
Terence Hampsonafded262013-06-18 14:48:18 -0400162 return 0;
163}
164
165void display_init(void)
166{
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700167 gcdb_display_init(MDP_REV_304, MIPI_FB_ADDR);
Terence Hampsonafded262013-06-18 14:48:18 -0400168}
169
170void display_shutdown(void)
171{
Dhaval Patel8ae0bbd2013-08-15 15:45:01 -0700172 gcdb_display_shutdown();
Terence Hampsonafded262013-06-18 14:48:18 -0400173}