smartreflex-class3.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 "soc.h"
  15. #include "voltage.h"
  16. static int sr_class3_enable(struct omap_sr *sr)
  17. {
  18. unsigned long volt = voltdm_get_voltage(sr->voltdm);
  19. if (!volt) {
  20. pr_warn("%s: Curr voltage unknown. Cannot enable %s\n",
  21. __func__, sr->name);
  22. return -ENODATA;
  23. }
  24. omap_vp_enable(sr->voltdm);
  25. return sr_enable(sr, volt);
  26. }
  27. static int sr_class3_disable(struct omap_sr *sr, int is_volt_reset)
  28. {
  29. sr_disable_errgen(sr);
  30. omap_vp_disable(sr->voltdm);
  31. sr_disable(sr);
  32. if (is_volt_reset)
  33. voltdm_reset(sr->voltdm);
  34. return 0;
  35. }
  36. static int sr_class3_configure(struct omap_sr *sr)
  37. {
  38. return sr_configure_errgen(sr);
  39. }
  40. /* SR class3 structure */
  41. static struct omap_sr_class_data class3_data = {
  42. .enable = sr_class3_enable,
  43. .disable = sr_class3_disable,
  44. .configure = sr_class3_configure,
  45. .class_type = SR_CLASS3,
  46. };
  47. /* Smartreflex Class3 init API to be called from board file */
  48. static int __init sr_class3_init(void)
  49. {
  50. pr_info("SmartReflex Class3 initialized\n");
  51. return sr_register_class(&class3_data);
  52. }
  53. omap_late_initcall(sr_class3_init);