blob: af1c0eb8dc5d1b0c291972e969d9b99a1652804f [file] [log] [blame]
Matt Wagantallbf430eb2012-03-22 11:45:49 -07001/* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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>
Matt Wagantallbf430eb2012-03-22 11:45:49 -070014#include <linux/module.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070015#include <linux/init.h>
16#include <linux/io.h>
Matt Wagantallbf430eb2012-03-22 11:45:49 -070017#include <linux/platform_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018#include <mach/board.h>
19
20#include "acpuclock.h"
21
22/* Registers */
23#define PLL1_CTL_ADDR (MSM_CLK_CTL_BASE + 0x604)
24
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070025static unsigned long acpuclk_9xxx_get_rate(int cpu)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026{
27 unsigned int pll1_ctl;
28 unsigned int pll1_l, pll1_div2;
29 unsigned int pll1_khz;
30
31 pll1_ctl = readl_relaxed(PLL1_CTL_ADDR);
32 pll1_l = ((pll1_ctl >> 3) & 0x3f) * 2;
33 pll1_div2 = pll1_ctl & 0x20000;
34 pll1_khz = 19200 * pll1_l;
35 if (pll1_div2)
36 pll1_khz >>= 1;
37
38 return pll1_khz;
39}
40
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070041static struct acpuclk_data acpuclk_9xxx_data = {
42 .get_rate = acpuclk_9xxx_get_rate,
43};
44
Matt Wagantallbf430eb2012-03-22 11:45:49 -070045static int __init acpuclk_9xxx_probe(struct platform_device *pdev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046{
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070047 acpuclk_register(&acpuclk_9xxx_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070048 pr_info("ACPU running at %lu KHz\n", acpuclk_get_rate(0));
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070049 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070050}
Matt Wagantallec57f062011-08-16 23:54:46 -070051
Matt Wagantallbf430eb2012-03-22 11:45:49 -070052static struct platform_driver acpuclk_9xxx_driver = {
53 .driver = {
54 .name = "acpuclk-9xxx",
55 .owner = THIS_MODULE,
56 },
Matt Wagantallec57f062011-08-16 23:54:46 -070057};
Matt Wagantallbf430eb2012-03-22 11:45:49 -070058
59static int __init acpuclk_9xxx_init(void)
60{
61 return platform_driver_probe(&acpuclk_9xxx_driver, acpuclk_9xxx_probe);
62}
63device_initcall(acpuclk_9xxx_init);