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