power: qpnp-bms: Implement RDS resistance reading
Up until now, qpnp-bms did not actually support using internal
rsense. When configured to use internal rsense, the BMS driver would
simply use the external rsense value provided in place of the RDS
resistance.
Implement reading the RDS resistance from the IADC at BMS probe time,
and save it as the canonical rsense resistance value. Also, expose
the IADC function qpnp_iadc_get_rsense to facilitate reading the iadc
rsense trim registers.
Change-Id: Iab0834e6228c0263cd055bdf6ac5c2561a375a85
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
diff --git a/include/linux/qpnp/qpnp-adc.h b/include/linux/qpnp/qpnp-adc.h
index 3ab7b9d..903cc3f 100644
--- a/include/linux/qpnp/qpnp-adc.h
+++ b/include/linux/qpnp/qpnp-adc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -1228,6 +1228,12 @@
int32_t qpnp_iadc_read(enum qpnp_iadc_channels channel,
struct qpnp_iadc_result *result);
/**
+ * qpnp_iadc_get_rsense() - Reads the RDS resistance value from the
+ trim registers.
+ * @rsense: RDS resistance in nOhms.
+ */
+int32_t qpnp_iadc_get_rsense(int32_t *rsense);
+/**
* qpnp_iadc_get_gain_and_offset() - Performs gain calibration
* over 17.8571mV and offset over selected
* channel. Channel can be internal rsense,
@@ -1314,6 +1320,8 @@
{ return -ENXIO; }
static inline int32_t qpnp_adc_tm_is_ready(void)
{ return -ENXIO; }
+static inline int32_t qpnp_iadc_get_rsense(int32_t *rsense)
+{ return -ENXIO; }
#endif
#endif