From patchwork Wed Jan 8 10:40:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 3453311 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D458CC02DC for ; Wed, 8 Jan 2014 10:41:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B6F9A20122 for ; Wed, 8 Jan 2014 10:41:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8D4A4200F0 for ; Wed, 8 Jan 2014 10:41:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755278AbaAHKlE (ORCPT ); Wed, 8 Jan 2014 05:41:04 -0500 Received: from mga02.intel.com ([134.134.136.20]:44975 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751069AbaAHKlD (ORCPT ); Wed, 8 Jan 2014 05:41:03 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 08 Jan 2014 02:41:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,623,1384329600"; d="scan'208";a="463415671" Received: from blue.fi.intel.com ([10.237.72.156]) by orsmga002.jf.intel.com with ESMTP; 08 Jan 2014 02:40:58 -0800 Received: by blue.fi.intel.com (Postfix, from userid 1004) id 53473E0094; Wed, 8 Jan 2014 12:40:57 +0200 (EET) From: Mika Westerberg To: linux-acpi@vger.kernel.org Cc: "Rafael J. Wysocki" , Linus Walleij , Chris Ball , Johannes Berg , Rhyland Klein , Adrian Hunter , Heikki Krogerus , Mathias Nyman , Alexandre Courbot , Rob Landley , Stephen Warren , Thierry Reding , Mika Westerberg , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 4/4] Documentation / ACPI: update to GPIO descriptor API Date: Wed, 8 Jan 2014 12:40:57 +0200 Message-Id: <1389177657-29266-5-git-send-email-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1389177657-29266-1-git-send-email-mika.westerberg@linux.intel.com> References: <1389177657-29266-1-git-send-email-mika.westerberg@linux.intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Update the documentation also to reflect the fact that there are no ACPI specific GPIO interfaces anymore but drivers should instead use the descriptor based GPIO APIs. Signed-off-by: Mika Westerberg Acked-by: Rafael J. Wysocki --- Documentation/acpi/enumeration.txt | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/Documentation/acpi/enumeration.txt b/Documentation/acpi/enumeration.txt index b994bcb32b92..2a1519b87177 100644 --- a/Documentation/acpi/enumeration.txt +++ b/Documentation/acpi/enumeration.txt @@ -293,36 +293,13 @@ the device to the driver. For example: These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0" specifies the path to the controller. In order to use these GPIOs in Linux -we need to translate them to the Linux GPIO numbers. +we need to translate them to the corresponding Linux GPIO descriptors. -In a simple case of just getting the Linux GPIO number from device -resources one can use acpi_get_gpio_by_index() helper function. It takes -pointer to the device and index of the GpioIo/GpioInt descriptor in the -device resources list. For example: +There is a standard GPIO API for that and is documented in +Documentation/gpio.txt. - int gpio_irq, gpio_power; - int ret; - - gpio_irq = acpi_get_gpio_by_index(dev, 1, NULL); - if (gpio_irq < 0) - /* handle error */ - - gpio_power = acpi_get_gpio_by_index(dev, 0, NULL); - if (gpio_power < 0) - /* handle error */ - - /* Now we can use the GPIO numbers */ - -Other GpioIo parameters must be converted first by the driver to be -suitable to the gpiolib before passing them. - -In case of GpioInt resource an additional call to gpio_to_irq() must be -done before calling request_irq(). - -Note that the above API is ACPI specific and not recommended for drivers -that need to support non-ACPI systems. The recommended way is to use -the descriptor based GPIO interfaces. The above example looks like this -when converted to the GPIO desc: +In the above example we can get the corresponding two GPIO descriptors with +a code like this: #include ... @@ -339,4 +316,5 @@ when converted to the GPIO desc: /* Now we can use the GPIO descriptors */ -See also Documentation/gpio.txt. +There are also devm_* versions of these functions which release the +descriptors once the device is released.