cps4038_cmfet.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * mfc_cmfet.h
  3. * Samsung Mobile MFC CMFET Header
  4. *
  5. * Copyright (C) 2023 Samsung Electronics, Inc.
  6. *
  7. *
  8. * This software is licensed under the terms of the GNU General Public
  9. * License version 2, as published by the Free Software Foundation, and
  10. * may be copied, distributed, and modified under those terms.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. */
  18. #ifndef __MFC_CMFET_H
  19. #define __MFC_CMFET_H __FILE__
  20. #include <linux/err.h>
  21. struct device;
  22. struct mfc_cmfet;
  23. union mfc_cmfet_state {
  24. unsigned long long value;
  25. struct {
  26. unsigned cma : 1,
  27. cmb : 1,
  28. resv : 6,
  29. tx_id : 8,
  30. vout : 16,
  31. bat_cap : 7,
  32. full : 1,
  33. chg_done : 1,
  34. high_swell : 1,
  35. auth : 1;
  36. };
  37. };
  38. typedef int (*mfc_set_cmfet)(struct device *dev, union mfc_cmfet_state *state, bool cma, bool cmb);
  39. #define MFC_CMFET_DISABLED (-ESRCH)
  40. #if IS_ENABLED(CONFIG_WIRELESS_CHARGING)
  41. struct mfc_cmfet *mfc_cmfet_init(struct device *dev, mfc_set_cmfet cb_func);
  42. int mfc_cmfet_init_state(struct mfc_cmfet *cmfet);
  43. int mfc_cmfet_refresh(struct mfc_cmfet *cmfet);
  44. int mfc_cmfet_set_tx_id(struct mfc_cmfet *cmfet, int tx_id);
  45. int mfc_cmfet_set_bat_cap(struct mfc_cmfet *cmfet, int bat_cap);
  46. int mfc_cmfet_set_vout(struct mfc_cmfet *cmfet, int vout);
  47. int mfc_cmfet_set_high_swell(struct mfc_cmfet *cmfet, bool state);
  48. int mfc_cmfet_set_full(struct mfc_cmfet *cmfet, bool full);
  49. int mfc_cmfet_set_chg_done(struct mfc_cmfet *cmfet, bool chg_done);
  50. int mfc_cmfet_set_auth(struct mfc_cmfet *cmfet, bool auth);
  51. int mfc_cmfet_get_state(struct mfc_cmfet *cmfet, union mfc_cmfet_state *state);
  52. #else
  53. static inline struct mfc_cmfet *mfc_cmfet_init(struct device *dev, mfc_set_cmfet cb_func)
  54. { return ERR_PTR(MFC_CMFET_DISABLED); }
  55. static inline int mfc_cmfet_init_state(struct mfc_cmfet *cmfet)
  56. { return MFC_CMFET_DISABLED; }
  57. static inline int mfc_cmfet_refresh(struct mfc_cmfet *cmfet)
  58. { return MFC_CMFET_DISABLED; }
  59. static inline int mfc_cmfet_set_tx_id(struct mfc_cmfet *cmfet, int tx_id)
  60. { return MFC_CMFET_DISABLED; }
  61. static inline int mfc_cmfet_set_bat_cap(struct mfc_cmfet *cmfet, int bat_cap)
  62. { return MFC_CMFET_DISABLED; }
  63. static inline int mfc_cmfet_set_vout(struct mfc_cmfet *cmfet, int vout)
  64. { return MFC_CMFET_DISABLED; }
  65. static inline int mfc_cmfet_set_high_swell(struct mfc_cmfet *cmfet, bool state)
  66. { return MFC_CMFET_DISABLED; }
  67. static inline int mfc_cmfet_set_full(struct mfc_cmfet *cmfet, bool full)
  68. { return MFC_CMFET_DISABLED; }
  69. static inline int mfc_cmfet_set_chg_done(struct mfc_cmfet *cmfet, bool chg_done)
  70. { return MFC_CMFET_DISABLED; }
  71. static inline int mfc_cmfet_set_auth(struct mfc_cmfet *cmfet, bool auth)
  72. { return MFC_CMFET_DISABLED; }
  73. static inline int mfc_cmfet_get_state(struct mfc_cmfet *cmfet, union mfc_cmfet_state *state)
  74. { return MFC_CMFET_DISABLED; }
  75. #endif
  76. #endif /* __MFC_CMFET_H */