smartreflex-class3.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Smart reflex Class 3 specific implementations
  3. *
  4. * Author: Thara Gopinath <thara@ti.com>
  5. *
  6. * Copyright (C) 2010 Texas Instruments, Inc.
  7. * Thara Gopinath <thara@ti.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. #include <linux/power/smartreflex.h>
  14. #include "voltage.h"
  15. static int sr_class3_enable(struct omap_sr *sr)
  16. {
  17. unsigned long volt = voltdm_get_voltage(sr->voltdm);
  18. if (!volt) {
  19. pr_warning("%s: Curr voltage unknown. Cannot enable %s\n",
  20. __func__, sr->name);
  21. return -ENODATA;
  22. }
  23. omap_vp_enable(sr->voltdm);
  24. return sr_enable(sr->voltdm, volt);
  25. }
  26. static int sr_class3_disable(struct omap_sr *sr, int is_volt_reset)
  27. {
  28. sr_disable_errgen(sr->voltdm);
  29. omap_vp_disable(sr->voltdm);
  30. sr_disable(sr->voltdm);
  31. if (is_volt_reset)
  32. voltdm_reset(sr->voltdm);
  33. return 0;
  34. }
  35. static int sr_class3_configure(struct omap_sr *sr)
  36. {
  37. return sr_configure_errgen(sr->voltdm);
  38. }
  39. /* SR class3 structure */
  40. static struct omap_sr_class_data class3_data = {
  41. .enable = sr_class3_enable,
  42. .disable = sr_class3_disable,
  43. .configure = sr_class3_configure,
  44. .class_type = SR_CLASS3,
  45. };
  46. /* Smartreflex Class3 init API to be called from board file */
  47. static int __init sr_class3_init(void)
  48. {
  49. pr_info("SmartReflex Class3 initialized\n");
  50. return sr_register_class(&class3_data);
  51. }
  52. late_initcall(sr_class3_init);