All of lore.kernel.org
 help / color / mirror / Atom feed
* Accessing specific hardware features of mxs-lradc
@ 2013-07-02 10:49 Hector Palacios
  2013-07-02 12:06 ` Marek Vasut
  2013-07-02 12:58 ` Lars-Peter Clausen
  0 siblings, 2 replies; 9+ messages in thread
From: Hector Palacios @ 2013-07-02 10:49 UTC (permalink / raw)
  To: linux-iio; +Cc: Marek Vasut, fabio.estevam

Greetings,

The mxs-lradc has some hardware specific features like the DIVIDE_BY_TWO (an analog 
divide by two circuit that can be activated per channel).
This is not currently implemented in the driver and I was wondering what would be the 
way to expose and control such setting. A specific sysfs entry? Somehow through the 
device tree?

Is there any example of how to control a hw-specific feature in other similar iio drivers?

Best regards,
--
Hector Palacios

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Accessing specific hardware features of mxs-lradc
  2013-07-02 10:49 Accessing specific hardware features of mxs-lradc Hector Palacios
@ 2013-07-02 12:06 ` Marek Vasut
  2013-07-02 12:58 ` Lars-Peter Clausen
  1 sibling, 0 replies; 9+ messages in thread
From: Marek Vasut @ 2013-07-02 12:06 UTC (permalink / raw)
  To: Hector Palacios; +Cc: linux-iio, fabio.estevam

Hi Hector,

> Greetings,
> 
> The mxs-lradc has some hardware specific features like the DIVIDE_BY_TWO
> (an analog divide by two circuit that can be activated per channel).
> This is not currently implemented in the driver and I was wondering what
> would be the way to expose and control such setting. A specific sysfs
> entry? Somehow through the device tree?

The proper way would be to see of IIO doesn't already have some ways to control 
those (it likely does) and then these would automatically be accessible via 
sysfs.

> Is there any example of how to control a hw-specific feature in other
> similar iio drivers?

None that I'm aware of, but I didn't look. I suspect this would be somewhere 
around the channel defitionion, since the /2 function of the LRADC is a per-
channel feature on the LRADC.

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Accessing specific hardware features of mxs-lradc
  2013-07-02 10:49 Accessing specific hardware features of mxs-lradc Hector Palacios
  2013-07-02 12:06 ` Marek Vasut
@ 2013-07-02 12:58 ` Lars-Peter Clausen
  2013-07-02 13:28   ` Alexandre Belloni
  1 sibling, 1 reply; 9+ messages in thread
From: Lars-Peter Clausen @ 2013-07-02 12:58 UTC (permalink / raw)
  To: Hector Palacios; +Cc: linux-iio, Marek Vasut, fabio.estevam

On 07/02/2013 12:49 PM, Hector Palacios wrote:
> Greetings,
> 
> The mxs-lradc has some hardware specific features like the DIVIDE_BY_TWO (an
> analog divide by two circuit that can be activated per channel).
> This is not currently implemented in the driver and I was wondering what would
> be the way to expose and control such setting. A specific sysfs entry? Somehow
> through the device tree?
> 
> Is there any example of how to control a hw-specific feature in other similar
> iio drivers?
> 

This sounds as if the channel scale is programmable. There are quite a few
drivers for devices which have similar features, just make the scale property
writable and provide a scale_available.

- Lars

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Accessing specific hardware features of mxs-lradc
  2013-07-02 12:58 ` Lars-Peter Clausen
@ 2013-07-02 13:28   ` Alexandre Belloni
  2013-07-02 14:55     ` Hector Palacios
  0 siblings, 1 reply; 9+ messages in thread
From: Alexandre Belloni @ 2013-07-02 13:28 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Hector Palacios, linux-iio, Marek Vasut, fabio.estevam

On 02/07/2013 14:58, Lars-Peter Clausen wrote:
> On 07/02/2013 12:49 PM, Hector Palacios wrote:
>> Greetings,
>>
>> The mxs-lradc has some hardware specific features like the DIVIDE_BY_TWO (an
>> analog divide by two circuit that can be activated per channel).
>> This is not currently implemented in the driver and I was wondering what would
>> be the way to expose and control such setting. A specific sysfs entry? Somehow
>> through the device tree?
>>
>> Is there any example of how to control a hw-specific feature in other similar
>> iio drivers?
>>
> 
> This sounds as if the channel scale is programmable. There are quite a few
> drivers for devices which have similar features, just make the scale property
> writable and provide a scale_available.
> 

