How to turn on device by gpio in kernel space?

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

How to turn on device by gpio in kernel space?

1,381 Views
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

Labels (1)
Tags (3)
0 Kudos
3 Replies

837 Views
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 Kudos

836 Views
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 Kudos

836 Views
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 Kudos