From patchwork Wed Oct 29 14:04:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: kamlakant.patel@linaro.org X-Patchwork-Id: 404653 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B2C12140077 for ; Thu, 30 Oct 2014 01:04:30 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932906AbaJ2OE3 (ORCPT ); Wed, 29 Oct 2014 10:04:29 -0400 Received: from mail-gw1-out.broadcom.com ([216.31.210.62]:22117 "EHLO mail-gw1-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932768AbaJ2OE3 (ORCPT ); Wed, 29 Oct 2014 10:04:29 -0400 X-IronPort-AV: E=Sophos;i="5.04,810,1406617200"; d="scan'208";a="49625695" Received: from irvexchcas07.broadcom.com (HELO IRVEXCHCAS07.corp.ad.broadcom.com) ([10.9.208.55]) by mail-gw1-out.broadcom.com with ESMTP; 29 Oct 2014 08:31:03 -0700 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS07.corp.ad.broadcom.com (10.9.208.55) with Microsoft SMTP Server (TLS) id 14.3.174.1; Wed, 29 Oct 2014 07:04:28 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) with Microsoft SMTP Server id 14.3.174.1; Wed, 29 Oct 2014 07:04:28 -0700 Received: from linaro.ban.broadcom.com (unknown [10.131.60.135]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id C8EC740FEB; Wed, 29 Oct 2014 07:04:09 -0700 (PDT) From: To: Linus Walleij , Alexandre Courbot , Jonathan Corbet CC: Kamlakant Patel , , Subject: [PATCH 5/5] gpio: document basic mmio gpio library Date: Wed, 29 Oct 2014 19:34:17 +0530 Message-ID: <1414591457-31074-1-git-send-email-kamlakant.patel@linaro.org> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Kamlakant Patel This is a brief documentation on how to use GPIO Generic library for memory-mapped GPIO controllers. Signed-off-by: Kamlakant Patel --- Documentation/gpio/driver.txt | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/Documentation/gpio/driver.txt b/Documentation/gpio/driver.txt index 31e0b5d..563abea 100644 --- a/Documentation/gpio/driver.txt +++ b/Documentation/gpio/driver.txt @@ -190,3 +190,53 @@ gpiochip_free_own_desc(). These functions must be used with care since they do not affect module use count. Do not use the functions to request gpio descriptors not owned by the calling driver. + + +Generic driver for memory-mapped GPIO controllers +------------------------------------------------- +The GPIO generic library provides support for basic platform_device +memory-mapped GPIO controllers, which can be accessed by selecting Kconfig +symbol GPIO_GENERIC and using library functions provided by GPIO generic +driver (see drivers/gpio/gpio-generic.c). +The simplest form of a GPIO controller that the driver support is just a +single "data" register, where GPIO state can be read and/or written. + +The driver can be registered using "basic-mmio-gpio" or for big-endian +notation support use "basic-mmio-gpio-be". The code will configure gpio_chip +and issue gpiochip_add(). + +The driver supports: +- 8/16/32/64 bits registers. The number of GPIOs is determined by the width of + the registers. +- GPIO controllers with clear/set registers. +- GPIO controllers with a single "data" register. +- Big endian bits/GPIOs ordering. + +For setting GPIO's there are three supported configurations: +- single input/output register resource (named "dat"). +- set/clear pair (named "set" and "clr"). +- single output register resource and single input resource ("set" and dat"). + +For setting the GPIO direction, there are three supported configurations: +- simple bidirection GPIO that requires no configuration. +- an output direction register (named "dirout") where a 1 bit indicates the + GPIO is an output. +- an input direction register (named "dirin") where a 1 bit indicates the GPIO + is an input. + +It is possible to use only parts of GPIO generic library. Each GPIO controller +using GPIO generic library needs to include the following header. + + #include + +Use bgpio_init to configure gpio_chip and bgpio_remove to remove the controller. +int bgpio_init(struct bgpio_chip *bgc, struct device *dev, + unsigned long sz, void __iomem *dat, void __iomem *set, + void __iomem *clr, void __iomem *dirout, void __iomem *dirin, + unsigned long flags); + +The "flag" parameter can be following depending on controller configuration: +BGPIOF_BIG_ENDIAN BIT(0) +BGPIOF_UNREADABLE_REG_SET BIT(1) /* reg_set is unreadable */ +BGPIOF_UNREADABLE_REG_DIR BIT(2) /* reg_dir is unreadable */ +BGPIOF_BIG_ENDIAN_BYTE_ORDER BIT(3)