Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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> |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 14 | #include <linux/module.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 15 | #include <linux/init.h> |
| 16 | #include <linux/io.h> |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 17 | #include <linux/platform_device.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 18 | #include <mach/board.h> |
| 19 | |
| 20 | #include "acpuclock.h" |
| 21 | |
| 22 | /* Registers */ |
| 23 | #define PLL1_CTL_ADDR (MSM_CLK_CTL_BASE + 0x604) |
| 24 | |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 25 | static unsigned long acpuclk_9xxx_get_rate(int cpu) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 26 | { |
| 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 Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 41 | static struct acpuclk_data acpuclk_9xxx_data = { |
| 42 | .get_rate = acpuclk_9xxx_get_rate, |
| 43 | }; |
| 44 | |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 45 | static int __init acpuclk_9xxx_probe(struct platform_device *pdev) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 46 | { |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 47 | acpuclk_register(&acpuclk_9xxx_data); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 48 | pr_info("ACPU running at %lu KHz\n", acpuclk_get_rate(0)); |
Matt Wagantall | 6d9ebee | 2011-08-26 12:15:24 -0700 | [diff] [blame] | 49 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 50 | } |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 51 | |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 52 | static struct platform_driver acpuclk_9xxx_driver = { |
| 53 | .driver = { |
| 54 | .name = "acpuclk-9xxx", |
| 55 | .owner = THIS_MODULE, |
| 56 | }, |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 57 | }; |
Matt Wagantall | bf430eb | 2012-03-22 11:45:49 -0700 | [diff] [blame] | 58 | |
| 59 | static int __init acpuclk_9xxx_init(void) |
| 60 | { |
| 61 | return platform_driver_probe(&acpuclk_9xxx_driver, acpuclk_9xxx_probe); |
| 62 | } |
| 63 | device_initcall(acpuclk_9xxx_init); |