vexpress-spc-cpufreq.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Versatile Express SPC CPUFreq Interface driver
  3. *
  4. * It provides necessary ops to arm_big_little cpufreq driver.
  5. *
  6. * Copyright (C) 2013 ARM Ltd.
  7. * Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  14. * kind, whether express or implied; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  19. #include <linux/cpufreq.h>
  20. #include <linux/module.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/pm_opp.h>
  23. #include <linux/types.h>
  24. #include "arm_big_little.h"
  25. static int ve_spc_init_opp_table(struct device *cpu_dev)
  26. {
  27. /*
  28. * platform specific SPC code must initialise the opp table
  29. * so just check if the OPP count is non-zero
  30. */
  31. return dev_pm_opp_get_opp_count(cpu_dev) <= 0;
  32. }
  33. static int ve_spc_get_transition_latency(struct device *cpu_dev)
  34. {
  35. return 1000000; /* 1 ms */
  36. }
  37. static struct cpufreq_arm_bL_ops ve_spc_cpufreq_ops = {
  38. .name = "vexpress-spc",
  39. .get_transition_latency = ve_spc_get_transition_latency,
  40. .init_opp_table = ve_spc_init_opp_table,
  41. };
  42. static int ve_spc_cpufreq_probe(struct platform_device *pdev)
  43. {
  44. return bL_cpufreq_register(&ve_spc_cpufreq_ops);
  45. }
  46. static int ve_spc_cpufreq_remove(struct platform_device *pdev)
  47. {
  48. bL_cpufreq_unregister(&ve_spc_cpufreq_ops);
  49. return 0;
  50. }
  51. static struct platform_driver ve_spc_cpufreq_platdrv = {
  52. .driver = {
  53. .name = "vexpress-spc-cpufreq",
  54. },
  55. .probe = ve_spc_cpufreq_probe,
  56. .remove = ve_spc_cpufreq_remove,
  57. };
  58. module_platform_driver(ve_spc_cpufreq_platdrv);
  59. MODULE_LICENSE("GPL");