Re: question on generic gpio interface

From: David Brownell
Date: Tue Apr 17 2007 - 14:46:42 EST


On Tuesday 17 April 2007 12:04 am, Francis Moreau wrote:

> BTW, are there any plan to make gpio usable from userspace ? I don't
> know if it makes sense but I saw some patches on LKML that did that.

Only the usual plan: someone who wants that feature provides a driver,
which can be merged after suitable review.

For example, the gpio_keys and leds-gpio drivers already exist to
expose some kinds of GPIOs ... though not specifically as GPIOs.
And I've seen various drivers that package GPIOs on specific chips,
mostly for _exclusive_ use by userspace (no kernel access).


In this case I'm not entirely sure how it'd work. I've seen a few
drivers which let userspace peek and poke at GPIO signals -- like
one for Gumstix boards -- but generalizing the model isn't simple.
Sub-problems include:

- Configuring the relevant pins. Especially for SOC cases, GPIO
roles are multiplexed with several others. So there are two
issues: (a) the platform-specific setup of that multiplexing,
plus (b) the board-specific knowledge of what pins are truly
available for use as GPIOs, and not otherwise in use.

- Enumerating those GPIOs to userspace. One SOC might have just
a few dozen, another might have a few hundred; and then there
are all the board-specific ones, on FPGA or I2C chips etc.

- Exposing those pins to userspace. It'd be unsafe to let pins
claimed by drivers be managed by userspace; the default should
be that only unclaimed GPIOs can be accessed.

Those points imply part of a design that includes board-specific
hooks of various kinds (maybe delegating a lot to platform code).

But nobody's yet provided code that would generalize.

- Dave
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/