internal.h 2.7 KB

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