From: jamie@jamieiles.com (Jamie Iles)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] drivers: create a pinmux subsystem v2
Date: Mon, 16 May 2011 10:36:02 +0100 [thread overview]
Message-ID: <20110516093602.GC17104@pulham.picochip.com> (raw)
In-Reply-To: <BANLkTim5wurV7aFSm4ae6+HBpGZO1z_=XA@mail.gmail.com>
On Mon, May 16, 2011 at 02:09:20AM +0200, Linus Walleij wrote:
> 2011/5/11 Jamie Iles <jamie@jamieiles.com>:
> > [...]
> >> +static struct foo_pmx_func myfuncs[] = {
> >> + ? ? {
> >> + ? ? ? ? ? ? .name = "spi0-0",
> >> + ? ? ? ? ? ? .pins = spi0_0_pins,
> >> + ? ? ? ? ? ? .num_pins = ARRAY_SIZE(spi0_1_pins),
> >> + ? ? },
> >> + ? ? {
> >> + ? ? ? ? ? ? .name = "i2c0",
> >> + ? ? ? ? ? ? .pins = i2c0_pins,
> >> + ? ? ? ? ? ? .num_pins = ARRAY_SIZE(i2c0_pins),
> >> + ? ? },
> >> + ? ? {
> >> + ? ? ? ? ? ? .name = "spi0-1",
> >> + ? ? ? ? ? ? .pins = spi0_1_pins,
> >> + ? ? ? ? ? ? .num_pins = ARRAY_SIZE(spi0_1_pins),
> >> + ? ? },
> >> +};
> >
> > So I can see how this works well for these examples, but on our devices,
> > we have some interfaces for connecting to radios and these have a pair
> > of 8-bit RX and TX busses. ?However, depending on what radio you
> > connect, you may not need all 8 bits of each and this is dependent on
> > the board. ?What would be the best way to deal with that in this scheme
> > where say we only wanted 4 bits of each, saving the others for GPIO?
> > Would this need to be a function for each configuration?
>
> Yes. Define a function containing the pins you need, then when that
> function is muxed in by pinmux_get() the remaining pins are still
> available for GPIO.
>
> The framework only deals with functions as groups of pins and
> individual GPIO pins, defining the groups is currently up to each
> platform.
OK, from this and your other emails I think I understand this now. So
for this (using the current, non-device-tree method) case I guess we
could leave the registration of these pins to the board code rather than
the chip specific stuff.
> > [...]
> >> +/**
> >> + * pinmux_request_gpio() - request a single pin to be muxed in to be used
> >> + * ? as a GPIO pin
> >> + * @pin: the pin to mux in as GPIO
> >> + * @gpio: the corresponding GPIO pin number
> >> + */
> >> +int pinmux_request_gpio(int pin, unsigned gpio)
> >> +{
> >> + ? ? char gpiostr[16];
> >> +
> >> + ? ? snprintf(gpiostr, 15, "gpio%d", gpio);
> >> + ? ? return pin_request(pin, gpiostr, true);
> >> +}
> >> +EXPORT_SYMBOL_GPL(pinmux_request_gpio);
> >
> > Our devices have two different GPIO controllers, which can be muxed to
> > the same pad (they're slightly different - one is a bit slower but can
> > do sigma-delta output) and our pinmux driver would need to know what
> > GPIO controller it should route to the pad. ?Could gpio_request_enable()
> > be passed the GPIO number or is there a better way to do this?
>
> Hmmmm that was really new!
>
> But like we have the more complex config function for pinmux groups:
> extern int pinmux_config(struct pinmux *pmx, u16 param, unsigned long *data);
>
> I believe your case could be handled with a similar more complex
> per-pin config function like this:
> extern int pinmux_config_gpio(int pin, unsigned gpio, u16 param,
> unsigned long *data);
>
> Would that work?
Yes, I think it probably would. I'm travelling for a bit now so won't
get chance to try this for a week or two but I'll try porting our
platform over to this system; it would be great to have a standardized
way of handling pin muxing.
Jamie
next prev parent reply other threads:[~2011-05-16 9:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-10 23:39 [PATCH] drivers: create a pinmux subsystem v2 Linus Walleij
2011-05-10 23:58 ` Jamie Iles
2011-05-16 0:09 ` Linus Walleij
2011-05-16 9:36 ` Jamie Iles [this message]
2011-05-18 5:31 ` Linus Walleij
2011-05-11 0:15 ` Joe Perches
2011-05-13 21:29 ` Stephen Warren
2011-05-16 0:36 ` Linus Walleij
2011-05-17 21:48 ` Stephen Warren
2011-05-18 5:47 ` Linus Walleij
2011-05-19 17:42 ` Stephen Warren
2011-05-17 22:01 ` Stephen Warren
2011-05-18 5:56 ` Linus Walleij
2011-05-19 17:19 ` Stephen Warren
2011-05-19 17:38 ` Linus Walleij
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=20110516093602.GC17104@pulham.picochip.com \
--to=jamie@jamieiles.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).