blob: 2da792e2e6da3249eee5254e0a1da465f02c6225 [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 = {
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 Banerjeec5f78df2013-05-24 15:43:40 -070055int target_backlight_ctrl(uint8_t enable)
Ray Zhang743e5032013-05-25 23:25:39 +080056{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070057 dprintf(SPEW, "target_backlight_ctrl\n");
58
Ray Zhang743e5032013-05-25 23:25:39 +080059 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 Banerjee0906ffd2013-05-24 16:25:38 -070067int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
Ray Zhang743e5032013-05-25 23:25:39 +080068{
Arpita Banerjee0906ffd2013-05-24 16:25:38 -070069 struct mdss_dsi_pll_config *pll_data;
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070070 dprintf(SPEW, "target_panel_clock\n");
Ray Zhang743e5032013-05-25 23:25:39 +080071
Arpita Banerjee0906ffd2013-05-24 16:25:38 -070072 pll_data = pinfo->mipi.dsi_pll_config;
73
Ray Zhang743e5032013-05-25 23:25:39 +080074 if (enable) {
75 mdp_gdsc_ctrl(enable);
76 mdp_clock_init();
Arpita Banerjee0906ffd2013-05-24 16:25:38 -070077 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 Zhang743e5032013-05-25 23:25:39 +080081 } 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 Banerjeec5f78df2013-05-24 15:43:40 -070092int target_panel_reset(uint8_t enable,
93 struct gpio_pin *resetgpio,
94 struct gpio_pin *enablegpio,
95 struct panel_reset_sequence *resetseq)
Ray Zhang743e5032013-05-25 23:25:39 +080096{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070097 int ret = NO_ERROR;
Ray Zhang743e5032013-05-25 23:25:39 +080098 if (enable) {
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070099 gpio_tlmm_config(resetgpio->pin_id, 0,
100 resetgpio->pin_direction, resetgpio->pin_pull,
101 resetgpio->pin_strength, resetgpio->pin_state);
Ray Zhang743e5032013-05-25 23:25:39 +0800102
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700103 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 Zhang743e5032013-05-25 23:25:39 +0800111 } else if(!target_cont_splash_screen()) {
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700112 gpio_set_value(resetgpio->pin_id, 0);
Ray Zhang743e5032013-05-25 23:25:39 +0800113 }
114
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700115 return ret;
Ray Zhang743e5032013-05-25 23:25:39 +0800116}
117
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700118int target_ldo_ctrl(uint8_t enable, struct ldo_entry ldo_entry_array[],
119 uint8_t ldo_array_size)
Ray Zhang743e5032013-05-25 23:25:39 +0800120{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700121 uint32_t ret = NO_ERROR;
122 uint32_t ldocounter = 0;
123 uint32_t pm8x41_ldo_base = 0x13F00;
Ray Zhang743e5032013-05-25 23:25:39 +0800124
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700125 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 Zhang743e5032013-05-25 23:25:39 +0800129
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700130 dprintf(SPEW, "Setting %s\n",
131 ldo_entry_array[ldocounter].ldo_id);
Ray Zhang743e5032013-05-25 23:25:39 +0800132
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700133 /* 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 Zhang743e5032013-05-25 23:25:39 +0800140 }
141
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700142 return ret;
Ray Zhang743e5032013-05-25 23:25:39 +0800143}
144
145void display_init(void)
146{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700147 gcdb_display_init(MDP_REV_50, MIPI_FB_ADDR);
Ray Zhang743e5032013-05-25 23:25:39 +0800148}
149
150void display_shutdown(void)
151{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700152 gcdb_display_shutdown();
Ray Zhang743e5032013-05-25 23:25:39 +0800153}