blob: e990502a7c17b005b59d7cc14921401dbb6bbae3 [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>
34#include <pm8x41.h>
35#include <pm8x41_wled.h>
36#include <board.h>
37#include <mdp5.h>
38#include <platform/gpio.h>
39#include <platform/iomap.h>
40#include <target/display.h>
41
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070042#include "include/display_resource.h"
Ray Zhang743e5032013-05-25 23:25:39 +080043
44static struct pm8x41_wled_data wled_ctrl = {
45 .mod_scheme = 0xC3,
46 .led1_brightness = (0x0F << 8) | 0xEF,
47 .led2_brightness = (0x0F << 8) | 0xEF,
48 .led3_brightness = (0x0F << 8) | 0xEF,
49 .max_duty_cycle = 0x01,
50 .ovp = 0x2,
51 .full_current_scale = 0x19
52};
53
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070054int target_backlight_ctrl(uint8_t enable)
Ray Zhang743e5032013-05-25 23:25:39 +080055{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070056 dprintf(SPEW, "target_backlight_ctrl\n");
57
Ray Zhang743e5032013-05-25 23:25:39 +080058 pm8x41_wled_config(&wled_ctrl);
59 pm8x41_wled_sink_control(1);
60 pm8x41_wled_iled_sync_control(1);
61 pm8x41_wled_enable(1);
62
63 return 0;
64}
65
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070066int target_panel_clock(uint8_t enable)
Ray Zhang743e5032013-05-25 23:25:39 +080067{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070068 dprintf(SPEW, "target_panel_clock\n");
Ray Zhang743e5032013-05-25 23:25:39 +080069
70 if (enable) {
71 mdp_gdsc_ctrl(enable);
72 mdp_clock_init();
73 mdss_dsi_uniphy_pll_config(MIPI_DSI0_BASE);
74 mmss_clock_init(0x100);
75 } else if(!target_cont_splash_screen()) {
76 /* Add here for non-continuous splash */
77 /* FIXME:Need to disable the clocks.
78 * For now leave the clocks enabled until the kernel
79 * hang issue gets resolved
80 */
81 }
82
83 return 0;
84}
85
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070086int target_panel_reset(uint8_t enable,
87 struct gpio_pin *resetgpio,
88 struct gpio_pin *enablegpio,
89 struct panel_reset_sequence *resetseq)
Ray Zhang743e5032013-05-25 23:25:39 +080090{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070091 int ret = NO_ERROR;
Ray Zhang743e5032013-05-25 23:25:39 +080092 if (enable) {
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070093 gpio_tlmm_config(resetgpio->pin_id, 0,
94 resetgpio->pin_direction, resetgpio->pin_pull,
95 resetgpio->pin_strength, resetgpio->pin_state);
Ray Zhang743e5032013-05-25 23:25:39 +080096
Arpita Banerjeec5f78df2013-05-24 15:43:40 -070097 gpio_set_dir(resetgpio->pin_id, 2);
98
99 gpio_set_value(resetgpio->pin_id, resetseq->pin_state[0]);
100 mdelay(resetseq->sleep[0]);
101 gpio_set_value(resetgpio->pin_id, resetseq->pin_state[1]);
102 mdelay(resetseq->sleep[1]);
103 gpio_set_value(resetgpio->pin_id, resetseq->pin_state[2]);
104 mdelay(resetseq->sleep[2]);
Ray Zhang743e5032013-05-25 23:25:39 +0800105 } else if(!target_cont_splash_screen()) {
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700106 gpio_set_value(resetgpio->pin_id, 0);
Ray Zhang743e5032013-05-25 23:25:39 +0800107 }
108
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700109 return ret;
Ray Zhang743e5032013-05-25 23:25:39 +0800110}
111
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700112int target_ldo_ctrl(uint8_t enable, struct ldo_entry ldo_entry_array[],
113 uint8_t ldo_array_size)
Ray Zhang743e5032013-05-25 23:25:39 +0800114{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700115 uint32_t ret = NO_ERROR;
116 uint32_t ldocounter = 0;
117 uint32_t pm8x41_ldo_base = 0x13F00;
Ray Zhang743e5032013-05-25 23:25:39 +0800118
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700119 while (ldocounter < ldo_array_size) {
120 struct pm8x41_ldo ldo_entry = LDO((pm8x41_ldo_base +
121 0x100 * ldo_entry_array[ldocounter].ldo_id),
122 ldo_entry_array[ldocounter].ldo_type);
Ray Zhang743e5032013-05-25 23:25:39 +0800123
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700124 dprintf(SPEW, "Setting %s\n",
125 ldo_entry_array[ldocounter].ldo_id);
Ray Zhang743e5032013-05-25 23:25:39 +0800126
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700127 /* Set voltage during power on */
128 if (enable == 1) {
129 pm8x41_ldo_set_voltage(&ldo_entry,
130 ldo_entry_array[ldocounter].ldo_voltage);
131 }
132 pm8x41_ldo_control(&ldo_entry, enable);
133 ldocounter++;
Ray Zhang743e5032013-05-25 23:25:39 +0800134 }
135
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700136 return ret;
Ray Zhang743e5032013-05-25 23:25:39 +0800137}
138
139void display_init(void)
140{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700141 gcdb_display_init(MDP_REV_50, MIPI_FB_ADDR);
Ray Zhang743e5032013-05-25 23:25:39 +0800142}
143
144void display_shutdown(void)
145{
Arpita Banerjeec5f78df2013-05-24 15:43:40 -0700146 gcdb_display_shutdown();
Ray Zhang743e5032013-05-25 23:25:39 +0800147}