mc13xxx.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * mc13xxx.h - regulators for the Freescale mc13xxx PMIC
  4. *
  5. * Copyright (C) 2010 Yong Shen <yong.shen@linaro.org>
  6. */
  7. #ifndef __LINUX_REGULATOR_MC13XXX_H
  8. #define __LINUX_REGULATOR_MC13XXX_H
  9. #include <linux/regulator/driver.h>
  10. struct mc13xxx_regulator {
  11. struct regulator_desc desc;
  12. int reg;
  13. int enable_bit;
  14. int vsel_reg;
  15. int vsel_shift;
  16. int vsel_mask;
  17. };
  18. struct mc13xxx_regulator_priv {
  19. struct mc13xxx *mc13xxx;
  20. u32 powermisc_pwgt_state;
  21. struct mc13xxx_regulator *mc13xxx_regulators;
  22. int num_regulators;
  23. struct regulator_dev *regulators[];
  24. };
  25. extern int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev,
  26. int min_uV, int max_uV, unsigned *selector);
  27. #ifdef CONFIG_OF
  28. extern int mc13xxx_get_num_regulators_dt(struct platform_device *pdev);
  29. extern struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
  30. struct platform_device *pdev, struct mc13xxx_regulator *regulators,
  31. int num_regulators);
  32. #else
  33. static inline int mc13xxx_get_num_regulators_dt(struct platform_device *pdev)
  34. {
  35. return -ENODEV;
  36. }
  37. static inline struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
  38. struct platform_device *pdev, struct mc13xxx_regulator *regulators,
  39. int num_regulators)
  40. {
  41. return NULL;
  42. }
  43. #endif
  44. extern const struct regulator_ops mc13xxx_regulator_ops;
  45. extern const struct regulator_ops mc13xxx_fixed_regulator_ops;
  46. #define MC13xxx_DEFINE(prefix, _name, _node, _reg, _vsel_reg, _voltages, _ops) \
  47. [prefix ## _name] = { \
  48. .desc = { \
  49. .name = #_node, \
  50. .n_voltages = ARRAY_SIZE(_voltages), \
  51. .volt_table = _voltages, \
  52. .ops = &_ops, \
  53. .type = REGULATOR_VOLTAGE, \
  54. .id = prefix ## _name, \
  55. .owner = THIS_MODULE, \
  56. }, \
  57. .reg = prefix ## _reg, \
  58. .enable_bit = prefix ## _reg ## _ ## _name ## EN, \
  59. .vsel_reg = prefix ## _vsel_reg, \
  60. .vsel_shift = prefix ## _vsel_reg ## _ ## _name ## VSEL,\
  61. .vsel_mask = prefix ## _vsel_reg ## _ ## _name ## VSEL_M,\
  62. }
  63. #define MC13xxx_FIXED_DEFINE(prefix, _name, _node, _reg, _voltages, _ops) \
  64. [prefix ## _name] = { \
  65. .desc = { \
  66. .name = #_node, \
  67. .n_voltages = ARRAY_SIZE(_voltages), \
  68. .volt_table = _voltages, \
  69. .ops = &_ops, \
  70. .type = REGULATOR_VOLTAGE, \
  71. .id = prefix ## _name, \
  72. .owner = THIS_MODULE, \
  73. }, \
  74. .reg = prefix ## _reg, \
  75. .enable_bit = prefix ## _reg ## _ ## _name ## EN, \
  76. }
  77. #define MC13xxx_GPO_DEFINE(prefix, _name, _node, _reg, _voltages, _ops) \
  78. [prefix ## _name] = { \
  79. .desc = { \
  80. .name = #_node, \
  81. .n_voltages = ARRAY_SIZE(_voltages), \
  82. .volt_table = _voltages, \
  83. .ops = &_ops, \
  84. .type = REGULATOR_VOLTAGE, \
  85. .id = prefix ## _name, \
  86. .owner = THIS_MODULE, \
  87. }, \
  88. .reg = prefix ## _reg, \
  89. .enable_bit = prefix ## _reg ## _ ## _name ## EN, \
  90. }
  91. #define MC13xxx_DEFINE_SW(_name, _node, _reg, _vsel_reg, _voltages, ops) \
  92. MC13xxx_DEFINE(SW, _name, _node, _reg, _vsel_reg, _voltages, ops)
  93. #define MC13xxx_DEFINE_REGU(_name, _node, _reg, _vsel_reg, _voltages, ops) \
  94. MC13xxx_DEFINE(REGU, _name, _node, _reg, _vsel_reg, _voltages, ops)
  95. #endif