Re: [meta-xilinx] gpio export from device tree

2017-03-02 Thread Alan Levy
The following DTS example fragment defines the EMIO pins used to control an 
external 8-way Mux:

/ {
/*
 * Provide a set of aliases describing the GPIOs that are exported via 
sysfs for use by applications.
 *
 * The format of each signal entry is as follows:
 *  = ",INPUT | OUTPUT, ACTIVE_HIGH | ACTIVE_LOW"
 *
 * e.g:
 *
 * pin1 = "10,OUTPUT,ACTIVE_HIGH";
 * pin2 = "25,INPUT,ACTIVE_LOW";
 *
 * To make it easy to maintain this data, pin numbers are as seen by the 
EMIO GPIO controller,
 * not as known to SysFs, hence the need for  GPIO_OFFSET so that 
application code knows
 * how to calculate the correct number to pass to SysFs.
 */
aliases {
GPIO_OFFSET =   "960"; /* = 1024 - 64 - due to the way that Linux 
allocates GPIO pin numbering for use with Sysfs. */

/* Outputs - all EMIO pins */
MUX_ADDR0 = "30,OUTPUT,ACTIVE_HIGH";/* Schematic Pin: MUX_SEL0  
*/
MUX_ADDR1 = "31,OUTPUT,ACTIVE_HIGH";/* Schematic Pin: MUX _SEL1 
 */
MUX_ADDR2 = "32,OUTPUT,ACTIVE_HIGH";/* Schematic Pin: MUX _SEL2 
 */
MUX_ENABLE ="29,OUTPUT,ACTIVE_LOW"; /* Schematic Pin: MUX 
_SEL_N */
};
};

Apps read the value of GPIO_OFFSET and parse the individual MUX_xxx strings to 
extract the settings. The GPIO numbers are then GPIO_OFFSET + pin number. So 
for example MUX_ENABLE is on GPIO 989 (960 + 29).

-Original Message-
From: Jean-Francois Dagenais [mailto:jeff.dagen...@gmail.com] 
Sent: 02 March 2017 15:19
To: Alan Levy
Cc: Mike Looijmans; meta-xilinx@yoctoproject.org
Subject: Re: [meta-xilinx] gpio export from device tree

Hi Alan,

Thanks for this insight.

> On Mar 1, 2017, at 05:16, Alan Levy  wrote:
> 
> In order to give userspace GPIOs sane names I use devicetree aliases which 
> application code can access from /proc/device-tree/aliases. Each GPIO has an 
> alias with a sensible name and the string I assign to it supplies the GPIO 
> pin number and any other relevant info such as whether it's an input or an 
> output and whether it's active high or active low.
> 
> This technique can also be used to tell application the base pin numbers for 
> MIO/EMIO if you wish. 

Can you point to an example? Or copy/paste a bit of it here?
-- 
___
meta-xilinx mailing list
meta-xilinx@yoctoproject.org
https://lists.yoctoproject.org/listinfo/meta-xilinx


Re: [meta-xilinx] gpio export from device tree

2017-03-02 Thread Jean-Francois Dagenais
Hi Alan,

Thanks for this insight.

> On Mar 1, 2017, at 05:16, Alan Levy  wrote:
> 
> In order to give userspace GPIOs sane names I use devicetree aliases which 
> application code can access from /proc/device-tree/aliases. Each GPIO has an 
> alias with a sensible name and the string I assign to it supplies the GPIO 
> pin number and any other relevant info such as whether it's an input or an 
> output and whether it's active high or active low.
> 
> This technique can also be used to tell application the base pin numbers for 
> MIO/EMIO if you wish. 

Can you point to an example? Or copy/paste a bit of it here?
-- 
___
meta-xilinx mailing list
meta-xilinx@yoctoproject.org
https://lists.yoctoproject.org/listinfo/meta-xilinx


Re: [meta-xilinx] gpio export from device tree

2017-03-01 Thread Mike Looijmans

On 01-03-17 11:16, Alan Levy wrote:

In order to give userspace GPIOs sane names I use devicetree aliases which 
application code can access from /proc/device-tree/aliases. Each GPIO has an 
alias with a sensible name and the string I assign to it supplies the GPIO pin 
number and any other relevant info such as whether it's an input or an output 
and whether it's active high or active low.

This technique can also be used to tell application the base pin numbers for 
MIO/EMIO if you wish.


That's a neat trick actually. Will keep that in mind for a next project.






Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: mike.looijm...@topicproducts.com
Website: www.topicproducts.com

Please consider the environment before printing this e-mail





-Original Message-

From: Mike Looijmans [mailto:mike.looijm...@topic.nl]
Sent: 28 February 2017 11:07
To: meta-xilinx@yoctoproject.org
Subject: Re: [meta-xilinx] gpio export from device tree

On 27-02-17 22:52, Jean-Francois Dagenais wrote:
...

So my questions are:
* which clause, if any, is proper in dts to export the GPIOs
preferably with names (like /sys/class/gpio/my_gpio_name_here). Do I
need to declare a new node which doesn’t bind to a diver for example…


There have been a number of proposals for this in the kernel, but they've all 
been rejected. The consensus seems to be that you should write a driver if you 
want to do this kind of thing in a portable way.


* (this one may be quite available in the megabytes of documentation) how does 
the gpio numbers in the kernel map to MIOxx and EMIOxx numbers. If anyone could 
point at the right doc that would save me so much grief.


They map really weird yeah. Maybe it's on purpose to discourage using gpio from 
userspace...
Best solution I found was to open /sys/class/gpiochip*/name files and look for the zynq 
gpio controller, and then use that offset. On my current board the zynq GPIO starts at 
"906". With 54 MIO GPIO pins, the EMIO GPIO pins thus start at 960.


