blob: 0ecb68f9e7fa3566ce25a7734dac16a981ade859 [file] [log] [blame]
Ajay Dudani60b5b5d2009-11-25 15:48:42 -08001/*
2 * Copyright (c) 2008, Google Inc.
3 * All rights reserved.
Duy Truongf3ac7b32013-02-13 01:07:28 -08004 * Copyright (c) 2009, The Linux Foundation. All rights reserved.
Ajay Dudani60b5b5d2009-11-25 15:48:42 -08005 *
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
42void 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 Dudanibf669d52010-07-08 13:21:23 -070050 thread_sleep(1);
Ajay Dudani60b5b5d2009-11-25 15:48:42 -080051 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 Dudanibf669d52010-07-08 13:21:23 -070060 thread_sleep(1);
Ajay Dudani60b5b5d2009-11-25 15:48:42 -080061 val = readl(SCPLL_CTL);
62 val |= 0x7;
63 writel(val, SCPLL_CTL);
Ajay Dudanibf669d52010-07-08 13:21:23 -070064 thread_sleep(1);
Ajay Dudani60b5b5d2009-11-25 15:48:42 -080065
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 Dudanibf669d52010-07-08 13:21:23 -070077 thread_sleep(1);
Ajay Dudani60b5b5d2009-11-25 15:48:42 -080078
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 Dudanibf669d52010-07-08 13:21:23 -070088 thread_sleep(1);
Ajay Dudani60b5b5d2009-11-25 15:48:42 -080089
90 val = readl(A11S_CLK_SEL);
91 val &= ~(0x3 << 1);
92 val |= (1 << 1);
93 writel(val, A11S_CLK_SEL);
94}
95