hwmon: epm_adc: Update timestamp commands

Provide a seperate ioctl interface for obtaining and
setting the PSOC timestamp. Currently we rely on the
clients to set the get/set timestamp command within
the PSOC request command. Unlike other commands
which are obvious, this particular command relies
on the clients. Therefore seperate the command
so that it is obvious and a cleaner approach.

Change-Id: I71915a3e58751cf7c0a961b062c7c06948658e09
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
hwmon: epm_adc: Fix clear buffer command

Currently when clients request to clear the PSOC buffer
the result returned to the user is not valid. This is
because the response byte that indicates the status
of the PSOC is the second byte and not the third.
Fix it by reading the appropriate byte to indicate
the status of the command request.

Change-Id: I1604274619bb881ecc2e0afc46979ae4eb85a154
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
hwmon: qpnp-adc-current: Fix setting external rsense

The iadc compensation uses the external/internal rsense
as one of the parameters for compensating the values
for current. Currently it defaults to internal rsense.
Fix this by updating the compensation rsense parameter
based on the inputs from the DT whether its internal
or external rsense.

Change-Id: Id931e20915967f410b16174eb2484377fbc858f3
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
hwmon: qpnp-current: Update offset channel selection based on rsense

Use the appropriate offset channel based on whether
the rsense is external or internal.

Change-Id: I573571653c6cee41fa396a2fd123641cdcf085d6
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
hwmon: epm_adc: Add gpio buffer commands

Add support to set requests to monitor gpio commands
such as markers and supported PSOC gpio functionality.

Change-Id: I4be00b4330f68e683912412bcf84dd801997eafc
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
hwmon: epm_adc: Add pause and unpause commands

Pause/unpause commands can be issued when clients want
to use buffered averaging and would like to pause the
psoc from filling the buffer with samples to avoid
overflow.

Change-Id: I60c184a62d432a41960c6f76d7356667f35bdf92
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
hwmon: qpnp-current: specify batfet status while calibrating

For internal Rsense or external Rsense, when current is requested by
BMS while battery fet (BATFET) is open, IADC switches to channel 5
even though channel 0 or channel 1 was requested. This is done so that
it returns the same value as offset calibration would have returned
resulting in 0mA of current.

This is okay for external Rsense since offset calibrations are done on
channel 5 which measures across same pins as those used for current
readings.

However this results in incorrect offset values for internal Rsense
because the offset calibrations happens on channel 6 which uses
different pins than channel 5.

Update the code to specify whether a calibration is being requested
while the battery fet is open. If it is open then use channel 5 for offset
calculations even when internal Rsense is used.

Change-Id: I1b36ea1d5dd078b177d6c5a92d7c49e8402c36dc
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>