smartreflex-class3.c 1.3 KB

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