tps65090.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Core driver interface for TI TPS65090 PMIC family
  3. *
  4. * Copyright (C) 2012 NVIDIA Corporation
  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. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. *
  20. */
  21. #ifndef __LINUX_MFD_TPS65090_H
  22. #define __LINUX_MFD_TPS65090_H
  23. #include <linux/irq.h>
  24. #include <linux/regmap.h>
  25. /* TPS65090 IRQs */
  26. enum {
  27. TPS65090_IRQ_INTERRUPT,
  28. TPS65090_IRQ_VAC_STATUS_CHANGE,
  29. TPS65090_IRQ_VSYS_STATUS_CHANGE,
  30. TPS65090_IRQ_BAT_STATUS_CHANGE,
  31. TPS65090_IRQ_CHARGING_STATUS_CHANGE,
  32. TPS65090_IRQ_CHARGING_COMPLETE,
  33. TPS65090_IRQ_OVERLOAD_DCDC1,
  34. TPS65090_IRQ_OVERLOAD_DCDC2,
  35. TPS65090_IRQ_OVERLOAD_DCDC3,
  36. TPS65090_IRQ_OVERLOAD_FET1,
  37. TPS65090_IRQ_OVERLOAD_FET2,
  38. TPS65090_IRQ_OVERLOAD_FET3,
  39. TPS65090_IRQ_OVERLOAD_FET4,
  40. TPS65090_IRQ_OVERLOAD_FET5,
  41. TPS65090_IRQ_OVERLOAD_FET6,
  42. TPS65090_IRQ_OVERLOAD_FET7,
  43. };
  44. /* TPS65090 Regulator ID */
  45. enum {
  46. TPS65090_REGULATOR_DCDC1,
  47. TPS65090_REGULATOR_DCDC2,
  48. TPS65090_REGULATOR_DCDC3,
  49. TPS65090_REGULATOR_FET1,
  50. TPS65090_REGULATOR_FET2,
  51. TPS65090_REGULATOR_FET3,
  52. TPS65090_REGULATOR_FET4,
  53. TPS65090_REGULATOR_FET5,
  54. TPS65090_REGULATOR_FET6,
  55. TPS65090_REGULATOR_FET7,
  56. TPS65090_REGULATOR_LDO1,
  57. TPS65090_REGULATOR_LDO2,
  58. /* Last entry for maximum ID */
  59. TPS65090_REGULATOR_MAX,
  60. };
  61. struct tps65090 {
  62. struct device *dev;
  63. struct regmap *rmap;
  64. struct regmap_irq_chip_data *irq_data;
  65. };
  66. /*
  67. * struct tps65090_regulator_plat_data
  68. *
  69. * @reg_init_data: The regulator init data.
  70. * @enable_ext_control: Enable extrenal control or not. Only available for
  71. * DCDC1, DCDC2 and DCDC3.
  72. * @gpio: Gpio number if external control is enabled and controlled through
  73. * gpio.
  74. */
  75. struct tps65090_regulator_plat_data {
  76. struct regulator_init_data *reg_init_data;
  77. bool enable_ext_control;
  78. int gpio;
  79. };
  80. struct tps65090_platform_data {
  81. int irq_base;
  82. char **supplied_to;
  83. size_t num_supplicants;
  84. int enable_low_current_chrg;
  85. struct tps65090_regulator_plat_data *reg_pdata[TPS65090_REGULATOR_MAX];
  86. };
  87. /*
  88. * NOTE: the functions below are not intended for use outside
  89. * of the TPS65090 sub-device drivers
  90. */
  91. static inline int tps65090_write(struct device *dev, int reg, uint8_t val)
  92. {
  93. struct tps65090 *tps = dev_get_drvdata(dev);
  94. return regmap_write(tps->rmap, reg, val);
  95. }
  96. static inline int tps65090_read(struct device *dev, int reg, uint8_t *val)
  97. {
  98. struct tps65090 *tps = dev_get_drvdata(dev);
  99. unsigned int temp_val;
  100. int ret;
  101. ret = regmap_read(tps->rmap, reg, &temp_val);
  102. if (!ret)
  103. *val = temp_val;
  104. return ret;
  105. }
  106. static inline int tps65090_set_bits(struct device *dev, int reg,
  107. uint8_t bit_num)
  108. {
  109. struct tps65090 *tps = dev_get_drvdata(dev);
  110. return regmap_update_bits(tps->rmap, reg, BIT(bit_num), ~0u);
  111. }
  112. static inline int tps65090_clr_bits(struct device *dev, int reg,
  113. uint8_t bit_num)
  114. {
  115. struct tps65090 *tps = dev_get_drvdata(dev);
  116. return regmap_update_bits(tps->rmap, reg, BIT(bit_num), 0u);
  117. }
  118. #endif /*__LINUX_MFD_TPS65090_H */