[U-Boot] [PATCH V2 2/4] s5p: gpio: add implementation of dm_gpio_set_pull()
Przemyslaw Marczak
p.marczak at samsung.com
Wed Feb 18 11:51:04 CET 2015
This commit adds implementation of driver model gpio pull
setting to s5p gpio driver.
Signed-off-by: Przemyslaw Marczak <p.marczak at samsung.com>
Cc: Simon Glass <sjg at chromium.org>
Cc: Minkyu Kang <mk7.kang at samsung.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
---
Changes v2:
- adjust code after added gpio pull enum to gpio api
---
drivers/gpio/s5p_gpio.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c
index 0a245ba..ed531c6 100644
--- a/drivers/gpio/s5p_gpio.c
+++ b/drivers/gpio/s5p_gpio.c
@@ -129,6 +129,7 @@ static void s5p_gpio_set_pull(struct s5p_gpio_bank *bank, int gpio, int mode)
value &= ~PULL_MASK(gpio);
switch (mode) {
+ case S5P_GPIO_PULL_NONE:
case S5P_GPIO_PULL_DOWN:
case S5P_GPIO_PULL_UP:
value |= PULL_MODE(gpio, mode);
@@ -231,6 +232,32 @@ static int exynos_gpio_set_value(struct udevice *dev, unsigned offset,
return 0;
}
+
+static int exynos_gpio_set_pull(struct udevice *dev, unsigned offset,
+ int pull)
+{
+ struct exynos_bank_info *state = dev_get_priv(dev);
+ int gpio_pull;
+
+ switch (pull) {
+ case GPIOP_NONE:
+ gpio_pull = S5P_GPIO_PULL_NONE;
+ break;
+ case GPIOP_DOWN:
+ gpio_pull = S5P_GPIO_PULL_DOWN;
+ break;
+ case GPIOP_UP:
+ gpio_pull = S5P_GPIO_PULL_UP;
+ break;
+ default:
+ return -EINVAL;
+ break;
+ }
+
+ s5p_gpio_set_pull(state->bank, offset, gpio_pull);
+
+ return 0;
+}
#endif /* nCONFIG_SPL_BUILD */
/*
@@ -290,6 +317,7 @@ static const struct dm_gpio_ops gpio_exynos_ops = {
.direction_output = exynos_gpio_direction_output,
.get_value = exynos_gpio_get_value,
.set_value = exynos_gpio_set_value,
+ .set_pull = exynos_gpio_set_pull,
.get_function = exynos_gpio_get_function,
.xlate = exynos_gpio_xlate,
};
--
1.9.1
More information about the U-Boot
mailing list