Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp547021pxv; Thu, 8 Jul 2021 08:24:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfjCjCbN6Nt1cuY+StWgD2Y0szHznE0F/MNwsy9hJVuN0r0BMt9yUUFopM8F91lTBlHbB2 X-Received: by 2002:a17:907:97c3:: with SMTP id js3mr32305934ejc.114.1625757886058; Thu, 08 Jul 2021 08:24:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625757886; cv=none; d=google.com; s=arc-20160816; b=C4Pfrf8N0r/dt/vSMpzBiRpHJoFBmBcYihjbgBP6sN9rrRYZjtnyqTPQ3KxGO/LIKT 4PO5viEhsqCjX+5qnlHNiRygpwXseJLMbgeP0br0cUa5+dpN1Tyz32fSPkdMdwkc2TId QOPEJVvhGiQIfA2BDyacVpdwzQe/OOswtGgB0rexl/JgDlWA2DdG9HkJc/y11tpBEW9g SXZ10/07tkbKemB3xq4Ie+UBZoNaN63vvbQlbZltBgJoA9w2r9wkiDqig3xKskjzAxGx 22uUajCN6pJAkDQ5Pg9C65ZRNueL8zEXP1oJP5XGk6fDy6A79wdnW+Xx+TZ1YPTI+1oa PpDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=vSXN7Kh9x6gUYLLQwWC/sSb0E4UPI2sT9SAOdpYbkPg=; b=c/FhJlQfuQ5k2Bi2QoGlgxFBXTGts4Z7HblYnXPCtIj+SMACqKz2T3ha/FcTNgwuuN wAeNEqekXtwXKW2jaBOjrbuafPVHlWUmKpFNdqPI+ATh/H/5xfJGcyCby9pMLZWw1mhR nYU88fADvgbMfQvGW+BhngQZeslW1r9htOjQIuDQH+fzHf1M+NQKcxvt4ClojRuxuw/s rvZ71DTJL230+JQyR88CzbkO/fRVSrHgcoHnCBtqtAma4gg4ITbTr44ha8KQOW7OuSri OafKR6KLWnQh4/0DsyVitPO1Snr9J767ZCQxyMzVeNcXUaBfb/+ZXjWKq1qGJNfwzVRp Q3XQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m19si4128707edd.234.2021.07.08.08.24.23; Thu, 08 Jul 2021 08:24:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232018AbhGHPYD (ORCPT + 99 others); Thu, 8 Jul 2021 11:24:03 -0400 Received: from mail-lf1-f51.google.com ([209.85.167.51]:45844 "EHLO mail-lf1-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231815AbhGHPYB (ORCPT ); Thu, 8 Jul 2021 11:24:01 -0400 Received: by mail-lf1-f51.google.com with SMTP id p1so16720906lfr.12; Thu, 08 Jul 2021 08:21:18 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=vSXN7Kh9x6gUYLLQwWC/sSb0E4UPI2sT9SAOdpYbkPg=; b=QX0vL98es+y/BQNXMBqfb3IPiTURZw0irJ8w/w7nqNPD5fYIgonVsa/GbWWE/U5Bvl nFMn4xCEK0uyBZY/W794KPr97788o3DJTa//bish6ThatEK2/yoKoA6Kbq8oM0iO4TDG jbBtxieyTxhQwdJN/GY2hkORe5xEY9odwyDsI6uqelxeD6pJ0zdbo+QT1//keHtKdorF 8tnhuY7/y3wquik8tZL9X8ZWsiz1ALW9Uo9pheA/n9o5jcpzMuPtAJpJRCfJnCU9yH1d DZogYz8gVjFWtco4DJosD7JYMmmQrJLANJKF58b9dlLGGAhDKHIzgRiNLZOe1Q71hpWG Kqxw== X-Gm-Message-State: AOAM533BRX0API8RvZ3+DTUN81PkgWEexK12HPtcL+AB0B7XK87vdyp9 IPahKKxwTeAgmJUL3iCmQQ0= X-Received: by 2002:a05:6512:224e:: with SMTP id i14mr20966868lfu.195.1625757677635; Thu, 08 Jul 2021 08:21:17 -0700 (PDT) Received: from localhost (88-112-11-80.elisa-laajakaista.fi. [88.112.11.80]) by smtp.gmail.com with ESMTPSA id a24sm221525lfg.231.2021.07.08.08.21.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jul 2021 08:21:17 -0700 (PDT) From: Hannu Hartikainen To: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org Cc: Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Hannu Hartikainen Subject: [PATCH] docs: gpio: explain GPIOD_OUT_* values and toggling active low Date: Thu, 8 Jul 2021 18:20:54 +0300 Message-Id: <20210708152054.361704-1-hannu@hrtk.in> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I was confused about the gpiod_flags values and thought that GPIOD_OUT_LOW and GPIOD_OUT_HIGH set the line to be active low / active high. This is not true, but I got the misconception because the flags GPIOD_OUT_*_OPEN_DRAIN do change line configuration and there's a subchapter about *active low* and *open drain* semantics. Add an explicit mention that the initial value is a logical value (and not the line configuration or physical line level). Also add a mention of the function gpiod_toggle_active_low which was previously missing from this document. Signed-off-by: Hannu Hartikainen --- Documentation/driver-api/gpio/consumer.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Documentation/driver-api/gpio/consumer.rst b/Documentation/driver-api/gpio/consumer.rst index 3366a991b4aa..47869ca8ccf0 100644 --- a/Documentation/driver-api/gpio/consumer.rst +++ b/Documentation/driver-api/gpio/consumer.rst @@ -72,6 +72,10 @@ for the GPIO. Values can be: * GPIOD_OUT_HIGH_OPEN_DRAIN same as GPIOD_OUT_HIGH but also enforce the line to be electrically used with open drain. +Note that the initial value is *logical* and the physical line level depends on +whether the line is configured active high or active low (see +:ref:`active_low_semantics`). + The two last flags are used for use cases where open drain is mandatory, such as I2C: if the line is not already configured as open drain in the mappings (see board.txt), then open drain will be enforced anyway and a warning will be @@ -252,6 +256,8 @@ that can't be accessed from hardIRQ handlers, these calls act the same as the spinlock-safe calls. +.. _active_low_semantics: + The active low and open drain semantics --------------------------------------- As a consumer should not have to care about the physical line level, all of the @@ -309,9 +315,11 @@ work on the raw line value:: void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value) int gpiod_direction_output_raw(struct gpio_desc *desc, int value) -The active low state of a GPIO can also be queried using the following call:: +The active low state of a GPIO can also be queried and toggled using the +following calls:: int gpiod_is_active_low(const struct gpio_desc *desc) + void gpiod_toggle_active_low(struct gpio_desc *desc) Note that these functions should only be used with great moderation; a driver should not have to care about the physical line level or open drain semantics. -- 2.32.0