Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5583965img; Wed, 27 Mar 2019 11:08:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwf4m1Dl+0RcTnQno/NhRtPHqiCB9mV0dqqQALV8hstA7PWlCfYx/UG5SGo91LOKSgjF0/i X-Received: by 2002:a63:7153:: with SMTP id b19mr29456049pgn.289.1553710131270; Wed, 27 Mar 2019 11:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710131; cv=none; d=google.com; s=arc-20160816; b=KscEXsQ9N4uTkM9HAjxRUUjARwlP2xCxJgV+CtidmLUeqtI7yHcKF/tDKSwPIKP7oH Tn0goJPDlkQeO89pht34ujkvTPicWaRVb9JIYOJyxw00yXNsxbEBJMF9tTyTYxOQJd4y AXWM63ymoFlBUirmZPve7BV2pyk5gRqYYAU3IPUP4Hz1bP9jaVrm/jxaNYyYHme0R0r1 r4qhzwI0yMZKBj0mxesEP1PrALBc6XijoMFtPDB/tJLHrkMt1myQfBtfRMXqNUtaeCOH /9+WwkMnPdSdu62/y1u8sr16bx2ge9K8ReyhQaIaqD/9I1FTTT5gVZezJxa7PwWtxKtX aIJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=B7R6y5ljoU0vI9Os2nBRJNh1Cse0mOUlp6B68pvliDo=; b=XQCeMT64vWWkL51f5C2yKdp6yecJaaCrKCPU5/mNI7xpMcH5rff0x2fwZKlPiY+Q8C atK9EnBYRueR4KjY7ci12volIQrYwRIEpp9MIu8/Jc1dHEPvtmgUDeiFndYna8o1IEQQ pmL5ceruZEIXN5h7wLoJWU7xmY0f2P3uwHpBImlcoSwcxSmA1afXohZyYv82cEFU8knD 2VFP3CTPJeKPbehAMiHbpBaDkXNgvy/hpRaVis5JOit7UnqpsVh7wJmVuRpDuIMRCVRm kFmTutEf4ymXBj2gvXKq0jRcelv9WnaCFBrSsrLOjn6ftzE6fSO8hvdei6tSfAri7SxZ B6+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0R6NUSEH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u37si636047pga.301.2019.03.27.11.08.35; Wed, 27 Mar 2019 11:08:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0R6NUSEH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387827AbfC0SF7 (ORCPT + 99 others); Wed, 27 Mar 2019 14:05:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:47238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387801AbfC0SFz (ORCPT ); Wed, 27 Mar 2019 14:05:55 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 120622075C; Wed, 27 Mar 2019 18:05:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709954; bh=YwqxMsNUsCI5zqPkmbPECmgbv7W5UwBh0BcdPZFv+S4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0R6NUSEHArzqM7A5iBadthDRTJWx2bIc523juxEf+IBjf5og0HZ82DlH+Y9dKBJIC fG6B8N76Qd6VndSqZz7GeAmDT/w67awCAAtXLQf9gcyGLhYfTVgN+SIP0HMgjVuzeo xVC7OMbTkG0LiNoz9hVQJAGZiudV+KGMsoXtu2JE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Jan Kotas , Linus Walleij , Mark Brown , Wolfram Sang , linux-renesas-soc@vger.kernel.org, Sasha Levin , linux-gpio@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 129/262] gpio: of: Apply regulator-gpio quirk only to enable-gpios Date: Wed, 27 Mar 2019 13:59:44 -0400 Message-Id: <20190327180158.10245-129-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marek Vasut [ Upstream commit 0e7d6f94016407fd7e1ae472e254d64d4454e9c8 ] Since commit d6cd33ad7102 ("regulator: gpio: Convert to use descriptors") the GPIO regulator had inverted the polarity of the control GPIO. This problem manifested itself on systems with DT containing the following description (snippet from salvator-common.dtsi): gpios = <&gpio5 1 GPIO_ACTIVE_HIGH>; gpios-states = <1>; states = <3300000 1 1800000 0>; Prior to the aforementioned commit, the gpio-regulator code used gpio_request_array() to claim the GPIO(s) specified in the "gpios" DT node, while the commit changed that to devm_gpiod_get_index(). The legacy gpio_request_array() calls gpio_request_one() and then gpiod_request(), which parses the DT flags of the "gpios" node and populates the GPIO descriptor flags field accordingly. The new devm_gpiod_get_index() calls gpiod_get_index(), then of_find_gpio(), of_get_named_gpiod_flags() with flags != NULL, and then of_gpio_flags_quirks(). Since commit a603a2b8d86e ("gpio: of: Add special quirk to parse regulator flags"), of_gpio_flags_quirks() contains a quirk for regulator-gpio which was never triggered by the legacy gpio_request_array() code path, but is triggered by devm_gpiod_get_index() code path. This quirk checks whether a GPIO is associated with a fixed or gpio-regulator and if so, checks two additional conditions. First, whether such GPIO is active-low, and if so, ignores the active-low flag. Second, whether the regulator DT node does have an "enable-active-high" property and if the property is NOT present, sets the GPIO flags as active-low. The second check triggers a problem, since it is applied to all GPIOs associated with a gpio-regulator, rather than only on the "enable" GPIOs, as the old code did. This changes the way the gpio-regulator interprets the DT description of the control GPIOs. The old code using gpio_request_array() explicitly parsed the "enable-active-high" DT property and only applied it to the GPIOs described in the "enable-gpios" DT node, and only if those were present. This patch fixes the quirk code by only applying the quirk to "enable-gpios", thus restoring the old behavior. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Jan Kotas Cc: Linus Walleij Cc: Mark Brown Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org To: linux-gpio@vger.kernel.org Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/gpio/gpiolib-of.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index a6e1891217e2..30542a10014f 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -84,6 +84,7 @@ static void of_gpio_flags_quirks(struct device_node *np, * Note that active low is the default. */ if (IS_ENABLED(CONFIG_REGULATOR) && + !strcmp(propname, "enable-gpio") && (of_device_is_compatible(np, "regulator-fixed") || of_device_is_compatible(np, "reg-fixed-voltage") || of_device_is_compatible(np, "regulator-gpio"))) { -- 2.19.1