blob: d05b28e209580562cce9e4c565821fa2e40601fe [file] [log] [blame]
Kinson Chik18e36332011-08-15 10:07:28 -07001/*
2 * Copyright (c) 2008, Google Inc.
3 * All rights reserved.
4 *
Duy Truongf3ac7b32013-02-13 01:07:28 -08005 * Copyright (c) 2009-2011, The Linux Foundation. All rights reserved.
Kinson Chik18e36332011-08-15 10:07:28 -07006 *
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;
Amol Jadia63aaff2012-02-01 15:51:50 -080052 uint8_t gsbi_id = target_uart_gsbi();
Kinson Chik18e36332011-08-15 10:07:28 -070053
Amol Jadia63aaff2012-02-01 15:51:50 -080054 uart_dm_init(gsbi_id, GSBI_BASE(gsbi_id), GSBI_UART_DM_BASE(gsbi_id));
55
Kinson Chik18e36332011-08-15 10:07:28 -070056 /* Timers - QGIC Config */
57 writel((cfg_bid << 7 | cfg_pid << 10), APCS_GLB_QGIC_CFG);
58 qgic_init();
59 platform_init_timer();
60}
61
62void platform_init(void)
63{
64 dprintf(INFO, "platform_init()\n");
65 acpu_clock_init();
66}
67
68void platform_uninit(void)
69{
70 platform_uninit_timer();
71}
72
73/* Initialize DGT timer */
74void platform_init_timer(void)
75{
76 /* disable timer */
77 writel(0, DGT_ENABLE);
78
79 ticks_per_sec = 19200000; /* Uses CXO (19.2 MHz) */
80}
81
82/* Returns timer ticks per sec */
83uint32_t platform_tick_rate(void)
84{
85 return ticks_per_sec;
86}