internal.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * internal.h -- Voltage/Current Regulator framework internal code
  4. *
  5. * Copyright 2007, 2008 Wolfson Microelectronics PLC.
  6. * Copyright 2008 SlimLogic Ltd.
  7. *
  8. * Author: Liam Girdwood <lrg@slimlogic.co.uk>
  9. */
  10. #ifndef __REGULATOR_INTERNAL_H
  11. #define __REGULATOR_INTERNAL_H
  12. #include <linux/suspend.h>
  13. #define REGULATOR_STATES_NUM (PM_SUSPEND_MAX + 1)
  14. struct regulator_voltage {
  15. int min_uV;
  16. int max_uV;
  17. };
  18. /*
  19. * struct regulator
  20. *
  21. * One for each consumer device.
  22. * @voltage - a voltage array for each state of runtime, i.e.:
  23. * PM_SUSPEND_ON
  24. * PM_SUSPEND_TO_IDLE
  25. * PM_SUSPEND_STANDBY
  26. * PM_SUSPEND_MEM
  27. * PM_SUSPEND_MAX
  28. */
  29. struct regulator {
  30. struct device *dev;
  31. struct list_head list;
  32. unsigned int always_on:1;
  33. unsigned int bypass:1;
  34. unsigned int device_link:1;
  35. int uA_load;
  36. unsigned int enable_count;
  37. unsigned int deferred_disables;
  38. struct regulator_voltage voltage[REGULATOR_STATES_NUM];
  39. const char *supply_name;
  40. struct device_attribute dev_attr;
  41. struct regulator_dev *rdev;
  42. struct dentry *debugfs;
  43. };
  44. extern struct class regulator_class;
  45. static inline struct regulator_dev *dev_to_rdev(struct device *dev)
  46. {
  47. return container_of(dev, struct regulator_dev, dev);
  48. }
  49. #ifdef CONFIG_OF
  50. struct regulator_dev *of_find_regulator_by_node(struct device_node *np);
  51. struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
  52. const struct regulator_desc *desc,
  53. struct regulator_config *config,
  54. struct device_node **node);
  55. struct regulator_dev *of_parse_coupled_regulator(struct regulator_dev *rdev,
  56. int index);
  57. int of_get_n_coupled(struct regulator_dev *rdev);
  58. bool of_check_coupling_data(struct regulator_dev *rdev);
  59. #else
  60. static inline struct regulator_dev *
  61. of_find_regulator_by_node(struct device_node *np)
  62. {
  63. return NULL;
  64. }
  65. static inline struct regulator_init_data *
  66. regulator_of_get_init_data(struct device *dev,
  67. const struct regulator_desc *desc,
  68. struct regulator_config *config,
  69. struct device_node **node)
  70. {
  71. return NULL;
  72. }
  73. static inline struct regulator_dev *
  74. of_parse_coupled_regulator(struct regulator_dev *rdev,
  75. int index)
  76. {
  77. return NULL;
  78. }
  79. static inline int of_get_n_coupled(struct regulator_dev *rdev)
  80. {
  81. return 0;
  82. }
  83. static inline bool of_check_coupling_data(struct regulator_dev *rdev)
  84. {
  85. return false;
  86. }
  87. #endif
  88. enum regulator_get_type {
  89. NORMAL_GET,
  90. EXCLUSIVE_GET,
  91. OPTIONAL_GET,
  92. MAX_GET_TYPE
  93. };
  94. struct regulator *_regulator_get(struct device *dev, const char *id,
  95. enum regulator_get_type get_type);
  96. #endif