From ea845714fd4cc163002ca1bbd3c14ab4e35ed3ec Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 2 May 2012 19:41:44 -0700 Subject: [PATCH] Add gpio_get_name() to return the name of a signal Add this to the GPIO API. It seems that the implementation is copied in LM4 and STM32 so I have reluctantly done the same with this new function. BUG=chrome-os-partner:9424 TEST=build and boot on Daisy Change-Id: Ifddc52e69b2b33af2645384c0171dd264e588fcd Signed-off-by: Simon Glass --- chip/lm4/gpio.c | 6 ++++++ chip/stm32/gpio-stm32l15x.c | 6 ++++++ include/gpio.h | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/chip/lm4/gpio.c b/chip/lm4/gpio.c index 09be616771..fedfedc6e8 100644 --- a/chip/lm4/gpio.c +++ b/chip/lm4/gpio.c @@ -182,6 +182,12 @@ void gpio_set_alternate_function(int port, int mask, int func) } +const char *gpio_get_name(enum gpio_signal signal) +{ + return gpio_list[signal].name; +} + + int gpio_get_level(enum gpio_signal signal) { return LM4_GPIO_DATA(gpio_list[signal].port, diff --git a/chip/stm32/gpio-stm32l15x.c b/chip/stm32/gpio-stm32l15x.c index 55eaa22171..cd07e61361 100644 --- a/chip/stm32/gpio-stm32l15x.c +++ b/chip/stm32/gpio-stm32l15x.c @@ -127,6 +127,12 @@ void gpio_set_alternate_function(int port, int mask, int func) } +const char *gpio_get_name(enum gpio_signal signal) +{ + return gpio_list[signal].name; +} + + int gpio_get_level(enum gpio_signal signal) { return !!(STM32_GPIO_IDR_OFF(gpio_list[signal].port) & diff --git a/include/gpio.h b/include/gpio.h index 23cd1e9537..b3bd4258f4 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -62,6 +62,14 @@ int gpio_pre_init(void); /* Gets the current value of a signal (0=low, 1=hi). */ int gpio_get_level(enum gpio_signal signal); +/** + * Returns the name of a given GPIO signal. + * + * @param signal Signal to return. + * @returns name of the given signal + */ +const char *gpio_get_name(enum gpio_signal signal); + /* Sets the current value of a signal. Returns error if the signal is * not supported or is an input signal. */ int gpio_set_level(enum gpio_signal signal, int value);