mc13xxx.h 3.3 KB

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