Hi,
How can i control/configure the gpio?
I want to read signal from the user's buttons and control the leds?
Thanks to Freescale tech support, I have this working.
The fix is to remove the lines from mx53_loco.c that configure these GPIO as "buttons", or they can't be used as simple GPIO and won't appear in /sys/class/gpio:
static struct gpio_keys_button loco_buttons[] = {
GPIO_BUTTON(MX53_nONKEY, KEY_POWER, 1, "power", 0),
/* GPIO_BUTTON(USER_UI1, KEY_VOLUMEUP, 1, "volume-up", 0),
GPIO_BUTTON(USER_UI2, KEY_VOLUMEDOWN, 1, "volume-down", 0),
*/
};
Now these commands work to read the pins:
echo 46 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio46/direction
cat /sys/class/gpio/gpio46/value
echo 47 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio47/direction
cat /sys/class/gpio/gpio47/value
Hi Steeve,
I would like to use USERDEF GPIO's on IMX53 Quick STart-R Board Ubuntu(Linux). I couldn't find the file mx53_loco.c in kernel source which you said in above conversation. Did u said the above one for Ubuntu Linux or is it for Android. Could you please help me in enabling this Pins for Linux.
Thanks in advance.
I have an unexpected problem with exporting (opening) the two user defined buttons on the QSB.
/sys/class/gpio is enabled in the kernel.
According to the QSB users manual:
USERDEF1: USERDEF2:
These two buttons are user defined buttons attached to PATA_DATA14 (P6) and PATA_DATA15 (P5).
---------------------------------------------
iomux-mx53.h is unmodified and contains:
#define _MX53_PAD_PATA_DATA14__GPIO2_14 IOMUX_PAD(0x660, 0x2DC, 1, 0x0, 0, 0)
....
#define _MX53_PAD_PATA_DATA15__GPIO2_15 IOMUX_PAD(0x664, 0x2E0, 1, 0x0, 0, 0)
....
....
#define MX53_PAD_PATA_DATA14__GPIO2_14 (_MX53_PAD_PATA_DATA14__GPIO2_14 | MUX_PAD_CTRL(NO_PAD_CTRL))
....
#define MX53_PAD_PATA_DATA15__GPIO2_15 (_MX53_PAD_PATA_DATA15__GPIO2_15 | MUX_PAD_CTRL(NO_PAD_CTRL))
....
---------------------------------------------
mx53_loco.c is unmodified and contains:
static iomux_v3_cfg_t mx53_loco_pads[]
{
....
/* GPIO */
....
MX53_PAD_PATA_DATA14__GPIO2_14,
MX53_PAD_PATA_DATA15__GPIO2_15,
....
};
---------------------------------------------
Calculating GPIO number:
GPIO2_14 = (2 - 1) * 32 + 14 = 46
GPIO2_15 = (2 - 1) * 32 + 15 = 47
At the command line, export GPIO2_14 and GPIO_15:
echo 46 > /sys/class/gpio/export
echo 47 > /sys/class/gpio/export
.... no error is shown.
Then do "ls /sys/class/gpio" but they do not appear in the file list
I can do the same with GPIO number 199, which is the LED on the QSB, and it works fine.
/sys/class/gpio/gpio199 appears in the file list when I do ls and I can set and clear it to turn the LED on and off.
Any ideas? Thanks.
I am also lookin forward to that but... we just have to wait bec. we are just askin a favor right?
I hope sir kurt will give a follow up on this and we should thank him for his effort.
sir kurt... just sayin hello here...
everyone is waitin for your tutorial sir... thank you
jose,
this is for the user-space side.
I'm trying now to setup a kernel module.
gr.
Kurt
jose said:
By the way, this is for the user-space side right?
How about the kernel-space? Or should i say the driver part?
I don't know if i make sense sorry correct me if im wrong.
kurt said:hi all,
if someone still looking for a very good starting point
https://www.ridgerun.com/developer/wiki/index.php/Gpio-int-test.c
See this post where I explain how you can access GPIOs in Linux:
http://forums.freescale.com/t5/i-MX-Microprocessors/iMX28-SYSFS-and-GPIO/td-p/60938
see the file arch/arm/mach-mx5/mx53_evk.c ,
you can find much sample code which control/configure the gpio.
it's under linux kernel in freescale's bsp.
"What's tha function/API to read the event of press on the buttuns" ?
it's standard input event API . you can use evtest to monitor the button event.
if you want your function, can reference the evtest's source code.
in ubuntu PC, you can install evtest through apt-get install evtest.
hope helpful.
Take a look at file i.MX53 System Development User’s Guide, Chapter 13
Configuring the IOMUX Controller (IOMUXC).
There you can find a way to control a gpio pin from user space.