blob: 50869d5780e3f4b29582ffc3b12b7206f0f0b9fc [file] [log] [blame]
Shashank Mittal246f8d02011-01-21 17:12:27 -08001/*
2 * Copyright (c) 2008, Google Inc.
3 * All rights reserved.
4 *
Duy Truongf3ac7b32013-02-13 01:07:28 -08005 * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
Shashank Mittal246f8d02011-01-21 17:12:27 -08006 *
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>
Channagoud Kadabi3acfb742011-11-15 18:19:32 +053039#include <platform/irqs.h>
Shashank Mittal246f8d02011-01-21 17:12:27 -080040#include <mddi.h>
41#include <dev/fbcon.h>
Channagoud Kadabi21992692011-08-12 14:59:38 +053042#include <dev/gpio.h>
Aparna Mallavarapu45869c32011-08-05 13:22:35 +053043#include <smem.h>
Shashank Mittal246f8d02011-01-21 17:12:27 -080044
45static struct fbcon_config *fb_config;
46
Amol Jadiaeda4e62011-07-19 18:07:29 -070047static uint32_t ticks_per_sec = 0;
48
Shashank Mittal246f8d02011-01-21 17:12:27 -080049void platform_init_interrupts(void);
50void platform_init_timer();
51
52void uart3_clock_init(void);
53void uart_init(void);
54
55void acpu_clock_init(void);
56
57void mddi_clock_init(unsigned num, unsigned rate);
58
Aparna Mallavarapu45869c32011-08-05 13:22:35 +053059unsigned board_msm_id(void);
60
Channagoud Kadabi3acfb742011-11-15 18:19:32 +053061static int target_uses_qgic;
62int debug_timer = 0, gpt_timer = 0, usb_hs_int = 0;
63
Shashank Mittal246f8d02011-01-21 17:12:27 -080064void platform_early_init(void)
65{
Shashank Mittal2fad67f2011-04-08 19:45:10 -070066#if WITH_DEBUG_UART
67 uart1_clock_init();
68 uart_init();
69#endif
Channagoud Kadabi81ba1102011-10-01 16:37:59 +053070 if(machine_is_8x25()) {
71 qgic_init();
72 target_uses_qgic = 1;
Channagoud Kadabi3acfb742011-11-15 18:19:32 +053073 debug_timer = (GIC_PPI_START + 2);
74 gpt_timer = (GIC_PPI_START + 3);
75 usb_hs_int = INT_USB_HS_GIC;
Channagoud Kadabi81ba1102011-10-01 16:37:59 +053076 } else {
77 platform_init_interrupts();
Channagoud Kadabi3acfb742011-11-15 18:19:32 +053078 debug_timer = 8;
79 gpt_timer = 7;
80 usb_hs_int = INT_USB_HS_VIC;
Channagoud Kadabi81ba1102011-10-01 16:37:59 +053081 }
Shashank Mittal246f8d02011-01-21 17:12:27 -080082 platform_init_timer();
83}
84
85void platform_init(void)
86{
87 dprintf(INFO, "platform_init()\n");
Shashank Mittal246f8d02011-01-21 17:12:27 -080088 acpu_clock_init();
Shashank Mittal246f8d02011-01-21 17:12:27 -080089}
90
Amol Jadi4421e652011-06-16 15:00:48 -070091void platform_uninit(void)
92{
Amol Jadi4421e652011-06-16 15:00:48 -070093#if DISPLAY_SPLASH_SCREEN
94 display_shutdown();
95#endif
Amol Jadid7cfc032012-01-09 16:56:08 -080096
97 platform_uninit_timer();
Amol Jadi4421e652011-06-16 15:00:48 -070098}
Amol Jadiaeda4e62011-07-19 18:07:29 -070099
100/* Initialize DGT timer */
101void platform_init_timer(void)
102{
103 /* disable timer */
104 writel(0, DGT_ENABLE);
105
Ajay Dudanib01e5062011-12-03 23:23:42 -0800106 ticks_per_sec = 19200000; /* Uses TCXO (19.2 MHz) */
Amol Jadiaeda4e62011-07-19 18:07:29 -0700107}
108
109/* Returns timer ticks per sec */
110uint32_t platform_tick_rate(void)
111{
112 return ticks_per_sec;
113}
Ajay Dudanib01e5062011-12-03 23:23:42 -0800114
Aparna Mallavarapu45869c32011-08-05 13:22:35 +0530115bool machine_is_7x25a(void)
116{
117 if ((board_msm_id() == MSM7225A) || (board_msm_id() == MSM7625A))
118 return 1;
119 else
120 return 0;
121}
Channagoud Kadabi21992692011-08-12 14:59:38 +0530122
Channagoud Kadabi81ba1102011-10-01 16:37:59 +0530123
124int target_supports_qgic()
125{
126 return target_uses_qgic;
127}