mc13xxx.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. };
  23. struct mc13xxx_regulator_priv {
  24. struct mc13xxx *mc13xxx;
  25. u32 powermisc_pwgt_state;
  26. struct mc13xxx_regulator *mc13xxx_regulators;
  27. int num_regulators;
  28. struct regulator_dev *regulators[];
  29. };
  30. extern int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev,
  31. int min_uV, int max_uV, unsigned *selector);
  32. extern int mc13xxx_fixed_regulator_get_voltage(struct regulator_dev *rdev);
  33. #ifdef CONFIG_OF
  34. extern int mc13xxx_get_num_regulators_dt(struct platform_device *pdev);
  35. extern struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
  36. struct platform_device *pdev, struct mc13xxx_regulator *regulators,
  37. int num_regulators);
  38. #else
  39. static inline int mc13xxx_get_num_regulators_dt(struct platform_device *pdev)
  40. {
  41. return -ENODEV;
  42. }
  43. static inline struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
  44. struct platform_device *pdev, struct mc13xxx_regulator *regulators,
  45. int num_regulators)
  46. {
  47. return NULL;
  48. }
  49. #endif
  50. extern struct regulator_ops mc13xxx_regulator_ops;
  51. extern struct regulator_ops mc13xxx_fixed_regulator_ops;
  52. #define MC13xxx_DEFINE(prefix, _name, _reg, _vsel_reg, _voltages, _ops) \
  53. [prefix ## _name] = { \
  54. .desc = { \
  55. .name = #_name, \
  56. .n_voltages = ARRAY_SIZE(_voltages), \
  57. .volt_table = _voltages, \
  58. .ops = &_ops, \
  59. .type = REGULATOR_VOLTAGE, \
  60. .id = prefix ## _name, \
  61. .owner = THIS_MODULE, \
  62. }, \
  63. .reg = prefix ## _reg, \
  64. .enable_bit = prefix ## _reg ## _ ## _name ## EN, \
  65. .vsel_reg = prefix ## _vsel_reg, \
  66. .vsel_shift = prefix ## _vsel_reg ## _ ## _name ## VSEL,\
  67. .vsel_mask = prefix ## _vsel_reg ## _ ## _name ## VSEL_M,\
  68. }
  69. #define MC13xxx_FIXED_DEFINE(prefix, _name, _reg, _voltages, _ops) \
  70. [prefix ## _name] = { \
  71. .desc = { \
  72. .name = #_name, \
  73. .n_voltages = ARRAY_SIZE(_voltages), \
  74. .volt_table = _voltages, \
  75. .ops = &_ops, \
  76. .type = REGULATOR_VOLTAGE, \
  77. .id = prefix ## _name, \
  78. .owner = THIS_MODULE, \
  79. }, \
  80. .reg = prefix ## _reg, \
  81. .enable_bit = prefix ## _reg ## _ ## _name ## EN, \
  82. }
  83. #define MC13xxx_GPO_DEFINE(prefix, _name, _reg, _voltages, _ops) \
  84. [prefix ## _name] = { \
  85. .desc = { \
  86. .name = #_name, \
  87. .n_voltages = ARRAY_SIZE(_voltages), \
  88. .volt_table = _voltages, \
  89. .ops = &_ops, \
  90. .type = REGULATOR_VOLTAGE, \
  91. .id = prefix ## _name, \
  92. .owner = THIS_MODULE, \
  93. }, \
  94. .reg = prefix ## _reg, \
  95. .enable_bit = prefix ## _reg ## _ ## _name ## EN, \
  96. }
  97. #define MC13xxx_DEFINE_SW(_name, _reg, _vsel_reg, _voltages, ops) \
  98. MC13xxx_DEFINE(SW, _name, _reg, _vsel_reg, _voltages, ops)
  99. #define MC13xxx_DEFINE_REGU(_name, _reg, _vsel_reg, _voltages, ops) \
  100. MC13xxx_DEFINE(REGU, _name, _reg, _vsel_reg, _voltages, ops)
  101. #endif