cps4038_fod.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * mfc_fod.h
  3. * Samsung Mobile MFC FOD 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_FOD_H
  19. #define __MFC_FOD_H __FILE__
  20. #include <linux/err.h>
  21. struct device;
  22. struct mfc_fod;
  23. #define MFC_FOD_MAX_SIZE 256
  24. enum {
  25. MFC_FOD_BAT_STATE_CC = 0,
  26. MFC_FOD_BAT_STATE_CV,
  27. MFC_FOD_BAT_STATE_FULL,
  28. MFC_FOD_BAT_STATE_MAX
  29. };
  30. union mfc_fod_state {
  31. unsigned long long value;
  32. struct {
  33. unsigned tx_id : 8,
  34. vendor_id : 8,
  35. op_mode : 8,
  36. fake_op_mode : 8,
  37. bat_state : 8,
  38. bat_cap : 7,
  39. high_swell : 1,
  40. vout : 16;
  41. };
  42. };
  43. typedef unsigned int fod_data_t;
  44. typedef int (*mfc_set_fod)(struct device *dev, union mfc_fod_state *state, fod_data_t *data);
  45. enum {
  46. MFC_FOD_EXT_EPP_REF_QF = 0,
  47. MFC_FOD_EXT_EPP_REF_RF,
  48. MFC_FOD_EXT_MAX
  49. };
  50. #define MFC_FOD_DISABLED (-ESRCH)
  51. #if IS_ENABLED(CONFIG_WIRELESS_CHARGING)
  52. struct mfc_fod *mfc_fod_init(struct device *dev, unsigned int fod_size, mfc_set_fod cb_func);
  53. int mfc_fod_init_state(struct mfc_fod *fod);
  54. int mfc_fod_refresh(struct mfc_fod *fod);
  55. int mfc_fod_set_op_mode(struct mfc_fod *fod, int op_mode);
  56. int mfc_fod_set_vendor_id(struct mfc_fod *fod, int vendor_id);
  57. int mfc_fod_set_tx_id(struct mfc_fod *fod, int tx_id);
  58. int mfc_fod_set_bat_state(struct mfc_fod *fod, int bat_state);
  59. int mfc_fod_set_bat_cap(struct mfc_fod *fod, int bat_cap);
  60. int mfc_fod_set_vout(struct mfc_fod *fod, int vout);
  61. int mfc_fod_set_high_swell(struct mfc_fod *fod, bool state);
  62. int mfc_fod_get_state(struct mfc_fod *fod, union mfc_fod_state *state);
  63. int mfc_fod_get_ext(struct mfc_fod *fod, int ext_type, int *data);
  64. #else
  65. static inline struct mfc_fod *mfc_fod_init(struct device *dev, unsigned int fod_size, mfc_set_fod cb_func)
  66. { return ERR_PTR(MFC_FOD_DISABLED); }
  67. static inline int mfc_fod_init_state(struct mfc_fod *fod)
  68. { return MFC_FOD_DISABLED; }
  69. static inline int mfc_fod_refresh(struct mfc_fod *fod)
  70. { return MFC_FOD_DISABLED; }
  71. static inline int mfc_fod_set_op_mode(struct mfc_fod *fod, int op_mode)
  72. { return MFC_FOD_DISABLED; }
  73. static inline int mfc_fod_set_vendor_id(struct mfc_fod *fod, int vendor_id)
  74. { return MFC_FOD_DISABLED; }
  75. static inline int mfc_fod_set_tx_id(struct mfc_fod *fod, int tx_id)
  76. { return MFC_FOD_DISABLED; }
  77. static inline int mfc_fod_set_bat_state(struct mfc_fod *fod, int bat_state)
  78. { return MFC_FOD_DISABLED; }
  79. static inline int mfc_fod_set_bat_cap(struct mfc_fod *fod, int bat_cap)
  80. { return MFC_FOD_DISABLED; }
  81. static inline int mfc_fod_set_vout(struct mfc_fod *fod, int vout)
  82. { return MFC_FOD_DISABLED; }
  83. static inline int mfc_fod_set_high_swell(struct mfc_fod *fod, bool state)
  84. { return MFC_FOD_DISABLED; }
  85. static inline int mfc_fod_get_state(struct mfc_fod *fod, union mfc_fod_state *state)
  86. { return MFC_FOD_DISABLED; }
  87. static inline int mfc_fod_get_ext(struct mfc_fod *fod, int ext_type, int *data)
  88. { return MFC_FOD_DISABLED; }
  89. #endif
  90. #endif /* __MFC_FOD_H */