Message ID | 1533308471-14098-2-git-send-email-patrice.chotard@st.com |
---|---|
State | Superseded |
Delegated to: | Tom Rini |
Headers | show |
Series | Add get_alternate_function ops | expand |
Hi Patrice, +Stephen and Masahiro for comment on this vs. pinctrl. On 3 August 2018 at 09:01, Patrice Chotard <patrice.chotard@st.com> wrote: > From: Patrick Delaunay <patrick.delaunay@st.com> > > When a pin is not configured as a GPIO, it could > have several alternate function. > > To be able to identify the alternate function, > add ops get_alternate_function() to request the pin > alternate function index from the driver when pin is > not used as gpio. > > Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> > Signed-off-by: Patrice Chotard <patrice.chotard@st.com> > --- > > Changes in v2: > - Rename get_function_number to get_alternate_function > in include/asm-generic/gpio.h > > drivers/gpio/gpio-uclass.c | 6 ++++++ > include/asm-generic/gpio.h | 13 +++++++++++++ > 2 files changed, 19 insertions(+) Reviewed-by: Simon Glass <sjg@chromium.org> But please replace 'alternative' with 'alt' as it is shorter. Regards, Simon
Hi Simon On 08/08/2018 11:55 AM, Simon Glass wrote: > Hi Patrice, > > +Stephen and Masahiro for comment on this vs. pinctrl. > > On 3 August 2018 at 09:01, Patrice Chotard <patrice.chotard@st.com> wrote: >> From: Patrick Delaunay <patrick.delaunay@st.com> >> >> When a pin is not configured as a GPIO, it could >> have several alternate function. >> >> To be able to identify the alternate function, >> add ops get_alternate_function() to request the pin >> alternate function index from the driver when pin is >> not used as gpio. >> >> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> >> Signed-off-by: Patrice Chotard <patrice.chotard@st.com> >> --- >> >> Changes in v2: >> - Rename get_function_number to get_alternate_function >> in include/asm-generic/gpio.h >> >> drivers/gpio/gpio-uclass.c | 6 ++++++ >> include/asm-generic/gpio.h | 13 +++++++++++++ >> 2 files changed, 19 insertions(+) > > Reviewed-by: Simon Glass <sjg@chromium.org> > > But please replace 'alternative' with 'alt' as it is shorter. ok Thanks Patrice > > Regards, > Simon > _______________________________________________ > Uboot-stm32 mailing list > Uboot-stm32@st-md-mailman.stormreply.com > https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32 >
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index da5e9ba6e524..705ca9016c8a 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -568,6 +568,12 @@ int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize) label ? label : ""); } + if (func == GPIOF_FUNC && ops->get_alternate_function) { + ret = ops->get_alternate_function(dev, offset); + if (ret >= 0) + snprintf(str + len, buffsize - len, ": %d", ret); + } + return 0; } diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index d03602696f6d..e3a677ffd6c2 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -266,6 +266,19 @@ struct dm_gpio_ops { int (*get_function)(struct udevice *dev, unsigned offset); /** + * get_alternate_function() Get the pins alternate function + * + * When a pin is not configured as GPIO, this pin can have several + * alternate function. get_alternate_function indicate the current + * pin's alternate function index + * + * @dev: Device to check + * @offset: GPIO offset within that device + * @return current alternate function index + */ + int (*get_alternate_function)(struct udevice *dev, unsigned int offset); + + /** * xlate() - Translate phandle arguments into a GPIO description * * This function should set up the fields in desc according to the