* [PATCH] iio: adc: mcp320x: support more differential voltage measurement
@ 2016-01-07 15:40 Akinobu Mita
2016-01-09 16:28 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Akinobu Mita @ 2016-01-07 15:40 UTC (permalink / raw)
To: linux-iio
Cc: Akinobu Mita, Oskar Andero, Jonathan Cameron, Hartmut Knaack,
Lars-Peter Clausen, Peter Meerwald
mcp320x driver supports the pseudo-differential mode by
in_voltage'IN+'-voltage'IN-'_raw where (IN+, IN-) = (0, 1), (2, 3), ...
mcp320x chips except MCP3X01 can also select swapped IN+ and IN-
pairs in the pseudo-differential mode.
i.e. in_voltage'IN+'-voltage'IN-'_raw where (IN+, IN-) = (1, 0),
(3, 2), ...
If the voltage level of IN+ is equal to or less than IN-, the
resultant code will be 000h. So it is useful to provide these, too.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Oskar Andero <oskar.andero@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
Cc: linux-iio@vger.kernel.org
---
drivers/iio/adc/mcp320x.c | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c
index 8569c8e..a9c4acd 100644
--- a/drivers/iio/adc/mcp320x.c
+++ b/drivers/iio/adc/mcp320x.c
@@ -187,26 +187,27 @@ out:
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) \
}
-#define MCP320X_VOLTAGE_CHANNEL_DIFF(num) \
+#define MCP320X_VOLTAGE_CHANNEL_DIFF(chan1, chan2) \
{ \
.type = IIO_VOLTAGE, \
.indexed = 1, \
- .channel = (num * 2), \
- .channel2 = (num * 2 + 1), \
- .address = (num * 2), \
+ .channel = (chan1), \
+ .channel2 = (chan2), \
+ .address = (chan1), \
.differential = 1, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) \
}
static const struct iio_chan_spec mcp3201_channels[] = {
- MCP320X_VOLTAGE_CHANNEL_DIFF(0),
+ MCP320X_VOLTAGE_CHANNEL_DIFF(0, 1),
};
static const struct iio_chan_spec mcp3202_channels[] = {
MCP320X_VOLTAGE_CHANNEL(0),
MCP320X_VOLTAGE_CHANNEL(1),
- MCP320X_VOLTAGE_CHANNEL_DIFF(0),
+ MCP320X_VOLTAGE_CHANNEL_DIFF(0, 1),
+ MCP320X_VOLTAGE_CHANNEL_DIFF(1, 0),
};
static const struct iio_chan_spec mcp3204_channels[] = {
@@ -214,8 +215,10 @@ static const struct iio_chan_spec mcp3204_channels[] = {
MCP320X_VOLTAGE_CHANNEL(1),
MCP320X_VOLTAGE_CHANNEL(2),
MCP320X_VOLTAGE_CHANNEL(3),
- MCP320X_VOLTAGE_CHANNEL_DIFF(0),
- MCP320X_VOLTAGE_CHANNEL_DIFF(1),
+ MCP320X_VOLTAGE_CHANNEL_DIFF(0, 1),
+ MCP320X_VOLTAGE_CHANNEL_DIFF(1, 0),
+ MCP320X_VOLTAGE_CHANNEL_DIFF(2, 3),
+ MCP320X_VOLTAGE_CHANNEL_DIFF(3, 2),
};
static const struct iio_chan_spec mcp3208_channels[] = {
@@ -227,10 +230,14 @@ static const struct iio_chan_spec mcp3208_channels[] = {
MCP320X_VOLTAGE_CHANNEL(5),
MCP320X_VOLTAGE_CHANNEL(6),
MCP320X_VOLTAGE_CHANNEL(7),
- MCP320X_VOLTAGE_CHANNEL_DIFF(0),
- MCP320X_VOLTAGE_CHANNEL_DIFF(1),
- MCP320X_VOLTAGE_CHANNEL_DIFF(2),
- MCP320X_VOLTAGE_CHANNEL_DIFF(3),
+ MCP320X_VOLTAGE_CHANNEL_DIFF(0, 1),
+ MCP320X_VOLTAGE_CHANNEL_DIFF(1, 0),
+ MCP320X_VOLTAGE_CHANNEL_DIFF(2, 3),
+ MCP320X_VOLTAGE_CHANNEL_DIFF(3, 2),
+ MCP320X_VOLTAGE_CHANNEL_DIFF(4, 5),
+ MCP320X_VOLTAGE_CHANNEL_DIFF(5, 4),
+ MCP320X_VOLTAGE_CHANNEL_DIFF(6, 7),
+ MCP320X_VOLTAGE_CHANNEL_DIFF(7, 6),
};
static const struct iio_info mcp320x_info = {
--
2.5.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: adc: mcp320x: support more differential voltage measurement
2016-01-07 15:40 [PATCH] iio: adc: mcp320x: support more differential voltage measurement Akinobu Mita
@ 2016-01-09 16:28 ` Jonathan Cameron
2016-01-16 13:04 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2016-01-09 16:28 UTC (permalink / raw)
To: Akinobu Mita, linux-iio
Cc: Oskar Andero, Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald
On 07/01/16 15:40, Akinobu Mita wrote:
> mcp320x driver supports the pseudo-differential mode by
> in_voltage'IN+'-voltage'IN-'_raw where (IN+, IN-) = (0, 1), (2, 3), ...
>
> mcp320x chips except MCP3X01 can also select swapped IN+ and IN-
> pairs in the pseudo-differential mode.
> i.e. in_voltage'IN+'-voltage'IN-'_raw where (IN+, IN-) = (1, 0),
> (3, 2), ...
>
> If the voltage level of IN+ is equal to or less than IN-, the
> resultant code will be 000h. So it is useful to provide these, too.
>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Oskar Andero <oskar.andero@gmail.com>
> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: Hartmut Knaack <knaack.h@gmx.de>
> Cc: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Peter Meerwald <pmeerw@pmeerw.net>
> Cc: linux-iio@vger.kernel.org
Looks good to me. Will let it sit for a while longer on the list
as we have lots of time at this point in a kernel cycle (new one
has just started as far as IIO is concerned)
Jonathan
> ---
> drivers/iio/adc/mcp320x.c | 31 +++++++++++++++++++------------
> 1 file changed, 19 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c
> index 8569c8e..a9c4acd 100644
> --- a/drivers/iio/adc/mcp320x.c
> +++ b/drivers/iio/adc/mcp320x.c
> @@ -187,26 +187,27 @@ out:
> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) \
> }
>
> -#define MCP320X_VOLTAGE_CHANNEL_DIFF(num) \
> +#define MCP320X_VOLTAGE_CHANNEL_DIFF(chan1, chan2) \
> { \
> .type = IIO_VOLTAGE, \
> .indexed = 1, \
> - .channel = (num * 2), \
> - .channel2 = (num * 2 + 1), \
> - .address = (num * 2), \
> + .channel = (chan1), \
> + .channel2 = (chan2), \
> + .address = (chan1), \
> .differential = 1, \
> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) \
> }
>
> static const struct iio_chan_spec mcp3201_channels[] = {
> - MCP320X_VOLTAGE_CHANNEL_DIFF(0),
> + MCP320X_VOLTAGE_CHANNEL_DIFF(0, 1),
> };
>
> static const struct iio_chan_spec mcp3202_channels[] = {
> MCP320X_VOLTAGE_CHANNEL(0),
> MCP320X_VOLTAGE_CHANNEL(1),
> - MCP320X_VOLTAGE_CHANNEL_DIFF(0),
> + MCP320X_VOLTAGE_CHANNEL_DIFF(0, 1),
> + MCP320X_VOLTAGE_CHANNEL_DIFF(1, 0),
> };
>
> static const struct iio_chan_spec mcp3204_channels[] = {
> @@ -214,8 +215,10 @@ static const struct iio_chan_spec mcp3204_channels[] = {
> MCP320X_VOLTAGE_CHANNEL(1),
> MCP320X_VOLTAGE_CHANNEL(2),
> MCP320X_VOLTAGE_CHANNEL(3),
> - MCP320X_VOLTAGE_CHANNEL_DIFF(0),
> - MCP320X_VOLTAGE_CHANNEL_DIFF(1),
> + MCP320X_VOLTAGE_CHANNEL_DIFF(0, 1),
> + MCP320X_VOLTAGE_CHANNEL_DIFF(1, 0),
> + MCP320X_VOLTAGE_CHANNEL_DIFF(2, 3),
> + MCP320X_VOLTAGE_CHANNEL_DIFF(3, 2),
> };
>
> static const struct iio_chan_spec mcp3208_channels[] = {
> @@ -227,10 +230,14 @@ static const struct iio_chan_spec mcp3208_channels[] = {
> MCP320X_VOLTAGE_CHANNEL(5),
> MCP320X_VOLTAGE_CHANNEL(6),
> MCP320X_VOLTAGE_CHANNEL(7),
> - MCP320X_VOLTAGE_CHANNEL_DIFF(0),
> - MCP320X_VOLTAGE_CHANNEL_DIFF(1),
> - MCP320X_VOLTAGE_CHANNEL_DIFF(2),
> - MCP320X_VOLTAGE_CHANNEL_DIFF(3),
> + MCP320X_VOLTAGE_CHANNEL_DIFF(0, 1),
> + MCP320X_VOLTAGE_CHANNEL_DIFF(1, 0),
> + MCP320X_VOLTAGE_CHANNEL_DIFF(2, 3),
> + MCP320X_VOLTAGE_CHANNEL_DIFF(3, 2),
> + MCP320X_VOLTAGE_CHANNEL_DIFF(4, 5),
> + MCP320X_VOLTAGE_CHANNEL_DIFF(5, 4),
> + MCP320X_VOLTAGE_CHANNEL_DIFF(6, 7),
> + MCP320X_VOLTAGE_CHANNEL_DIFF(7, 6),
> };
>
> static const struct iio_info mcp320x_info = {
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: adc: mcp320x: support more differential voltage measurement
2016-01-09 16:28 ` Jonathan Cameron
@ 2016-01-16 13:04 ` Jonathan Cameron
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2016-01-16 13:04 UTC (permalink / raw)
To: Akinobu Mita, linux-iio
Cc: Oskar Andero, Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald
On 09/01/16 16:28, Jonathan Cameron wrote:
> On 07/01/16 15:40, Akinobu Mita wrote:
>> mcp320x driver supports the pseudo-differential mode by
>> in_voltage'IN+'-voltage'IN-'_raw where (IN+, IN-) = (0, 1), (2, 3), ...
>>
>> mcp320x chips except MCP3X01 can also select swapped IN+ and IN-
>> pairs in the pseudo-differential mode.
>> i.e. in_voltage'IN+'-voltage'IN-'_raw where (IN+, IN-) = (1, 0),
>> (3, 2), ...
>>
>> If the voltage level of IN+ is equal to or less than IN-, the
>> resultant code will be 000h. So it is useful to provide these, too.
>>
>> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
>> Cc: Oskar Andero <oskar.andero@gmail.com>
>> Cc: Jonathan Cameron <jic23@kernel.org>
>> Cc: Hartmut Knaack <knaack.h@gmx.de>
>> Cc: Lars-Peter Clausen <lars@metafoo.de>
>> Cc: Peter Meerwald <pmeerw@pmeerw.net>
>> Cc: linux-iio@vger.kernel.org
> Looks good to me. Will let it sit for a while longer on the list
> as we have lots of time at this point in a kernel cycle (new one
> has just started as far as IIO is concerned)
>
Applied to the togreg branch of iio.git - initially pushed out
as testing for the autobuilders to play with it.
Thanks,
Jonathan
> Jonathan
>> ---
>> drivers/iio/adc/mcp320x.c | 31 +++++++++++++++++++------------
>> 1 file changed, 19 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c
>> index 8569c8e..a9c4acd 100644
>> --- a/drivers/iio/adc/mcp320x.c
>> +++ b/drivers/iio/adc/mcp320x.c
>> @@ -187,26 +187,27 @@ out:
>> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) \
>> }
>>
>> -#define MCP320X_VOLTAGE_CHANNEL_DIFF(num) \
>> +#define MCP320X_VOLTAGE_CHANNEL_DIFF(chan1, chan2) \
>> { \
>> .type = IIO_VOLTAGE, \
>> .indexed = 1, \
>> - .channel = (num * 2), \
>> - .channel2 = (num * 2 + 1), \
>> - .address = (num * 2), \
>> + .channel = (chan1), \
>> + .channel2 = (chan2), \
>> + .address = (chan1), \
>> .differential = 1, \
>> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
>> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) \
>> }
>>
>> static const struct iio_chan_spec mcp3201_channels[] = {
>> - MCP320X_VOLTAGE_CHANNEL_DIFF(0),
>> + MCP320X_VOLTAGE_CHANNEL_DIFF(0, 1),
>> };
>>
>> static const struct iio_chan_spec mcp3202_channels[] = {
>> MCP320X_VOLTAGE_CHANNEL(0),
>> MCP320X_VOLTAGE_CHANNEL(1),
>> - MCP320X_VOLTAGE_CHANNEL_DIFF(0),
>> + MCP320X_VOLTAGE_CHANNEL_DIFF(0, 1),
>> + MCP320X_VOLTAGE_CHANNEL_DIFF(1, 0),
>> };
>>
>> static const struct iio_chan_spec mcp3204_channels[] = {
>> @@ -214,8 +215,10 @@ static const struct iio_chan_spec mcp3204_channels[] = {
>> MCP320X_VOLTAGE_CHANNEL(1),
>> MCP320X_VOLTAGE_CHANNEL(2),
>> MCP320X_VOLTAGE_CHANNEL(3),
>> - MCP320X_VOLTAGE_CHANNEL_DIFF(0),
>> - MCP320X_VOLTAGE_CHANNEL_DIFF(1),
>> + MCP320X_VOLTAGE_CHANNEL_DIFF(0, 1),
>> + MCP320X_VOLTAGE_CHANNEL_DIFF(1, 0),
>> + MCP320X_VOLTAGE_CHANNEL_DIFF(2, 3),
>> + MCP320X_VOLTAGE_CHANNEL_DIFF(3, 2),
>> };
>>
>> static const struct iio_chan_spec mcp3208_channels[] = {
>> @@ -227,10 +230,14 @@ static const struct iio_chan_spec mcp3208_channels[] = {
>> MCP320X_VOLTAGE_CHANNEL(5),
>> MCP320X_VOLTAGE_CHANNEL(6),
>> MCP320X_VOLTAGE_CHANNEL(7),
>> - MCP320X_VOLTAGE_CHANNEL_DIFF(0),
>> - MCP320X_VOLTAGE_CHANNEL_DIFF(1),
>> - MCP320X_VOLTAGE_CHANNEL_DIFF(2),
>> - MCP320X_VOLTAGE_CHANNEL_DIFF(3),
>> + MCP320X_VOLTAGE_CHANNEL_DIFF(0, 1),
>> + MCP320X_VOLTAGE_CHANNEL_DIFF(1, 0),
>> + MCP320X_VOLTAGE_CHANNEL_DIFF(2, 3),
>> + MCP320X_VOLTAGE_CHANNEL_DIFF(3, 2),
>> + MCP320X_VOLTAGE_CHANNEL_DIFF(4, 5),
>> + MCP320X_VOLTAGE_CHANNEL_DIFF(5, 4),
>> + MCP320X_VOLTAGE_CHANNEL_DIFF(6, 7),
>> + MCP320X_VOLTAGE_CHANNEL_DIFF(7, 6),
>> };
>>
>> static const struct iio_info mcp320x_info = {
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-01-16 13:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-07 15:40 [PATCH] iio: adc: mcp320x: support more differential voltage measurement Akinobu Mita
2016-01-09 16:28 ` Jonathan Cameron
2016-01-16 13:04 ` Jonathan Cameron
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.