Ajay Dudani | 60b5b5d | 2009-11-25 15:48:42 -0800 | [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, The Linux Foundation. All rights reserved. |
Ajay Dudani | 60b5b5d | 2009-11-25 15:48:42 -0800 | [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_CTLE 0xA8800010 |
| 40 | #define SCPLL_STAT 0xA8800018 |
| 41 | |
| 42 | void acpu_clock_init(void) |
| 43 | { |
| 44 | unsigned val; |
| 45 | |
| 46 | /* Init Scorpion PLL */ |
| 47 | writel(0x0, SCPLL_CTL); |
| 48 | writel(0x00400002, SCPLL_CTL); |
| 49 | writel(0x00600004, SCPLL_CTL); |
Ajay Dudani | bf669d5 | 2010-07-08 13:21:23 -0700 | [diff] [blame] | 50 | thread_sleep(1); |
Ajay Dudani | 60b5b5d | 2009-11-25 15:48:42 -0800 | [diff] [blame] | 51 | while(readl(SCPLL_STAT) & 0x2); |
| 52 | writel(0x0, SCPLL_CTL); |
| 53 | |
| 54 | /* Enable pll */ |
| 55 | while(readl(SCPLL_STAT) & 0x1); |
| 56 | val = readl(SCPLL_CTL); |
| 57 | val &= ~(0x7); |
| 58 | val |= 0x2; |
| 59 | writel(val, SCPLL_CTL); |
Ajay Dudani | bf669d5 | 2010-07-08 13:21:23 -0700 | [diff] [blame] | 60 | thread_sleep(1); |
Ajay Dudani | 60b5b5d | 2009-11-25 15:48:42 -0800 | [diff] [blame] | 61 | val = readl(SCPLL_CTL); |
| 62 | val |= 0x7; |
| 63 | writel(val, SCPLL_CTL); |
Ajay Dudani | bf669d5 | 2010-07-08 13:21:23 -0700 | [diff] [blame] | 64 | thread_sleep(1); |
Ajay Dudani | 60b5b5d | 2009-11-25 15:48:42 -0800 | [diff] [blame] | 65 | |
| 66 | /* For Scorpion PLL, must first SHOT to 384MHz then HOP to 768MHz */ |
| 67 | |
| 68 | /* Set pll to 384 MHz */ |
| 69 | while(readl(SCPLL_STAT) & 0x3); |
| 70 | val = readl(SCPLL_CTLE); |
| 71 | val &= ~(0x3F << 3); |
| 72 | val |= (0xA << 3); |
| 73 | val &= ~(0x3 << 0); |
| 74 | val |= (4 << 0); // SHOT method |
| 75 | writel(val, SCPLL_CTLE); |
| 76 | writel(0x00600007, SCPLL_CTL); |
Ajay Dudani | bf669d5 | 2010-07-08 13:21:23 -0700 | [diff] [blame] | 77 | thread_sleep(1); |
Ajay Dudani | 60b5b5d | 2009-11-25 15:48:42 -0800 | [diff] [blame] | 78 | |
| 79 | /* HOP to 768MHz */ |
| 80 | while(readl(SCPLL_STAT) & 0x3); |
| 81 | val = readl(SCPLL_CTLE); |
| 82 | val &= ~(0x3F << 3); |
| 83 | val |= (0x14 << 3); // Use 0x1A instead of 0x14 for 998MHz |
| 84 | val &= ~(0x3 << 0); |
| 85 | val |= (5 << 0); // HOP method |
| 86 | writel(val, SCPLL_CTLE); |
| 87 | writel(0x00600007, SCPLL_CTL); |
Ajay Dudani | bf669d5 | 2010-07-08 13:21:23 -0700 | [diff] [blame] | 88 | thread_sleep(1); |
Ajay Dudani | 60b5b5d | 2009-11-25 15:48:42 -0800 | [diff] [blame] | 89 | |
| 90 | val = readl(A11S_CLK_SEL); |
| 91 | val &= ~(0x3 << 1); |
| 92 | val |= (1 << 1); |
| 93 | writel(val, A11S_CLK_SEL); |
| 94 | } |
| 95 | |