OSDN Git Service

gpio: of: Check for "spi-cs-high" in child instead of parent node
[uclinux-h8/linux.git] / drivers / gpio / gpiolib-of.c
index c34eb9d..0220dd6 100644 (file)
@@ -86,7 +86,9 @@ static void of_gpio_flags_quirks(struct device_node *np,
        if (IS_ENABLED(CONFIG_REGULATOR) &&
            (of_device_is_compatible(np, "regulator-fixed") ||
             of_device_is_compatible(np, "reg-fixed-voltage") ||
-            of_device_is_compatible(np, "regulator-gpio"))) {
+            (of_device_is_compatible(np, "regulator-gpio") &&
+             !(strcmp(propname, "enable-gpio") &&
+               strcmp(propname, "enable-gpios"))))) {
                /*
                 * The regulator GPIO handles are specified such that the
                 * presence or absence of "enable-active-high" solely controls
@@ -118,7 +120,8 @@ static void of_gpio_flags_quirks(struct device_node *np,
         * to determine if the flags should have inverted semantics.
         */
        if (IS_ENABLED(CONFIG_SPI_MASTER) &&
-           of_property_read_bool(np, "cs-gpios")) {
+           of_property_read_bool(np, "cs-gpios") &&
+           !strcmp(propname, "cs-gpios")) {
                struct device_node *child;
                u32 cs;
                int ret;
@@ -140,16 +143,16 @@ static void of_gpio_flags_quirks(struct device_node *np,
                                 * conflict and the "spi-cs-high" flag will
                                 * take precedence.
                                 */
-                               if (of_property_read_bool(np, "spi-cs-high")) {
+                               if (of_property_read_bool(child, "spi-cs-high")) {
                                        if (*flags & OF_GPIO_ACTIVE_LOW) {
                                                pr_warn("%s GPIO handle specifies active low - ignored\n",
-                                                       of_node_full_name(np));
+                                                       of_node_full_name(child));
                                                *flags &= ~OF_GPIO_ACTIVE_LOW;
                                        }
                                } else {
                                        if (!(*flags & OF_GPIO_ACTIVE_LOW))
                                                pr_info("%s enforce active low on chipselect handle\n",
-                                                       of_node_full_name(np));
+                                                       of_node_full_name(child));
                                        *flags |= OF_GPIO_ACTIVE_LOW;
                                }
                                break;
@@ -345,6 +348,11 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
        if (of_flags & OF_GPIO_TRANSITORY)
                *flags |= GPIO_TRANSITORY;
 
+       if (of_flags & OF_GPIO_PULL_UP)
+               *flags |= GPIO_PULL_UP;
+       if (of_flags & OF_GPIO_PULL_DOWN)
+               *flags |= GPIO_PULL_DOWN;
+
        return desc;
 }