--
Mike Looijmans


Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: mike.looijm...@topicproducts.com
Website: www.topicproducts.com

Please consider the environment before printing this e-mail








--
___
meta-xilinx mailing list
meta-xilinx@yoctoproject.org
https://lists.yoctoproject.org/listinfo/meta-xilinx


Re: [meta-xilinx] gpio export from device tree

2017-03-01 Thread Alan Levy
In order to give userspace GPIOs sane names I use devicetree aliases which 
application code can access from /proc/device-tree/aliases. Each GPIO has an 
alias with a sensible name and the string I assign to it supplies the GPIO pin 
number and any other relevant info such as whether it's an input or an output 
and whether it's active high or active low.

This technique can also be used to tell application the base pin numbers for 
MIO/EMIO if you wish. 

-Original Message-
From: Mike Looijmans [mailto:mike.looijm...@topic.nl] 
Sent: 28 February 2017 11:07
To: meta-xilinx@yoctoproject.org
Subject: Re: [meta-xilinx] gpio export from device tree

On 27-02-17 22:52, Jean-Francois Dagenais wrote:
...
> So my questions are:
> * which clause, if any, is proper in dts to export the GPIOs 
> preferably with names (like /sys/class/gpio/my_gpio_name_here). Do I 
> need to declare a new node which doesn’t bind to a diver for example…

There have been a number of proposals for this in the kernel, but they've all 
been rejected. The consensus seems to be that you should write a driver if you 
want to do this kind of thing in a portable way.

> * (this one may be quite available in the megabytes of documentation) how 
> does the gpio numbers in the kernel map to MIOxx and EMIOxx numbers. If 
> anyone could point at the right doc that would save me so much grief.

They map really weird yeah. Maybe it's on purpose to discourage using gpio from 
userspace...
Best solution I found was to open /sys/class/gpiochip*/name files and look for 
the zynq gpio controller, and then use that offset. On my current board the 
zynq GPIO starts at "906". With 54 MIO GPIO pins, the EMIO GPIO pins thus start 
at 960.


--
Mike Looijmans


Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: mike.looijm...@topicproducts.com
Website: www.topicproducts.com

Please consider the environment before printing this e-mail






-- 
___
meta-xilinx mailing list
meta-xilinx@yoctoproject.org
https://lists.yoctoproject.org/listinfo/meta-xilinx


Re: [meta-xilinx] gpio export from device tree

2017-02-28 Thread Mike Looijmans

On 27-02-17 22:52, Jean-Francois Dagenais wrote:
...

So my questions are:
* which clause, if any, is proper in dts to export the GPIOs preferably with 
names (like /sys/class/gpio/my_gpio_name_here). Do I need to declare a new node 
which doesn’t bind to a diver for example…


There have been a number of proposals for this in the kernel, but 
they've all been rejected. The consensus seems to be that you should 
write a driver if you want to do this kind of thing in a portable way.



* (this one may be quite available in the megabytes of documentation) how does 
the gpio numbers in the kernel map to MIOxx and EMIOxx numbers. If anyone could 
point at the right doc that would save me so much grief.


They map really weird yeah. Maybe it's on purpose to discourage using 
gpio from userspace...
Best solution I found was to open /sys/class/gpiochip*/name files and 
look for the zynq gpio controller, and then use that offset. On my 
current board the zynq GPIO starts at "906". With 54 MIO GPIO pins, the 
EMIO GPIO pins thus start at 960.



--
Mike Looijmans


Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: mike.looijm...@topicproducts.com
Website: www.topicproducts.com

Please consider the environment before printing this e-mail





--
___
meta-xilinx mailing list
meta-xilinx@yoctoproject.org
https://lists.yoctoproject.org/listinfo/meta-xilinx


[meta-xilinx] gpio export from device tree

2017-02-27 Thread Jean-Francois Dagenais
Hi guys,

In a previous design on x86, in the kernel, I was exporting a bunch of system 
gpios to sysfs/userspace with direction and names using gpio_request_one() from 
platform init code.

I’m now trying to achieve something similar on zynq/zynqmp but hopefully 
without having to write a driver, i.e. all from devicetree.

I am kind of new to the zynq architecture so please bear with me.

I have already integrated our ps[u7]_init_gpl.[ch] into my build of u-boot. 
These files come from my colleagues who spend their day in Vivado and have 
correctly configured the project and generated the correct output (fpga.bin and 
platform init files). So my understanding is that from my vantage point once 
the kernel is loading, all that needs to be configured is the direction and 
value (if output). That is, I don’t think I need to mess around the pinctrl 
part of things in my dts.

Now I know I could have the userspace do the job of exporting specific pins 
right from sysfs but I think this knowledge should reside in a devicetree. The 
pins I am trying to export are part of a subsystem composed of various parts 
which are all declared in the dts. To give you a better idea, the subsystem 
includes a DAC (iio driver), a ADC (a hwmon driver) and some GPIOs in both 
input and output. The subsystem is controlled from userspace and uses all of 
the components.

So my questions are:
* which clause, if any, is proper in dts to export the GPIOs preferably with 
names (like /sys/class/gpio/my_gpio_name_here). Do I need to declare a new node 
which doesn’t bind to a diver for example…
* (this one may be quite available in the megabytes of documentation) how does 
the gpio numbers in the kernel map to MIOxx and EMIOxx numbers. If anyone could 
point at the right doc that would save me so much grief.

Thanks a bunch to all contributors!
Really looking forward to keep working with all of you! (we should get our ZU+ 
board soon)

/jfd
-- 
___
meta-xilinx mailing list
meta-xilinx@yoctoproject.org
https://lists.yoctoproject.org/listinfo/meta-xilinx