Configuring IMX6 SW CTL PAD Registers

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

Configuring IMX6 SW CTL PAD Registers

跳至解决方案
4,778 次查看
soumyadas
Contributor I

Dear all,

I am an absolute newbie in this device driver field. I am developing a character driver for IMX6 with a custom keyboard. I have been able to develop a basic device driver for the system.

Now I need to configure some of the pins as GPIOs using the SW CTL PAD Register.I am able to get my system to work using the memtools but could not figure out a way to configure the register in the device driver source code or otherwise. I need assistance on how to set the CTL PAD Register to the appropriate value.

Thanks in advance.

标签 (2)
0 项奖励
回复
1 解答
3,726 次查看
soumyadas
Contributor I

Dear All,

Solution

/********************************************************************************************************************************************/

Prerequisite:

1. Find the IOMUX SW MUX CTL PAD Base Address

2. Find the offset address of the register that needs to be modified. (Example DIO Register)

Now the source code

Include the following Header file

#include <asm/io.h>

Declare a Variable of type void __iomem RegAddress

Next we need to use ioremap to map that register to an address

RegAddress = ioremap(BASE_ADDRESS + OFFSET , 4)  // void *ioremap(unsigned long phys_addr, unsigned long size);

Now we read the register value using

RegValue = readl(RegAddress);  // unsigned readl(address);

Write to the register using

writel((RegValue | VALUE), RegAddress);    // void writel(unsigned value, address);

where VALUE is the data that needs to be written to the register

Before exiting make sure to unmap the regsiter using

iounmap(RegAddress) // void ioport_unmap(void *addr);

Thanks You

Happy Coding. :smileyhappy: :smileyhappy: :smileyhappy:

/******************************************************************************************************************************************/

在原帖中查看解决方案

0 项奖励
回复
2 回复数
3,727 次查看
soumyadas
Contributor I

Dear All,

Solution

/********************************************************************************************************************************************/

Prerequisite:

1. Find the IOMUX SW MUX CTL PAD Base Address

2. Find the offset address of the register that needs to be modified. (Example DIO Register)

Now the source code

Include the following Header file

#include <asm/io.h>

Declare a Variable of type void __iomem RegAddress

Next we need to use ioremap to map that register to an address

RegAddress = ioremap(BASE_ADDRESS + OFFSET , 4)  // void *ioremap(unsigned long phys_addr, unsigned long size);

Now we read the register value using

RegValue = readl(RegAddress);  // unsigned readl(address);

Write to the register using

writel((RegValue | VALUE), RegAddress);    // void writel(unsigned value, address);

where VALUE is the data that needs to be written to the register

Before exiting make sure to unmap the regsiter using

iounmap(RegAddress) // void ioport_unmap(void *addr);

Thanks You

Happy Coding. :smileyhappy: :smileyhappy: :smileyhappy:

/******************************************************************************************************************************************/

0 项奖励
回复
3,726 次查看
igorpadykov
NXP Employee
NXP Employee

Hi Soumia

one can look at linux documentation in folder:

../Documentation/devicetree/bindings/gpio/fsl-imx-gpio.txt

AN5125 Introduction to Device Tree

http://cache.nxp.com/files/32bit/doc/app_note/AN5125.pdf

Definitive GPIO guide - Studio Kousagi Wiki

Best regards

igor

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

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

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

0 项奖励
回复