gpio: samsung: add flags specifier to device-tree binding
authorOlof Johansson <olofj@chromium.org>
Tue, 26 Jun 2012 03:51:36 +0000 (20:51 -0700)
committerOlof Johansson <olofj@chromium.org>
Thu, 28 Jun 2012 22:09:53 +0000 (15:09 -0700)
This adds a flags field to the gpio specifier for Samsung. I didn't
want to add yet another field in the already quite long specifier, so
I decided to compress it together with the Pull Up/Down settings instead.

This is needed to, for example, have a gpio-keys input that is active low.

BUG=chrome-os-partner:10861
TEST=boot, make sure system stays awake, close lid, make sure system suspends

Change-Id: Ia3ad27c13ab773da6d584370ac585d7c982590a5
Signed-off-by: Olof Johansson <olofj@chromium.org>
Reviewed-on: https://gerrit-int.chromium.org/20819
Reviewed-by: Doug Anderson <dianders@google.com>
Reviewed-by: <thomas.ab@samsung.com>
Tested-by: Olof Johansson <olofj@google.com>
Commit-Ready: Olof Johansson <olofj@google.com>

Documentation/devicetree/bindings/gpio/gpio-samsung.txt
drivers/gpio/gpio-samsung.c

index 8f50fe5..6a6f5e4 100644 (file)
@@ -11,14 +11,15 @@ Required properties:
      <[phandle of the gpio controller node]
       [pin number within the gpio controller]
       [mux function]
-      [pull up/down]
+      [flags and pull up/down]
       [drive strength]>
 
   Values for gpio specifier:
   - Pin number: is a value between 0 to 7.
-  - Pull Up/Down: 0 - Pull Up/Down Disabled.
-                  1 - Pull Down Enabled.
-                  3 - Pull Up Enabled.
+  - Flags and Pull Up/Down: 0 - Pull Up/Down Disabled.
+                            1 - Pull Down Enabled.
+                            3 - Pull Up Enabled.
+          Bit 16 (0x00010000) - Input is active low
   - Drive Strength: 0 - 1x,
                     1 - 3x,
                     2 - 2x,
index f88bb9f..e20043a 100644 (file)
@@ -2681,11 +2681,18 @@ static int exynos_gpio_xlate(struct gpio_chip *gc,
 
        if (s3c_gpio_cfgpin(pin, S3C_GPIO_SFN(gpiospec->args[1])))
                pr_warn("gpio_xlate: failed to set pin function\n");
-       if (s3c_gpio_setpull(pin, gpiospec->args[2]))
+       if (s3c_gpio_setpull(pin, gpiospec->args[2] & 0xffff))
                pr_warn("gpio_xlate: failed to set pin pull up/down\n");
        if (s5p_gpio_set_drvstr(pin, gpiospec->args[3]))
                pr_warn("gpio_xlate: failed to set pin drive strength\n");
 
+       /* flags are the upper 16 bits of the pull up/down cell, and currently
+        * they correspond to the of_gpio_flags so we can just do a straight
+        * assignment here.
+        */
+       if (flags)
+               *flags = gpiospec->args[2] >> 16;
+
        return gpiospec->args[0];
 }