diff --git a/drivers/of/of_gpio.c b/drivers/of/of_gpio.c index dc8ae22..9a8331e 100644 --- a/drivers/of/of_gpio.c +++ b/drivers/of/of_gpio.c @@ -4,6 +4,37 @@ #include #include +static void of_gpio_flags_quirks(struct device_node *np, + const char *propname, + enum of_gpio_flags *flags, + int index) +{ + /* + * Some GPIO fixed regulator quirks. + * Note that active low is the default. + */ + if (IS_ENABLED(CONFIG_REGULATOR) && + (of_device_is_compatible(np, "regulator-fixed") || + of_device_is_compatible(np, "reg-fixed-voltage") || + (!(strcmp(propname, "enable-gpio") && + strcmp(propname, "enable-gpios")) && + of_device_is_compatible(np, "regulator-gpio")))) { + /* + * The regulator GPIO handles are specified such that the + * presence or absence of "enable-active-high" solely controls + * the polarity of the GPIO line. Any phandle flags must + * be actively ignored. + */ + if (*flags & OF_GPIO_ACTIVE_LOW) { + pr_warn("%s GPIO handle specifies active low - ignored\n", + np->full_name); + *flags &= ~OF_GPIO_ACTIVE_LOW; + } + if (!of_property_read_bool(np, "enable-active-high")) + *flags |= OF_GPIO_ACTIVE_LOW; + } +} + /** * of_get_named_gpio_flags() - Get a GPIO number and flags to use with GPIO API * @np: device node to get GPIO from @@ -46,8 +77,10 @@ return ret; } - if (flags) + if (flags) { *flags = out_args.args[1]; + of_gpio_flags_quirks(np, propname, flags, index); + } return ret; }