Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934116AbdDFRTQ (ORCPT ); Thu, 6 Apr 2017 13:19:16 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:17966 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751605AbdDFRTF (ORCPT ); Thu, 6 Apr 2017 13:19:05 -0400 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 06 Apr 2017 10:19:04 -0700 Message-ID: <58E67328.5040805@nvidia.com> Date: Thu, 6 Apr 2017 22:26:08 +0530 From: Laxman Dewangan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Andy Shevchenko CC: Linus Walleij , Alexandre Courbot , Rob Herring , Mark Rutland , Frank Rowand , "linux-gpio@vger.kernel.org" , "linux-kernel@vger.kernel.org" , devicetree Subject: Re: [PATCH 1/1] gpio: core: Decouple open drain/source flag with active low/high References: <1491485752-28030-1-git-send-email-ldewangan@nvidia.com> In-Reply-To: X-Originating-IP: [10.19.65.30] X-ClientProxiedBy: DRHKMAIL101.nvidia.com (10.25.59.15) To bgmail102.nvidia.com (10.25.59.11) Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2221 Lines: 62 On Thursday 06 April 2017 09:40 PM, Andy Shevchenko wrote: > On Thu, Apr 6, 2017 at 4:35 PM, Laxman Dewangan wrote: >> Currently, the GPIO interface is said to Open Drain if it is Single >> Ended and active LOW. Similarly, it is said as Open Source if it is >> Single Ended and active HIGH. >> >> The active HIGH/LOW is used in the interface for setting the pin >> state to HIGH or LOW when enabling/disabling the interface. >> >> In Open Drain interface, pin is set to HIGH by putting pin in >> high impedance and LOW by driving to the LOW. >> >> In Open Source interface, pin is set to HIGH by driving pin to >> HIGH and set to LOW by putting pin in high impedance. >> >> With above, the Open Drain/Source is unrelated to the active LOW/HIGH >> in interface. There is interface where the enable/disable of interface >> is ether active LOW or HIGH but it is Open Drain type. >> >> Hence decouple the Open Drain with Single Ended + Active LOW and >> Open Source with Single Ended + Active HIGH. >> >> Adding different flag for the Open Drain/Open Source which is valid >> only when Single ended flag is enabled. >> if (single_ended) { >> - if (active_low) >> + if (open_drain) > This breaks ACPI case, right? > In acpi case, single_ended is not handled. It only handles the active LOW. From code: bool active_low = false; bool single_ended = false; int ret; if (!fwnode) return ERR_PTR(-EINVAL); if (is_of_node(fwnode)) { enum of_gpio_flags flags; desc = of_get_named_gpiod_flags(to_of_node(fwnode), propname, index, &flags); if (!IS_ERR(desc)) { active_low = flags & OF_GPIO_ACTIVE_LOW; single_ended = flags & OF_GPIO_SINGLE_ENDED; } } else if (is_acpi_node(fwnode)) { struct acpi_gpio_info info; desc = acpi_node_get_gpiod(fwnode, propname, index, &info); if (!IS_ERR(desc)) active_low = info.polarity == GPIO_ACTIVE_LOW; }