blob: 76964f912274a1b074fb83b80273472e6dc128b3 [file] [log] [blame]
Shashank Mittal246f8d02011-01-21 17:12:27 -08001/*
2 * Copyright (c) 2008, Google Inc.
3 * All rights reserved.
4 *
5 * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google, Inc. nor the names of its contributors
17 * may be used to endorse or promote products derived from this
18 * software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
Amol Jadiaeda4e62011-07-19 18:07:29 -070034#include <reg.h>
Shashank Mittal246f8d02011-01-21 17:12:27 -080035#include <debug.h>
36#include <kernel/thread.h>
37#include <platform/debug.h>
Amol Jadiaeda4e62011-07-19 18:07:29 -070038#include <platform/iomap.h>
Shashank Mittal246f8d02011-01-21 17:12:27 -080039#include <mddi.h>
40#include <dev/fbcon.h>
Channagoud Kadabi21992692011-08-12 14:59:38 +053041#include <dev/gpio.h>
Aparna Mallavarapu45869c32011-08-05 13:22:35 +053042#include <smem.h>
Shashank Mittal246f8d02011-01-21 17:12:27 -080043
44static struct fbcon_config *fb_config;
45
Amol Jadiaeda4e62011-07-19 18:07:29 -070046static uint32_t ticks_per_sec = 0;
47
Shashank Mittal246f8d02011-01-21 17:12:27 -080048void platform_init_interrupts(void);
49void platform_init_timer();
50
51void uart3_clock_init(void);
52void uart_init(void);
53
54void acpu_clock_init(void);
55
56void mddi_clock_init(unsigned num, unsigned rate);
57
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +053058extern void mipi_dsi_shutdown(void);
59
Aparna Mallavarapu45869c32011-08-05 13:22:35 +053060unsigned board_msm_id(void);
61
Channagoud Kadabi81ba1102011-10-01 16:37:59 +053062static int target_uses_qgic = 0;
Shashank Mittal246f8d02011-01-21 17:12:27 -080063void platform_early_init(void)
64{
Shashank Mittal2fad67f2011-04-08 19:45:10 -070065#if WITH_DEBUG_UART
66 uart1_clock_init();
67 uart_init();
68#endif
Channagoud Kadabi81ba1102011-10-01 16:37:59 +053069 if(machine_is_8x25()) {
70 qgic_init();
71 target_uses_qgic = 1;
72 } else {
73 platform_init_interrupts();
74 }
Shashank Mittal246f8d02011-01-21 17:12:27 -080075 platform_init_timer();
76}
77
78void platform_init(void)
79{
80 dprintf(INFO, "platform_init()\n");
Shashank Mittal246f8d02011-01-21 17:12:27 -080081 acpu_clock_init();
Shashank Mittal246f8d02011-01-21 17:12:27 -080082}
83
84void display_init(void)
85{
86#if DISPLAY_TYPE_MDDI
87 fb_config = mddi_init();
88 ASSERT(fb_config);
89 fbcon_setup(fb_config);
90#endif
91#if DISPLAY_TYPE_LCDC
92 fb_config = lcdc_init();
93 ASSERT(fb_config);
94 fbcon_setup(fb_config);
95#endif
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +053096#if DISPLAY_TYPE_MIPI
Channagoud Kadabi21992692011-08-12 14:59:38 +053097 dprintf(SPEW, "display_init()\n");
98 panel_dsi_init();
99 fb_config = mipi_init();
100 ASSERT(fb_config);
101 fbcon_setup(fb_config);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530102#endif
103}
104
105void display_shutdown(void)
106{
107#if DISPLAY_TYPE_MIPI
Channagoud Kadabid53664b2011-12-28 16:39:15 +0530108 if (machine_is_7x27a_evb())
109 return;
Channagoud Kadabi21992692011-08-12 14:59:38 +0530110 dprintf(SPEW, "display_shutdown()\n");
111 mipi_dsi_shutdown();
112 /* Power down DSI bridge chip */
Ajay Dudanib01e5062011-12-03 23:23:42 -0800113 gpio_set(128, 0x1);
Aparna Mallavarapuf712f5e2011-08-04 21:11:00 +0530114#endif
Shashank Mittal246f8d02011-01-21 17:12:27 -0800115}
Amol Jadi4421e652011-06-16 15:00:48 -0700116
117void platform_uninit(void)
118{
Amol Jadi4421e652011-06-16 15:00:48 -0700119#if DISPLAY_SPLASH_SCREEN
120 display_shutdown();
121#endif
Amol Jadid7cfc032012-01-09 16:56:08 -0800122
123 platform_uninit_timer();
Amol Jadi4421e652011-06-16 15:00:48 -0700124}
Amol Jadiaeda4e62011-07-19 18:07:29 -0700125
126/* Initialize DGT timer */
127void platform_init_timer(void)
128{
129 /* disable timer */
130 writel(0, DGT_ENABLE);
131
Ajay Dudanib01e5062011-12-03 23:23:42 -0800132 ticks_per_sec = 19200000; /* Uses TCXO (19.2 MHz) */
Amol Jadiaeda4e62011-07-19 18:07:29 -0700133}
134
135/* Returns timer ticks per sec */
136uint32_t platform_tick_rate(void)
137{
138 return ticks_per_sec;
139}
Ajay Dudanib01e5062011-12-03 23:23:42 -0800140
Aparna Mallavarapu45869c32011-08-05 13:22:35 +0530141bool machine_is_7x25a(void)
142{
143 if ((board_msm_id() == MSM7225A) || (board_msm_id() == MSM7625A))
144 return 1;
145 else
146 return 0;
147}
Channagoud Kadabi21992692011-08-12 14:59:38 +0530148
149/* Toggle RESET pin of the DSI Client before sending
150 * panel init commands
151 */
152void panel_dsi_init(void)
153{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800154 gpio_set(128, 0x1);
Aparna Mallavarapu34144df2011-08-20 21:16:03 +0530155 mdelay(5);
Ajay Dudanib01e5062011-12-03 23:23:42 -0800156 gpio_set(128, 0x0);
157 gpio_set(129, 0x1);
Channagoud Kadabi21992692011-08-12 14:59:38 +0530158 gpio_config(129, GPIO_OUTPUT);
Ajay Dudanib01e5062011-12-03 23:23:42 -0800159 gpio_set(129, 0x0);
160 gpio_set(129, 0x1);
Channagoud Kadabi21992692011-08-12 14:59:38 +0530161 mdelay(10);
162}
Channagoud Kadabi81ba1102011-10-01 16:37:59 +0530163
164int target_supports_qgic()
165{
166 return target_uses_qgic;
167}