summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2014-10-04 17:29:53 (GMT)
committerSimon Glass <sjg@chromium.org>2014-10-24 01:30:50 (GMT)
commit5aff3acdb75bf075a746783eace341300191a061 (patch)
treed40edc1fd6a9c6a9412924e4b8b675c3c4347a07
parent57d99d368e0eff624c5403b1f04d2548c5813598 (diff)
downloadu-boot-5aff3acdb75bf075a746783eace341300191a061.tar.xz
dm: gpio: omap3: Drop request()/free() in the driver
Now that the uclass supports gpio_request/free() there is no need for the driver to implement it too. Drop this unnecessary code. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--drivers/gpio/omap_gpio.c116
1 files changed, 1 insertions, 115 deletions
diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
index a4651bc..f3a7ccb 100644
--- a/drivers/gpio/omap_gpio.c
+++ b/drivers/gpio/omap_gpio.c
@@ -29,11 +29,9 @@
#ifdef CONFIG_DM_GPIO
-#define GPIO_NAME_SIZE 20
#define GPIO_PER_BANK 32
struct gpio_bank {
- char label[GPIO_PER_BANK][GPIO_NAME_SIZE];
/* TODO(sjg@chromium.org): Can we use a struct here? */
void *base; /* address of registers in physical memory */
enum gpio_method method;
@@ -246,47 +244,10 @@ int gpio_free(unsigned gpio)
#else /* new driver model interface CONFIG_DM_GPIO */
-/**
- * gpio_is_requested() - check if a GPIO has been requested
- *
- * @bank: Bank to check
- * @offset: GPIO offset within bank to check
- * @return true if marked as requested, false if not
- */
-static inline bool gpio_is_requested(struct gpio_bank *bank, int offset)
-{
- return *bank->label[offset] != '\0';
-}
-
-static int omap_gpio_is_output(struct gpio_bank *bank, int offset)
-{
- return _get_gpio_direction(bank, offset) == OMAP_GPIO_DIR_OUT;
-}
-
-static int check_requested(struct udevice *dev, unsigned offset,
- const char *func)
-{
- struct gpio_bank *bank = dev_get_priv(dev);
- struct gpio_dev_priv *uc_priv = dev->uclass_priv;
-
- if (!gpio_is_requested(bank, offset)) {
- printf("omap_gpio: %s: error: gpio %s%d not requested\n",
- func, uc_priv->bank_name, offset);
- return -EPERM;
- }
-
- return 0;
-}
-
/* set GPIO pin 'gpio' as an input */
static int omap_gpio_direction_input(struct udevice *dev, unsigned offset)
{
struct gpio_bank *bank = dev_get_priv(dev);
- int ret;
-
- ret = check_requested(dev, offset, __func__);
- if (ret)
- return ret;
/* Configure GPIO direction as input. */
_set_gpio_direction(bank, offset, 1);
@@ -299,11 +260,6 @@ static int omap_gpio_direction_output(struct udevice *dev, unsigned offset,
int value)
{
struct gpio_bank *bank = dev_get_priv(dev);
- int ret;
-
- ret = check_requested(dev, offset, __func__);
- if (ret)
- return ret;
_set_gpio_dataout(bank, offset, value);
_set_gpio_direction(bank, offset, 0);
@@ -315,11 +271,6 @@ static int omap_gpio_direction_output(struct udevice *dev, unsigned offset,
static int omap_gpio_get_value(struct udevice *dev, unsigned offset)
{
struct gpio_bank *bank = dev_get_priv(dev);
- int ret;
-
- ret = check_requested(dev, offset, __func__);
- if (ret)
- return ret;
return _get_gpio_value(bank, offset);
}
@@ -329,94 +280,29 @@ static int omap_gpio_set_value(struct udevice *dev, unsigned offset,
int value)
{
struct gpio_bank *bank = dev_get_priv(dev);
- int ret;
-
- ret = check_requested(dev, offset, __func__);
- if (ret)
- return ret;
_set_gpio_dataout(bank, offset, value);
return 0;
}
-static int omap_gpio_get_state(struct udevice *dev, unsigned int offset,
- char *buf, int bufsize)
-{
- struct gpio_dev_priv *uc_priv = dev->uclass_priv;
- struct gpio_bank *bank = dev_get_priv(dev);
- const char *label;
- bool requested;
- bool is_output;
- int size;
-
- label = bank->label[offset];
- is_output = omap_gpio_is_output(bank->base, offset);
- size = snprintf(buf, bufsize, "%s%d: ",
- uc_priv->bank_name ? uc_priv->bank_name : "", offset);
- buf += size;
- bufsize -= size;
- requested = gpio_is_requested(bank, offset);
- snprintf(buf, bufsize, "%s: %d [%c]%s%s",
- is_output ? "out" : " in",
- _get_gpio_value(bank, offset),
- requested ? 'x' : ' ',
- requested ? " " : "",
- label);
-
- return 0;
-}
-
-static int omap_gpio_request(struct udevice *dev, unsigned offset,
- const char *label)
-{
- struct gpio_bank *bank = dev_get_priv(dev);
-
- if (gpio_is_requested(bank, offset))
- return -EBUSY;
-
- strncpy(bank->label[offset], label, GPIO_NAME_SIZE);
- bank->label[offset][GPIO_NAME_SIZE - 1] = '\0';
-
- return 0;
-}
-
-static int omap_gpio_free(struct udevice *dev, unsigned offset)
-{
- struct gpio_bank *bank = dev_get_priv(dev);
- int ret;
-
- ret = check_requested(dev, offset, __func__);
- if (ret)
- return ret;
- bank->label[offset][0] = '\0';
-
- return 0;
-}
-
static int omap_gpio_get_function(struct udevice *dev, unsigned offset)
{
struct gpio_bank *bank = dev_get_priv(dev);
- if (!gpio_is_requested(bank, offset))
- return GPIOF_UNUSED;
-
/* GPIOF_FUNC is not implemented yet */
- if (_get_gpio_direction(bank->base, offset))
+ if (_get_gpio_direction(bank->base, offset) == OMAP_GPIO_DIR_OUT)
return GPIOF_OUTPUT;
else
return GPIOF_INPUT;
}
static const struct dm_gpio_ops gpio_omap_ops = {
- .request = omap_gpio_request,
- .free = omap_gpio_free,
.direction_input = omap_gpio_direction_input,
.direction_output = omap_gpio_direction_output,
.get_value = omap_gpio_get_value,
.set_value = omap_gpio_set_value,
.get_function = omap_gpio_get_function,
- .get_state = omap_gpio_get_state,
};
static int omap_gpio_probe(struct udevice *dev)