I was looking at that yesterday as I had to had a scale for the
temperature sensors. You'll have to be careful because the maximum
measured voltage when DIVIDE_BY_TWO is not set is 1.85V and when it is
set, it becomes VDDIO - 50mv.

Also, scaling for quite a lot of channels is fixed. You'll also get
channels with a fixed divider that can take DIVIDE_BY_TWO. That is quite
a mess ;)

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Accessing specific hardware features of mxs-lradc
  2013-07-02 13:28   ` Alexandre Belloni
@ 2013-07-02 14:55     ` Hector Palacios
  2013-07-02 15:21       ` Lars-Peter Clausen
  0 siblings, 1 reply; 9+ messages in thread
From: Hector Palacios @ 2013-07-02 14:55 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Lars-Peter Clausen, linux-iio, Marek Vasut, fabio.estevam

Hello,

On 07/02/2013 03:28 PM, Alexandre Belloni wrote:
> On 02/07/2013 14:58, Lars-Peter Clausen wrote:
>> On 07/02/2013 12:49 PM, Hector Palacios wrote:
>>> Greetings,
>>>
>>> The mxs-lradc has some hardware specific features like the DIVIDE_BY_TWO (an
>>> analog divide by two circuit that can be activated per channel).
>>> This is not currently implemented in the driver and I was wondering what would
>>> be the way to expose and control such setting. A specific sysfs entry? Somehow
>>> through the device tree?
>>>
>>> Is there any example of how to control a hw-specific feature in other similar
>>> iio drivers?
>>>
>>
>> This sounds as if the channel scale is programmable. There are quite a few
>> drivers for devices which have similar features, just make the scale property
>> writable and provide a scale_available.
>>
>
> I was looking at that yesterday as I had to had a scale for the
> temperature sensors. You'll have to be careful because the maximum
> measured voltage when DIVIDE_BY_TWO is not set is 1.85V and when it is
> set, it becomes VDDIO - 50mv.
>
> Also, scaling for quite a lot of channels is fixed. You'll also get
> channels with a fixed divider that can take DIVIDE_BY_TWO. That is quite
> a mess ;)

Thank you, I checked and it's easy to add custom sysfs attributes using 
IIO_DEVICE_ATTR(). I was thinking whether adding a divide_by_two attribute per channel:

	divide_by_two0
	divide_by_two1
	...
	divide_by_two7

or a unique divide_by_two descriptor that admits a mask value for all channels.
I think the first approach (one per channel) is cleaner. Opinions?

Best regards,
--
Hector Palacios

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Accessing specific hardware features of mxs-lradc
  2013-07-02 14:55     ` Hector Palacios
@ 2013-07-02 15:21       ` Lars-Peter Clausen
  2013-07-02 15:41         ` Lars-Peter Clausen
  2013-07-02 15:45         ` Alexandre Belloni
  0 siblings, 2 replies; 9+ messages in thread
From: Lars-Peter Clausen @ 2013-07-02 15:21 UTC (permalink / raw)
  To: Hector Palacios; +Cc: Alexandre Belloni, linux-iio, Marek Vasut, fabio.estevam

On 07/02/2013 04:55 PM, Hector Palacios wrote:
> Hello,
> 
> On 07/02/2013 03:28 PM, Alexandre Belloni wrote:
>> On 02/07/2013 14:58, Lars-Peter Clausen wrote:
>>> On 07/02/2013 12:49 PM, Hector Palacios wrote:
>>>> Greetings,
>>>>
>>>> The mxs-lradc has some hardware specific features like the DIVIDE_BY_TWO (an
>>>> analog divide by two circuit that can be activated per channel).
>>>> This is not currently implemented in the driver and I was wondering what would
>>>> be the way to expose and control such setting. A specific sysfs entry? Somehow
>>>> through the device tree?
>>>>
>>>> Is there any example of how to control a hw-specific feature in other similar
>>>> iio drivers?
>>>>
>>>
>>> This sounds as if the channel scale is programmable. There are quite a few
>>> drivers for devices which have similar features, just make the scale property
>>> writable and provide a scale_available.
>>>
>>
>> I was looking at that yesterday as I had to had a scale for the
>> temperature sensors. You'll have to be careful because the maximum
>> measured voltage when DIVIDE_BY_TWO is not set is 1.85V and when it is
>> set, it becomes VDDIO - 50mv.

I had a quick peak at the datasheet and I think that's a typo. VDDIO is 3.3V.
This sentence also doesn't make much sense if divide by two would actually
lower the range. "For input channels (other than BATT, 5V, or VDDIO) with
signals larger than 1.85 V, the divide-by-two option should be set."

>>
>> Also, scaling for quite a lot of channels is fixed. You'll also get
>> channels with a fixed divider that can take DIVIDE_BY_TWO. That is quite
>> a mess ;)
> 
> Thank you, I checked and it's easy to add custom sysfs attributes using
> IIO_DEVICE_ATTR(). I was thinking whether adding a divide_by_two attribute per
> channel:
> 
>     divide_by_two0
>     divide_by_two1
>     ...
>     divide_by_two7
> 
> or a unique divide_by_two descriptor that admits a mask value for all channels.
> I think the first approach (one per channel) is cleaner. Opinions?

Just use the scale attribute for this. That's the standard way to handle this,
don't invent custom interfaces if there is already a generic one.

- Lars


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Accessing specific hardware features of mxs-lradc
  2013-07-02 15:21       ` Lars-Peter Clausen
