Hi Simon On 08/02/2018 06:56 PM, Simon Glass wrote: > Hi Patrice, > > On 1 August 2018 at 10:38, Patrice Chotard <patrice.chot...@st.com> wrote: >> From: Patrick Delaunay <patrick.delau...@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_function_number() to request the pin >> function index from the driver when pin is not used >> as gpio. >> >> Signed-off-by: Patrick Delaunay <patrick.delau...@st.com> >> Signed-off-by: Patrice Chotard <patrice.chot...@st.com> >> --- >> >> drivers/gpio/gpio-uclass.c | 6 ++++++ >> include/asm-generic/gpio.h | 11 +++++++++++ >> 2 files changed, 17 insertions(+) >> >> diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c >> index da5e9ba6e524..fa249f7b12d4 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_function_number) { >> + ret = ops->get_function_number(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..f8cd6ddccbbf 100644 >> --- a/include/asm-generic/gpio.h >> +++ b/include/asm-generic/gpio.h >> @@ -266,6 +266,17 @@ struct dm_gpio_ops { >> int (*get_function)(struct udevice *dev, unsigned offset); >> >> /** >> + * get_function_number() Get the function number >> + * >> + * get index for GPIOF_FUNC, when pin is not used as a GPIO >> + * >> + * @dev: Device to check >> + * @offset: GPIO offset within that device >> + * @return current function index >> + */ >> + int (*get_function_number)(struct udevice *dev, unsigned int offset); > > Can you please add comments as to how this is different from > get_function(), Also, I suggest a different name, since it would be > confusing for people to have such similar names for different things,
Ok, i will rename get_function_number() to get_alternate_function() and add a comments Thanks Patrice > >> + >> + /** >> * xlate() - Translate phandle arguments into a GPIO description >> * >> * This function should set up the fields in desc according to the >> -- >> 1.9.1 >> > Regards, > Simon > _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot