qg-util.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __QG_UTIL_H__
  7. #define __QG_UTIL_H__
  8. #define MAX_STEP_CHG_ENTRIES 8
  9. int qg_read(struct qpnp_qg *chip, u32 addr, u8 *val, int len);
  10. int qg_write(struct qpnp_qg *chip, u32 addr, u8 *val, int len);
  11. int qg_masked_write(struct qpnp_qg *chip, int addr, u32 mask, u32 val);
  12. int qg_read_raw_data(struct qpnp_qg *chip, int addr, u32 *data);
  13. int get_fifo_length(struct qpnp_qg *chip, u32 *fifo_length, bool rt);
  14. int get_sample_count(struct qpnp_qg *chip, u32 *sample_count);
  15. int get_sample_interval(struct qpnp_qg *chip, u32 *sample_interval);
  16. int get_fifo_done_time(struct qpnp_qg *chip, bool rt, int *time_ms);
  17. int get_rtc_time(unsigned long *rtc_time);
  18. bool is_usb_present(struct qpnp_qg *chip);
  19. bool is_dc_present(struct qpnp_qg *chip);
  20. bool is_input_present(struct qpnp_qg *chip);
  21. bool is_parallel_enabled(struct qpnp_qg *chip);
  22. bool is_cp_available(struct qpnp_qg *chip);
  23. bool is_parallel_available(struct qpnp_qg *chip);
  24. int qg_write_monotonic_soc(struct qpnp_qg *chip, int msoc);
  25. int qg_get_battery_temp(struct qpnp_qg *chip, int *batt_temp);
  26. int qg_get_battery_current(struct qpnp_qg *chip, int *ibat_ua);
  27. int qg_get_battery_voltage(struct qpnp_qg *chip, int *vbat_uv);
  28. int qg_get_vbat_avg(struct qpnp_qg *chip, int *vbat_uv);
  29. s64 qg_iraw_to_ua(struct qpnp_qg *chip, int iraw);
  30. int qg_get_ibat_avg(struct qpnp_qg *chip, int *ibat_ua);
  31. bool is_chan_valid(struct qpnp_qg *chip, enum qg_ext_iio_channels chan);
  32. int qg_read_iio_chan(struct qpnp_qg *chip,
  33. enum qg_ext_iio_channels chan, int *val);
  34. int qg_write_iio_chan(struct qpnp_qg *chip,
  35. enum qg_ext_iio_channels chan, int val);
  36. int qg_read_int_iio_chan(struct iio_channel *iio_chan_list, int chan_id,
  37. int *val);
  38. int qg_read_range_data_from_node(struct device_node *node,
  39. const char *prop_str, struct range_data *ranges,
  40. int max_threshold, u32 max_value);
  41. #endif