linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linus.walleij@linaro.org (Linus Walleij)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] gpio: add pin biasing and drive mode to gpiolib
Date: Wed, 20 Apr 2011 17:39:28 +0200	[thread overview]
Message-ID: <BANLkTi=QGoaNvJNM6SNsEduVa958bcLC1A@mail.gmail.com> (raw)
In-Reply-To: <20110420162958.09286aa7@lxorguk.ukuu.org.uk>

2011/4/20 Alan Cox <alan@lxorguk.ukuu.org.uk>:

> Would it not make sense to assume that given a situation where you have a
> GPIO that can be routed four ways that you actually implement it like the
> rest of the kernel - ie
>
> ? ? ? ?r = gpio_request(n); ? ?/* n, n+1, n+2, n+3 are the four ways
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?*/
>
> ? ? ? ?if (r < 0) ? ? ?/* EBUSY - someone else is using one of the
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?four */
> ? ? ? ? ? ? ? ?return -EBUSY;
> ? ? ? ?/* Succeeded - will also have set the mux for us */
>
> At that point drivers don't need to know if a GPIO is muxed it'll just be
> busy if someone else is using it.

Yes indeed. I'd achive that by have the GPIO driver call the
padmux subsystem to see if it can mux in that specific pin or whether it's
taken by some other user/mux setting.

> It seems to me that if the goal of the gpio layer is to provide an
> abstraction then it can abstract muxes just fine and without needing
> drivers to know.

It's hard to use for all mux cases because it's pin-oriented rather
than mux-setting oriented I'd say.

For example: pins 0-7 can be used for an SDIO interface, or
you can use pins 0-3 and 4-7 as two SPI interfaces (just making
this up) then what you want is to control different mux alternatives
than mapping specific pins.

So my idea is you abstract muxes separately, we've done so
in the past, see c.f. this crude but working example:
arch/arm/mach-u300/padmux.[c|h]:

enum pmx_settings {
        U300_APP_PMX_MMC_SETTING,
        U300_APP_PMX_SPI_SETTING
};

struct pmx *pmx_get(struct device *dev, enum pmx_settings setting);
int pmx_put(struct device *dev, struct pmx *pmx);
int pmx_activate(struct device *dev, struct pmx *pmx);
int pmx_deactivate(struct device *dev, struct pmx *pmx);

(then snip mmc.c):

        /*
         * Setup padmuxing for MMC. Since this must always be
         * compiled into the kernel, pmx is never released.
         */
        pmx = pmx_get(mmcsd_device, U300_APP_PMX_MMC_SETTING);

        if (IS_ERR(pmx))
                pr_warning("Could not get padmux handle\n");
        else {
                ret = pmx_activate(mmcsd_device, pmx);
                if (IS_ERR_VALUE(ret))
                        pr_warning("Could not activate padmuxing\n");
        }

So while this enum cannot cut it for the generic case, the idea
is that you enumerate your padmux settings one way or another
and this is orthogonal to GPIO or other such stuff.

Then of course the GPIO driver can in turn call the padmux
subsystem to request its pins or fail/bail out if they are taken.

Yours,
Linus Walleij

  reply	other threads:[~2011-04-20 15:39 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-17 21:37 [PATCH 1/2] gpio: add pin biasing and drive mode to gpiolib Linus Walleij
2011-04-17 21:48 ` Alan Cox
2011-04-17 21:58   ` Linus Walleij
2011-04-17 22:03     ` Alan Cox
2011-04-18  0:09 ` Kyungmin Park
2011-04-18  7:17   ` Kurt Van Dijck
2011-04-18  8:04 ` Ben Nizette
2011-04-18  8:19   ` Alan Cox
2011-04-18  8:50     ` Ben Nizette
2011-04-18 11:59       ` Mark Brown
2011-04-18 22:16         ` Ben Nizette
2011-04-18 22:31           ` Mark Brown
2011-04-19  4:50             ` Ben Nizette
2011-04-20 12:11           ` Linus Walleij
2011-04-18 12:26       ` Alan Cox
2011-04-18 22:26         ` Ben Nizette
2011-04-19  8:38           ` Alan Cox
2011-04-19  8:51             ` Kyungmin Park
2011-04-20 12:32               ` Linus Walleij
2011-04-20 12:38                 ` Kyungmin Park
2011-04-20 14:54                 ` Alan Cox
2011-04-20 14:26               ` Haojian Zhuang
2011-04-20 14:40                 ` Kyungmin Park
2011-04-20 15:04                   ` Haojian Zhuang
2011-04-20 15:17                     ` Linus Walleij
2011-04-20 15:32                       ` Alan Cox
2011-04-20 15:45                         ` Linus Walleij
2011-04-27 21:55                         ` Russell King - ARM Linux
2011-04-27 22:16                           ` H Hartley Sweeten
2011-04-20 15:13                 ` Linus Walleij
2011-04-20 15:29                   ` Alan Cox
2011-04-20 15:39                     ` Linus Walleij [this message]
2011-04-20 15:43                       ` Alan Cox
2011-04-27 21:58                         ` Russell King - ARM Linux
2011-04-20  0:09             ` Ben Nizette
2011-04-20  9:45               ` Alan Cox
2011-04-20 12:38               ` Linus Walleij
2011-04-20 14:55                 ` Alan Cox
2011-04-20 12:21           ` Linus Walleij
2011-04-20 23:32             ` Ben Nizette
2011-04-21  6:48               ` Linus Walleij
2011-04-23  8:25                 ` Ben Nizette
2011-04-21  0:29             ` Ben Nizette
2011-04-20 12:19         ` Linus Walleij
2011-04-20 12:22           ` Alan Cox
2011-04-20 12:04   ` Linus Walleij
2011-04-20 23:24     ` Ben Nizette
2011-04-21 15:39 ` Stijn Devriendt
2011-04-22 11:36   ` Linus Walleij
2011-04-22 11:56     ` Alan Cox
2011-04-23  8:35     ` Ben Nizette
2011-04-25 18:52 ` Rohit Vaswani
2011-04-26  7:48   ` 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='BANLkTi=QGoaNvJNM6SNsEduVa958bcLC1A@mail.gmail.com' \
    --to=linus.walleij@linaro.org \
    --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).