Update epm_adc_psoc_show_in() to fix potential
dereference to adc_code used to store the
PSOC code data.
Change-Id: I7b68f50f89fd38f0ac32f1793720e1af3ef43022
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
commit 1035a9e3e9 upstream.
Writing to fanX_div does not clear the cache. As a result, reading
from fanX_div may return the old value for up to two seconds
after writing a new value.
This patch ensures the fan_div cache is updated in set_fan_div().
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit df86754b74 upstream.
temp2_input should not be writable, fix it.
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 3a18e1398f upstream.
The datasheet for EMC1413/EMC1414, which is fully compatible to
EMC1403/1404 and uses the same chip identification, references revision
numbers 0x01, 0x03, and 0x04. Accept the full range of revision numbers
from 0x01 to 0x04 to make sure none are missed.
Signed-off-by: Josef Gajdusek <atx@atx.name>
[Guenter Roeck: Updated headline and description]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 17c048fc4b upstream.
Attempts to set the hysteresis value to a temperature below the target
limit fails with "write error: Numerical result out of range" due to
an inverted comparison.
Signed-off-by: Josef Gajdusek <atx@atx.name>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
[Guenter Roeck: Updated headline and description]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 3806b45ba4 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>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 25f2bd7f5a 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>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 1102dcab84 upstream.
TjMax for the CE4100 series of Atom CPUs was previously reported to be
110 degrees C.
cpuinfo logs on the web show existing CPU types CE4110, CE4150, and CE4170,
reported as "model name : Intel(R) Atom(TM) CPU CE41{1|5|7}0 @ 1.{2|6}0GHz"
with model 28 (0x1c) and stepping 10 (0x0a). Add the three known variants
to the tjmax table.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 41e58a1f2b upstream.
Atom CPUs don't have a register to retrieve TjMax. Detection so far was
incomplete. Use the X86 model ID to improve it.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 5592906f8b upstream.
Document the Atom series D2000 and N2000 (Cedar Trail) as being supported.
List and set TjMax for those series.
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: "R, Durgadoss" <durgadoss.r@intel.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit fcc14ac1a8 upstream.
Document the new Atom series (Tunnel Creek and Medfield) as being
supported, and list TjMax for the Atom E600 series.
Also enable the Atom tjmax heuristic for these Atom CPU models.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Reviewed-by: Guenter Roeck <guenter.roeck@ericsson.com>
Cc: Alexander Stein <alexander.stein@systec-electronic.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: "R, Durgadoss" <durgadoss.r@intel.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 500a91571f 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>
commit 3f9aec7610 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>
commit 33a7ab91d5 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 cf7559bc05 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 e41fae2b1e 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>
commit 5f45138643 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 93d783bcca upstream.
In adt7470_write_word_data(), which writes two bytes using
i2c_smbus_write_byte_data(), the return codes are incorrectly AND-ed
together when they should be OR-ed together.
The return code of i2c_smbus_write_byte_data() is zero for success.
The upshot is only the first byte was ever written to the hardware.
The 2nd byte was never written out.
I noticed that trying to set the fan speed limits was not working
correctly on my system. Setting the fan speed limits is the only
code that uses adt7470_write_word_data(). After making the change
the limit settings work and the alarms work also.
Signed-off-by: Curt Brune <curt@cumulusnetworks.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1.[Issue 9728761] [Flo/Deb] To prevent Deadlock while switching on/off CapSensor
Change-Id: Ia4aa17a5f8f3e67081c2ae88d02094f071d78881
Signed-off-by: rock lin <Rock_Lin@asus.com>
1. If kconfig CAP_SENSOR_RMNET_CTL is checked, cap1106 will be disabled
if and only if all of the rmnet_usb network interfaces turn off.
2. cap1106 is disabled by default now.
Bug: 9148999
Change-Id: I9e9fa65265e5972f31a607487cb86942bb6384dc
Signed-off-by: Raphanus Lo <raphanus_lo@asus.com>
commit 591bfcfc33 upstream.
On a system with both MAX1617 and JC42 sensors, JC42 sensors can be misdetected
as LM84. Strengthen detection sufficiently enough to avoid this misdetection.
Also improve detection for ADM1021.
Modeled after chip detection code in sensors-detect command.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit ecacb0b17c upstream.
Fix to return a negative error code from the error handling
case instead of 0, as done elsewhere in this function.
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Fine-tune parameters from RF:
1.change the sensor gain from 8 to 4,(less sensitive).
2.change the sensor sensitivity multiplier setting from 64x to 32x,(less sensitive).
Enlarged period alleviates I2C bus transition & power-saving:
3.change the polling rate from 500 msec to 1000 msecs.
bug id :8862570 [Flo/Deb]SW Changes for PR (HW_REV_E) Support
Change-Id: Ie2d8bb4067569dc88c410e57709c538a02255b1c
Signed-off-by: rock lin <Rock_Lin@asus.com>
Signed-off-by: tryout chen <tryout_chen@asus.com>
Commit 3e78080f81 ('hwmon: (sht15) Check return value of
regulator_enable()') depends on the use of devm_kmalloc() for automatic
resource cleanup in the failure cases, which was introduced in 3.7. In
older stable branches, explicit cleanup is needed.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 8c958c703e upstream.
On LTC2978, only READ_TEMPERATURE is supported. It reports
the internal junction temperature. This register is unpaged.
On LTC3880, READ_TEMPERATURE and READ_TEMPERATURE2 are supported.
READ_TEMPERATURE is paged and reports external temperatures.
READ_TEMPERATURE2 is unpaged and reports the internal junction
temperature.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
We need to tune the board specific adcmap parameters
So need functions to set specific parameters.
void pm8xxx_set_adcmap_btm_threshold(void *pts, int size)
void pm8xxx_set_adcmap_pa_therm(void *pts, int size)
void pm8xxx_set_adcmap_ntcg_104ef_104fb(void *pts, int size)
Change-Id: Ie78c11f5fb998ecc456defa3c8e3e7a3e0b9b45f
Incorrect PMIC_THERM/XO_THERM readings are seen when
the XO clock is disabled.
The internal PMIC therm relies on the PMIC band gap
reference which in turn is enabled when any of the
PMIC clock buffers are enabled. The XO_THERM relies
on the VREF_XO as its reference source which gets
enabled when any of the PMIC clock buffers are
switched on. Therefore vote for a clock buffer when
a PMIC_THERM/XO_THERM is requested.
CRs-Fixed: 392602
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
(cherry picked from commit f9dfe1b7b70b634422fbbbf65756aa997536bd33)
Change-Id: I09e132dbc4e635b96cd08ece245a766d68ed27b4
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
Conflicts:
drivers/hwmon/pm8xxx-adc.c
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
(cherry picked from commit 8ab75c713cef66317f9507b35cc08a5d7b49ae44)
Conflicts:
drivers/hwmon/pm8xxx-adc.c
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
commit f366fccd08 upstream.
We read the chip ID from the chip, use it to determine if the chip ID provided
to the driver is correct, and report it if wrong. We should also use the
correct chip ID to select supported functionality.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit dbd712c227 upstream.
Peak attributes were not initialized and cleared correctly.
Also, temp2_max is only supported on page 0 and thus does not need to be
an array.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 3e78080f81 upstream.
Not having power is a pretty serious error so check that we are able to
enable the supply and error out if we can't.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
VADC/IADC peripheral is supported from PMIC 2.0 onwards.
Add version check to allow VADC/IADC reads if the
version is supported. Add probe defereal api for clients
who need to know if the ADC driver is ready. There is a
bug where the completion is not initialized. Fix it
by initializing it. Add support to disable the peripheral
after the ADC is read and enable it before starting a
conversion.
Add scaling functions to support reading the die temperature,
XO_THERM, batt_therm and batt_id. Add the ratiometric
calibration routine that uses the vref/gnd for calibration.
The ratiometric calibration is used for calibrating xo_therm,
batt_therm, batt_id.
Update the gain value used for calibration on the IADC
peripheral. PMIC 2.0 IADC peripheral uses 17.857mV instead
of 25mV for its gain calibration.
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
(cherry picked from commit 5ace110e2165fba66227e18154d58b0e6cbb24b2)
Change-Id: I37b02de53ea2bed913c30261624c31a1ae57131c
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
Incorrect spi write transactions and incorrect readings
are seen. This is because of using incorrect SPI slave
address while initiating the SPI writes to the ADS ADC.
Also fix the incorrect scaling when converting the raw ADC
code to the appropriate physical result.
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
(cherry picked from commit de90ed4d1f8285e4fe663a3ca52d3e377b590ef1)
Change-Id: I0280d7d014a9ba88e3b6eac02764feb8cdd55c66
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
Add support for communicating with the PSOC
using the supported protocol commands from
the PSOC.
The support includes communicating with the
controller to initiate and start the ADC
conversion for the selected channels. Start
and receive ADC conversion for single measurement,
buffered reads, averaging the samples and returning
the results over the set averaging period.
Other commands supported include setting/receiving
the timestamp, setting reference voltage, toggling
gpio to set triggers on set events.
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
(cherry picked from commit efddea4639f2953375fb822524fcae756ae67dc0)
Change-Id: Id519a5b9033b85953f1d6229a144f9df78910900
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
The scaling function multiplies the ADC code with
a high scale factor to avoid rouding accuracy errors.
This results in a 32 bit integer not being sufficient
to store the result. Therefore use a 64 bit integer
type to process the result.
Signed-off-by: Yan He <yanhe@codeaurora.org>
(cherry picked from commit f6adab796cfd509c4c5beb9f0458e0d9fd8da6a6)
Change-Id: I94b26df3a3d0860c92fbb991e015ed0e3b185884
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
We need to tune the board specific adcmap parameters
So need functions to set specific parameters.
void pm8xxx_set_adcmap_btm_threshold(void *pts, int size)
void pm8xxx_set_adcmap_pa_therm(void *pts, int size)
void pm8xxx_set_adcmap_ntcg_104ef_104fb(void *pts, int size)
Change-Id: Ie78c11f5fb998ecc456defa3c8e3e7a3e0b9b45f
Fix reading/writing to the correct ADC peripheral offset
address during SPMI read/writes. While adding multiple
channels an incorrect channel index initialization causes
the ADC reads to occur only on one channel. Fix it by
initializing the channel index only once at init.
The configure api has few register read/writes done
without using the bit mask field. Fix it by reading
the register and updating only the concerned bits.
Also add more comments to the configure api to list
out the steps for each register configuration and
fix using the correct print statements on error.
Change-Id: I0ce67163c5f27021f5fb0905fe601f4b1e0ee8b8
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
The QPNP IADC driver supports the user bank
peripheral of the current ADC(IADC).
IADC is a 16 bit ADC used for measuring current.
The single measurement mode is supported to read
current from upto seven channel configuration.
Clients can read the internal/external Rsense,
CSP_EX, CSN_RX along with gain and offset
calibraton channels.
Change-Id: I7e5ae3fc70878d16827d33705853a36bb0aa04f6
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
The PM8xxx ADC interrupt is configured as a
wakeable interrupt. Therefore the system can suspend
and still have the end of conversion interrupt be
serviced.
Add a timeout in the wait_for_completion in case
the end of conversion event is not received. This
is to rule out any side affects if a missed interrupt
occurs.
Change-Id: Iad36ad4fb7e550e563f0bf7803d3e5e861b7aacd
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
The QPNP VADC driver supports the User Bank Peripheral of
the voltage ADC(VADC).
VADC is a 15 bit ADC that measures signals through the
Main analog multiplexer (AMUX) and PREMUX. The driver
arbitrates the request to issue ADC read requests.
VADC driver includes support for the conversion sequencer.
The conversion sequencer is a HW triggered signal to start
ADC measurement on trigger events for PA ON,
camera flash and TX threshold.
The AMUX supports external pull-ups simultaneously. Clients
can select the appropriate AMUX input channel to measure the
ADC for the intended pull up configuration.
Change-Id: I8886968ccec54ad03334b113b4516d4d200e0da8
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>