LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-27-2015, 03:44 PM   #1
newhorizon101
LQ Newbie
 
Registered: Apr 2014
Posts: 16

Rep: Reputation: Disabled
Linux GPIO Driver


Hi All,

I am trying to play with the gpio subsystem. I have a question, is there a way to hardcode the gpio number with regards to /sys/class/gpiochipxxx

I have multiple platforms and I would like to have same code run on both platforms, if some how I can tell driver to tell gpio subsystem of a fixed gpio number.

Thanks,
 
Old 05-29-2015, 09:58 PM   #2
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,805

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
My understanding is that the device number xxx represents the base address so this should already be persistent? My apologies in advance if I don't quite understand your question, but the answer will almost certainly involve udev

For example, if I do
Code:
udevadm info -a -p /devices/virtual/gpio/gpiochip240
I get
Code:
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/virtual/gpio/gpiochip240':
    KERNEL=="gpiochip240"
    SUBSYSTEM=="gpio"
    DRIVER==""
    ATTR{base}=="240"
    ATTR{label}=="ssb_chipco_gpio"
    ATTR{ngpio}=="16"
In general it is possible to create a udev rule to recognise a specific device in question (using unique device attributes) and assign a desired preferred name (via symlink).
 
Old 05-29-2015, 10:40 PM   #3
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,805

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
The following reference might also be useful

http://www.wiki.xilinx.com/Linux+GPIO+Driver

They have an example user-space application that might help with your code too.

This GPIO User space app mentions
Code:
// Figuring out the exact GPIO was not totally obvious when there
// were multiple GPIOs in the system. One way to do is to go into
// the gpiochips in /sys/class/gpio and view the label as it should
// reflect the address of the GPIO in the system. The name of the
// the chip appears to be the 1st GPIO of the controller.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
issue with gpio driver thirun Slackware 0 10-31-2013 03:44 PM
GPIO access on a Fujitsu Mini-ITX Industrial Mainboard, PCI Driver for GPIO mechatrix Linux - Embedded & Single-board computer 3 11-20-2011 03:57 PM
How to use i2c-gpio driver sajnanazeer Linux - Newbie 1 03-03-2011 06:21 PM
[SOLVED] ppc4xx gpio driver not loading using arch_initcall max21226 Linux - Kernel 3 08-31-2010 11:04 AM
GPIO driver for MPC837xerdb ramukaka Linux - Kernel 1 08-15-2010 09:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration