How to turn on device by gpio in kernel space?

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

How to turn on device by gpio in kernel space?

1,408 次查看
trongthinh
Contributor IV

I connected a GPS module to i.MX6 as the picture below. The power of gps module is controlled by a gpio of i.MX6. My question is "How to power on gps module in kernel space by pulling down i.MX6 gpio?" Which driver should i used? Please advise! 

pastedImage_1.png

标签 (1)
标记 (3)
0 项奖励
3 回复数

864 次查看
Carlos_Musich
NXP Employee
NXP Employee

Hi Thinh,

Please take a look to the following thread Issue with configuring GPIO as an interrupt - i.MX6Q 

Here I share a .c file and a .dts of a kernel module that handles a GPIO interrupt.


Regards,
Carlos
NXP Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励

863 次查看
trongthinh
Contributor IV

Thank for replying me! maybe my question is unclear or you misunderstand my idea. I would like to explain it more clearly now:

The power supply (+5V) of GPS module is controled by a GPIO of i.MX6.  If i.MX6 pin has logic 0, this means GPS module has +5V (Module is turned on). If i.MX6 pis has logic 1, this means module is turned off. I would like to power on GPS module on boot up in kernel space (default GPS module is off), so I think there should be a regulator driver.

I have read/studied regulator-fixed driver, is it the exact driver that i need in this situations?

0 项奖励

863 次查看
mtx512
Contributor V

If your wanting to enable gpio at startup then you could do it from uboot hence before the kernel is launched.

A regulator isn't the ideal way to achieve this as the regulator should represent a physical regulator on the board (in your case there isn't one). However it can be used as a workaround to enable the gpio pin. 

Normally in these types of scenarios there would a custom device tree entry (ie gps) in the dts with 2 properties, one to configure the power gpio pin and the other to enable/disable the power. The custom device tree entry would map to a custom kernel driver (you need to write) that would toggle the pin. However can you imagine this is more work than using a pseudo regulator.

0 项奖励