How to set iomux for GPIO operation?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to set iomux for GPIO operation?

ソリューションへジャンプ
3,115件の閲覧回数
timellis
Contributor I

I'm trying to find a simple example of how to set the iomux in a kernel module to enable GPIO operation on a given pin.

For example, I want to use GPIO3_IO01. I see that it's ALT5 on the EIM_DA1 pad. I've found that the Pad Mux Register is IOMUXC_SW_MUX_CTL_PAD_EIM_AD01.

However, when I try to set this register with a writel(), I get an error that "Unable to handle kernel paging request at virtual address..."

Obviously I'm missing something in the way I am setting this up. Can someone please enlighten me with a simple example of code that would properly set the pad mux register to allow me to use the GPIO?

Thank you.

ラベル(2)
タグ(2)
0 件の賞賛
1 解決策
2,235件の閲覧回数
CommunityBot
Community Manager
This an automatic process.

We are marking this post as solved, due to the either low activity or any reply marked as correct.

If you have additional questions, please create a new post and reference to this closed post.

NXP Community!

元の投稿で解決策を見る

0 件の賞賛
5 返答(返信)
2,236件の閲覧回数
CommunityBot
Community Manager
This an automatic process.

We are marking this post as solved, due to the either low activity or any reply marked as correct.

If you have additional questions, please create a new post and reference to this closed post.

NXP Community!
0 件の賞賛
2,236件の閲覧回数
igorpadykov
NXP Employee
NXP Employee

Hi Tim

one can use functions gpio_request,gpio_direction_output, gpio_set_value

as in attached file. Also one can look at

FAQ All Boards GPIO Test

Best regards

igor

-----------------------------------------------------------------------------------------------------------------------

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

-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
2,236件の閲覧回数
timellis
Contributor I

I know all of that. My question is lower-level than that.

I'm talking about how do you set the registers to configure the pad to even be accessible as a GPIO instead of the other possible modes that each pad can be.

I figured out something that works, but I'm not entirely clear on the concept and would like to fully understand the proper way to do it. Here's the code I'm using to set GPIO3_IO09:

#include "iomux_register.h"

#define GPIO3_IO09 73

{

     void __iomem *eim_da9 = ioremap(IOMUXC_SW_MUX_CTL_PAD_EIM_DA9,28);

     writel(0x05,eim_da9);

     gpio_request(GPIO3_IO09,"gpio3-09");

     gpio_direction_output(GPIO3_IO09,0);

}


It's the ioremap and the writel part that I'm talking about.

0 件の賞賛
2,236件の閲覧回数
andrewdyer
Contributor III

I'm not sure ioremap is what you want.  The tools I've seen for this use mmap on /dev/mem

http://free-electrons.com/pub/mirror/devmem2.c

boundarydevices/devregs · GitHub

or the memtool that comes in the unit tests in a yocto release build

0 件の賞賛
2,236件の閲覧回数
igorpadykov
NXP Employee
NXP Employee

SION bit is used to configure the pad to even be accessible as a GPIO instead of the other possible modes

0 件の賞賛