tps65090.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. struct tps65090 {
  26. struct device *dev;
  27. struct regmap *rmap;
  28. struct irq_chip irq_chip;
  29. struct mutex irq_lock;
  30. int irq_base;
  31. };
  32. struct tps65090_platform_data {
  33. int irq_base;
  34. };
  35. /*
  36. * NOTE: the functions below are not intended for use outside
  37. * of the TPS65090 sub-device drivers
  38. */
  39. static inline int tps65090_write(struct device *dev, int reg, uint8_t val)
  40. {
  41. struct tps65090 *tps = dev_get_drvdata(dev);
  42. return regmap_write(tps->rmap, reg, val);
  43. }
  44. static inline int tps65090_read(struct device *dev, int reg, uint8_t *val)
  45. {
  46. struct tps65090 *tps = dev_get_drvdata(dev);
  47. unsigned int temp_val;
  48. int ret;
  49. ret = regmap_read(tps->rmap, reg, &temp_val);
  50. if (!ret)
  51. *val = temp_val;
  52. return ret;
  53. }
  54. static inline int tps65090_set_bits(struct device *dev, int reg,
  55. uint8_t bit_num)
  56. {
  57. struct tps65090 *tps = dev_get_drvdata(dev);
  58. return regmap_update_bits(tps->rmap, reg, BIT(bit_num), ~0u);
  59. }
  60. static inline int tps65090_clr_bits(struct device *dev, int reg,
  61. uint8_t bit_num)
  62. {
  63. struct tps65090 *tps = dev_get_drvdata(dev);
  64. return regmap_update_bits(tps->rmap, reg, BIT(bit_num), 0u);
  65. }
  66. #endif /*__LINUX_MFD_TPS65090_H */