imx6ul adc driver with selected pins only

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imx6ul adc driver with selected pins only

2,081 Views
krzysztoflukasz
Contributor I

Good morning,

I am trying to set up the ADC on iMX6UL on my custom board and I based on the following thread imx6ul adc driver.

I would like to run ADC on the following pins:

GPIO1_IO02 to GPIO1_IO07.

GPIO1_IO00 to GPIO1_IO01 I want to use as I2C pins.

GPIO1_IO08 to GPIO1_IO09 I want to use as output pins.

I understand that I need to modify in imx6ul.dtsi as follow:

num-channels = <6>;

But doing so I have the following files in

/sys/bus/iio/devices/iio:device0#

-rw-r--r--1 root root      4096 May 21 10:42 in_voltage0_raw                                            
-rw-r--r--1 root root      4096 May 21 10:42 in_voltage1_raw                                            
-rw-r--r--1 root root      4096 May 21 10:42 in_voltage2_raw                                            
-rw-r--r--1 root root      4096 May 21 10:42 in_voltage3_raw                                            
-rw-r--r--1 root root      4096 May 21 10:42 in_voltage4_raw
-rw-r--r--1 root root      4096 May 21 10:42 in_voltage5_raw

which correspond to pins GPIO1_IO00 to GPIO1_IO05.

How to apply the offset to not start from channel 0 but 2 to read pins GPIO1_IO02 to GPIO1_IO07?

Or shall I set channel number to 8 and read only files from in_voltage2_raw to in_voltage7_raw? Can I then still use GPIO1_IO00 to GPIO1_IO01 I2C pins?

How to use adc to read ADC continiously? How should I read /dev/iio:device0 to get access to desired channels?

Best Regards,

Krzysztof Lukaszewicz

Labels (4)
0 Kudos
Reply
7 Replies

1,377 Views
CarlosCasillas
NXP Employee
NXP Employee

Hi Krzysztof,

In case of the “dynamic” drivers that are mounted to the system after the boot up, the regular behavior is having the “first available” device on 0 location. Therefore, if you removed the first two ADC channels, the originally 3rd should now be available as channel 0, but it is recommended verify the connections.

You could also take a look at the following Community document, related to Device Tree:

Basic Device Tree for the Udoo Board

Hope this will be useful for you.
Best regards!
/Carlos
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,377 Views
krzysztoflukasz
Contributor I

Hi Carlos,

Thank you very much for the answer.

I configured pins in my device tree  .dts file in section as follow:

    pinctrl_adc1: adc1grp {

                                        fsl,pins = <

                                        MX6UL_PAD_GPIO1_IO02__GPIO1_IO02 0xb0

                                        MX6UL_PAD_GPIO1_IO03__GPIO1_IO03 0xb0

                                        MX6UL_PAD_GPIO1_IO04__GPIO1_IO04 0xb0

                                        MX6UL_PAD_GPIO1_IO05__GPIO1_IO05 0xb0

                                        MX6UL_PAD_GPIO1_IO06__GPIO1_IO06 0xb0

                                        MX6UL_PAD_GPIO1_IO07__GPIO1_IO07 0xb0

                        >;

                };

And I would like to play only with ADC channels that correspond to these pins.

In imx6ul.dtsi I set as following:

num-channels = <6>;

The following channel files are being created after boot up:

/sys/bus/iio/devices/iio:device0#

-rw-r--r--1 rootroot    4096 May 21 10:42 in_voltage0_raw                                         
-rw-r--r--1 rootroot    4096 May 21 10:42 in_voltage1_raw                                         
-rw-r--r--1 rootroot    4096 May 21 10:42 in_voltage2_raw                                         
-rw-r--r--1 rootroot    4096 May 21 10:42 in_voltage3_raw                                         
-rw-r--r--1 rootroot    4096 May 21 10:42 in_voltage4_raw
-rw-r--r--1 rootroot    4096 May 21 10:42 in_voltage5_raw

But for example file in_voltage0_raw does not correspond to MX6UL_PAD_GPIO1_IO02__GPIO1_IO02 but to MX6UL_PAD_GPIO1_IO00__GPIO1_IO00 which is not as I desired.

So could you please tell me how to remove the two first if not in pinctrl_adc1: adc1grp section as I did?

What do you mean and how to proceed  "removing the first two ADC channels"?

Or maybe I should set num-channels = <10>; and just use them by reading the files from in_voltage_2 to 7_raw only. And the rest of that files until not internally connected to any pins do not affect the system behaviour and they can be kept as they are.

BR,

Krzysztof Lukaszewicz

0 Kudos
Reply

1,377 Views
宗標廖
Contributor V

Hello, Krzysztof

I am also confused by the num-channels, did you resolved this problem?

BR,

ZongbiaoLiao

0 Kudos
Reply

1,377 Views
krzysztoflukasz
Contributor I

Hi Zongbiao,

I think that you can set it to maximum -10 so thanks to that you will have created devices as files to be read or write. Then in pin control section add only the pins you want to phisically mux and use. Then use only the adc files that are phisically muxed. In rest you will have some not true values.

Hope this helps.

BR

Krzysztof Lukaszewicz

0 Kudos
Reply

1,377 Views
宗標廖
Contributor V

Hi, Krzysztof

Thank you for your reply!

Is it no problem to use the rest GPIO1_IOXX as some functions else?

BR

ZongbiaoLiao

0 Kudos
Reply

1,377 Views
krzysztoflukasz
Contributor I

Hi,

It should not be a problem until they are not attached to the pinctrl section of adc. This is what I found out with my prototype. But please check and share the results you will receive.

BR

Krzysztof

0 Kudos
Reply

1,377 Views
宗標廖
Contributor V

Hi, Krzysztof

Thank you!

0 Kudos
Reply