@ 2013-07-02 15:41         ` Lars-Peter Clausen
  2013-07-02 15:45         ` Alexandre Belloni
  1 sibling, 0 replies; 9+ messages in thread
From: Lars-Peter Clausen @ 2013-07-02 15:41 UTC (permalink / raw)
  To: Hector Palacios; +Cc: Alexandre Belloni, linux-iio, Marek Vasut, fabio.estevam

On 07/02/2013 05:21 PM, Lars-Peter Clausen wrote:
> On 07/02/2013 04:55 PM, Hector Palacios wrote:
>> Hello,
>>
>> On 07/02/2013 03:28 PM, Alexandre Belloni wrote:
>>> On 02/07/2013 14:58, Lars-Peter Clausen wrote:
>>>> On 07/02/2013 12:49 PM, Hector Palacios wrote:
>>>>> Greetings,
>>>>>
>>>>> The mxs-lradc has some hardware specific features like the DIVIDE_BY_TWO (an
>>>>> analog divide by two circuit that can be activated per channel).
>>>>> This is not currently implemented in the driver and I was wondering what would
>>>>> be the way to expose and control such setting. A specific sysfs entry? Somehow
>>>>> through the device tree?
>>>>>
>>>>> Is there any example of how to control a hw-specific feature in other similar
>>>>> iio drivers?
>>>>>
>>>>
>>>> This sounds as if the channel scale is programmable. There are quite a few
>>>> drivers for devices which have similar features, just make the scale property
>>>> writable and provide a scale_available.
>>>>
>>>
>>> I was looking at that yesterday as I had to had a scale for the
>>> temperature sensors. You'll have to be careful because the maximum
>>> measured voltage when DIVIDE_BY_TWO is not set is 1.85V and when it is
>>> set, it becomes VDDIO - 50mv.
> 
> I had a quick peak at the datasheet and I think that's a typo. VDDIO is 3.3V.
> This sentence also doesn't make much sense if divide by two would actually
> lower the range. "For input channels (other than BATT, 5V, or VDDIO) with
> signals larger than 1.85 V, the divide-by-two option should be set."

Uhm, ignore this, parse error on my side. I thought the dash was a hyphen not a
minus.

> 
>>>
>>> Also, scaling for quite a lot of channels is fixed. You'll also get
>>> channels with a fixed divider that can take DIVIDE_BY_TWO. That is quite
>>> a mess ;)
>>
>> Thank you, I checked and it's easy to add custom sysfs attributes using
>> IIO_DEVICE_ATTR(). I was thinking whether adding a divide_by_two attribute per
>> channel:
>>
>>     divide_by_two0
>>     divide_by_two1
>>     ...
>>     divide_by_two7
>>
>> or a unique divide_by_two descriptor that admits a mask value for all channels.
>> I think the first approach (one per channel) is cleaner. Opinions?
> 
> Just use the scale attribute for this. That's the standard way to handle this,
> don't invent custom interfaces if there is already a generic one.
> 
> - Lars
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Accessing specific hardware features of mxs-lradc
  2013-07-02 15:21       ` Lars-Peter Clausen
  2013-07-02 15:41         ` Lars-Peter Clausen
@ 2013-07-02 15:45         ` Alexandre Belloni
  2013-07-02 15:55           ` Lars-Peter Clausen
  1 sibling, 1 reply; 9+ messages in thread
