driver.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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_dev;
  19. struct regulator_init_data;
  20. /**
  21. * struct regulator_ops - regulator operations.
  22. *
  23. * This struct describes regulator operations which can be implemented by
  24. * regulator chip drivers.
  25. *
  26. * @enable: Enable the regulator.
  27. * @disable: Disable the regulator.
  28. * @is_enabled: Return 1 if the regulator is enabled, 0 otherwise.
  29. *
  30. * @set_voltage: Set the voltage for the regulator within the range specified.
  31. * The driver should select the voltage closest to min_uV.
  32. * @get_voltage: Return the currently configured voltage for the regulator.
  33. *
  34. * @set_current_limit: Configure a limit for a current-limited regulator.
  35. * @get_current_limit: Get the limit for a current-limited regulator.
  36. *
  37. * @set_mode: Set the operating mode for the regulator.
  38. * @get_mode: Get the current operating mode for the regulator.
  39. * @get_optimum_mode: Get the most efficient operating mode for the regulator
  40. * when running with the specified parameters.
  41. *
  42. * @set_suspend_voltage: Set the voltage for the regulator when the system
  43. * is suspended.
  44. * @set_suspend_enable: Mark the regulator as enabled when the system is
  45. * suspended.
  46. * @set_suspend_disable: Mark the regulator as disabled when the system is
  47. * suspended.
  48. * @set_suspend_mode: Set the operating mode for the regulator when the
  49. * system is suspended.
  50. */
  51. struct regulator_ops {
  52. /* get/set regulator voltage */
  53. int (*set_voltage) (struct regulator_dev *, int min_uV, int max_uV);
  54. int (*get_voltage) (struct regulator_dev *);
  55. /* get/set regulator current */
  56. int (*set_current_limit) (struct regulator_dev *,
  57. int min_uA, int max_uA);
  58. int (*get_current_limit) (struct regulator_dev *);
  59. /* enable/disable regulator */
  60. int (*enable) (struct regulator_dev *);
  61. int (*disable) (struct regulator_dev *);
  62. int (*is_enabled) (struct regulator_dev *);
  63. /* get/set regulator operating mode (defined in regulator.h) */
  64. int (*set_mode) (struct regulator_dev *, unsigned int mode);
  65. unsigned int (*get_mode) (struct regulator_dev *);
  66. /* get most efficient regulator operating mode for load */
  67. unsigned int (*get_optimum_mode) (struct regulator_dev *, int input_uV,
  68. int output_uV, int load_uA);
  69. /* the operations below are for configuration of regulator state when
  70. * its parent PMIC enters a global STANDBY/HIBERNATE state */
  71. /* set regulator suspend voltage */
  72. int (*set_suspend_voltage) (struct regulator_dev *, int uV);
  73. /* enable/disable regulator in suspend state */
  74. int (*set_suspend_enable) (struct regulator_dev *);
  75. int (*set_suspend_disable) (struct regulator_dev *);
  76. /* set regulator suspend operating mode (defined in regulator.h) */
  77. int (*set_suspend_mode) (struct regulator_dev *, unsigned int mode);
  78. };
  79. /*
  80. * Regulators can either control voltage or current.
  81. */
  82. enum regulator_type {
  83. REGULATOR_VOLTAGE,
  84. REGULATOR_CURRENT,
  85. };
  86. /**
  87. * struct regulator_desc - Regulator descriptor
  88. *
  89. * Each regulator registered with the core is described with a structure of
  90. * this type.
  91. *
  92. * @name: Identifying name for the regulator.
  93. * @id: Numerical identifier for the regulator.
  94. * @ops: Regulator operations table.
  95. * @irq: Interrupt number for the regulator.
  96. * @type: Indicates if the regulator is a voltage or current regulator.
  97. * @owner: Module providing the regulator, used for refcounting.
  98. */
  99. struct regulator_desc {
  100. const char *name;
  101. int id;
  102. struct regulator_ops *ops;
  103. int irq;
  104. enum regulator_type type;
  105. struct module *owner;
  106. };
  107. struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
  108. struct device *dev, void *driver_data);
  109. void regulator_unregister(struct regulator_dev *rdev);
  110. int regulator_notifier_call_chain(struct regulator_dev *rdev,
  111. unsigned long event, void *data);
  112. void *rdev_get_drvdata(struct regulator_dev *rdev);
  113. struct device *rdev_get_dev(struct regulator_dev *rdev);
  114. int rdev_get_id(struct regulator_dev *rdev);
  115. void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);
  116. #endif