core.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. /*
  14. * Qualcomm PMIC 8xxx driver header file
  15. *
  16. */
  17. #ifndef __MFD_PM8XXX_CORE_H
  18. #define __MFD_PM8XXX_CORE_H
  19. #include <linux/mfd/core.h>
  20. struct pm8xxx_drvdata {
  21. int (*pmic_readb) (const struct device *dev, u16 addr, u8 *val);
  22. int (*pmic_writeb) (const struct device *dev, u16 addr, u8 val);
  23. int (*pmic_read_buf) (const struct device *dev, u16 addr, u8 *buf,
  24. int n);
  25. int (*pmic_write_buf) (const struct device *dev, u16 addr, u8 *buf,
  26. int n);
  27. void *pm_chip_data;
  28. };
  29. static inline int pm8xxx_readb(const struct device *dev, u16 addr, u8 *val)
  30. {
  31. struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
  32. if (!dd)
  33. return -EINVAL;
  34. return dd->pmic_readb(dev, addr, val);
  35. }
  36. static inline int pm8xxx_writeb(const struct device *dev, u16 addr, u8 val)
  37. {
  38. struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
  39. if (!dd)
  40. return -EINVAL;
  41. return dd->pmic_writeb(dev, addr, val);
  42. }
  43. static inline int pm8xxx_read_buf(const struct device *dev, u16 addr, u8 *buf,
  44. int n)
  45. {
  46. struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
  47. if (!dd)
  48. return -EINVAL;
  49. return dd->pmic_read_buf(dev, addr, buf, n);
  50. }
  51. static inline int pm8xxx_write_buf(const struct device *dev, u16 addr, u8 *buf,
  52. int n)
  53. {
  54. struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
  55. if (!dd)
  56. return -EINVAL;
  57. return dd->pmic_write_buf(dev, addr, buf, n);
  58. }
  59. #endif