Currently __tm_handler_work() assumes that each element in chan_props[]
represents 1 SDAM register. However, chan_props[] has an element for every
ADC and ADC TM channel. Since every ADC channel shares the same SDAM
register the loop within __tm_handler_work() has incorrect conditions. Fix
this.
While at it, remove __tm_handler_work() which was invoked for every SDAM
as tm_handler_work() goes through all channels.
Change-Id: I5f3444ab831ff2067a1a53f49dea0c5dbbdc8758
Signed-off-by: Anjelique Melendez <quic_amelende@quicinc.com>
Add TEMP_ALARM_LITE channel mapping so that the proper scaling
function can be used with ADC code obtained after the conversion.
Change-Id: I4ad0564ba4e4bd3d8409e3923d4b0ad5f0395503
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
Add ADC5_GEN3_TEMP_ALARM_LITE channel id that can be read from
PM8550B PMIC. Also, update ADC5_GEN3_ICHG_SMB channel that
was using the same channel id before.
Change-Id: Ic8d69fc651abe73ab11a8086876d2d2dea686542
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
Currently adc5_gen3_probe() registers thermal zone devices and then
registers interrupt handlers. While registering the thermal zones the
ADC5 GEN3 TM get/set callbacks are called by thermal framework that relies
on interrupt completion. Since interrupts have not been registered the
callbacks will time out. Fix this and add error handling for thermal zone
registration.
Change-Id: I3ad94211f7831c94b0847fda549295ecfebcb90b
Signed-off-by: Anjelique Melendez <quic_amelende@quicinc.com>
Currently, when reading an ADC channel the SID is always configured to 0.
This is causing incorrect readings for ADC and ADC TM channels. Fix this.
Change-Id: If6332c6ec83f04ce4294df27e5bdb784cc5d23be
Signed-off-by: Anjelique Melendez <quic_amelende@quicinc.com>
adc5_prescaling_from_dt() is not needed as that is replaced with
qcom_adc5_prescaling_from_dt() in qcom-vadc-common.c. Since
adc5_prescale_ratios[] is also used from qcom-vadc-common.c and
not needed in qcom-spmi-adc5-gen3.c, remove it.
With the above change, adc5_chans_pmic[] needs to be updated with
the right indices. Update it.
Change-Id: Ibeb8ef6d9436ae448aadc9a99e5d0ef69767ac47
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
[quic_collinsd@quicinc.com: fixed minor merge conflict]
Signed-off-by: David Collins <quic_collinsd@quicinc.com>
Fix the indentation to keep it uniform and readable.
Change-Id: I73da8941c72857a9f63dca3e8085873413b3a1f2
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
Typo found in two of PM8550B ADC channel names. Fix them.
Change-Id: I3e69402f3837cb6e29d84ea1ddb789801c72ec2f
Signed-off-by: Anjelique Melendez <quic_amelende@quicinc.com>
Currently, the adc5 gen3 interrupt handler always returns IRQ_HANDLED.
Fix the handler so that on errors IRQ_NONE is returned.
Change-Id: I2ccebb985c81ad9de57b829b469ec8e58437f9e9
Signed-off-by: Anjelique Melendez <quic_amelende@quicinc.com>
Add the ADC5 GEN3 channels used by PMK8550, PM8550 and PM8550B.
Change-Id: I0a52446634dfa2108e1b3f2c0e990610138340b9
Signed-off-by: Anjelique Melendez <quic_amelende@quicinc.com>
Currently, ADC5 GEN3 driver allows up to 8 channels. In Kalama up to 16
channels can be configured over 2 SDAMS. Update member variables,
interrupt handling and read and write functions so that driver can handle
2 or more SDAMS.
Change-Id: I2d65d9a420092db98cdbf27bba5188700c46fd0a
Signed-off-by: Anjelique Melendez <quic_amelende@quicinc.com>
Currently, ADC5 GEN3 driver allows up to 8 channels. In Kalama up to 16
channels can be configured over 2 SDAMs. Dynamically set max_channels
based on number of registers(SDAMs) specified.
Change-Id: I789b142306dfb0099d955f9e166c17b331a47517
Signed-off-by: Anjelique Melendez <quic_amelende@quicinc.com>
Currently, the debug base address is defined under the reg property. This
would be confusing if multiple addresses are specified under reg property
to support more ADC channels. Separate debug base into its own property.
Change-Id: Id96621bafd85bde0e601a89849aef7f094f53bf9
Signed-off-by: Anjelique Melendez <quic_amelende@quicinc.com>
Currently, calls to qcom_adc5_hw_scale() are passing in a prescale pointer.
The qcom_adc5_hw_scale() function signature asks for the prescale int and
interanally will get the prescale pointer. Fix this.
Change-Id: I4cf630cf47f0b69678b69aecd5058e510bde6b3c
Signed-off-by: Anjelique Melendez <quic_amelende@quicinc.com>
When an ADC conversion results in a conversion fault, the
conversion fault bit in the status register is set, but never
cleared, by PBS, causing an error print for conversion fault
to appear for all future conversions. Update interrupt handler
to clear conversion fault bit if it is found set.
Change-Id: I83b36ce585ab5d20639dbf5050f91e8850cc2b75
Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
Add support for reading ADC channels on a PMIC7 ADC directly from
the ADC_PBS peripheral on that PMIC instead of through PMK8350
ADC peripheral using PBS, for targets where PMK8350 does not run in
master mode.
The conversion request sequence for using ADC_PBS is similar to
the existing one for ADC7, with some differences in register
writes. In addition, SW now performs calibration in place of PBS,
for every conversion, by reading the three calibration channels,
calculating the reference values and entering them in the
calibration registers.
Change-Id: I9e47ed69e75ee2580a37195ea9063f24ffb8aac5
Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
[quic_subbaram@quicinc.com: Fixed merge conflicts and modified
to compile with upstream driver version.]
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
Add support to adc driver for suspend to disk feature.
Free interrupts during hibernation and re-register them during
resume.
Change-Id: I71d2aed51f0697e712db59dcc1ef4af0fa98aae4
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
Signed-off-by: Veera Vegivada <vvegivad@codeaurora.org>
[quic_subbaram@quicinc.com: Fixed merge conflict]
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
Correct base offset and register read API used in register
dump API called for conversion faults.
Change-Id: I274d40fe29f9f32238b9baa5e42b23d4df64cbf2
Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
Fix timer value for immediate conversion to the right constant
to avoid TM conversions for immediate conversion requests.
Correct TM channel offsets checked from status and data registers
in TM interrupt handler.
Change-Id: I43a9a5cf33d31029fe306e61c4bf2e80966b9b7e
Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
1.Remove mutexes used in TM configure API to avoid deadlock.
2.Update register writes in immediate and TM configure APIs.
3.Correct register and bit to check for end of conversion for immediate
conversion in IRQ handler.
Change-Id: I68d0bc4d6aeef089939d0d9ae9161b6122bf110e
Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
Add scaling functions for batt_therm, batt_id and usb_in_i ADC channels
for PM5100. Also add usb_sns_v_div_16 and vin_div_16 channels to list of
supported channels and correct default prescaling value for vbat_sns
channel and full scale ADC current.
Change-Id: I86b86c319bff6df583efab8cc4c877218a79fe56
Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
[quic_subbaram@quicinc.com: Fixed merge conflicts in
qcom-vadc-common.h due to location change and in qcom-vadc-common.c]
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
[quic_collinsd@quicinc.com: changed struct vadc_prescale_ratio to
struct u32_fract and changed prescale "num" and "den" to
"numerator" and "denominator" respectively]
Signed-off-by: David Collins <quic_collinsd@quicinc.com>
Add support for QCOM SPMI PMIC5 GEN3 ADC driver that supports
hardware based offset and gain compensation.
The ADC peripheral can measure both voltage and current
channels whose input signal is connected to the PMIC ADC AMUX.
The PMIC5 GEN3 ADC peripheral uses registers defined in SDAM.
The register set and configuration have been refreshed compared
to the prior QCOM PMIC7 ADC family.
Change-Id: I3512c3c067d9102406aa92c389d66283f0b12103
Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
[quic_subbaram@quicinc.com: Fixed merge conflicts in
qcom-vadc-common.h due to location change; Made changes in
qcom-vadc-common.c to re-use existing qcom_vadc_map_temp_voltage();
Added entire include/linux/adc-tm-clients.h as it doesn't exist
anymore but needed to compile qcom-spmi-adc5-gen3.c and removed
the APIs used when CONFIG_QTI_ADC_TM is enabled.]
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
[quic_collinsd@quicinc.com: changed struct vadc_prescale_ratio to
struct u32_fract and changed prescale "num" and "den" to
"numerator" and "denominator" respectively]
Signed-off-by: David Collins <quic_collinsd@quicinc.com>
Add definitions for ADC channels for PMIC5 GEN3 ADC driver.
Add virtual channel definitions for PM5100, to be used
by ADC clients for PMIC5 GEN3.
Change-Id: I1180553c3ee697f994324c60ebfb4e996221108e
Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
Add ADC5_GPIO2_100K_PU channel to the list of rev2 ADC channels.
Change-Id: I684c4e5124f37345e378fa552cad789d24be6a69
Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
As per the hardware recommendation, add a ratio of 41/40 (i.e.
numerator 40 and denominator 41 based on how it's used in our
calculations) for the ADC channels that use SMB_TEMP pin because
of the voltage divider circuit with a 1 K and 40 K in parallel.
IIN_FB channel should be using the same ratio as that of IIN_SMB
before. Hence, add a separate scaling factor for it.
Change-Id: I4c3d76a068edf7c964a71c5082da54b115e7eb04
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
[quic_subbaram@quicinc.com: Fixed merge conflicts in qcom-spmi-adc5.c
because common code moved to qcom-vadc-common.c]
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
[quic_collinsd@quicinc.com: changed prescale "num" and "den"
to "numerator" and "denominator" respectively]
Signed-off-by: David Collins <quic_collinsd@quicinc.com>
Some device tree files refers these definitions when
"qcom,scale-fn-type" is specified. Add them.
Change-Id: I559de48eff20666194b01e32320de5c647afccae
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Add ADC7_USB_IN_V_16 to adc7_chans_pmic list to support reading
USB VBUS voltage directly from ADC channel if needed during
testing.
Change-Id: Id27cd50c65a549c1361f0b0185afa4048b66423c
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Update scaling ratios for SMB_ICHG and SMB_IIN ADC channels, following
HW recommendation. Update default prescaling values used for SMB_IIN
and ICHG_FB channels to match changes made in the prescaling array.
Change-Id: I2b016e021d3c9e8b76cd5400c6790030da088093
Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
[quic_subbaram@quicinc.com: Fixed merge conflicts in qcom-spmi-adc5.c
because common code moved to qcom-vadc-common.c]
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
[quic_collinsd@quicinc.com: changed prescale "num" and "den"
to "numerator" and "denominator" respectively]
Signed-off-by: David Collins <quic_collinsd@quicinc.com>
Correct the hw_settling times array defined for ADC5 lite.
Change-Id: I38eee9b3f76cb40e286f9e7e3fbf296b3f3ccfe5
Signed-off-by: Shyam Kumar Thella <sthella@codeaurora.org>
Currently, interrupts of qcom-spmi-adc5 driver are registered
with name "pm-adc5". However on platforms with multiple PMICs
that can have different ADC types (adc5 or adc7), this naming
is not user friendly when looking at interrupt data. Add a name
that looks unique for different adc types so that they can be
interpreted easily.
Change-Id: Iac1080dc8e02d278b30cff0d61eca40e081bc306
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
[quic_subbaram@quicinc.com: Fixed merge conflicts in
qcom-vadc-common.h due to location change]
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
Add scaling function required to read PMIC5 current ADC channels
so that channel 0xA5 (ADC5_PARALLEL_ISENSE) can use that.
Change-Id: I55ede0c736c6f350df8ac92ea8661db4129da13c
Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
[quic_subbaram@quicinc.com: Fixed merge conflicts in
qcom-vadc-common.h due to location change]
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
[quic_collinsd@quicinc.com: changed struct vadc_prescale_ratio to
struct u32_fract and changed prescale "num" and "den" to
"numerator" and "denominator" respectively]
Signed-off-by: David Collins <quic_collinsd@quicinc.com>
Add support for reading S3 die_temp channel on PM2250 by
specifying the scaling function.
Change-Id: I1e8fcba0058851a540bc39adc7606d4f0ad8f6db
Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
[quic_subbaram@quicinc.com: Fixed merge conflicts in
qcom-vadc-common.h due to location change]
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
[quic_collinsd@quicinc.com: changed struct vadc_prescale_ratio to
struct u32_fract and changed prescale "num" and "den" to
"numerator" and "denominator" respectively]
Signed-off-by: David Collins <quic_collinsd@quicinc.com>
Add support to read ADC channel 0xA5 for parallel charger
current.
Some PMICs (PMI632) the max supported current is 5A, hence
define a new config data and compatible string for it.
Change-Id: I973dfdf81ee955d322da7e2c328d8b1472d33013
Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
Add support to read current channels on PM8350B and SMB139x
charge pumps.
IIN_FB - Input current drawn by main charger (PM8350B)
ICHG_FB - Charging current from main charger (PM8350B)
IIN_SMB - Input current drawn by one of SMB139x
ICHG_SMB - Charging current from one of SMB139x
Since, most of these channels needs prescale ratios post reading
ADC code and before scaling, add the necessary prescale ratios.
Change-Id: Id9b866f684d574813904a5fd8e658f59b1d7bcbf
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
[quic_subbaram@quicinc.com: Fixed merge conflicts in
qcom-vadc-common.h due to location change and common code moved
to qcom-vadc-common.c]
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
[quic_collinsd@quicinc.com: changed struct vadc_prescale_ratio to
struct u32_fract and changed prescale "num" and "den" to
"numerator" and "denominator" respectively]
Signed-off-by: David Collins <quic_collinsd@quicinc.com>
Add PM8350B_ADC7_ICHG_FB channel to read charging current for
PM8350B. Also, update qcom,spmi-vadc.h to add ADC7_ICHG_FB and
other relevant channels that are needed for reading input and
charging current for SMB139x charger pumps along with scale
function indices.
Change-Id: I4a1b53f328e1b394063cbf951f6ff978eb96d21e
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
[quic_subbaram@quicinc.com: Fixed trivial merge conflict in
include/dt-bindings/iio/qcom,spmi-vadc.h and updated copyright]
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
Add support to read CHG_TEMP channel on PM8350B to get charger
temperature.
Change-Id: I33c69e56d47b0ab37772df8d55eae2ab0c5bad86
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
[quic_subbaram@quicinc.com: Fixed trivial merge conflict in
qcom-vadc-common.h due to location change]
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
[quic_collinsd@quicinc.com: changed struct vadc_prescale_ratio to
struct u32_fract]
Signed-off-by: David Collins <quic_collinsd@quicinc.com>
Add support to read SMB_TEMP channel on PM8350B that is output by
charge pump (smb139x). When this virtual channel is read for
one of SMB139x charger pumps, PBS does the configuration for that
SMB139x appropriately.
Change-Id: Ia9af1ef78571c56898057d567117fcd9b7d28172
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
[quic_subbaram@quicinc.com: Fixed trivial merge conflict in
qcom-vadc-common.h due to location change and changes from upstream
merge]
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
[quic_collinsd@quicinc.com: changed struct vadc_prescale_ratio to
struct u32_fract]
Signed-off-by: David Collins <quic_collinsd@quicinc.com>
Currently, when an ADC7 channel is read, there is a wait time of
10 ms where an EOC (end of conversion) interrupt should happen
thereby completing the wait for ADC conversion. However, if this
wait times out, it is not handled and stale data can be read. Add
error logs to print when this wait times out as well as if EOC
bit is not set and return an error.
Also, this 10 ms wait time for EOC after requesting for a channel
conversion is not sufficient. As per the hardware recommendation
when multiple subsystems requests PMIC HW arbiter to read same
or different channels on different PMICs simultaneously, it could
take 15 ms for a good case i.e. where all the conversion requests
went through successfully. However, for a worst case where this
conversion request times out, it could take up to 500 ms before
an EOC interrupt is sent by PBS to SW. Hence, increase conversion
wait time to 501 ms so that no other channel reads can be made in
the worst case. Also print a warning when the wait time for EOC
is more than 15 ms.
Change-Id: I69eeade3e85f740af10cd7a3d668e67f67f6617d
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Correct scaling function for SMB1398 to ensure
temperature is calculated accurately.
Change-Id: I7ec497ef9d1171da7a08a97730912727c583830a
Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
[quic_collinsd@quicinc.com: changed prescale "num" and "den"
to "numerator" and "denominator" respectively]
Signed-off-by: David Collins <quic_collinsd@quicinc.com>
Add the following PMIC5 ADC features:
Update ADC polling time delay for end of conversion (EOC) to match
values on kernel 4.19.
Add missing channels in driver's channel list (bat_therm, bat_id
and some thermistor channels), which may be needed by PMIC5 clients.
Add scaling functions for bat_therm and smb_therm.
Change-Id: I0612560513fbb3f29ff3fda6ad86b939f190410e
Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
[quic_subbaram@quicinc.com: Fixed trivial merge conflict in
qcom-spmi-adc5.c and in qcom-vadc-common.h due to location change]
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
[quic_collinsd@quicinc.com: changed struct vadc_prescale_ratio to
struct u32_fract]
Signed-off-by: David Collins <quic_collinsd@quicinc.com>