driver.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * driver.h -- SoC Regulator driver support.
  3. *
  4. * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC.
  5. *
  6. * Author: Liam Girdwood <lg@opensource.wolfsonmicro.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * Regulator Driver Interface.
  13. */
  14. #ifndef __LINUX_REGULATOR_DRIVER_H_
  15. #define __LINUX_REGULATOR_DRIVER_H_
  16. #include <linux/device.h>
  17. #include <linux/regulator/consumer.h>
  18. struct regulator_constraints;
  19. struct regulator_dev;
  20. /**
  21. * struct regulator_ops - regulator operations.
  22. *
  23. * This struct describes regulator operations.
  24. */
  25. struct regulator_ops {
  26. /* get/set regulator voltage */
  27. int (*set_voltage) (struct regulator_dev *, int min_uV, int max_uV);
  28. int (*get_voltage) (struct regulator_dev *);
  29. /* get/set regulator current */
  30. int (*set_current_limit) (struct regulator_dev *,
  31. int min_uA, int max_uA);
  32. int (*get_current_limit) (struct regulator_dev *);
  33. /* enable/disable regulator */
  34. int (*enable) (struct regulator_dev *);
  35. int (*disable) (struct regulator_dev *);
  36. int (*is_enabled) (struct regulator_dev *);
  37. /* get/set regulator operating mode (defined in regulator.h) */
  38. int (*set_mode) (struct regulator_dev *, unsigned int mode);
  39. unsigned int (*get_mode) (struct regulator_dev *);
  40. /* get most efficient regulator operating mode for load */
  41. unsigned int (*get_optimum_mode) (struct regulator_dev *, int input_uV,
  42. int output_uV, int load_uA);
  43. /* the operations below are for configuration of regulator state when
  44. * it's parent PMIC enters a global STANBY/HIBERNATE state */
  45. /* set regulator suspend voltage */
  46. int (*set_suspend_voltage) (struct regulator_dev *, int uV);
  47. /* enable/disable regulator in suspend state */
  48. int (*set_suspend_enable) (struct regulator_dev *);
  49. int (*set_suspend_disable) (struct regulator_dev *);
  50. /* set regulator suspend operating mode (defined in regulator.h) */
  51. int (*set_suspend_mode) (struct regulator_dev *, unsigned int mode);
  52. };
  53. /*
  54. * Regulators can either control voltage or current.
  55. */
  56. enum regulator_type {
  57. REGULATOR_VOLTAGE,
  58. REGULATOR_CURRENT,
  59. };
  60. /**
  61. * struct regulator_desc - Regulator descriptor
  62. *
  63. */
  64. struct regulator_desc {
  65. const char *name;
  66. int id;
  67. struct regulator_ops *ops;
  68. int irq;
  69. enum regulator_type type;
  70. struct module *owner;
  71. };
  72. struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
  73. void *reg_data);
  74. void regulator_unregister(struct regulator_dev *rdev);
  75. int regulator_notifier_call_chain(struct regulator_dev *rdev,
  76. unsigned long event, void *data);
  77. void *rdev_get_drvdata(struct regulator_dev *rdev);
  78. int rdev_get_id(struct regulator_dev *rdev);
  79. #endif