Read ADC values in imx6ul in Kernel space

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Read ADC values in imx6ul in Kernel space

跳至解决方案
5,716 次查看
chandraevolute
Contributor V

Hi,

I have a printer attached to imx6ul using SPI. It is a thermal printer so on printing the printer gets heated up so I have change the printing time according to the Head temperature. Now the problem is If I read from the sysfs interface from Application space it is taking too much time for printing and my printer head is getting damaged.

Is there any way to do in the kernel space itself. I have to read the ADC for each dotted line printing and take decision for heating time or else I should terminate the printing. 

Thanks

CHandrasekhar

标签 (3)
0 项奖励
回复
1 解答
5,127 次查看
igorpadykov
NXP Employee
NXP Employee

Hi Chandrasekhar

reason may be that when vf610 adc driver is disabled, adc clocks are gated.

Best regards
igor

在原帖中查看解决方案

0 项奖励
回复
11 回复数
5,127 次查看
igorpadykov
NXP Employee
NXP Employee

Hi Chandra

one can look for answer on that linux generic question on

linux - How to access kernel space from user space? - Stack Overflow 

or probably write own application using driver sources described in Chapter 53 ADC Driver

attached Linux Manual.

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
5,127 次查看
chandraevolute
Contributor V

Hi Igor,

Any example for dt-bindings for consumer adc for imx6ul??

0 项奖励
回复
5,127 次查看
igorpadykov
NXP Employee
NXP Employee
0 项奖励
回复
5,127 次查看
chandraevolute
Contributor V

Hi Igor,

I am able to read ADC values from sysfs interface. 

I am going through the imx-test-5.7 for /dev/mem interface accessing ADC. I found a strange issue . I enable vf610 adc driver and running memtool on ADC, what ever data I write to ADC registers when reading back I am able to read the updated values. 

When I disable the vf610 adc driver from make menuconfig and build the kernel and update it and after running memtool on adc values are not updating. Below is the log. 

root@imx6ulevk:/# ./a.out ADC1.CFG.MODE=1

write 0x00000001 to Bit 2..3 of 0x02198014

root@imx6ulevk:/# ./a.out ADC1.CFG.MODE 1

ADC1     Addr:0x2198000

  ADC1.CFG Addr:0x02198014 Value:0x00000200 - Selects the mode of operation, clock source, clock divide, configure for low power, long sample time, high speed configuration and selects the sample time duration.

     ADC1.CFG.MODE(2..3)        :0x0

             Used to set the ADC resolution mode.

Can you tell me what is the wrong I am doing.

Thanks and Regards,

Chandrasekhar

0 项奖励
回复
5,128 次查看
igorpadykov
NXP Employee
NXP Employee

Hi Chandrasekhar

reason may be that when vf610 adc driver is disabled, adc clocks are gated.

Best regards
igor

0 项奖励
回复
5,127 次查看
chandraevolute
Contributor V

Thank you igor for pointing about ADC clock gating. I have enabled adc1 clock (adc1_clk_enable) in CCM register(CCM.CCGR1.CG8=1
)and able to get the ADC working using memtool. 

0 项奖励
回复
5,127 次查看
chandraevolute
Contributor V

Hi Igor, 

How to resolve the above issue

Regards,

CHandrasekhar

0 项奖励
回复
5,127 次查看
srikittu34
Contributor II

hi Chandra sekhar

 i am trying to interface thermal printer using spi .. getting full of confusions regarding driver code . can you please suggest me the procedure of how to interface thermal printer . here i am going with imx6solo sabresd board. your info more valuable for me.

regards,

srikrishna

0 项奖励
回复
5,127 次查看
chandraevolute
Contributor V

It depends on Thermal printer you use. There will be a sequence to use, that you have to push the data to SPI and Enable Strobes and VH and rotate paper. I don't know what is your exact requirement. 

0 项奖励
回复
5,127 次查看
igorpadykov
NXP Employee
NXP Employee

Hi Chandrasekhar

 

seems vf610 adc driver should be enabled.

 

Best regards
igor

0 项奖励
回复
5,127 次查看
chandraevolute
Contributor V

I have just gone through the IIO subsystem in drivers, there I have found a source file inkern.c I understood that we can call the functions present in inkern.c file to read a ADC value. Is that correct ?? Below is the link for the same from stackoverflow

linux - Communication between different subsystem drivers(For ex: IIO and Charging driver) - Stack O... 

0 项奖励
回复