From: Alexandre Belloni @ 2013-07-02 15:45 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Hector Palacios, linux-iio, Marek Vasut, fabio.estevam

On 02/07/2013 17:21, Lars-Peter Clausen wrote:
>>>
>>> I was looking at that yesterday as I had to had a scale for the
>>> temperature sensors. You'll have to be careful because the maximum
>>> measured voltage when DIVIDE_BY_TWO is not set is 1.85V and when it is
>>> set, it becomes VDDIO - 50mv.
> 
> I had a quick peak at the datasheet and I think that's a typo. VDDIO is 3.3V.
> This sentence also doesn't make much sense if divide by two would actually
> lower the range. "For input channels (other than BATT, 5V, or VDDIO) with
> signals larger than 1.85 V, the divide-by-two option should be set."
> 

Yeah, what I think they meant is if !DIVIDE_BY_TWO : Vmax = 1.85V else
Vmax = 3.25V. So it may not be as easy as multiplying hte scale by two.
I couldn't test it, so I didn't implement it.

>>>
>>> Also, scaling for quite a lot of channels is fixed. You'll also get
>>> channels with a fixed divider that can take DIVIDE_BY_TWO. That is quite
>>> a mess ;)
>>
>> Thank you, I checked and it's easy to add custom sysfs attributes using
>> IIO_DEVICE_ATTR(). I was thinking whether adding a divide_by_two attribute per
>> channel:
>>
>>     divide_by_two0
>>     divide_by_two1
>>     ...
>>     divide_by_two7
>>
>> or a unique divide_by_two descriptor that admits a mask value for all channels.
>> I think the first approach (one per channel) is cleaner. Opinions?
> 
> Just use the scale attribute for this. That's the standard way to handle this,
> don't invent custom interfaces if there is already a generic one.
> 

Hector, you can have a look at what I did there:

http://marc.info/?l=linux-iio&m=137269905605960&w=2

Add IIO_CHAN_INFO_SCALE to .info_mask_separate in the MXS_ADC_CHAN
macro. Then, implement the scaling in the switch case in
mxs_lradc_read_raw and you'll probably also want to implement a write_raw.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Accessing specific hardware features of mxs-lradc
  2013-07-02 15:45         ` Alexandre Belloni
@ 2013-07-02 15:55           ` Lars-Peter Clausen
  0 siblings, 0 replies; 9+ messages in thread
From: Lars-Peter Clausen @ 2013-07-02 15:55 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Hector Palacios, linux-iio, Marek Vasut, fabio.estevam

On 07/02/2013 05:45 PM, Alexandre Belloni wrote:
> On 02/07/2013 17:21, Lars-Peter Clausen wrote:
>>>>
>>>> I was looking at that yesterday as I had to had a scale for the
>>>> temperature sensors. You'll have to be careful because the maximum
>>>> measured voltage when DIVIDE_BY_TWO is not set is 1.85V and when it is
>>>> set, it becomes VDDIO - 50mv.
>>
>> I had a quick peak at the datasheet and I think that's a typo. VDDIO is 3.3V.
>> This sentence also doesn't make much sense if divide by two would actually
>> lower the range. "For input channels (other than BATT, 5V, or VDDIO) with
>> signals larger than 1.85 V, the divide-by-two option should be set."
>>
> 
> Yeah, what I think they meant is if !DIVIDE_BY_TWO : Vmax = 1.85V else
> Vmax = 3.25V. So it may not be as easy as multiplying hte scale by two.
> I couldn't test it, so I didn't implement it.

Parse error on my side, in the datasheet it is a hyphen not a minus, so I
though the sentence meant that the maximum is 50mV.

I guess it is still a divide by two, but since the max input voltage is 3.3V
you simply can't max out the ADC anymore since the maximum value corresponds to
3.7V

-Lars

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-07-02 15:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-02 10:49 Accessing specific hardware features of mxs-lradc Hector Palacios
2013-07-02 12:06 ` Marek Vasut
2013-07-02 12:58 ` Lars-Peter Clausen
2013-07-02 13:28   ` Alexandre Belloni
2013-07-02 14:55     ` Hector Palacios
2013-07-02 15:21       ` Lars-Peter Clausen
2013-07-02 15:41         ` Lars-Peter Clausen
2013-07-02 15:45         ` Alexandre Belloni
2013-07-02 15:55           ` Lars-Peter Clausen

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.