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.
Solved! Go to Solution.
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:
/******************************************************************************************************************************************/
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:
/******************************************************************************************************************************************/
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!
-----------------------------------------------------------------------------------------------------------------------