* [PATCH v2] Implement temperature sensor for vf610-adc
@ 2014-09-18 11:53 Sanchayan Maity
2014-09-18 11:53 ` [PATCH v2] ARM: imx: vf610-adc: Add temperature sensor support Sanchayan Maity
2014-09-18 13:34 ` [PATCH v2] Implement temperature sensor for vf610-adc Shawn Guo
0 siblings, 2 replies; 4+ messages in thread
From: Sanchayan Maity @ 2014-09-18 11:53 UTC (permalink / raw)
To: shawn.guo; +Cc: stefan, jic23, B38611, linux-iio, linux-kernel, Sanchayan Maity
Vybrid ADC peripheral includes a temperature sensor
which is connected to channel number 26. The patch
adds support for the sensor. The raw value is read
and the temperature calculated in milli degree Celsius,
which is returned using IIO_CHAN_INFO_PROCESSED option.
Sanchayan Maity (1):
ARM: imx: vf610-adc: Add temperature sensor support
drivers/iio/adc/vf610_adc.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] ARM: imx: vf610-adc: Add temperature sensor support
2014-09-18 11:53 [PATCH v2] Implement temperature sensor for vf610-adc Sanchayan Maity
@ 2014-09-18 11:53 ` Sanchayan Maity
2014-09-18 13:34 ` [PATCH v2] Implement temperature sensor for vf610-adc Shawn Guo
1 sibling, 0 replies; 4+ messages in thread
From: Sanchayan Maity @ 2014-09-18 11:53 UTC (permalink / raw)
To: shawn.guo; +Cc: stefan, jic23, B38611, linux-iio, linux-kernel, Sanchayan Maity
Vybrid ADC peripheral includes a temperature sensor
which is connected to channel number 26. This patch
adds support for the sensor. The raw value is read
and the temperature calculated in milli degree Celsius,
which is returned using IIO_CHAN_INFO_PROCESSED option.
Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
---
drivers/iio/adc/vf610_adc.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
index 44799eb5..cec257d 100644
--- a/drivers/iio/adc/vf610_adc.c
+++ b/drivers/iio/adc/vf610_adc.c
@@ -91,7 +91,7 @@
#define VF610_ADC_CAL 0x80
/* Other field define */
-#define VF610_ADC_ADCHC(x) ((x) & 0xF)
+#define VF610_ADC_ADCHC(x) ((x) & 0x1F)
#define VF610_ADC_AIEN (0x1 << 7)
#define VF610_ADC_CONV_DISABLE 0x1F
#define VF610_ADC_HS_COCO0 0x1
@@ -153,6 +153,12 @@ struct vf610_adc {
BIT(IIO_CHAN_INFO_SAMP_FREQ), \
}
+#define VF610_ADC_TEMPERATURE_CHAN(_idx, _chan_type) { \
+ .type = (_chan_type), \
+ .channel = (_idx), \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), \
+}
+
static const struct iio_chan_spec vf610_adc_iio_channels[] = {
VF610_ADC_CHAN(0, IIO_VOLTAGE),
VF610_ADC_CHAN(1, IIO_VOLTAGE),
@@ -170,6 +176,7 @@ static const struct iio_chan_spec vf610_adc_iio_channels[] = {
VF610_ADC_CHAN(13, IIO_VOLTAGE),
VF610_ADC_CHAN(14, IIO_VOLTAGE),
VF610_ADC_CHAN(15, IIO_VOLTAGE),
+ VF610_ADC_TEMPERATURE_CHAN(26, IIO_TEMP),
/* sentinel */
};
@@ -451,6 +458,7 @@ static int vf610_read_raw(struct iio_dev *indio_dev,
switch (mask) {
case IIO_CHAN_INFO_RAW:
+ case IIO_CHAN_INFO_PROCESSED:
mutex_lock(&indio_dev->mlock);
reinit_completion(&info->completion);
@@ -468,7 +476,23 @@ static int vf610_read_raw(struct iio_dev *indio_dev,
return ret;
}
- *val = info->value;
+ switch (chan->type) {
+ case IIO_VOLTAGE:
+ *val = info->value;
+ break;
+ case IIO_TEMP:
+ /*
+ * Calculate in degree Celsius times 1000
+ * Using sensor slope of 1.84 mV/°C and
+ * V at 25°C of 696mv
+ */
+ *val = 25000 - ((int)info->value - 864) * 1000000 / 1840;
+ break;
+ default:
+ mutex_unlock(&indio_dev->mlock);
+ return -EINVAL;
+ }
+
mutex_unlock(&indio_dev->mlock);
return IIO_VAL_INT;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] Implement temperature sensor for vf610-adc
2014-09-18 11:53 [PATCH v2] Implement temperature sensor for vf610-adc Sanchayan Maity
2014-09-18 11:53 ` [PATCH v2] ARM: imx: vf610-adc: Add temperature sensor support Sanchayan Maity
@ 2014-09-18 13:34 ` Shawn Guo
2014-09-19 9:57 ` Sanchayan Maity
1 sibling, 1 reply; 4+ messages in thread
From: Shawn Guo @ 2014-09-18 13:34 UTC (permalink / raw)
To: Sanchayan Maity; +Cc: stefan, jic23, B38611, linux-iio, linux-kernel
On Thu, Sep 18, 2014 at 05:23:22PM +0530, Sanchayan Maity wrote:
> Vybrid ADC peripheral includes a temperature sensor
> which is connected to channel number 26. The patch
> adds support for the sensor. The raw value is read
> and the temperature calculated in milli degree Celsius,
> which is returned using IIO_CHAN_INFO_PROCESSED option.
>
> Sanchayan Maity (1):
> ARM: imx: vf610-adc: Add temperature sensor support
This is not an arch/arm/mach-imx patch, so shouldn't be prefixed with
"ARM: imx: ". And also it's more appropriate to put Jonathan Cameron
<jic23@kernel.org> on "To:", since he is responsible for picking
drivers/iio/adc patches.
Shawn
>
> drivers/iio/adc/vf610_adc.c | 28 ++++++++++++++++++++++++++--
> 1 file changed, 26 insertions(+), 2 deletions(-)
>
> --
> 1.7.9.5
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] Implement temperature sensor for vf610-adc
2014-09-18 13:34 ` [PATCH v2] Implement temperature sensor for vf610-adc Shawn Guo
@ 2014-09-19 9:57 ` Sanchayan Maity
0 siblings, 0 replies; 4+ messages in thread
From: Sanchayan Maity @ 2014-09-19 9:57 UTC (permalink / raw)
To: Shawn Guo; +Cc: Stefan Agner, jic23, B38611, linux-iio, linux-kernel
>> Vybrid ADC peripheral includes a temperature sensor
>> which is connected to channel number 26. The patch
>> adds support for the sensor. The raw value is read
>> and the temperature calculated in milli degree Celsius,
>> which is returned using IIO_CHAN_INFO_PROCESSED option.
>>
>> Sanchayan Maity (1):
>> ARM: imx: vf610-adc: Add temperature sensor support
>
> This is not an arch/arm/mach-imx patch, so shouldn't be prefixed with
> "ARM: imx: ". And also it's more appropriate to put Jonathan Cameron
> <jic23@kernel.org> on "To:", since he is responsible for picking
> drivers/iio/adc patches.
>
> Shawn
Thanks for the input. Will clean and resend. Will address the v3 patch
to Jonathan.
>
>>
>> drivers/iio/adc/vf610_adc.c | 28 ++++++++++++++++++++++++++--
>> 1 file changed, 26 insertions(+), 2 deletions(-)
>>
>> --
>> 1.7.9.5
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-09-19 9:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-18 11:53 [PATCH v2] Implement temperature sensor for vf610-adc Sanchayan Maity
2014-09-18 11:53 ` [PATCH v2] ARM: imx: vf610-adc: Add temperature sensor support Sanchayan Maity
2014-09-18 13:34 ` [PATCH v2] Implement temperature sensor for vf610-adc Shawn Guo
2014-09-19 9:57 ` Sanchayan Maity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox