Need info on exporting/registering a GPIO pin via sysfs.

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

Need info on exporting/registering a GPIO pin via sysfs.

5,129 Views
VikramU_ng
Contributor III

Hi ,

  On the iMX233, with ltib we have configured GPIO threough sys class support as detailed here <>

 

However creating/exporting the device fails with a BUSY error (status code 16).

 

for "echo 59 >>/sys/class/gpio/export"   -- 59 is Bank 1 Pin 27 - for GPIO-PMW1.

Kernel dmesg reports status 16.

>>gpio_request: gpio-59 (sysfs) status -16
>>export_store: status -16

This has been seen in bot kernel/module space(as a .ko and via uImage).

Kindly provide pointers if the GPIO export via sysfs needs any additional configuration?.

Tags (1)
11 Replies

2,420 Views
VikramU_ng
Contributor III
Finally a concise document GPIO
0 Kudos

2,420 Views
VikramU_ng
Contributor III

All,

 

  Found this link of some use at what i planned to do. GPIO-IMX51.  Allows one to access IO from Userspace direct though this is not what is advisable unless there is a single user application/service. 

 

regards,

Vikram.

0 Kudos

2,420 Views
VikramU_ng
Contributor III

Thanks Bryan..

  Helps me in clearly listing my GPIO for footprint. Would need something on this documented if you are Mux'ing IO on a Board though...

 

regards,

Vikram.

0 Kudos

2,419 Views
BryanJI
Contributor I

1. when you config the system, ./ltib -c, DONT SELECT the driver/led part. Then I believe the following code would not be excuted. Because there is macro before and after the code.

2. Ugly method. Simply comment your definition and everything well be all right. Because the group pin init function would not initial your pin.

static struct pin_desc mx23evk_fixed_pins[] = {
  /*

  {
     .name = "DUART.RX",
     .id = PINID_PWM0,
     .fun = PIN_FUN3,
     },
    {
     .name = "DUART.TX",
     .id = PINID_PWM1,
     .fun = PIN_FUN3,
     },

*/

 


vikram u said:

Hi Bryan,

   In the case of iMX233 EVK the Pins 58 and 59 are multiplexed as PWM0/1 and as DUARTTX/RX. No way you can bypass the initialiation of these pins. Is my understanding correct?.

 

from the mx23evk_pins.c file.

static struct pin_desc mx23evk_fixed_pins[] = {
    {
     .name = "DUART.RX",
     .id = PINID_PWM0,
     .fun = PIN_FUN3,
     },
    {
     .name = "DUART.TX",
     .id = PINID_PWM1,
     .fun = PIN_FUN3,
     },

 

 

0 Kudos

2,420 Views
VikramU_ng
Contributor III

Hi Bryan,

   In the case of iMX233 EVK the Pins 58 and 59 are multiplexed as PWM0/1 and as DUARTTX/RX. No way you can bypass the initialiation of these pins. Is my understanding correct?.

 

from the mx23evk_pins.c file.

static struct pin_desc mx23evk_fixed_pins[] = {
    {
     .name = "DUART.RX",
     .id = PINID_PWM0,
     .fun = PIN_FUN3,
     },
    {
     .name = "DUART.TX",
     .id = PINID_PWM1,
     .fun = PIN_FUN3,
     },

 

 

0 Kudos

2,419 Views
BryanJI
Contributor I

Well, you should not request your pin in your BSP.

If you want to use /sys feature.

Don't initialize your pin in your BSP.

On my i.MX 28 evk board. The pin initialization is located at mx28evk_pins.c file. 

 

Or you can unselect your led driver, then the led pin will not be initialized.

0 Kudos

2,421 Views
VikramU_ng
Contributor III

Hi Sanath,

   I think i am unable to see the voltage change on my board. is there a problem with my configuration?.

0 Kudos

2,420 Views
sancti
Contributor I

Hi Vikram,

   Please check this file for the iMX233 where i have exported a unitialized pin and can change the direction to input/output. By default the pllup is set to HIGH

 

.pull = 1,
.pullup = 1,
.voltage = PAD_3_3V,

.strength    = PAD_12MA,

Changing this configuration gives the appropriate output (Voltage) and configured current (Check pinctrl.h) for more details!.

 

Once the pin is exported by

 DEVICE:

    echo  71 >>/sys/class/gpio/export  // configures the PIN ROTARYA(Bank 2, Pin 7) for Pin 71.

    echo "out" >>/sys/class/gpio/gpio71/direction

    echo 1 >>/sys/class/gpio/gpio71/value

 

Check the voltage on the configured pin(71) on the board - must be unpopulated for Evk233. This should change acording to echo value of 1/0 according to the set voltage (1.8/3.3V)

GPIO

Good Luck!.

2,420 Views
VikramU_ng
Contributor III

Hi Vladan,

  I have built the kernel with GPIO as Modules( as enclosed) and have just initilized/registered the GPIO pins under /sys/class/gpio as a device.

 

When i insmod the example ko file i get a Error code 16.(EBUSY). Could you please review the code attached.

 

Console Output:

>>

gpio_request: gpio-59 (sysfs) status -16
***Status sysfs gpio request: -16
export_store: status -16
root@freescale ~$ rmmod /lib/modules/2.6.31-626-g602af1c/misc/imxgpiosimple.ko
root@freescale ~$ dmesg |tail
Freeing init memory: 136K
gpio_request: gpio-58 (sysfs) status -16
***Status sysfs gpio request: -16
export_store: status -16
gpio_request: gpio-58 (sysfs) status -16
***Status sysfs gpio request: -16
export_store: status -16
gpio_request: gpio-59 (sysfs) status -16
***Status sysfs gpio request: -16
export_store: status -16

 

 

 

<<

 

 

Thanks and regards,

Vikram.

0 Kudos

2,420 Views
VladanJovanovic
NXP Employee
NXP Employee

Isn't PWM1 multiplexed with debug uart signals? You can't use both at the same time, so that is why the busy error. Have to disable debug uart and remove init calls in the i.MX233 board file.

 

Vladan

0 Kudos

2,420 Views
sancti
Contributor I

Hi,

  Please make sure that these configuration are enabled. Do you get any specific error messages?

 

 

--- LED support

[*] LED Class Support

 <*> LED Support for GPIO connected LEDs

[*]      Platform device bindings for GPIO LEDs

 ...

[*] LED Trigger support

 <*> LED Heartbeat Trigger

<*> LED GPIO Trigger

0 Kudos