blob: d55b1d3c5f036115d83e8c547c2625f07a473229 [file] [log] [blame]
Brian Swetland2500aa12009-01-01 04:33:55 -08001/*
2 * Copyright (c) 2008, Google Inc.
3 * All rights reserved.
4 *
Duy Truongf3ac7b32013-02-13 01:07:28 -08005 * Copyright (c) 2009-2010, The Linux Foundation. All rights reserved.
Shashank Mittal4f99a882010-02-01 13:58:50 -08006 *
Brian Swetland2500aa12009-01-01 04:33:55 -08007 * 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>
Brian Swetland2500aa12009-01-01 04:33:55 -080035#include <debug.h>
Brian Swetland2500aa12009-01-01 04:33:55 -080036#include <kernel/thread.h>
37#include <platform/debug.h>
Amol Jadiaeda4e62011-07-19 18:07:29 -070038#include <platform/iomap.h>
Chandan Uddaraju2943fd62010-06-21 10:56:39 -070039#include <mddi.h>
Dima Zavin36785e32009-01-28 17:26:43 -080040#include <dev/fbcon.h>
Amol Jadi9ef9b732011-05-23 16:00:17 -070041#include <arch/arm/mmu.h>
42
43#define MB (1024*1024)
Dima Zavin36785e32009-01-28 17:26:43 -080044
45static struct fbcon_config *fb_config;
Brian Swetland2500aa12009-01-01 04:33:55 -080046
Amol Jadiaeda4e62011-07-19 18:07:29 -070047static uint32_t ticks_per_sec = 0;
48
Brian Swetland2500aa12009-01-01 04:33:55 -080049void platform_init_interrupts(void);
50void platform_init_timer();
51
Brian Swetlandf4acf732009-01-29 17:25:44 -080052void uart3_clock_init(void);
53void uart_init(void);
54
Chandan Uddarajufcc15f52009-11-17 21:02:46 -080055void acpu_clock_init(void);
56
Dima Zavin36785e32009-01-28 17:26:43 -080057void mddi_clock_init(unsigned num, unsigned rate);
58
Brian Swetland2500aa12009-01-01 04:33:55 -080059void platform_early_init(void)
60{
Brian Swetland2500aa12009-01-01 04:33:55 -080061 platform_init_interrupts();
62 platform_init_timer();
63}
64
65void platform_init(void)
66{
67 dprintf(INFO, "platform_init()\n");
Dima Zavin36785e32009-01-28 17:26:43 -080068
Chandan Uddarajufcc15f52009-11-17 21:02:46 -080069 acpu_clock_init();
Chandan Uddaraju24120502009-12-12 19:17:04 -080070}
Chandan Uddarajufcc15f52009-11-17 21:02:46 -080071
Chandan Uddaraju24120502009-12-12 19:17:04 -080072void display_init(void)
73{
Chandan Uddaraju96f581d2009-11-24 22:38:40 -080074#if DISPLAY_TYPE_MDDI
Dima Zavin36785e32009-01-28 17:26:43 -080075 fb_config = mddi_init();
76 ASSERT(fb_config);
77 fbcon_setup(fb_config);
Chandan Uddaraju96f581d2009-11-24 22:38:40 -080078#endif
Shashank Mittal4f99a882010-02-01 13:58:50 -080079#if DISPLAY_TYPE_LCDC
80 fb_config = lcdc_init();
81 ASSERT(fb_config);
82 fbcon_setup(fb_config);
83#endif
Brian Swetland2500aa12009-01-01 04:33:55 -080084}
Amol Jadi9ef9b732011-05-23 16:00:17 -070085
86
87/* Setup memory for this platform */
88void platform_init_mmu_mappings(void)
89{
90 uint32_t sections = 1152;
91
92 /* Map io mapped peripherals as device non-shared memory */
93 while (sections--)
94 {
95 arm_mmu_map_section(0x88000000 + sections*MB,
96 0x88000000 + sections*MB,
97 (MMU_MEMORY_TYPE_DEVICE_NON_SHARED |
98 MMU_MEMORY_AP_READ_WRITE));
99 }
100}
Amol Jadiaeda4e62011-07-19 18:07:29 -0700101
102/* Initialize DGT timer */
103void platform_init_timer(void)
104{
105 /* disable timer */
106 writel(0, DGT_ENABLE);
107
108 ticks_per_sec = 19200000; /* Uses TCXO (19.2 MHz) */
109}
110
111/* Returns timer ticks per sec */
112uint32_t platform_tick_rate(void)
113{
114 return ticks_per_sec;
115}