blob: a30b56815fcb887f7bc951379d88ba79bfa242db [file] [log] [blame]
Ray Zhang743e5032013-05-25 23:25:39 +08001/* 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 Banerjeec5f78df2013-05-24 15:43:40 -070032#include <err.h>
Ray Zhang743e5032013-05-25 23:25:39 +080033#include <msm_panel.h>
Arpita Banerjee0906ffd2013-05-24 16:25:38 -070034#include <mipi_dsi.h>
Ray Zhang743e5032013-05-25 23:25:39 +080035#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 Banerjeec5f78df2013-05-24 15:43:40 -070043#include "include/display_resource.h"
Ray Zhang743e5032013-05-25 23:25:39 +080044
45static struct pm8x41_wled_data wled_ctrl = {
rayzhanga3667cd2013-07-01 12:22:54 +080046 .mod_scheme = 0x00,
Ray Zhang743e5032013-05-25 23:25:39 +080047 .led1_brightness = (0x0F << 8) | 0xEF,
Ray Zhang743e5032013-05-25 23:25:39 +080048 .max_duty_cycle = 0x01,
rayzhanga3667cd2013-07-01 12:22:54 +080049 .ovp = 0x0,
Ray Zhang743e5032013-05-25 23:25:39 +080050 .full_current_scale = 0x19
51};
52
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070053int target_backlight_ctrl(uint8_t enable)
Ray Zhang743e5032013-05-25 23:25:39 +080054{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070055 dprintf(SPEW, "target_backlight_ctrl\n");
56
Ray Zhang743e5032013-05-25 23:25:39 +080057 pm8x41_wled_config(&wled_ctrl);
58 pm8x41_wled_sink_control(1);
59 pm8x41_wled_iled_sync_control(1);
60 pm8x41_wled_enable(1);
61
62 return 0;
63}
64
Arpita Banerjee0906ffd2013-05-24 16:25:38 -070065int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
Ray Zhang743e5032013-05-25 23:25:39 +080066{
Arpita Banerjee0906ffd2013-05-24 16:25:38 -070067 struct mdss_dsi_pll_config *pll_data;
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070068 dprintf(SPEW, "target_panel_clock\n");
Ray Zhang743e5032013-05-25 23:25:39 +080069
Arpita Banerjee0906ffd2013-05-24 16:25:38 -070070 pll_data = pinfo->mipi.dsi_pll_config;
71
Ray Zhang743e5032013-05-25 23:25:39 +080072 if (enable) {
73 mdp_gdsc_ctrl(enable);
74 mdp_clock_init();
Arpita Banerjee0906ffd2013-05-24 16:25:38 -070075 mdss_dsi_auto_pll_config(pll_data);
76 mmss_clock_auto_pll_init(pll_data->pclk_m,
77 pll_data->pclk_n,
78 pll_data->pclk_d);
Ray Zhang743e5032013-05-25 23:25:39 +080079 } else if(!target_cont_splash_screen()) {
80 /* Add here for non-continuous splash */
81 /* FIXME:Need to disable the clocks.
82 * For now leave the clocks enabled until the kernel
83 * hang issue gets resolved
84 */
85 }
86
87 return 0;
88}
89
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070090int target_panel_reset(uint8_t enable,
91 struct gpio_pin *resetgpio,
92 struct gpio_pin *enablegpio,
93 struct panel_reset_sequence *resetseq)
Ray Zhang743e5032013-05-25 23:25:39 +080094{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070095 int ret = NO_ERROR;
Ray Zhang743e5032013-05-25 23:25:39 +080096 if (enable) {
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070097 gpio_tlmm_config(resetgpio->pin_id, 0,
98 resetgpio->pin_direction, resetgpio->pin_pull,
99 resetgpio->pin_strength, resetgpio->pin_state);
Ray Zhang743e5032013-05-25 23:25:39 +0800100
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700101 gpio_set_dir(resetgpio->pin_id, 2);
102
103 gpio_set_value(resetgpio->pin_id, resetseq->pin_state[0]);
104 mdelay(resetseq->sleep[0]);
105 gpio_set_value(resetgpio->pin_id, resetseq->pin_state[1]);
106 mdelay(resetseq->sleep[1]);
107 gpio_set_value(resetgpio->pin_id, resetseq->pin_state[2]);
108 mdelay(resetseq->sleep[2]);
Ray Zhang743e5032013-05-25 23:25:39 +0800109 } else if(!target_cont_splash_screen()) {
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700110 gpio_set_value(resetgpio->pin_id, 0);
Ray Zhang743e5032013-05-25 23:25:39 +0800111 }
112
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700113 return ret;
Ray Zhang743e5032013-05-25 23:25:39 +0800114}
115
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700116int target_ldo_ctrl(uint8_t enable, struct ldo_entry ldo_entry_array[],
117 uint8_t ldo_array_size)
Ray Zhang743e5032013-05-25 23:25:39 +0800118{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700119 uint32_t ret = NO_ERROR;
120 uint32_t ldocounter = 0;
121 uint32_t pm8x41_ldo_base = 0x13F00;
Ray Zhang743e5032013-05-25 23:25:39 +0800122
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700123 while (ldocounter < ldo_array_size) {
124 struct pm8x41_ldo ldo_entry = LDO((pm8x41_ldo_base +
125 0x100 * ldo_entry_array[ldocounter].ldo_id),
126 ldo_entry_array[ldocounter].ldo_type);
Ray Zhang743e5032013-05-25 23:25:39 +0800127
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700128 dprintf(SPEW, "Setting %s\n",
129 ldo_entry_array[ldocounter].ldo_id);
Ray Zhang743e5032013-05-25 23:25:39 +0800130
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700131 /* Set voltage during power on */
132 if (enable == 1) {
133 pm8x41_ldo_set_voltage(&ldo_entry,
134 ldo_entry_array[ldocounter].ldo_voltage);
135 }
136 pm8x41_ldo_control(&ldo_entry, enable);
137 ldocounter++;
Ray Zhang743e5032013-05-25 23:25:39 +0800138 }
139
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700140 return ret;
Ray Zhang743e5032013-05-25 23:25:39 +0800141}
142
143void display_init(void)
144{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700145 gcdb_display_init(MDP_REV_50, MIPI_FB_ADDR);
Ray Zhang743e5032013-05-25 23:25:39 +0800146}
147
148void display_shutdown(void)
149{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700150 gcdb_display_shutdown();
Ray Zhang743e5032013-05-25 23:25:39 +0800151}