From patchwork Mon Aug 7 12:41:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 798616 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="XHZDJPmz"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xQxxc6Xkzz9sNc for ; Mon, 7 Aug 2017 22:42:12 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752966AbdHGMmL (ORCPT ); Mon, 7 Aug 2017 08:42:11 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:37183 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752567AbdHGMmL (ORCPT ); Mon, 7 Aug 2017 08:42:11 -0400 Received: by mail-qk0-f194.google.com with SMTP id x77so284206qka.4 for ; Mon, 07 Aug 2017 05:42:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=5pnqlfY9x5zYLg5CB1x4mZ/uF/kaKMrTOorfQNzTCV4=; b=XHZDJPmzzGQmeen6WlB+xR+BTryQBZPsp0jsehz7I/d+xXYohYnCebvDm7clMyAx+u hB9V1fHtbBbfJkVmiI69ERnfD/6q2Ok2OzXqduxc4RQRTlhYMy+Wjak06i9Unn4EtlSv vbWrLRKUTFMSfk4lvrtNVb9gD7siH+cpCckhf3tAQXv8KoFrIww0DlHtSD1MS+vlCodz /qDJfHHTblYLyoTG9gWCMgmJXtSvrJwOX2Gen6Uu74VMnNImUASF/oUrdU3weN1i2EJE 4i03Nl6HcTHdiDIXyarvqRvQUiUFT6k6TxSOQ1YWuwtcIdCdmSMLgYdMsMqJD+sC5Mbz FBrA== 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=5pnqlfY9x5zYLg5CB1x4mZ/uF/kaKMrTOorfQNzTCV4=; b=lnx1cEEcJN8QKpYqXhoDVEfNs9tsphHyOhebYM21MbNRHQBV/GI4d5w4vHKhIQUHXR VZWnSxmtGWGBhjnDqSQTg8A+uKn6bPQ+ZeuznuYJwy/v5dhfSIfK5XCZc/xL+e5KKs2M OXZi3XAcZcnS3UNi5cKFvW2DY2KZ6L9NqTIcX81UbrGNDqJBiFMXs/9CzskBFy66RqiC aQsVvSl17hticxLahQslwj54PsGQ9oCRjRmp3uHCL/Faspeu5flbbiQJhUU3WhNA43NG FFNkfO+R1+cLrIzARSqIDploT+kUvgjAfDQlJ60bQ76/Qo9DtPXemHiAM1ShGUBy5hjk 0QGg== X-Gm-Message-State: AHYfb5i9Y/TdIRApgPt7/Cdj307IiLuBHWm45G6KoZDxpbl3liXdCrN5 pzZ+/U8SfP3sfg== X-Received: by 10.55.183.197 with SMTP id h188mr520424qkf.206.1502109730269; Mon, 07 Aug 2017 05:42:10 -0700 (PDT) Received: from localhost.localdomain ([187.180.180.203]) by smtp.gmail.com with ESMTPSA id l36sm3418270qte.31.2017.08.07.05.42.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 05:42:09 -0700 (PDT) From: Fabio Estevam To: linus.walleij@linaro.org Cc: linux-gpio@vger.kernel.org, robh+dt@kernel.org, peng.fan@nxp.com, Fabio Estevam Subject: [PATCH] gpio: 74x164: Introduce 'enable-gpios' property Date: Mon, 7 Aug 2017 09:41:50 -0300 Message-Id: <1502109710-31624-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Fabio Estevam 74HC595 has an /OE (output enable) pin that can be controlled by a GPIO. Introduce an optional property called 'enable-gpios' that allows controlling the /OE pin. Signed-off-by: Fabio Estevam Acked-by: Rob Herring --- Documentation/devicetree/bindings/gpio/gpio-74x164.txt | 3 +++ drivers/gpio/gpio-74x164.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/Documentation/devicetree/bindings/gpio/gpio-74x164.txt b/Documentation/devicetree/bindings/gpio/gpio-74x164.txt index ce1b223..2a97553 100644 --- a/Documentation/devicetree/bindings/gpio/gpio-74x164.txt +++ b/Documentation/devicetree/bindings/gpio/gpio-74x164.txt @@ -12,6 +12,9 @@ Required properties: 1 = active low - registers-number: Number of daisy-chained shift registers +Optional properties: +- enable-gpios: GPIO connected to the OE (Output Enable) pin. + Example: gpio5: gpio5@0 { diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index a6607fa..6b535ec 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -9,6 +9,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include @@ -31,6 +32,7 @@ struct gen_74x164_chip { * numbering, store the bytes in reverse order. */ u8 buffer[0]; + struct gpio_desc *gpiod_oe; }; static int __gen_74x164_write_config(struct gen_74x164_chip *chip) @@ -126,6 +128,13 @@ static int gen_74x164_probe(struct spi_device *spi) if (!chip) return -ENOMEM; + chip->gpiod_oe = devm_gpiod_get_optional(&spi->dev, "enable", + GPIOD_OUT_LOW); + if (IS_ERR(chip->gpiod_oe)) + return PTR_ERR(chip->gpiod_oe); + + gpiod_set_value_cansleep(chip->gpiod_oe, 1); + spi_set_drvdata(spi, chip); chip->gpio_chip.label = spi->modalias; @@ -164,6 +173,7 @@ static int gen_74x164_remove(struct spi_device *spi) { struct gen_74x164_chip *chip = spi_get_drvdata(spi); + gpiod_set_value_cansleep(chip->gpiod_oe, 0); gpiochip_remove(&chip->gpio_chip); mutex_destroy(&chip->lock);