Fix missing break statements in OCV and VBAT compensation
APIs for PM8026 v2.2 to avoid SOC and VBAT errors.
Change-Id: Idd2352c2cd9dad3b80a71f36a2947254792557bc
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
Update default scaling API to support absolute and
ratiometric calibration both to convert raw adc data
to voltages.
Change-Id: I45a109d77c388564c0063d1de926813a4a929c48
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
With wakeup_source APIs in VADC driver if the client
driver suspend call requests adc conversion then
suspend process will be aborted even if the wakeup
event released by VADC driver.
Add suspend_noirq support to allow the client
driver to read adc during their suspend call
and remove wakeup_source APIs.
Change-Id: I338463975de0eafd9c9e21e5f0ce8a0508ceeac2
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
QPNP PMIC SMPS current monitoring driver provides sysfs interface to
user-space clients for configuring current threshold of the regulator.
It also notifies user-space client whenever load current crosses the
configured threshold limit.
Change-Id: Ic4e7210e262bddd3e1aae6f0ebda35fb54931737
Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
For PM8026 some parts are reporting incorrect RSENSE trim value.
This fix updates the existing RSENSE trim error workaround to
cover them.
Change-Id: I80689e5da9294bee0afb9a83da2da787c4a1d6e7
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
The following commits have been reverted from this merge, as they are
known to introduce new bugs and are currently incompatible with our
audio implementation. Investigation of these commits is ongoing, and
they are expected to be brought in at a later time:
86e6de7 ALSA: compress: fix drain calls blocking other compress functions (v6)
16442d4 ALSA: compress: fix drain calls blocking other compress functions
This merge commit also includes a change in block, necessary for
compilation. Upstream has modified elevator_init_fn to prevent race
conditions, requring updates to row_init_queue and test_init_queue.
* commit 'v3.10.28': (1964 commits)
Linux 3.10.28
ARM: 7938/1: OMAP4/highbank: Flush L2 cache before disabling
drm/i915: Don't grab crtc mutexes in intel_modeset_gem_init()
serial: amba-pl011: use port lock to guard control register access
mm: Make {,set}page_address() static inline if WANT_PAGE_VIRTUAL
md/raid5: Fix possible confusion when multiple write errors occur.
md/raid10: fix two bugs in handling of known-bad-blocks.
md/raid10: fix bug when raid10 recovery fails to recover a block.
md: fix problem when adding device to read-only array with bitmap.
drm/i915: fix DDI PLLs HW state readout code
nilfs2: fix segctor bug that causes file system corruption
thp: fix copy_page_rep GPF by testing is_huge_zero_pmd once only
ftrace/x86: Load ftrace_ops in parameter not the variable holding it
SELinux: Fix possible NULL pointer dereference in selinux_inode_permission()
writeback: Fix data corruption on NFS
hwmon: (coretemp) Fix truncated name of alarm attributes
vfs: In d_path don't call d_dname on a mount point
staging: comedi: adl_pci9111: fix incorrect irq passed to request_irq()
staging: comedi: addi_apci_1032: fix subdevice type/flags bug
mm/memory-failure.c: recheck PageHuge() after hugetlb page migrate successfully
GFS2: Increase i_writecount during gfs2_setattr_chown
perf/x86/amd/ibs: Fix waking up from S3 for AMD family 10h
perf scripting perl: Fix build error on Fedora 12
ARM: 7815/1: kexec: offline non panic CPUs on Kdump panic
Linux 3.10.27
sched: Guarantee new group-entities always have weight
sched: Fix hrtimer_cancel()/rq->lock deadlock
sched: Fix cfs_bandwidth misuse of hrtimer_expires_remaining
sched: Fix race on toggling cfs_bandwidth_used
x86, fpu, amd: Clear exceptions in AMD FXSAVE workaround
netfilter: nf_nat: fix access to uninitialized buffer in IRC NAT helper
SCSI: sd: Reduce buffer size for vpd request
intel_pstate: Add X86_FEATURE_APERFMPERF to cpu match parameters.
mac80211: move "bufferable MMPDU" check to fix AP mode scan
ACPI / Battery: Add a _BIX quirk for NEC LZ750/LS
ACPI / TPM: fix memory leak when walking ACPI namespace
mfd: rtsx_pcr: Disable interrupts before cancelling delayed works
clk: exynos5250: fix sysmmu_mfc{l,r} gate clocks
clk: samsung: exynos5250: Add CLK_IGNORE_UNUSED flag for the sysreg clock
clk: samsung: exynos4: Correct SRC_MFC register
clk: clk-divider: fix divisor > 255 bug
ahci: add PCI ID for Marvell 88SE9170 SATA controller
parisc: Ensure full cache coherency for kmap/kunmap
drm/nouveau/bios: make jump conditional
ARM: shmobile: mackerel: Fix coherent DMA mask
ARM: shmobile: armadillo: Fix coherent DMA mask
ARM: shmobile: kzm9g: Fix coherent DMA mask
ARM: dts: exynos5250: Fix MDMA0 clock number
ARM: fix "bad mode in ... handler" message for undefined instructions
ARM: fix footbridge clockevent device
net: Loosen constraints for recalculating checksum in skb_segment()
bridge: use spin_lock_bh() in br_multicast_set_hash_max
netpoll: Fix missing TXQ unlock and and OOPS.
net: llc: fix use after free in llc_ui_recvmsg
virtio-net: fix refill races during restore
virtio_net: don't leak memory or block when too many frags
virtio-net: make all RX paths handle errors consistently
virtio_net: fix error handling for mergeable buffers
vlan: Fix header ops passthru when doing TX VLAN offload.
net: rose: restore old recvmsg behavior
rds: prevent dereference of a NULL device
ipv6: always set the new created dst's from in ip6_rt_copy
net: fec: fix potential use after free
hamradio/yam: fix info leak in ioctl
drivers/net/hamradio: Integer overflow in hdlcdrv_ioctl()
net: inet_diag: zero out uninitialized idiag_{src,dst} fields
ip_gre: fix msg_name parsing for recvfrom/recvmsg
net: unix: allow bind to fail on mutex lock
ipv6: fix illegal mac_header comparison on 32bit
netvsc: don't flush peers notifying work during setting mtu
tg3: Initialize REG_BASE_ADDR at PCI config offset 120 to 0
net: unix: allow set_peek_off to fail
net: drop_monitor: fix the value of maxattr
ipv6: don't count addrconf generated routes against gc limit
packet: fix send path when running with proto == 0
virtio: delete napi structures from netdev before releasing memory
macvtap: signal truncated packets
tun: update file current position
macvtap: update file current position
macvtap: Do not double-count received packets
rds: prevent BUG_ON triggered on congestion update to loopback
net: do not pretend FRAGLIST support
IPv6: Fixed support for blackhole and prohibit routes
HID: Revert "Revert "HID: Fix logitech-dj: missing Unifying device issue""
gpio-rcar: R-Car GPIO IRQ share interrupt
clocksource: em_sti: Set cpu_possible_mask to fix SMP broadcast
irqchip: renesas-irqc: Fix irqc_probe error handling
Linux 3.10.26
sh: add EXPORT_SYMBOL(min_low_pfn) and EXPORT_SYMBOL(max_low_pfn) to sh_ksyms_32.c
ext4: fix bigalloc regression
arm64: Use Normal NonCacheable memory for writecombine
arm64: Do not flush the D-cache for anonymous pages
arm64: Avoid cache flushing in flush_dcache_page()
ARM: KVM: arch_timers: zero CNTVOFF upon return to host
ARM: hyp: initialize CNTVOFF to zero
clocksource: arch_timer: use virtual counters
arm64: Remove unused cpu_name ascii in arch/arm64/mm/proc.S
arm64: dts: Reserve the memory used for secondary CPU release address
arm64: check for number of arguments in syscall_get/set_arguments()
arm64: fix possible invalid FPSIMD initialization state
...
Change-Id: Ia0e5d71b536ab49ec3a1179d59238c05bdd03106
Signed-off-by: Ian Maund <imaund@codeaurora.org>
For the condition when PM8941 is true use the BATFET status
that is passed to the calibration api. Ignore the BATFET
status for all other PMIC versions.
For PM8941 when BATFET is open, the reads on channel 0 for
Internal RSENSE are redirected in HW to channel 0x5:
EXTRSNS_OFFSET. Recalibrate based on this channel.
Change-Id: Ib0d477c5fb4537379b31faf1676d5956317b06a7
CRs-Fixed: 629758
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
On PM8941 depending on the status of the BATFET
the reads on channel 0 for Internal RSENSE go to
channel 5 therefore the offset is performed on that
channel. This is applicable to only to PM8941 and
not on PM8026 and PM8110. Therefore apply the check
for offset channel selection based on the BATFET
status on PM8941 only.
Change-Id: I146b244c2b562664b85e804694f8d4b2aac3fa86
CRs-Fixed: 629758
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
commit 500a91571f0a5d0d3242d83802ea2fd1faccc66e upstream.
When trying to set the minimum temperature, the driver was erroneously
writing the maximum temperature into the chip.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Update the raw code shown for VADC while printing the buffer
in hex format instead of decimal format to maintain the
format that is in the register.
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Change-Id: I57f39e1d32925a51ca2bc6e848cc897caf565c6c
Add reverse scaling to convert voltage in uV using absolute
calibration to raw ADC code written to set high/low threshold
for a specified BTM channel.
Change-Id: Ic56465df5ab60100cffe4303ff983480b71c0c95
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Add check for rsense and calib data to avoid division by
zero errors.
CRs-fixed: 619889
Change-Id: Icf282341107905b382eb3fa34d73cf11665ca647
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
commit d3d89c468ceebbcf9423d1a3d66c5bf91f569570 upstream.
The ntc thermistor code was doing math whose temporary result might
have overflowed 32-bits. We need some casts in there to make it safe.
In one example I found:
- pullup_uV: 1800000
- result of iio_read_channel_raw: 3226
- 1800000 * 3226 => 0x15a1cbc80
Signed-off-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Apply temperature compensation to minimum(die_temp, 60degC)
for vbatt compensation. For OCV temperature compensation
apply the compensation based on the die_temp for the
corresponding PMIC. The temperature compensation is
required on top of gain/offset calibration to compensate
for variations due to chip revision, manufacturer and
temperature.
Change-Id: I0826993ddebe7dae2f033d995fa1266f9509002c
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Add VBAT and OCV temperature compensation for PM8026v2.2.
The temperature compensation is required on top of
gain/offset calibration to compensate for variations
due to chip revision, manufacturer and temperature.
Change-Id: I7c62340a74a118d6f80e4e6bba51c2d07c4a57c6
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
commit d303b1b5fbb688282bbf72a534b9dfed7af9fe4f upstream.
Add new PCI ID to support new model "Kaveri" family.
Signed-off-by: Philip Pokorny <ppokorny@penguincomputing.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Add temperature compensation for IADC PM8026v2.2.
It shares the same temperature compensation parameters
as PM8026v2.1. The temperature compensation is required
on top of gain/offset calibration to compensate for
variations due to chip revision, manufacturer and
temperature.
Change-Id: Ic39ba249d8d28c36bf59d650dcc2c2a3889ee55b
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
This is a workaround for a RSENSE trim issue that may
affect some of the parts. The RSENSE might be trimmed to a
incorrect value resulting in an incorrect current value.
The workaround will check if the trim values stored in the
registers are valid and if not use a default RSENSE value.
CRs-Fixed: 606553
Change-Id: I8d77a2c6c28e57f2e537d1c5b65d0e08d5fabd90
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
commit 3f9aec7610b39521c7c69d754de7265f6994c194 upstream.
When the core number exceeds 9, the size of the buffer storing the
alarm attribute name is insufficient and the attribute name is
truncated. This causes libsensors to skip these attributes as the
truncated name is not recognized.
Reported-by: Andreas Hollmann <hollmann@in.tum.de>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Add Version and firmware debug logs during initialization.
Change-Id: I3ded6b8a141a1b20b155309df5cac42fd76b9471
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Embedded power monitor (EPM) PSoC is powered through a GPIO.
Add a property to pass the GPIO to the driver since this
the global enable for the EPM varies from target to target.
Change-Id: I731302f9ab33c216f5794721a4d36ee20fb261ec
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Since the new values of parameters including Rs1=30.3K,
Rs2=12.8K, Tcold=-15DegC and Thot=55DegC are used for
skug device, we add a new table accordingly.
Change-Id: I89d86274c5c198f904766d818cb2a7882c462496
Signed-off-by: Wu Fenglin <fenglinw@codeaurora.org>
commit 33a7ab91d509fa33b4bcd3ce0038cc80298050da upstream.
The W83L786NG stores the fan speed on 4 bits while the sysfs interface
uses a 0-255 range. Thus the driver should scale the user input down
to map it to the device range, and scale up the value read from the
device before presenting it to the user. The reserved register nibble
should be left unchanged.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit cf7559bc053471f32373d71d04a9aa19e0b48d59 upstream.
The wrong mask is used, which causes some fan speed control modes
(pwmX_enable) to be incorrectly reported, and some modes to be
impossible to set.
[JD: add subject and description.]
Signed-off-by: Brian Carnes <bmcarnes@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit efabcc2123f0ed47870033b8d6fc73b50d76d635 upstream.
Some I2C bus drivers do not allow zero-length data transfers which are
required to start a measurement with the HIH6130/1 sensor. Nevertheless,
we can overcome this limitation by writing a zero dummy byte. This byte
is ignored by the sensor and was verified to be working with the OMAP
I2C bus driver in a BeagleBone board.
Signed-off-by: José Miguel Gonçalves <jose.goncalves@inov.pt>
[Guenter Roeck: Simplified complexity of write_length initialization]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 3806b45ba4655147a011df03242cc197ab986c43 upstream.
The "rpm * div" operations can overflow here, so this patch adds an
upper limit to rpm to prevent that. Jean Delvare helped me with this
patch.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Roger Lucas <vt8231@hiddenengine.co.uk>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Add check when adc calibration data are similar
for both reference channels and return error to
avoid division by zero errors.
Change-Id: Id884eb79f606fb7361fc47a96e7a6f009a113869
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
The compensation coefficients are used to execute performance tests.
Provide this information in the debug logs of the IADC driver.
Change-Id: I59df9501d8edf652c6cf0999a17cc820115b07cc
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
commit e41fae2b1ed8c78283d73651cd65be0228c0dd1c upstream.
Bit 2 of status register 2 on MAX6696 (external diode 2 open)
sets ALERT; the bit thus has to be listed in alert_alarms.
Also display a message in the alert handler if the condition
is encountered.
Even though not all overtemperature conditions cause ALERT
to be set, we should not ignore them in the alert handler.
Display messages for all out-of-range conditions.
Reported-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
There should be no synchronous Voltage and Current readings
initiated on IADC_USR when a single VADC_USR conversion is
in progress. If a synchronous Voltage and Current read
occures while a VADC_USR is in progress it results in an
invalid state for that single conversion on the VADC_USR.
There is a potential race condition where the above scenario
can occur that is due to an IADC conversion occuring before
the VADC_IADC USR sync conversion is complete and ends up
using the mode select as a VADC_IADC sync request.
Therefore use a single lock for both IADC and
synchronous VADC_IADC request.
Change-Id: Idb451b813bc5f08b7239d371fc0f8fa5e17429b1
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Add support to return 16bit results for averaging buffering
command. This allows additional channels to be measured.
The generic command allows clients to send requests that
are supported by the PSoC. In addition fix the marker
gpio numbers between the marker 1 and marker 2 that are
flipped.
Change-Id: I2bf87ceb8fa9fa633ab6d082b12f66c77a374d34
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
This change removes source files from the kernel tree that
were not being used during make. The list of used files
was generated using an annotated make log and was then
compared with new files added since the public release of
kernel version 3.10.00. New files which were added but
not used have been removed from the tree.
A diff was also run to determine the list of files that had
been modified since the release of kernel version 3.10.00.
These files were then scrubbed based on the current kernel
configuration, removing invalid and unused conditionals.
Some files which support planned functionality or are
useful in debugging have been excluded from this reap.
Change-Id: Ia44a224d3cea7bc78dd45e8a8279860d35d4b008
Signed-off-by: Ian Maund <imaund@codeaurora.org>
Currently the current compensation in the IADC driver is using the wrong
polarity. The compensation function is treating the current with the
battery being the source (i.e. discharging is positive and charging is
negative), but the IADC's IBAT readings treat the battery as a sink
(i.e. charging is positive and discharging is negative).
Fix this by reversing the sign of the iadc current readings before doing
compensation.
Change-Id: I1413ce491b1f430b6a78bfc480174321c512e289
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
Add in support for PM8110 2.0 temperature compensation. Also, fix a few
bugs in the ADC compensation algorithm where 25C was treated as 2.5C.
Change-Id: Iafa3ceca2b5938432116ecc905dd54b2da7c4b0b
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
Update the revid check to use pr_debug instead of
pr_err to reduce potential errors to get printed.
This is an optional property as far is IADC is concerned
to apply temperature compensation for the supported chips.
Change-Id: I77036fb9f0eb640e43216762461ba036b2aa0caf
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
commit 25f2bd7f5add608c1d1405938f39c96927b275ca upstream.
The crash reported and investigated in commit 5f4513 turned out to be
caused by a change to the read interface on newer (2012) SMCs.
Tests by Chris show that simply reading the data valid line is enough
for the problem to go away. Additional tests show that the newer SMCs
no longer wait for the number of requested bytes, but start sending
data right away. Apparently the number of bytes to read is no longer
specified as before, but instead found out by reading until end of
data. Failure to read until end of data confuses the state machine,
which eventually causes the crash.
As a remedy, assuming bit0 is the read valid line, make sure there is
nothing more to read before leaving the read function.
Tested to resolve the original problem, and runtested on MBA3,1,
MBP4,1, MBP8,2, MBP10,1, MBP10,2. The patch seems to have no effect on
machines before 2012.
Tested-by: Chris Murphy <chris@cmurf.com>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
The batt_therm connected to SMB THERM uses a
100K pull-up. This channel can also be read through
PMA8084 VADC. Add resistive divider table that
converts voltage to temperature in decidegC for the
corresponding battery thermistor.
Change-Id: I7af1c6b74a14d292c7cff37f5e9673980df67912
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Add temperature compensation parameters for PM8026 2.1.
Compensate the vbatt voltage for temperature variance above
25degC. Add similar compensation for current compensation.
Also update using the revid api's to check for PMIC revision
instead of using peripheral revision registers. Using
revid PMIC api's makes it easy to follow on what PMIC versions
are the temperature compensation being applied to. Depending
on VADC/IADC revision registers alone may not suffice since
there is no correlation between the individual peripheral
revision and the PMIC number. You could have the same
VADC revision on different PMIC's and to avoid such a scenario
use the PMIC revid.
Change-Id: I90adb1130b2e2461f762df774ddcd018e806cf78
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
commit 5f4513864304672e6ea9eac60583eeac32e679f2 upstream.
After reports from Chris and Josh Boyer of a rare crash in applesmc,
Guenter pointed at the initialization problem fixed below. The patch
has not been verified to fix the crash, but should be applied
regardless.
Reported-by: <jwboyer@fedoraproject.org>
Suggested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 30b146d1cb5e7560192057098eb705118bd5511f upstream.
The temperature reporting interface stays the same, so we just
add the PCI-ID to the list.
Verified on AMD Olive Hill.
Signed-off-by: Wei Hu <wei@aristanetworks.com>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Fix the temperature compensation overflow that can occur when
using external rsense. Also fix the corresponding units for
coefficient on PM8941 3.1.
Change-Id: I9b27b54c606482fa42928f79460c3ae7ceb693b3
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
During warm/soft reset it is seen during qpnp-adc-tm
driver interrupt registration there are pending
interrupts.
Register the ADC interrupt handler after initializing
the workqueue to handle potential cases where interrupt
is pending when an interrupt is requested and causes
panic because the workqueue is called when its not
initialized yet.
Change-Id: Iba88ab3c9f71dc94579ab85980f8cfd726f3c5c1
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Mapping table for batt_therm used for converting voltage
to temperature is incorrect after 65degC. Fix the voltage
to temperature mapping for values after 65degC.
Change-Id: Ib8534a2be3b66f61b4edbe8f283cfee9f873af81
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Existing units returned for IADC current is in mA when
using external rsense. Fix it to return the units in uA
to keep it consistent with current read from internal rsense.
Change-Id: Ia9792ea4d894500829011db5510363b4e6e14616
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
The VADC does not meet VBAT and OCV accuracy spec with just
gain and offset calibration. Additional compensation is required
on top of gain/offset calibrated reading to compensate for
variations based on chip revision, manufacturer and tempreature.
Change-Id: I9e08987ac39ac8de8e880b96bee4f8bc76a88e46
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
The IADC does not meet accuracy spec with just gain
and offset calibration. Additional compensation is
required on top of gain/offset calibration to compensate
for variations due to chip revision, manufacturer and
temperature.
Change-Id: If69ec412b05746e49e98fff761a70cd987bd6f7e
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Invalid jump to cleanup before the hwmon device
is registered. Cleanup the error path to avoid
panic if a failure occurs before hwmon device
register occurs.
Change-Id: I3477d207dc6402bed33d15723f2763ee85a1ca46
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Since the new values of parameters including Rs1=17.8K,
Rs2=6.1K, Tcold=-5DegC and Thot=55DegC are used for
msm8610 qrd skuaa, we add a new table accordingly.
Change-Id: I14eab97a012de62cfdddf1df920ce16ac0f3561c
Signed-off-by: Xu Kai <kaixu@codeaurora.org>
Change the battery thermistor voltage under the corresponding
temperature based on the values of parameters including
R0=10.0K @ 25DegC, Rs1=13.0K, Rs2=2.1K, B=3380K, Tcold=0DegC
and Thot=45DegC.
Change-Id: Icc6957946b456be4cfecc18c92cc79db85ea215e
Signed-off-by: Xu Kai <kaixu@codeaurora.org>
Provide a DT property qcom,iadc-poll-eoc option to
allow clients to choose between using interrupt or
polling method for end of conversion interrupt.
When the optional property is present, use polling
when an ADC conversion is requested.
Change-Id: I2c62a9f8e30f5c1200d439343f0548212977b731
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Add a DT property qcom,vadc-poll-eoc option to allow
clients to use either interrupt mode or polling mode
for end of conversion request. The DT property is a
optional property to specify polling. If this property is not
present default to use interrupt mode.
Change-Id: I16f3677a24200b80dc5a8535a98ec4a44158302c
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
The IADC on PM8026 has been found to have improved accuracy if the
gain compensation is removed from the conversion equation. Implement
this in the IADC driver by faking a gain read of offset + ideal gain
during calibration.
Change-Id: I85abf713e796666946674e5ae603c918cfa9ae5a
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
Support multiple instance of the IADC device. Clients
need to register with the current ADC using the device
consumer name used to associate with the corresponding
phandle of the IADC. Clients receive the device instance
which is to be used everytime an ADC request is made.
This change involves changing the interface to issue
ADC request and the corresponding clients changes.
Change-Id: I51423395ed7282669ca7fbc7dc585e0292417e71
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Support multiple voltage ADC device instance. Clients
need to register with the voltage ADC using the device
consumer name used to associate with the corresponding
phandle of the VADC. Clients receive the device instance
which is to be used everytime an ADC request is made.
This change involves changing the interface to issue
ADC request and the corresponding clients changes.
Change-Id: If0557bc657fecd172a8cf960900ee93b4bce37f8
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
On certain PMICs there is a coupling issue which causes bad calibration
values that reports a high current value even when the BATFET is open.
This coupling issue happens regardless of an internal/external rsense
configuration.
The suggested workaround is to repeatedly calibrate until we get values
that result in less than 3mA of current.
Expose the BATFET open/closed as battery's ONLINE property. It is
reasonable use of this property since PRESENT suggests a battery is
actually present in the device and ONLINE suggests if it is connected to
the system via BATFET.
The BATFET can open when a charger is present and
* the battery is fully charged
* the battery is hot/cold
(Note that if charger is disabled the buck will not operate
and we don't have coupling issue)
The fully charged notifications trickle down to BMS driver,
since battery psy supplies to "bms", use it to check if the
BATFET has opened.
The hot/cold interrupt is not yet registered to, add it so we can notify
the BMS driver if the battery goes hot or cold. Since the battery can
go hot or cold while the device is sleeping, we need to wakeup for
calibration workaround.
The BATFET can close when
* the charger is removed
* the battery recovers form hot/cold conditions when charger is present
These notifications too trickle down to the BMS driver and can be used to
check if the BATFET has closed.
Also once good calibration values are detected above use them until BATFET
closes i.e. do NOT calibrate until the BATFET closes. Update the code
that periodically calculates SOC to skip calibrations as long as BATFET
is open. On the same lines ask the iadc driver to skip auto calibrations
until BATFET closes.
CRs-Fixed: 509620
Change-Id: I89b521368304d7171d75e462cf15f2f1daa55cdc
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
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>
The current driver forces a value of 0uV for offset and always
lands up with 17.857mV for gain. The raw values for offset and
gain are correct however.
Update the driver to do a proper conversion of raw offset and
gain to values in microvolts.
Change-Id: I19eda7a4f0cc8ab6af0d31e01e1168d99f00bf7a
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
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>
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>
There is a possibility of potential out of bound array
access errors and uninitialized variable access from code
inspection. Add additional checks in voltage ADC and
TSENS to check for such errors.
Change-Id: I1213cd76fb636aa457c88d3bdc3740b692f01cce
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Add support to have clients call the de-init of the PSOC
device which disables the EPM GPIO used to power up
the device. When clients call the Init ioctl call the
gpio request to enable the device.
Change-Id: Ifa2e165cb0297728b128aece14e0fea3d314749a
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Clients can request start/stop markers and perform
current measurement. Support is added to request a
marker and set a desired level. When client
has finished it needs to call release for freeing
the gpio.
Change-Id: I3e805352a8c4cd56e616f76fc77e8fb7fa97fb50
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
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>
Execute the complete probe failure path in the event that
QPNP VADC registers could not be read, to prevent a
use-after-free scenario with the qpnp_vadc data structure.
Change-Id: Ib22faded23d9bc5939f1481bfcd21f7235699b16
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
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>
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>
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>
When external rsense is selected the api used to
calculate the rsense needs to return back. Instead
it recalculates the rsense using the trim procedure
used for calcuating the internal rsense. Fix it
by returning the value that is used for the external
rsense.
Change-Id: Icde61ca2c95d1b4ab64d9f6db2fc97ac4e47daab
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
It is seen on certain conditions during bootup the end
of conversion interrupt is latched and this causes the
VADC to never receive the end of conversion interrupt.
This causes the clients to experience delays when requesting
an ADC request and on certain scenario during a soft reset
condition delays bootup.
qpnp-int expects the peripheral interrupt registers to be
in a known state. If an interrupt occured and is not
handled correctly it could lead to the interrupt being
latched and subsequent interrupts are never handled.
Each qpnp peripheral has an option to reset the peripheral
when a warm reset occurs to reset the peripheral to its
power on reset state. Set the VADC peripheral reset register
to enable resetting the peripheral during a warm reset.
Change-Id: Ic59726d327bf93900011d6f7051b2967ed0eae87
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
With PMIC 3.0, the iadc compensation scheme will return 0 current
because of an conversion bug. Fix this in the iadc driver.
Also, the iadc driver was incorrectly assuming GF as the fab. Remove
this from the compensation scheme.
Finally, when the ADC revision is unsupported, simply do not
compensate.
Change-Id: I8d4ec7bfe7e125bd18da9dba5d78f988ffaea515
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
Compensate the vbatt voltage for temperature variance
above 25degC. The vbatt readings improve with voltage
compensation based on the revision. Similar compensation
is applied to current which are based on the internal
or external rsense and the revision.
Change-Id: I3df8b918e6247041d651a0c9d819d77cc6af978c
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Add mapping table used for converting battery thermistor
voltage to the corresponding temperature based on
the qrd resistive divider circuit.
Change-Id: I5d3a8fd446cc59e30192485f28a9436e5517350f
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Use channel 0xc to read the buffered 625mV reference
channel during calibration if it exists. The channel
may not exist on all the PMIC versions. If the channel
is supported in the PMIC add it as a channel in the
VADC DT channel node.
Change-Id: I49b54e161538f075fcd89ed9beb7ffbdd8034a87
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Add more die_temp debug logs and fix the units for
converting millidegC to K during reverse calibration.
Also add bound checks in the status read to prevent
spurious interrupts.
Change-Id: I888216383ae9e8aed83bc5b22b4e36499b500c11
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
The qpnp adc drivers take different mutex locks one after the
other but lockdep can't figure that out because each mutex is
intialized with one call to mutex_init() in
qpnp_adc_get_devicetree_data(). Move the mutex initialization to
each caller so that lockdep can see different lock classes for
each adc mutex. This silences the below recursive mutex warning.
=============================================
[ INFO: possible recursive locking detected ]
3.4.0-gc11e688-00030-g8f5e269-dirty #567 Tainted: G W
---------------------------------------------
kworker/u:2/21 is trying to acquire lock:
(&adc_qpnp->adc_lock){+.+...}, at: [<c04c0918>] qpnp_iadc_read+0x64/0x174
but task is already holding lock:
(&adc_qpnp->adc_lock){+.+...}, at: [<c04be7f4>] qpnp_vadc_iadc_sync_request+0x34/0x198
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(&adc_qpnp->adc_lock);
lock(&adc_qpnp->adc_lock);
*** DEADLOCK ***
May be due to missing lock nesting notation
6 locks held by kworker/u:2/21:
#0: (deferwq){.+.+.+}, at: [<c00a7e84>] process_one_work+0x1c8/0x528
#1: (deferred_probe_work){+.+.+.}, at: [<c00a7e84>] process_one_work+0x1c8/0x528
#2: (&__lockdep_no_validate__){......}, at: [<c0339670>] device_attach+0x18/0xa4
#3: (&chip->last_ocv_uv_mutex){+.+...}, at: [<c04b8b74>] recalculate_soc+0x190/0x124c
#4: (&iadc->iadc_vadc_lock){+.+...}, at: [<c04c0aa8>] qpnp_iadc_vadc_sync_read+0x40/0xe4
#5: (&adc_qpnp->adc_lock){+.+...}, at: [<c04be7f4>] qpnp_vadc_iadc_sync_request+0x34/0x198
stack backtrace:
[<c00140cc>] (unwind_backtrace+0x0/0x11c) from [<c00d6ea8>] (__lock_acquire+0x238/0x1784)
[<c00d6ea8>] (__lock_acquire+0x238/0x1784) from [<c00d895c>] (lock_acquire+0xf0/0x138)
[<c00d895c>] (lock_acquire+0xf0/0x138) from [<c079aa50>] (mutex_lock_nested+0x5c/0x3d8)
[<c079aa50>] (mutex_lock_nested+0x5c/0x3d8) from [<c04c0918>] (qpnp_iadc_read+0x64/0x174)
[<c04c0918>] (qpnp_iadc_read+0x64/0x174) from [<c04c0ae0>] (qpnp_iadc_vadc_sync_read+0x78/0xe4)
[<c04c0ae0>] (qpnp_iadc_vadc_sync_read+0x78/0xe4) from [<c04b6d88>] (get_simultaneous_batt_v_and_i+0x24/0x68)
[<c04b6d88>] (get_simultaneous_batt_v_and_i+0x24/0x68) from [<c04b927c>] (recalculate_soc+0x898/0x124c)
[<c04b927c>] (recalculate_soc+0x898/0x124c) from [<c04b9cfc>] (calculate_soc_work+0x10/0x4c)
[<c04b9cfc>] (calculate_soc_work+0x10/0x4c) from [<c07750f8>] (qpnp_bms_probe+0xeac/0x1228)
[<c07750f8>] (qpnp_bms_probe+0xeac/0x1228) from [<c037d6b0>] (spmi_drv_probe+0x10/0x14)
[<c037d6b0>] (spmi_drv_probe+0x10/0x14) from [<c0339884>] (driver_probe_device+0x134/0x338)
[<c0339884>] (driver_probe_device+0x134/0x338) from [<c0337d28>] (bus_for_each_drv+0x48/0x8c)
[<c0337d28>] (bus_for_each_drv+0x48/0x8c) from [<c03396d8>] (device_attach+0x80/0xa4)
[<c03396d8>] (device_attach+0x80/0xa4) from [<c0338bdc>] (bus_probe_device+0x28/0x9c)
[<c0338bdc>] (bus_probe_device+0x28/0x9c) from [<c0339144>] (deferred_probe_work_func+0x68/0xa0)
[<c0339144>] (deferred_probe_work_func+0x68/0xa0) from [<c00a7f54>] (process_one_work+0x298/0x528)
[<c00a7f54>] (process_one_work+0x298/0x528) from [<c00a83a8>] (worker_thread+0x198/0x2b8)
[<c00a83a8>] (worker_thread+0x198/0x2b8) from [<c00ad2fc>] (kthread+0x90/0xa4)
[<c00ad2fc>] (kthread+0x90/0xa4) from [<c000edcc>] (kernel_thread_exit+0x0/0x8)
Change-Id: Iebda9a8dfc407273748545bb81f91d6dc27e97cc
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Use int64_t type to while scaling the threshold values with
absolute calibration arithmetic avoid overflow errors.
Change-Id: I29d3b4ad71776a45ec1cd2c076b0f058b7bf8723
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Instead of reading the die_temperature every time
perform calibration only if the die_temperature between
the previous calibration was greater than 5degC. It is
fine to perform calibration but is unnecessary to perform
it for every other read.
Change-Id: I2f819044395b37dd4aa906b3711a9de068260b3f
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Add support to read external rsense. We have an
existing DT property to pass the external rsense
value. Modify it as an optional property and when
present use it determine using the external rsense
and the corresponding value for computing the current.
Change-Id: Ie372bd25687b49d399f91bfcb803c669087655f0
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
At low current values, not using the correct units
for scaling the voltage and dividing it by the appropriate
units for rsense causes incorrect resolution in units for
current. Fix it by using the correct units.
Change-Id: Ia76382268b69db194f5f17f5a129140e75d66298
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Initialize the completion before requesting a
conversion. This is to avoid cases where we might
miss the completion and rely on the timed wait which
would cause slight delay before returning the result
to the client.
Change-Id: I49b635699c3432ca8363d68493ea02e17f7c6c64
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Fix issue when a call to qpnp_vadc_calib() does not
return due to the end of conversion status bits not
being set. Add a count check while reading the status
registers instead of waiting forever till the end of
conversion bits get set. Also make changes in the IADC
driver to schedule work for calibration when there
are no errors. Previously we wanted to give a couple
of re-tries but once the calibration error occurs we
have seen it fail continously so there is no need to
have retries.
Change-Id: I5f994f38fbeb0a044146174d4189b1cd95fd040e
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Update the scaling function for vbatt reverse scaling
api to fix issues while performing integer operations.
Clients request the voltage in micro-volts and the
reverse scaling fix is the use the correct absolute
reverse scaling function to convert it to voltage thresholds.
Change-Id: Iea61b768daf708b4f59e5728ed1249dd60f18258
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Currently calibration is performed every 5 minutes. Provide
an option to the clients to request for IADC re-calibration.
Change-Id: Ia66866610e0702dc25d4235608d123b2e0bf8004
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Remove instances of EXPORT_SYMBOL_GPL from the qpnp-adc driver.
Use EXPORT_SYMBOL instead.
Change-Id: If598d64a7978af8a8c1671fec9b11b6ac81d5517
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Add IADC gain, offset and rsense information for debug.
Also add VADC reference channel debug information.
Change-Id: Ice81d8ce8d4b725b3e5cbef33159a3bdd69dd621
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
For battery client the warm temperature equates to a low voltage
threshold and cool temperature equates to a high voltage. Factor
it in the reverse scaling when client enters the temperature
threshold.
Change-Id: I884319bd53f4c3c563f4536a6a3462ebdf805898
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
The change adds 3 additional channels and run-time
detects the supported number of channels to allow
clients to set threshold notification.
To support this, optimize the kernel api used to configure
and start a threshold monitoring request to include multiple
clients thus avoiding the need to have seperate kernel api's
for different clients. Changes are made to avoid the driver
depending on the order in which the VADC_TM DT channel
nodes should be added. Support is now included to
monitor DIE temperature for reading the pmic_therm, VBATT
and msm_thermistor scaling functions.
The change also disables the bank when an interrupt is
received or any changes are to be made in the settings,
make sure no measurements are in the queue, settings updated
and the bank is re-enabled.
Change-Id: I7a7c03857c86127dd6f1055df17099ecff4bb2f7
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
The A/D code from the PSOC can report negative values.
Use the correct typecast and treat the code as an int
to report low negative current readings. Currently we
treat the results as an uint and the value gets reported
as a huge value for low negative current readings.
Change-Id: I754f08e83b4664b72d33725f0d9227774d9896af
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>