[U-Boot] [PATCH v3 12/16] dm: Add GPIO support and tests
Simon Glass
sjg at chromium.org
Fri Oct 18 21:46:49 CEST 2013
Hi Marek,
On Fri, Jun 28, 2013 at 3:51 PM, Marek Vasut <marex at denx.de> wrote:
> Dear Simon Glass,
>
> > Add driver model support for GPIOs. Since existing GPIO drivers do not
> use
> > driver model, this feature must be enabled by CONFIG_DM_GPIO. After all
> > GPO drivers are converted over we can perhaps remove this config.
> >
> > Tests are provided for the sandbox implementation, and are a sufficient
> > sanity check for basic operation.
> >
> > The GPIO uclass understands the concept of named banks of GPIOs, with
> each
> > GPIO device providing a single bank. Within each bank the GPIOs are
> > numbered using an offset from 0 to n-1. For example a bank named 'b' with
> > 20 offsets will provide GPIOs named b0 to b19.
> >
> > Anonymous GPIO banks are also supported, and are just numbered without
> any
> > prefix.
> >
> > Each time a GPIO driver is added to the uclass, the GPIOs are renumbered
> > accordinging, so there is always a global GPIO numbering order.
>
> [...]
>
> > +struct dm_gpio_ops {
> > + int (*request)(struct device *dev, unsigned offset, const char
> *label);
> > + int (*free)(struct device *dev, unsigned offset);
> > + int (*direction_input)(struct device *dev, unsigned offset);
> > + int (*direction_output)(struct device *dev, unsigned offset,
> > + int value);
> > + int (*get_value)(struct device *dev, unsigned offset);
> > + int (*set_value)(struct device *dev, unsigned offset, int value);
> > + int (*get_function)(struct device *dev, unsigned offset);
>
> What's this "get_function()" call about? Is this to set GPIO AF ? If so,
> it's
> mixing pinmux and GPIO into one, that shouldn't happen.
>
It's this:
static const char * const gpio_function[] = {
"input",
"output",
"unknown",
};
We need to know the whether the pin is in use for GPIO and if so, whether
it is input or output.
I have not looked at pinmux, but consider this out of scope for this series.
>
> > + int (*get_state)(struct device *dev, unsigned offset, char *state,
> > + int maxlen);
> > +};
>
> [...]
>
>
> Regards,
Simon
More information about the U-Boot
mailing list