Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* 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 Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 23 | static unsigned long acpuclk_9xxx_get_rate(int cpu) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 24 | { |
| 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 Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 39 | static struct acpuclk_data acpuclk_9xxx_data = { |
| 40 | .get_rate = acpuclk_9xxx_get_rate, |
| 41 | }; |
| 42 | |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame^] | 43 | static int __init acpuclk_9xxx_init(struct acpuclk_soc_data *soc_data) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 44 | { |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 45 | acpuclk_register(&acpuclk_9xxx_data); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 46 | pr_info("ACPU running at %lu KHz\n", acpuclk_get_rate(0)); |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 47 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 48 | } |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame^] | 49 | |
| 50 | struct acpuclk_soc_data acpuclk_9xxx_soc_data __initdata = { |
| 51 | .init = acpuclk_9xxx_init, |
| 52 | }; |