mc13xxx.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * mc13xxx.h - regulators for the Freescale mc13xxx PMIC
  3. *
  4. * Copyright (C) 2010 Yong Shen <yong.shen@linaro.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #ifndef __LINUX_REGULATOR_MC13XXX_H
  12. #define __LINUX_REGULATOR_MC13XXX_H
  13. #include <linux/regulator/driver.h>
  14. struct mc13xxx_regulator {
  15. struct regulator_desc desc;
  16. int reg;
  17. int enable_bit;
  18. int vsel_reg;
  19. int vsel_shift;
  20. int vsel_mask;
  21. int hi_bit;
  22. int const *voltages;
  23. };
  24. struct mc13xxx_regulator_priv {
  25. struct mc13xxx *mc13xxx;
  26. u32 powermisc_pwgt_state;
  27. struct mc13xxx_regulator *mc13xxx_regulators;
  28. struct regulator_dev *regulators[];
  29. };
  30. extern int mc13xxx_sw_regulator(struct regulator_dev *rdev);
  31. extern int mc13xxx_sw_regulator_is_enabled(struct regulator_dev *rdev);
  32. extern int mc13xxx_get_best_voltage_index(struct regulator_dev *rdev,
  33. int min_uV, int max_uV);
  34. extern int mc13xxx_regulator_list_voltage(struct regulator_dev *rdev,
  35. unsigned selector);
  36. extern int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev,
  37. int min_uV, int max_uV, unsigned *selector);
  38. extern int mc13xxx_fixed_regulator_get_voltage(struct regulator_dev *rdev);
  39. extern struct regulator_ops mc13xxx_regulator_ops;
  40. extern struct regulator_ops mc13xxx_fixed_regulator_ops;
  41. #define MC13xxx_DEFINE(prefix, _name, _reg, _vsel_reg, _voltages, _ops) \
  42. [prefix ## _name] = { \
  43. .desc = { \
  44. .name = #prefix "_" #_name, \
  45. .n_voltages = ARRAY_SIZE(_voltages), \
  46. .ops = &_ops, \
  47. .type = REGULATOR_VOLTAGE, \
  48. .id = prefix ## _name, \
  49. .owner = THIS_MODULE, \
  50. }, \
  51. .reg = prefix ## _reg, \
  52. .enable_bit = prefix ## _reg ## _ ## _name ## EN, \
  53. .vsel_reg = prefix ## _vsel_reg, \
  54. .vsel_shift = prefix ## _vsel_reg ## _ ## _name ## VSEL,\
  55. .vsel_mask = prefix ## _vsel_reg ## _ ## _name ## VSEL_M,\
  56. .voltages = _voltages, \
  57. }
  58. #define MC13xxx_FIXED_DEFINE(prefix, _name, _reg, _voltages, _ops) \
  59. [prefix ## _name] = { \
  60. .desc = { \
  61. .name = #prefix "_" #_name, \
  62. .n_voltages = ARRAY_SIZE(_voltages), \
  63. .ops = &_ops, \
  64. .type = REGULATOR_VOLTAGE, \
  65. .id = prefix ## _name, \
  66. .owner = THIS_MODULE, \
  67. }, \
  68. .reg = prefix ## _reg, \
  69. .enable_bit = prefix ## _reg ## _ ## _name ## EN, \
  70. .voltages = _voltages, \
  71. }
  72. #define MC13xxx_GPO_DEFINE(prefix, _name, _reg, _voltages, _ops) \
  73. [prefix ## _name] = { \
  74. .desc = { \
  75. .name = #prefix "_" #_name, \
  76. .n_voltages = ARRAY_SIZE(_voltages), \
  77. .ops = &_ops, \
  78. .type = REGULATOR_VOLTAGE, \
  79. .id = prefix ## _name, \
  80. .owner = THIS_MODULE, \
  81. }, \
  82. .reg = prefix ## _reg, \
  83. .enable_bit = prefix ## _reg ## _ ## _name ## EN, \
  84. .voltages = _voltages, \
  85. }
  86. #define MC13xxx_DEFINE_SW(_name, _reg, _vsel_reg, _voltages, ops) \
  87. MC13xxx_DEFINE(SW, _name, _reg, _vsel_reg, _voltages, ops)
  88. #define MC13xxx_DEFINE_REGU(_name, _reg, _vsel_reg, _voltages, ops) \
  89. MC13xxx_DEFINE(REGU, _name, _reg, _vsel_reg, _voltages, ops)
  90. #endif