blob: 3cdc58d48897248119ae2ea9a12230d7bd90a4cf [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/io.h>
16#include <mach/board.h>
17
18#include "acpuclock.h"
19
20/* Registers */
21#define PLL1_CTL_ADDR (MSM_CLK_CTL_BASE + 0x604)
22
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070023static unsigned long acpuclk_9xxx_get_rate(int cpu)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070024{
25 unsigned int pll1_ctl;
26 unsigned int pll1_l, pll1_div2;
27 unsigned int pll1_khz;
28
29 pll1_ctl = readl_relaxed(PLL1_CTL_ADDR);
30 pll1_l = ((pll1_ctl >> 3) & 0x3f) * 2;
31 pll1_div2 = pll1_ctl & 0x20000;
32 pll1_khz = 19200 * pll1_l;
33 if (pll1_div2)
34 pll1_khz >>= 1;
35
36 return pll1_khz;
37}
38
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070039static struct acpuclk_data acpuclk_9xxx_data = {
40 .get_rate = acpuclk_9xxx_get_rate,
41};
42
Matt Wagantallec57f062011-08-16 23:54:46 -070043static int __init acpuclk_9xxx_init(struct acpuclk_soc_data *soc_data)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070044{
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070045 acpuclk_register(&acpuclk_9xxx_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046 pr_info("ACPU running at %lu KHz\n", acpuclk_get_rate(0));
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070047 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070048}
Matt Wagantallec57f062011-08-16 23:54:46 -070049
50struct acpuclk_soc_data acpuclk_9xxx_soc_data __initdata = {
51 .init = acpuclk_9xxx_init,
52};