LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 01-16-2016, 10:22 AM   #1
Jasson
LQ Newbie
 
Registered: Jan 2016
Posts: 15

Rep: Reputation: Disabled
/sys/class/gpio => Content (B-PI / Android 4.2)


Hello there,

i have a B-Pi with Android 4.2
and i´m exploring the filesystem in sys/class/gpio, because i´m interessted in using IOs

I´m new to linux - i read that everything is represented as files.

I have installed a programm where i can see and open files and wondering, what the directorys and files
are meaning which i see.
in "sys/class/gpio" there are directorys named
gpiochip0
gpiochip24
gpiochip54
gpiochip85
gpiochip119
gpiochip137
gpiochip149
gpiochip167
gpiochip201
gpiochip229
=> what do they mean? Do thier naming have a specific relation to the B-PI´s A20´pins? I can´t match them with the GPIO table from the WIKI / do the numbers have a meaning?
http://wiki.lemaker.org/File""IN_CONNECTOR.jpg

If i go into one of the folders, i see
power (folder)
subsystem (folder)
base (file)
label (file)
ngpio (file)
uevent (file)
=> here also - what do this mean? in power folder there is a file "async" where is just written "disabled", while in folder subsystem the directorys are repeating in a loop

And what is this thing with the "export" and "unexport" files in the gpio folder. I have seen a tutorial on youtube, where these files are used, but i don´t understand thier purpose.

best regards,
Jasson
 
Old 01-17-2016, 08:12 PM   #2
blue_z
Member
 
Registered: Jul 2015
Location: USA
Distribution: Ubuntu, Lubuntu, Mint, custom embedded
Posts: 104

Rep: Reputation: Disabled
Quote:
Originally Posted by Jasson View Post
I´m new to linux - i read that everything is represented as files.
Not "everything"..
You won't find network devices, e.g. eth0, in /dev.

Quote:
Originally Posted by Jasson View Post
... wondering, what the directorys and files
are meaning which i see.
in "sys/class/gpio" there are directorys named
gpiochip0
gpiochip24
gpiochip54
gpiochip85
gpiochip119
gpiochip137
gpiochip149
gpiochip167
gpiochip201
gpiochip229
=> what do they mean?
That is explained in Linux Documentation/gpio/sysfs.txt.

Regards
 
Old 01-19-2016, 01:08 PM   #3
Jasson
LQ Newbie
 
Registered: Jan 2016
Posts: 15

Original Poster
Rep: Reputation: Disabled
Ah ok, this clears things up.
I´m still wondering, what the trailing numbers to "gpiochip" are meaning.
Do they refer to the ports of the A20 like PoartA, PortB etc?
For example if i want to turn on PB21
http://wiki.lemaker.org/BananaPro/Pi...ON3_definition
whats the puzzle information i need to identify which "gpiochip(N)" i have to use?

best regards!
 
Old 01-20-2016, 06:32 PM   #4
blue_z
Member
 
Registered: Jul 2015
Location: USA
Distribution: Ubuntu, Lubuntu, Mint, custom embedded
Posts: 104

Rep: Reputation: Disabled
Quote:
Originally Posted by Jasson View Post
Ah ok, this clears things up.
Im still wondering, what the trailing numbers to "gpiochip" are meaning.
You need to study the Linux documentation better.
Code:
104     /sys/class/gpio/gpiochipN/
105 
106         "base" ... same as N, the first GPIO managed by this chip

Quote:
Originally Posted by Jasson View Post
Do they refer to the ports of the A20 like PoartA, PortB etc?
Exactly what "they" are you referring to?
The "N" (what you call a "trailing number") is for a (base) Linux GPIO number.
Normally there's a one-to-one mapping of gpiochipN directories with pin-control (or PIO) control blocks. Each control block is capable of configuring and controlling a group of pins.


But what you have listed for your A20 doesn't match up well with what's in the A20 datasheet and user manual.
Code:
1.19.1. Port Description

The chip has several ports for multi-functional input/out pins. They are shown below:
Port A(PA): 18 input/output port
Port B(PB): 24 input/output port
Port C(PC): 25 input/output port
Port D(PD): 28 input/output port
Port E(PE): 12 input/output port
Port F(PF):  6 input/output port
Port G(PG): 12 input/output port
Port H(PH): 28 input/output port
Port I(PI): 22 input/output port
Typically I would expect the second sysfs gpiochip to be either gpiochip32 (for easy port to chip calculations) or gpiochip18 (to keep the pin numbering consecutive). Instead you report that the second chip is gpiochip24 (which conforms to neither scheme).
You need to obtain the "base" and "ngpio" for each gpiochipN, and try to determine the mapping.

On Atmel SoCs it's easy to map each gpiochipN to its PIO device because the register block address is given in its "label":
Code:
# cat /sys/class/gpio/gpiochip32/label
fffff400.gpio
And the Atmel datasheet indicates that PIOB is located at 0xfffff400. So gpiochip32 (and its pins) maps to PIOB (and its control bits) on this Atmel SoC.

You have to determine the same for your Allwinner SoC. You have an SoC GPIO identified by PIO port letter (i.e. PB) and number (i.e. 21). You have to convert the port letter (PB) to its gpiochipN, and then verify that the PIO number (21) is within the "ngpio" range. The Linux GPIO number to use (for export) is then "base" plus the PIO number.

Regards

Last edited by blue_z; 01-21-2016 at 01:11 AM.
 
Old 01-23-2016, 05:59 AM   #5
Jasson
LQ Newbie
 
Registered: Jan 2016
Posts: 15

Original Poster
Rep: Reputation: Disabled
Yes, you´re right. I "over-read" a few things the first time. That´s what happens, when you´re doing stuff between 8pm and evening ;>
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] can I access /sys/class/gpio/gpioxx in the rc3.d? henryyao Linux - Newbie 3 09-18-2013 07:36 AM
what's the difference bewteen using /sys/class/gpio and gpio_key driver henryyao Linux - Newbie 2 08-23-2013 08:27 AM
[SOLVED] writing to /sys/class/gpio/export sharan013 Linux - Embedded & Single-board computer 5 02-22-2012 11:08 AM
sys/class/net/ethx/type What is it? tank junior Linux - Newbie 1 05-03-2011 08:23 PM
/sys/class/hwmon Question Aztral Linux - General 1 08-11-2009 02:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 12:59 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