From patchwork Fri Oct 2 11:27:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 54420 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id 69153218EF for ; Fri, 2 Oct 2015 11:27:57 +0000 (UTC) Received: by lafb9 with SMTP id b9sf1781620laf.3 for ; Fri, 02 Oct 2015 04:27:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=ehJAndWWICPrxyUMvnxTzGkHjPY+nYR7GndPeXihcnU=; b=CGgQ0i/y6aYaAhBbWShFDAYn+8NG05vu/hv3f+lXjlb5SozNMv4wz9Afy/1F0jbazZ 8zV1liVf0xoIgfa/jkqn3mn88BQWaFREpt33353TZbG8VYJLdRhRlguIeEmaXh7c0C6t oMH7ZBnPM8ndlNapL9OaE9R2fdUTjPPbHNCANRu7wJYSCAcFgyQnUWxU9Ft0KelV3C4V 8v6VCAutDpkLW/MRHEKxirIId/1yZmXY4VdjaybzFgo/nC19Yk49jX5BAwe7R+Ra+WZA 1bsmqPCtw/W6KKkY032R87Jn7nklY8B7Jf52TabqNXj4PajuobFJg0ZkIcU+RsRzVTpU 1bzg== X-Gm-Message-State: ALoCoQkSnqaUYp5HCOKBuMHYQl5jGZsbN+YIpCrFOkWs1kSJVVz8xBrjuqJfH8wHP3xge49WPBJE X-Received: by 10.112.125.104 with SMTP id mp8mr2523666lbb.20.1443785276340; Fri, 02 Oct 2015 04:27:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.77.80 with SMTP id a77ls211136lfb.70.gmail; Fri, 02 Oct 2015 04:27:56 -0700 (PDT) X-Received: by 10.25.150.83 with SMTP id y80mr3367751lfd.119.1443785276205; Fri, 02 Oct 2015 04:27:56 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id l4si5941408lfb.13.2015.10.02.04.27.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Oct 2015 04:27:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbwr8 with SMTP id r8so24651711lbw.2 for ; Fri, 02 Oct 2015 04:27:56 -0700 (PDT) X-Received: by 10.25.150.199 with SMTP id y190mr3593804lfd.35.1443785276035; Fri, 02 Oct 2015 04:27:56 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1170810lbq; Fri, 2 Oct 2015 04:27:54 -0700 (PDT) X-Received: by 10.107.130.149 with SMTP id m21mr16062289ioi.180.1443785274689; Fri, 02 Oct 2015 04:27:54 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64si8196813ioh.110.2015.10.02.04.27.54; Fri, 02 Oct 2015 04:27:54 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751577AbbJBL1x (ORCPT + 3 others); Fri, 2 Oct 2015 07:27:53 -0400 Received: from mail-la0-f43.google.com ([209.85.215.43]:35628 "EHLO mail-la0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751342AbbJBL1x (ORCPT ); Fri, 2 Oct 2015 07:27:53 -0400 Received: by laer8 with SMTP id r8so90609995lae.2 for ; Fri, 02 Oct 2015 04:27:51 -0700 (PDT) X-Received: by 10.25.211.201 with SMTP id k192mr3569016lfg.32.1443785271559; Fri, 02 Oct 2015 04:27:51 -0700 (PDT) Received: from localhost.localdomain.localdomain (c-297471d5.01-192-6c756e10.cust.bredbandsbolaget.se. [213.113.116.41]) by smtp.gmail.com with ESMTPSA id g7sm1414453lbs.10.2015.10.02.04.27.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Oct 2015 04:27:49 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org Cc: Alexandre Courbot , Linus Walleij , Tony Lindgren , Grygorii Strashko , "H. Nikolaus Schaller" Subject: [PATCH v2] gpio: add DT bindings for existing consumer flags Date: Fri, 2 Oct 2015 04:27:47 -0700 Message-Id: <1443785267-14689-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-gpio@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , It is customary for GPIO controllers to support open drain/collector and open source/emitter configurations. Add standard GPIO line flags to account for this and augment the documentation to say that these are the most generic bindings. Several people approached me to add new flags to the lines, and this makes sense, but let's first bind up the most common cases before we start to add exotic stuff. Thanks to H. Nikolaus Schaller for ideas on how to encode single-ended wiring such as open drain/source and open collector/emitter. Cc: Tony Lindgren Cc: Grygorii Strashko Cc: H. Nikolaus Schaller Signed-off-by: Linus Walleij --- Documentation/devicetree/bindings/gpio/gpio.txt | 17 +++++++++++++++-- include/dt-bindings/gpio/gpio.h | 12 ++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/gpio/gpio.txt b/Documentation/devicetree/bindings/gpio/gpio.txt index 5788d5cf1252..63b1b9039ce8 100644 --- a/Documentation/devicetree/bindings/gpio/gpio.txt +++ b/Documentation/devicetree/bindings/gpio/gpio.txt @@ -52,9 +52,13 @@ only uses one. gpio-specifier may encode: bank, pin position inside the bank, whether pin is open-drain and whether pin is logically inverted. + Exact meaning of each specifier cell is controller specific, and must -be documented in the device tree binding for the device. Use the macros -defined in include/dt-bindings/gpio/gpio.h whenever possible: +be documented in the device tree binding for the device. + +Most controllers are however specifying a generic flag bitfield +in the last cell, so for these, use the macros defined in +include/dt-bindings/gpio/gpio.h whenever possible: Example of a node using GPIOs: @@ -65,6 +69,15 @@ Example of a node using GPIOs: GPIO_ACTIVE_HIGH is 0, so in this example gpio-specifier is "18 0" and encodes GPIO pin number, and GPIO flags as accepted by the "qe_pio_e" gpio-controller. +Optional standard bitfield specifiers for the last cell: + +- Bit 0: 0 means active high, 1 means active low +- Bit 1: 1 means single-ended wiring, see: + https://en.wikipedia.org/wiki/Single-ended_triode + When used with active-low, this means open drain/collector, see: + https://en.wikipedia.org/wiki/Open_collector + When used with active-high, this means open source/emitter + 1.1) GPIO specifier best practices ---------------------------------- diff --git a/include/dt-bindings/gpio/gpio.h b/include/dt-bindings/gpio/gpio.h index e6b1e0a808ae..c673d2c87c60 100644 --- a/include/dt-bindings/gpio/gpio.h +++ b/include/dt-bindings/gpio/gpio.h @@ -9,7 +9,19 @@ #ifndef _DT_BINDINGS_GPIO_GPIO_H #define _DT_BINDINGS_GPIO_GPIO_H +/* Bit 0 express polarity */ #define GPIO_ACTIVE_HIGH 0 #define GPIO_ACTIVE_LOW 1 +/* Bit 1 express single-endedness */ +#define GPIO_PUSH_PULL 0 +#define GPIO_SINGLE_ENDED 2 + +/* + * Open Drain/Collector is the combination of single-ended active low, + * Open Source/Emitter is the combination of single-ended active high. + */ +#define GPIO_OPEN_DRAIN (GPIO_SINGLE_ENDED | GPIO_ACTIVE_LOW) +#define GPIO_OPEN_SOURCE (GPIO_SINGLE_ENDED | GPIO_ACTIVE_HIGH) + #endif