From patchwork Tue Jan 9 00:32:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 123794 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3382832qgn; Mon, 8 Jan 2018 16:34:47 -0800 (PST) X-Google-Smtp-Source: ACJfBovVn+Y63VI9ynfN6dxh5QKwvACRXuFNlT26NtmehhB8Nvg/98HFPDaWQhcr5GafwzBFP4qr X-Received: by 10.98.87.17 with SMTP id l17mr12169589pfb.201.1515458086986; Mon, 08 Jan 2018 16:34:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515458086; cv=none; d=google.com; s=arc-20160816; b=q8dJ3hNIU8nZnSdIIVKy2BEyKO4A3anDXysVuHUse49PxACvcKMHpIQ2jehbM2o9Gc poUaP+hT15bi5VJPXaig9XGdgraPIzHByQz+iwEq2sTfR4JwolvVaQL23L+eXhxKqcxO 3nEzD4Is+ESIkuH0zwYrGO64+7b2vYyEvp934jE/OSBUa4pc7NWvtFr7JLpTcx5lxu7v LcitNTPJpmyr7k50L2om9TGrabIvyDKc3fZSn+xVOQdPyxaV63XW0pk8Rt1sCqOLiiRD xgPe51CeU1lHuUWEBETxF2lFaZcKCPHxNkBPzFOCdLogQX018lfE2ZoeXpWLe+u0HL/l oUPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=WHpl7OvcPtsyKBkBZtMb9izgIbKDinJO/YTjTAtNvyU=; b=JMXRGT/2AKh8o0cSjZ1K8BiowFbW/cb6e2yc5tHh3/FpJS5uC3YA8czLLJfO2+8LUn Aqakq7G6U9lR25keflLQ5WOGROnWcMNU4eeNAdhGyp9CHKwUkDn/hce7cdYFogPQxAml RfrIGUG+iEKJyZdSy1VR3FAKVcPfhQztEtk37wHQYuOg3Xsr9oUsCVozXWACwPOoKhKi kgZHVbs9SRnLpcbNWcsAmgSbfK5hGn5vKqXMAQwpQVEMcgRO2Fvcz2m0wUjSNCnQwMDn H6iVXoju+/YBBV1dMwHLEn4ZV+BT8Soiv65X86y/58WOcuzEq564t2yoJ9arJ9rZkm/9 xZ2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LPpTmnwK; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n16si9408314pll.476.2018.01.08.16.34.46; Mon, 08 Jan 2018 16:34:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LPpTmnwK; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755022AbeAIAeq (ORCPT + 6 others); Mon, 8 Jan 2018 19:34:46 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34284 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752907AbeAIAep (ORCPT ); Mon, 8 Jan 2018 19:34:45 -0500 Received: by mail-lf0-f66.google.com with SMTP id h140so14038814lfg.1 for ; Mon, 08 Jan 2018 16:34:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=8po5DbOU+D2gLBjycWLFcgyH4oDl6KaDXH+9d2m8vS8=; b=LPpTmnwKO3D+Q4t+b1/M+yxC7ZNLvjCyrhAGW+iPKZfRnzK7JOv1n3TCAVpERHNPUA ya001lavZkcoqN4fhbq1meWvLjzi2L51GC1ofkSUOLzLUrcKH0EfoxSNTeR/iKTWg+LX tpS7lryELa3O0wPcqmiCsRiojOVc/PQ+rDCEI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8po5DbOU+D2gLBjycWLFcgyH4oDl6KaDXH+9d2m8vS8=; b=PaI3s6qGkdeT2F/gIqjDi2lOsmiJoC5ymw/vPHK5pZTU6UJF90U2mVA93lkFJYtz+d B67dKnH5dAP3wgcs5/auYYUygeKdwpWu11s2EgDJU8RTHj3+nwmuwpswhqee3wHEWsnv S8wpEFk5753Mb8nZ7jjM0bRptY0PO5yT45Vu5SI7v7R3gcFIdruWEAPAix90//wUCfh9 ie7dbtogY/m1JHBuDS2CsJLnMq9K7mou+oImPbicE6erBXkzHVPZez7Qf3hLPNPIdP1g 03wWcLKHdYiiiZA0HNbR4a8gjba2wbpjBpyfGN3xu3ufKgT0G3knJjSA1KJSCTJvwtRT xtTw== X-Gm-Message-State: AKwxytfHDIhbJ/6jmdf+DEsRPhAgT7MlSTdLbnUdq4VIy8pxV3/Ss198 lqAxTc1k6CKPTBBmBeXjZ8FwsA== X-Received: by 10.25.215.223 with SMTP id q92mr5914496lfi.107.1515458083645; Mon, 08 Jan 2018 16:34:43 -0800 (PST) Received: from localhost.localdomain (c-cb7471d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.116.203]) by smtp.gmail.com with ESMTPSA id g192sm2342786lfg.69.2018.01.08.16.34.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jan 2018 16:34:42 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown , linux-gpio@vger.kernel.org, Rob Herring Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 4/4] gpio: of: Add special quirk to parse regulator flags Date: Tue, 9 Jan 2018 01:32:40 +0100 Message-Id: <20180109003240.22924-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org While most GPIOs are indicated to be active low or open drain using their twocell flags, we have legacy regulator bindings to take into account. Add a quirk respecting the special boolean active-high and open drain flags when parsing regulator nodes for GPIOs. This makes it possible to get rid of duplicated inversion semantics handling in the regulator core and any regulator drivers parsing and handling this separately. Unfortunately the old regulator inversion semantics are specified such that the presence or absence of "enable-active-high" solely controls the semantics, so we cannot deprecate this in favor of the phandle-provided inversion flag, instead any such phandle inversion flag provided in the second cell of a GPIO handle must be actively ignored, so we print a warning to contain the situation and make things easy for the users. Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib-of.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 9686922310a4..37bd3e8f2b0b 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -56,6 +56,42 @@ static struct gpio_desc *of_xlate_and_get_gpiod_flags(struct gpio_chip *chip, return gpiochip_get_desc(chip, ret); } +static void of_gpio_flags_quirks(struct device_node *np, + enum of_gpio_flags *flags) +{ + /* + * Some GPIO fixed regulator quirks. + * Note that active low is the default. + */ + if (IS_ENABLED(CONFIG_REGULATOR) && + (of_device_is_compatible(np, "reg-fixed-voltage") || + 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", + of_node_full_name(np)); + *flags &= ~OF_GPIO_ACTIVE_LOW; + } + if (!of_property_read_bool(np, "enable-active-high")) + *flags |= OF_GPIO_ACTIVE_LOW; + } + /* + * Legacy open drain handling for fixed voltage regulators. + */ + if (IS_ENABLED(CONFIG_REGULATOR) && + of_device_is_compatible(np, "reg-fixed-voltage") && + of_property_read_bool(np, "gpio-open-drain")) { + *flags |= (OF_GPIO_SINGLE_ENDED | OF_GPIO_OPEN_DRAIN); + pr_info("%s uses legacy open drain flag - update the DTS if you can\n", + of_node_full_name(np)); + } +} + /** * of_get_named_gpiod_flags() - Get a GPIO descriptor and flags for GPIO API * @np: device node to get GPIO from @@ -93,6 +129,8 @@ struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np, if (IS_ERR(desc)) goto out; + of_gpio_flags_quirks(np, flags); + pr_debug("%s: parsed '%s' property of node '%pOF[%d]' - status (%d)\n", __func__, propname, np, index, PTR_ERR_OR_ZERO(desc));