acpuclock-fsm9xxx.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Copyright (c) 2010-2012, The Linux Foundation. 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/module.h>
  15. #include <linux/init.h>
  16. #include <linux/io.h>
  17. #include <linux/platform_device.h>
  18. #include <mach/board.h>
  19. #include "acpuclock.h"
  20. /* Registers */
  21. #define PLL1_CTL_ADDR (MSM_CLK_CTL_BASE + 0x604)
  22. static unsigned long acpuclk_9xxx_get_rate(int cpu)
  23. {
  24. unsigned int pll1_ctl;
  25. unsigned int pll1_l, pll1_div2;
  26. unsigned int pll1_khz;
  27. pll1_ctl = readl_relaxed(PLL1_CTL_ADDR);
  28. pll1_l = ((pll1_ctl >> 3) & 0x3f) * 2;
  29. pll1_div2 = pll1_ctl & 0x20000;
  30. pll1_khz = 19200 * pll1_l;
  31. if (pll1_div2)
  32. pll1_khz >>= 1;
  33. return pll1_khz;
  34. }
  35. static struct acpuclk_data acpuclk_9xxx_data = {
  36. .get_rate = acpuclk_9xxx_get_rate,
  37. };
  38. static int __init acpuclk_9xxx_probe(struct platform_device *pdev)
  39. {
  40. acpuclk_register(&acpuclk_9xxx_data);
  41. pr_info("ACPU running at %lu KHz\n", acpuclk_get_rate(0));
  42. return 0;
  43. }
  44. static struct platform_driver acpuclk_9xxx_driver = {
  45. .driver = {
  46. .name = "acpuclk-9xxx",
  47. .owner = THIS_MODULE,
  48. },
  49. };
  50. static int __init acpuclk_9xxx_init(void)
  51. {
  52. return platform_driver_probe(&acpuclk_9xxx_driver, acpuclk_9xxx_probe);
  53. }
  54. device_initcall(acpuclk_9xxx_init);