From patchwork Wed Apr 27 08:24:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 66773 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2055071qge; Wed, 27 Apr 2016 01:25:07 -0700 (PDT) X-Received: by 10.98.38.66 with SMTP id m63mr9747369pfm.57.1461745507773; Wed, 27 Apr 2016 01:25:07 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r81si2997212pfb.40.2016.04.27.01.25.07; Wed, 27 Apr 2016 01:25:07 -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; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; 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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752507AbcD0IZG (ORCPT + 4 others); Wed, 27 Apr 2016 04:25:06 -0400 Received: from mail-lf0-f47.google.com ([209.85.215.47]:35555 "EHLO mail-lf0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752385AbcD0IZB (ORCPT ); Wed, 27 Apr 2016 04:25:01 -0400 Received: by mail-lf0-f47.google.com with SMTP id c126so47596413lfb.2 for ; Wed, 27 Apr 2016 01:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=FBZQeo42ZxcXHgh2sZ7bgXm9Ae8vqV3wBdtVy8zIj1Y=; b=YQwLx+IBexsUnsAyeNXgRVWF8yy11IoNam6/5mnPLFZ9uZrPO2vUE+JzRIN5DoH5gM cmSW1ATDps5EmmF0pdQfTT81J5LYe9ZdusHuNCRFBDMJ6Cqo3XWrVub/AvqEV4HGhnHR Qeg5JNufOPpKNjtydqWQK7W3HNfPcyOZBOIqE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FBZQeo42ZxcXHgh2sZ7bgXm9Ae8vqV3wBdtVy8zIj1Y=; b=XVGn1alJO1/GwMfZ7wePFsblgfj198nJhLkPQsXT/VuKg7JQz+R8sDwlQHLoCGpsQ1 8+sPE63Tz5zjOTQbmU6PflEBmCoHFJIlT+IGhZhpDQeDcD+d19biRQ7ovRbr9Vb9IHVN RioFh25Q4SuIgv+3lkrGOpBzkjTZOWnzjNsqEZErAqWUlYMcyPq5JYkwtE0s69hjJwfw W6HtSxSOPcXtQWPeprgj0aWayPnWqul0+GJDVglwwAXGiOJ2gYkME2ze2sr0IuYrAg7F +PnVf+HzPk//SwFFQP4J8dvRQT451cVzO8RCgFF6I2xPRtrKNrp2930ikxXv3ya8qSMi mnBQ== X-Gm-Message-State: AOPr4FWySVRebzMmtKcLugNEc94lx17EUzVc0D44JY0j68+SQPFk6btlk6XxZEqS3d6eScpd X-Received: by 10.25.144.68 with SMTP id s65mr2616821lfd.26.1461745499293; Wed, 27 Apr 2016 01:24:59 -0700 (PDT) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id k6sm544371lby.49.2016.04.27.01.24.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Apr 2016 01:24:58 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot Cc: Linus Walleij Subject: [PATCH] gpio: clarify open drain/source docs Date: Wed, 27 Apr 2016 10:24:55 +0200 Message-Id: <1461745495-3854-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.11 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Make the text clearer, remove reference to confusing "positive" and "negative" and elaborate a bit. Signed-off-by: Linus Walleij --- Documentation/gpio/driver.txt | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) -- 2.4.11 -- 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/Documentation/gpio/driver.txt b/Documentation/gpio/driver.txt index ae6e0299b16c..6cb35a78eff4 100644 --- a/Documentation/gpio/driver.txt +++ b/Documentation/gpio/driver.txt @@ -100,6 +100,10 @@ Both usecases require that the line be equipped with a pull-up resistor. This resistor will make the line tend to high level unless one of the transistors on the rail actively pulls it down. +The level on the line will go as high as the VDD on the pull-up resistor, which +may be higher than the level supported by the transistor, achieveing a +level-shift to the higher VDD. + Integrated electronics often have an output driver stage in the form of a CMOS "totem-pole" with one N-MOS and one P-MOS transistor where one of them drives the line high and one of them drives the line low. This is called a push-pull @@ -110,14 +114,18 @@ output. The "totem-pole" looks like so: OD ||--+ +--/ ---o|| P-MOS-FET | ||--+ -in --+ +----- out +IN --+ +----- out | ||--+ +--/ ----|| N-MOS-FET OS ||--+ | GND -You see the little "switches" named "OD" and "OS" that enable/disable the +The desired output signal (e.g. coming directly from some GPIO output register) +arrives at IN. The switches named "OD" and "OS" are normally closed, creating +a push-pull circuit. + +Consider the little "switches" named "OD" and "OS" that enable/disable the P-MOS or N-MOS transistor right after the split of the input. As you can see, either transistor will go totally numb if this switch is open. The totem-pole is then halved and give high impedance instead of actively driving the line @@ -128,8 +136,8 @@ Some GPIO hardware come in open drain / open source configuration. Some are hard-wired lines that will only support open drain or open source no matter what: there is only one transistor there. Some are software-configurable: by flipping a bit in a register the output can be configured as open drain -or open source, by flicking open the switches labeled "OD" and "OS" in the -drawing above. +or open source, in practice by flicking open the switches labeled "OD" and "OS" +in the drawing above. By disabling the P-MOS transistor, the output can be driven between GND and high impedance (open drain), and by disabling the N-MOS transistor, the output @@ -146,8 +154,8 @@ set in the machine file, or coming from other hardware descriptions. If this state can not be configured in hardware, i.e. if the GPIO hardware does not support open drain/open source in hardware, the GPIO library will instead use a trick: when a line is set as output, if the line is flagged as open -drain, and the output value is negative, it will be driven low as usual. But -if the output value is set to positive, it will instead *NOT* be driven high, +drain, and the IN output value is low, it will be driven low as usual. But +if the IN output value is set to high, it will instead *NOT* be driven high, instead it will be switched to input, as input mode is high impedance, thus achieveing an "open drain emulation" of sorts: electrically the behaviour will be identical, with the exception of possible hardware glitches when switching