]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
dm: gpio: sandbox: Implement the get_function() method
authorSimon Glass <sjg@chromium.org>
Sat, 4 Oct 2014 17:29:45 +0000 (11:29 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 24 Oct 2014 01:29:52 +0000 (19:29 -0600)
Implement this method so that the 'gpio' command can do its job correctly.
For sandbox we only support input and output states for a gpio.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/gpio/sandbox.c

index 75ada5d3871a844935c22b1bb9557f2e3229c84f..7aa8b1f0f8cfcf92c76f16da4eff1166622c92d3 100644 (file)
@@ -203,6 +203,13 @@ static int sb_gpio_get_state(struct udevice *dev, unsigned int offset,
        return 0;
 }
 
+static int sb_gpio_get_function(struct udevice *dev, unsigned offset)
+{
+       if (get_gpio_flag(dev, offset, GPIOF_OUTPUT))
+               return GPIOF_OUTPUT;
+       return GPIOF_INPUT;
+}
+
 static const struct dm_gpio_ops gpio_sandbox_ops = {
        .request                = sb_gpio_request,
        .free                   = sb_gpio_free,
@@ -210,7 +217,7 @@ static const struct dm_gpio_ops gpio_sandbox_ops = {
        .direction_output       = sb_gpio_direction_output,
        .get_value              = sb_gpio_get_value,
        .set_value              = sb_gpio_set_value,
-       .get_state              = sb_gpio_get_state,
+       .get_function           = sb_gpio_get_function,
 };
 
 static int sandbox_gpio_ofdata_to_platdata(struct udevice *dev)