blob: 99e1ad4d10a0675305f66618b41ab2fcbc7d2b02 [file] [log] [blame]
Kinson Chik18e36332011-08-15 10:07:28 -07001/*
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
34#include <reg.h>
35#include <debug.h>
36#include <kernel/thread.h>
37#include <platform/debug.h>
38#include <platform/iomap.h>
39#include <smem.h>
40#include <qgic.h>
41
42static uint32_t ticks_per_sec = 0;
43
44extern void platform_uninit_timer(void);
45
46void platform_init_timer();
47
48void platform_early_init(void)
49{
50 uint8_t cfg_bid = 0x1;
51 uint8_t cfg_pid = 0x1;
52
53 uart_init(target_uart_gsbi());
54 /* Timers - QGIC Config */
55 writel((cfg_bid << 7 | cfg_pid << 10), APCS_GLB_QGIC_CFG);
56 qgic_init();
57 platform_init_timer();
58}
59
60void platform_init(void)
61{
62 dprintf(INFO, "platform_init()\n");
63 acpu_clock_init();
64}
65
66void platform_uninit(void)
67{
68 platform_uninit_timer();
69}
70
71/* Initialize DGT timer */
72void platform_init_timer(void)
73{
74 /* disable timer */
75 writel(0, DGT_ENABLE);
76
77 ticks_per_sec = 19200000; /* Uses CXO (19.2 MHz) */
78}
79
80/* Returns timer ticks per sec */
81uint32_t platform_tick_rate(void)
82{
83 return ticks_per_sec;
84}