提交 951d21de 编写于 作者: T Tony Lindgren 提交者: Jonathan Cameron

iio: adc: cpcap: Fix die temperature

It seems that "MC13783 Power Management and Audio Ciruit User's Guide"
MC1378UG.pdf documents several similar components as in the CPCAP PMIC.

Chapter "9.5.5 Die Temperature and UID" says that the die temperature
value is 282 at 25C with LSB of -1.14C. Converting CPCAP PMIC channel3
values with following seems to produce values that make sense for a
PMIC die:

temperature = 25000 + ((regval - 282) * 114)

As we don't have any other documentation, let's assume the die
temperature is unconfigured in the Motorola mapphone Linux kernel
and the current temperature conversion table should be only used
for the battery thermistor and not for the die temperature.

Cc: Marcel Partap <mpartap@gmx.net>
Cc: Michael Scott <michael.scott@linaro.org>
Cc: Sebastian Reichel <sre@kernel.org>
Signed-off-by: NTony Lindgren <tony@atomide.com>
Signed-off-by: NJonathan Cameron <jic23@kernel.org>
上级 3f9f3a1a
...@@ -874,6 +874,22 @@ static int cpcap_adc_init_request(struct cpcap_adc_request *req, ...@@ -874,6 +874,22 @@ static int cpcap_adc_init_request(struct cpcap_adc_request *req,
return 0; return 0;
} }
static int cpcap_adc_read_st_die_temp(struct cpcap_adc *ddata,
int addr, int *val)
{
int error;
error = regmap_read(ddata->reg, addr, val);
if (error)
return error;
*val -= 282;
*val *= 114;
*val += 25000;
return 0;
}
static int cpcap_adc_read(struct iio_dev *indio_dev, static int cpcap_adc_read(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, struct iio_chan_spec const *chan,
int *val, int *val2, long mask) int *val, int *val2, long mask)
...@@ -905,9 +921,18 @@ static int cpcap_adc_read(struct iio_dev *indio_dev, ...@@ -905,9 +921,18 @@ static int cpcap_adc_read(struct iio_dev *indio_dev,
error = cpcap_adc_start_bank(ddata, &req); error = cpcap_adc_start_bank(ddata, &req);
if (error) if (error)
goto err_unlock; goto err_unlock;
error = cpcap_adc_read_bank_scaled(ddata, &req); if ((ddata->vendor == CPCAP_VENDOR_ST) &&
if (error) (chan->channel == CPCAP_ADC_AD3)) {
goto err_unlock; error = cpcap_adc_read_st_die_temp(ddata,
chan->address,
&req.result);
if (error)
goto err_unlock;
} else {
error = cpcap_adc_read_bank_scaled(ddata, &req);
if (error)
goto err_unlock;
}
error = cpcap_adc_stop_bank(ddata); error = cpcap_adc_stop_bank(ddata);
if (error) if (error)
goto err_unlock; goto err_unlock;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册