vexpress-spc-cpufreq.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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/cpu.h>
  20. #include <linux/cpufreq.h>
  21. #include <linux/module.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/pm_opp.h>
  24. #include <linux/types.h>
  25. #include "arm_big_little.h"
  26. static int ve_spc_init_opp_table(const struct cpumask *cpumask)
  27. {
  28. struct device *cpu_dev = get_cpu_device(cpumask_first(cpumask));
  29. /*
  30. * platform specific SPC code must initialise the opp table
  31. * so just check if the OPP count is non-zero
  32. */
  33. return dev_pm_opp_get_opp_count(cpu_dev) <= 0;
  34. }
  35. static int ve_spc_get_transition_latency(struct device *cpu_dev)
  36. {
  37. return 1000000; /* 1 ms */
  38. }
  39. static struct cpufreq_arm_bL_ops ve_spc_cpufreq_ops = {
  40. .name = "vexpress-spc",
  41. .get_transition_latency = ve_spc_get_transition_latency,
  42. .init_opp_table = ve_spc_init_opp_table,
  43. };
  44. static int ve_spc_cpufreq_probe(struct platform_device *pdev)
  45. {
  46. return bL_cpufreq_register(&ve_spc_cpufreq_ops);
  47. }
  48. static int ve_spc_cpufreq_remove(struct platform_device *pdev)
  49. {
  50. bL_cpufreq_unregister(&ve_spc_cpufreq_ops);
  51. return 0;
  52. }
  53. static struct platform_driver ve_spc_cpufreq_platdrv = {
  54. .driver = {
  55. .name = "vexpress-spc-cpufreq",
  56. },
  57. .probe = ve_spc_cpufreq_probe,
  58. .remove = ve_spc_cpufreq_remove,
  59. };
  60. module_platform_driver(ve_spc_cpufreq_platdrv);
  61. MODULE_LICENSE("GPL");