blob: 5480e24f3040783d181d63c6b43d25b1327a3ceb [file] [log] [blame]
Ajay Dudani232ce812009-12-02 00:14:11 -08001/*
2 * Copyright (c) 2008, Google Inc.
3 * All rights reserved.
Ajay Dudani1a23bb22009-12-03 13:56:24 -08004 * Copyright (c) 2009, Code Aurora Forum. All rights reserved.
Ajay Dudani232ce812009-12-02 00:14:11 -08005 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google, Inc. nor the names of its contributors
16 * may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#include <debug.h>
34
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -070035#include <reg.h>
Ajay Dudani232ce812009-12-02 00:14:11 -080036#include <dev/fbcon.h>
37#include <kernel/thread.h>
38#include <platform/debug.h>
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -070039#include <mddi_hw.h>
40#include "gpio_hw.h"
Ajay Dudani232ce812009-12-02 00:14:11 -080041
42void platform_init_interrupts(void);
43void platform_init_timer();
44
Shashank Mittal1ddc04c2010-12-21 14:39:07 -080045void uart2_clock_init(void);
Ajay Dudani232ce812009-12-02 00:14:11 -080046void uart_init(void);
47
48struct fbcon_config *lcdc_init(void);
49
Shashank Mittal1ddc04c2010-12-21 14:39:07 -080050#define ARRAY_SIZE(a) (sizeof(a)/(sizeof((a)[0])))
51
52static unsigned uart2_gpio_table[] = {
53 GPIO_CFG(49, 2, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA),
54 GPIO_CFG(50, 2, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA),
55 GPIO_CFG(51, 2, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA),
56 GPIO_CFG(52, 2, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA),
57};
58
59void uart2_mux_init(void)
60{
61 platform_gpios_enable(uart2_gpio_table, ARRAY_SIZE(uart2_gpio_table));
62}
63
Ajay Dudani232ce812009-12-02 00:14:11 -080064void platform_early_init(void)
65{
Shashank Mittal1ddc04c2010-12-21 14:39:07 -080066#if WITH_DEBUG_UART
67 uart2_mux_init();
68 uart2_clock_init();
69 uart_init();
70#endif
Ajay Dudani232ce812009-12-02 00:14:11 -080071 platform_init_interrupts();
72 platform_init_timer();
73}
74
75void platform_init(void)
76{
77 struct fbcon_config *fb_cfg;
78
79 dprintf(INFO, "platform_init()\n");
80 acpu_clock_init();
Subbaraman Narayanamurthy4cc29732010-10-18 15:57:58 -070081 adm_enable_clock();
Chandan Uddaraju24120502009-12-12 19:17:04 -080082}
83
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -070084void mdp4_display_intf_sel(int output, int intf)
85{
86 unsigned bits, mask;
87 unsigned dma2_cfg_reg;
88 bits = readl(MSM_MDP_BASE1 + 0x0038);
89 mask = 0x03; /* 2 bits */
90 intf &= 0x03; /* 2 bits */
91
92 switch (output) {
93 case EXTERNAL_INTF_SEL:
94 intf <<= 4;
95 mask <<= 4;
96 break;
97 case SECONDARY_INTF_SEL:
98 intf &= 0x02; /* only MDDI and EBI2 support */
99 intf <<= 2;
100 mask <<= 2;
101 break;
102 default:
103 break;
104 }
105
106 bits &= ~mask;
107 bits |= intf;
108 writel(bits, MSM_MDP_BASE1 + 0x0038); /* MDP_DISP_INTF_SEL */
109}
110
111
112
Chandan Uddaraju24120502009-12-12 19:17:04 -0800113void display_init(void)
114{
Shashank Mittal37040832010-08-24 15:57:57 -0700115 struct fbcon_config *fb_cfg;
Chandan Uddarajuc009e4d2010-09-08 17:06:45 -0700116
117#if DISPLAY_TYPE_MDDI
118 mddi_clock_init(0, 480000000);
119 mddi_panel_poweron();
120 /* We need to config GPIO 38 for Sleep clock with Spl Fun 2 */
121 toshiba_pmic_gpio_init(GPIO38_GPIO_CNTRL);
122 fb_cfg = mddi_init();
123 fbcon_setup(fb_cfg);
124#endif
125
126#if DISPLAY_TYPE_LCDC
Shashank Mittal37040832010-08-24 15:57:57 -0700127 mdp_clock_init(122880000);
128 fb_cfg = lcdc_init();
129 panel_poweron();
130 fbcon_setup(fb_cfg);
131#endif
Ajay Dudani232ce812009-12-02 00:14:11 -0800132}
Shashank Mittal58317a72010-10-11 17:02:57 -0700133
134void display_shutdown(void)
135{
136#if DISPLAY_TYPE_LCDC
137 /* Turning off LCDC */
138 lcdc_shutdown();
139#endif
140}
141