Ajay Dudani | 513fb74 | 2010-05-24 20:39:26 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2008, Google Inc. |
| 3 | * All rights reserved. |
Duy Truong | f3ac7b3 | 2013-02-13 01:07:28 -0800 | [diff] [blame] | 4 | * Copyright (c) 2009-2010, The Linux Foundation. All rights reserved. |
Ajay Dudani | 513fb74 | 2010-05-24 20:39:26 -0700 | [diff] [blame] | 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions |
| 8 | * are met: |
| 9 | * * Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * * Redistributions in binary form must reproduce the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer in |
| 13 | * the documentation and/or other materials provided with the |
| 14 | * distribution. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 20 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 23 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 24 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 25 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 26 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 27 | * SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #include <stdint.h> |
| 31 | #include <kernel/thread.h> |
| 32 | #include <platform/iomap.h> |
| 33 | #include <reg.h> |
| 34 | |
| 35 | #define A11S_CLK_CNTL 0xAC100100 |
| 36 | #define A11S_CLK_SEL 0xAC100104 |
| 37 | |
| 38 | #define SCPLL_CTL 0xA8800004 |
| 39 | #define SCPLL_CAL 0xA8800008 |
| 40 | #define SCPLL_CTLE 0xA8800024 |
| 41 | #define SCPLL_STAT 0xA8800010 |
| 42 | |
| 43 | void acpu_clock_init(void) |
| 44 | { |
| 45 | unsigned val; |
| 46 | |
| 47 | /* Go to standby */ |
| 48 | writel(0x2, SCPLL_CTL); |
| 49 | thread_sleep(100); |
| 50 | |
| 51 | /* Calibrate for 384-1497 MHz */ |
| 52 | writel(0x270A0000, SCPLL_CAL); |
| 53 | writel(0x4, SCPLL_CTL); |
| 54 | thread_sleep(10); |
| 55 | while(readl(SCPLL_STAT) & 0x2); |
| 56 | |
Bikas Gurung | 6197c86 | 2010-09-10 11:35:18 -0700 | [diff] [blame] | 57 | /* Shot-switch directly to 768MHz */ |
| 58 | writel(0x001400A4, SCPLL_CTLE); |
Ajay Dudani | 513fb74 | 2010-05-24 20:39:26 -0700 | [diff] [blame] | 59 | writel(0x7, SCPLL_CTL); |
| 60 | thread_sleep(10); |
| 61 | while(readl(SCPLL_STAT) & 0x3); |
| 62 | |
| 63 | val = readl(A11S_CLK_SEL); |
| 64 | val &= ~(0x3 << 1); |
| 65 | val |= (1 << 1); |
| 66 | writel(val, A11S_CLK_SEL); |
| 67 | } |
| 68 | |