Deepa Dinamani | 7d6c897 | 2011-12-14 15:16:56 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * * Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in |
| 11 | * the documentation and/or other materials provided with the |
| 12 | * distribution. |
| 13 | * * Neither the name of Google, Inc. nor the names of its contributors |
| 14 | * may be used to endorse or promote products derived from this |
| 15 | * software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 20 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 21 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 24 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 25 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 27 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 28 | * SUCH DAMAGE. |
| 29 | */ |
| 30 | |
| 31 | #include <debug.h> |
| 32 | #include <reg.h> |
| 33 | #include <platform/iomap.h> |
| 34 | #include <qgic.h> |
| 35 | |
| 36 | static void platform_init_timer(void); |
| 37 | |
| 38 | static uint32_t ticks_per_sec = 0; |
| 39 | |
| 40 | #define MB (1024*1024) |
| 41 | |
| 42 | void platform_early_init(void) |
| 43 | { |
| 44 | qgic_init(); |
| 45 | platform_init_timer(); |
| 46 | } |
| 47 | |
| 48 | void platform_init(void) |
| 49 | { |
| 50 | dprintf(INFO, "platform_init()\n"); |
| 51 | } |
| 52 | |
| 53 | void platform_uninit(void) |
| 54 | { |
| 55 | } |
| 56 | |
| 57 | /* Initialize Qtimer */ |
| 58 | static void platform_init_timer(void) |
| 59 | { |
| 60 | uint32_t freq; |
| 61 | |
| 62 | /* program the Global counter frequency to 19.2 MHz |
| 63 | * Currently, this is the only frequency allowed. |
| 64 | * and this routine is a no-op since the simulation |
| 65 | * has already set to this frequency. |
| 66 | */ |
| 67 | freq = (192*1000*100); |
| 68 | |
| 69 | __asm__("mcr p15, 0, %0, c14, c0, 0" : : "r" (freq)); |
| 70 | |
| 71 | ticks_per_sec = 192*1000*100; |
| 72 | } |
| 73 | |
| 74 | /* Returns timer ticks per sec */ |
| 75 | uint32_t platform_tick_rate(void) |
| 76 | { |
| 77 | return ticks_per_sec; |
| 78 | } |