From: Matt Sealey <matt@genesi-usa.com>
To: Mitch Bradley <wmb@firmworks.com>
Cc: linuxppc-dev list <linuxppc-dev@ozlabs.org>,
devicetree-discuss list <devicetree-discuss@ozlabs.org>
Subject: Re: GPIO - marking individual pins (not) available in device tree
Date: Thu, 23 Oct 2008 18:05:19 -0500 [thread overview]
Message-ID: <4901032F.3090805@genesi-usa.com> (raw)
In-Reply-To: <4900F90B.80703@firmworks.com>
Mitch Bradley wrote:
[snip]
> You could adopt the convention that preassigned GPIOs must be
> represented by subordinate nodes, and any GPIO that is not covered by a
> subordinate node's "reg" property is implicitly available. That's the
> way it works for other address spaces.
I like that idea except for the implicitly available bit.
Just summarizing this in my head (also on the list), if we had
an "available" property in the node marked as a
gpio-controller, that would easily give gpiolib something to
parse so that it only gives out allocations for pins that are
really, really not being multiplexed for something else or
just not being connected.
There's a GPIO spec in booting-without-of.txt which basically
defines a controller and a bank, and you can assign a bank of
GPIO to some other device. Assigning specific GPIO pins should
be possible.. umm..
http://patchwork.ozlabs.org/patch/5478/
With regards to this patch, how about device usage of pins
being defined as a range of pins (reusing the standard-ish
"ranges" property from PCI binding)? That way you have all the
information you could ever need for each device.
1) where the controller sits ("gpio-controller" property)
2) which pins are available for use (everything not in
"available" is therefore out of bounds)
3) define banks of gpio for a specific function with "ranges"
(for instance pins 10, 11 and 15 would be encoded as <10 2>
and <15 1> and these encapsulate some kind of function be it
user definable gpio or some control function for a chip)
4) assign "gpio" properties to other nodes which refer to
banks (see booting-without-of.txt section IX, at the end)
rather than individual pins.
5) optionally a bank may contain gpio pin node which describes
EXACTLY what that pin function is (and any lovely properties
it may well have).
At the moment it's encoded as:
gpios = <&controller-phandle pin-number pin-flags>
Ad infinitum. Instead of a controller phandle you'd pass in a
bank (which is a subset of the controller's available pins)
and then you can give each pin it's little options.
Actually I would also advocate allowing each pin to be
assigned a node of it's own and a compatible property - after
all if you have a board where gpios can move around (consider
an FPGA with a processor core, where positions of lines to use
are actually reflected by a read-only register or the device
tree is derived directly from the VHDL source or a constraints
script?) and don't want to rewrite your driver every time, it
would be good to be able to find exactly which pin controls
exactly which line on the peripheral chip?
Therefore you'd get something like this in a DTS; please hit
me on the head if you think it's getting really unwieldy :D
gpio_1: gpio-controller@1000 {
#gpio-cells = <2>;
compatible = "fsl,mpc5200b-gpio";
reg = <0x1000 0x4>;
gpio-controller;
available = <1 10 15 4 30 1>;
gpio_1_bank_1: gpio-bank {
\\ 5 pins for some nefarious purpose
compatible = "gpio-bank";
ranges = <1 5 0>; \\ start length flags
gpio_pin@2 {
\\ I guess this address has to be
\\ the global offset and not the offset into the range to make
\\ it easier?
reg = <2 1>
compatible = "magic";
};
};
}
device@9000 {
compatible = "somedevice";
reg = <0x9000 0x18>;
gpios = <&gpio_1_bank_1>
};
Most implementations won't need the explicit pin definitions
but it would probably come in handy somewhere if you were
bitbanging some protocol (SPI, I2C or so) or driving a device
where you could change this stuff, or even dynamically work
out if a connector was inserted a certain way (I'm thinking of
maybe an expansion connector which can run line-reversed like
PCI Express.. but made out of GPIO. Am I nuts?)
--
Matt Sealey <matt@genesi-usa.com>
Genesi, Manager, Developer Relations
next prev parent reply other threads:[~2008-10-23 23:05 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-23 21:32 GPIO - marking individual pins (not) available in device tree Matt Sealey
2008-10-23 21:32 ` Matt Sealey
2008-10-23 22:22 ` Mitch Bradley
2008-10-23 23:05 ` Matt Sealey [this message]
2008-10-24 0:52 ` Mitch Bradley
2008-10-24 3:29 ` David Gibson
2008-10-24 3:29 ` David Gibson
2008-10-24 4:17 ` Mitch Bradley
2008-10-24 4:17 ` Mitch Bradley
2008-10-24 4:45 ` David Gibson
2008-10-24 4:45 ` David Gibson
2008-10-24 22:14 ` Matt Sealey
2008-10-26 23:47 ` David Gibson
2008-10-27 15:40 ` Matt Sealey
2008-10-27 18:34 ` Anton Vorontsov
2008-10-27 18:56 ` Matt Sealey
2008-10-27 20:10 ` Anton Vorontsov
2008-10-27 20:10 ` Anton Vorontsov
2008-10-27 21:56 ` Matt Sealey
2008-10-27 21:56 ` Matt Sealey
2008-10-27 23:12 ` Anton Vorontsov
2008-10-27 23:12 ` Anton Vorontsov
2008-10-27 23:40 ` Anton Vorontsov
2008-10-28 0:47 ` Matt Sealey
2008-10-28 1:11 ` Matt Sealey
2008-10-28 1:11 ` Matt Sealey
2008-10-28 2:37 ` Anton Vorontsov
2008-10-28 16:53 ` Matt Sealey
2008-10-28 16:53 ` Matt Sealey
2008-10-28 17:39 ` Grant Likely
2008-10-28 19:46 ` Matt Sealey
2008-10-28 19:46 ` Matt Sealey
2008-10-28 0:15 ` David Gibson
2008-10-28 0:15 ` David Gibson
2008-10-28 0:51 ` Matt Sealey
2008-10-28 1:50 ` David Gibson
2008-10-28 5:20 ` Grant Likely
2008-10-28 5:20 ` Grant Likely
2008-10-24 22:03 ` Matt Sealey
2008-10-24 22:20 ` Stephen Neuendorffer
2008-10-24 22:20 ` Stephen Neuendorffer
2008-10-26 21:39 ` Matt Sealey
2008-10-24 23:44 ` Mitch Bradley
2008-10-26 21:13 ` Matt Sealey
2008-10-26 21:13 ` Matt Sealey
2008-10-26 23:53 ` David Gibson
2008-10-27 16:12 ` Matt Sealey
2008-10-27 16:12 ` Matt Sealey
2008-10-27 16:35 ` Scott Wood
2008-10-27 16:35 ` Scott Wood
2008-10-27 17:05 ` Matt Sealey
2008-10-27 17:25 ` Scott Wood
2008-10-27 17:49 ` Matt Sealey
2008-10-27 17:54 ` Scott Wood
2008-10-28 0:38 ` David Gibson
2008-10-28 0:38 ` David Gibson
2008-10-28 0:34 ` David Gibson
2008-10-28 0:34 ` David Gibson
2008-10-24 4:58 ` David Gibson
2008-10-24 3:27 ` David Gibson
2008-10-24 3:27 ` David Gibson
2008-10-24 16:41 ` Anton Vorontsov
2008-10-24 17:01 ` Anton Vorontsov
2008-10-24 22:17 ` Matt Sealey
2008-10-24 22:17 ` Matt Sealey
2008-10-24 22:37 ` Anton Vorontsov
-- strict thread matches above, loose matches on Subject: below --
2008-10-28 13:31 Konstantinos Margaritis
2008-10-28 14:11 ` Anton Vorontsov
2008-10-28 14:11 ` Anton Vorontsov
2008-10-28 14:15 ` Grant Likely
2008-10-28 14:15 ` Grant Likely
2008-10-28 17:06 ` Matt Sealey
2008-10-28 17:06 ` Matt Sealey
2008-10-28 17:32 ` Grant Likely
2008-10-28 23:37 ` David Gibson
2008-10-28 23:37 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4901032F.3090805@genesi-usa.com \
--to=matt@genesi-usa.com \
--cc=devicetree-discuss@ozlabs.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=wmb@firmworks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.