From patchwork Wed Oct 29 13:56:41 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: 39778 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 32CAB24046 for ; Wed, 29 Oct 2014 13:57:29 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id h11sf1976313wiw.7 for ; Wed, 29 Oct 2014 06:57:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=ldOcMKoi9Wlx1UKpz5pldOCWLmfCwP8O92j5b8cAFuY=; b=FzlipWF6WWhoqMBzWz3IlKcuJXtCgfwrRdRzfwaB/HmwnILXx3e0srZr6e9N3gabDt Qcq9Bm1joiruoXuZSlwcB9iKqmq1ZJAHJf6eqvXC5t0mapTgU2u1WcZ3zj4iBbVFGrtM Tw7AQSnX0LWOlBU9jn+cV8Qzue6I4cxsTAqfQOYSXCZ0NtKP4WgDLLc/JrhsYz3EXTVP 1xG9bUocik6iBuDrNEKprjG/peGJrbXEdqLxHb9Iy8qIqcDIuH79sJv/a2mo4X24yEq9 Gzi3WtJEd46QO78ACOrgJoZ6Cx1SgqWtIh5b5IrZArY1w69e86Q4u0tLF/T/6Fwo3Kx5 zTog== X-Gm-Message-State: ALoCoQns7jVIoMg3/6+iCBaNgqzPNGJV5u4IFTnE6yl12WivXeRUuaGx4wlVB3+m5EBZJgVZj1ep X-Received: by 10.112.180.71 with SMTP id dm7mr205132lbc.18.1414591047906; Wed, 29 Oct 2014 06:57:27 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.178 with SMTP id az18ls193252lab.96.gmail; Wed, 29 Oct 2014 06:57:27 -0700 (PDT) X-Received: by 10.152.197.67 with SMTP id is3mr11701472lac.25.1414591047768; Wed, 29 Oct 2014 06:57:27 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id ks12si7403317lac.5.2014.10.29.06.57.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Oct 2014 06:57:27 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id ge10so2593470lab.36 for ; Wed, 29 Oct 2014 06:57:27 -0700 (PDT) X-Received: by 10.112.12.35 with SMTP id v3mr11561569lbb.80.1414591047681; Wed, 29 Oct 2014 06:57:27 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp661633lbz; Wed, 29 Oct 2014 06:57:26 -0700 (PDT) X-Received: by 10.70.41.138 with SMTP id f10mr10532534pdl.83.1414591046071; Wed, 29 Oct 2014 06:57:26 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fw12si4011976pdb.207.2014.10.29.06.57.25 for ; Wed, 29 Oct 2014 06:57:26 -0700 (PDT) Received-SPF: none (google.com: linux-gpio-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932849AbaJ2N5Z (ORCPT ); Wed, 29 Oct 2014 09:57:25 -0400 Received: from mail-gw1-out.broadcom.com ([216.31.210.62]:24659 "EHLO mail-gw1-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932834AbaJ2N5Y (ORCPT ); Wed, 29 Oct 2014 09:57:24 -0400 X-IronPort-AV: E=Sophos;i="5.04,810,1406617200"; d="scan'208";a="49625200" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw1-out.broadcom.com with ESMTP; 29 Oct 2014 08:23:58 -0700 Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.174.1; Wed, 29 Oct 2014 06:57:23 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.3.174.1; Wed, 29 Oct 2014 06:57:28 -0700 Received: from linaro.ban.broadcom.com (unknown [10.131.60.135]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 3383C40FE5; Wed, 29 Oct 2014 06:57:04 -0700 (PDT) From: To: Linus Walleij , Alexandre Courbot CC: Kamlakant Patel , , Jonas Jensen Subject: [PATCH 1/5] gpio: moxart: convert to use basic mmio gpio library Date: Wed, 29 Oct 2014 19:26:41 +0530 Message-ID: <1414591005-30961-2-git-send-email-kamlakant.patel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1414591005-30961-1-git-send-email-kamlakant.patel@linaro.org> References: <1414591005-30961-1-git-send-email-kamlakant.patel@linaro.org> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-gpio@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: kamlakant.patel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Kamlakant Patel This patch converts MOXART GPIO driver to use basic_mmio_gpio generic library. Signed-off-by: Kamlakant Patel --- drivers/gpio/Kconfig | 1 + drivers/gpio/gpio-moxart.c | 76 ++++++++++++++++------------------------------ 2 files changed, 27 insertions(+), 50 deletions(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 0959ca9..3bd4d63 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -184,6 +184,7 @@ config GPIO_F7188X config GPIO_MOXART bool "MOXART GPIO support" depends on ARCH_MOXART + select GPIO_GENERIC help Select this option to enable GPIO driver for MOXA ART SoC devices. diff --git a/drivers/gpio/gpio-moxart.c b/drivers/gpio/gpio-moxart.c index 4661e18..c06fdcf 100644 --- a/drivers/gpio/gpio-moxart.c +++ b/drivers/gpio/gpio-moxart.c @@ -23,6 +23,7 @@ #include #include #include +#include #define GPIO_DATA_OUT 0x00 #define GPIO_DATA_IN 0x04 @@ -48,20 +49,6 @@ static void moxart_gpio_free(struct gpio_chip *chip, unsigned offset) pinctrl_free_gpio(offset); } -static void moxart_gpio_set(struct gpio_chip *chip, unsigned offset, int value) -{ - struct moxart_gpio_chip *gc = to_moxart_gpio(chip); - void __iomem *ioaddr = gc->base + GPIO_DATA_OUT; - u32 reg = readl(ioaddr); - - if (value) - reg = reg | BIT(offset); - else - reg = reg & ~BIT(offset); - - writel(reg, ioaddr); -} - static int moxart_gpio_get(struct gpio_chip *chip, unsigned offset) { struct moxart_gpio_chip *gc = to_moxart_gpio(chip); @@ -73,65 +60,54 @@ static int moxart_gpio_get(struct gpio_chip *chip, unsigned offset) return !!(readl(gc->base + GPIO_DATA_IN) & BIT(offset)); } -static int moxart_gpio_direction_input(struct gpio_chip *chip, unsigned offset) -{ - struct moxart_gpio_chip *gc = to_moxart_gpio(chip); - void __iomem *ioaddr = gc->base + GPIO_PIN_DIRECTION; - - writel(readl(ioaddr) & ~BIT(offset), ioaddr); - return 0; -} - -static int moxart_gpio_direction_output(struct gpio_chip *chip, - unsigned offset, int value) -{ - struct moxart_gpio_chip *gc = to_moxart_gpio(chip); - void __iomem *ioaddr = gc->base + GPIO_PIN_DIRECTION; - - moxart_gpio_set(chip, offset, value); - writel(readl(ioaddr) | BIT(offset), ioaddr); - return 0; -} - -static struct gpio_chip moxart_template_chip = { - .label = "moxart-gpio", - .request = moxart_gpio_request, - .free = moxart_gpio_free, - .direction_input = moxart_gpio_direction_input, - .direction_output = moxart_gpio_direction_output, - .set = moxart_gpio_set, - .get = moxart_gpio_get, - .ngpio = 32, - .owner = THIS_MODULE, -}; - static int moxart_gpio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct resource *res; + struct bgpio_chip *bgc; struct moxart_gpio_chip *mgc; int ret; mgc = devm_kzalloc(dev, sizeof(*mgc), GFP_KERNEL); if (!mgc) return -ENOMEM; - mgc->gpio = moxart_template_chip; + + bgc = devm_kzalloc(dev, sizeof(*bgc), GFP_KERNEL); + if (!bgc) + return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); mgc->base = devm_ioremap_resource(dev, res); if (IS_ERR(mgc->base)) return PTR_ERR(mgc->base); - mgc->gpio.dev = dev; + ret = bgpio_init(bgc, dev, 4, mgc->base + GPIO_PIN_DIRECTION, + mgc->base + GPIO_DATA_OUT, NULL, + mgc->base + GPIO_PIN_DIRECTION, NULL, 0); + + if (ret) { + dev_err(&pdev->dev, "bgpio_init failed\n"); + return ret; + } + + bgc->gc.label = "moxart-gpio"; + bgc->gc.request = moxart_gpio_request; + bgc->gc.free = moxart_gpio_free, + bgc->gc.get = moxart_gpio_get, + bgc->gc.ngpio = 32; + bgc->gc.dev = dev; + bgc->gc.owner = THIS_MODULE; + + mgc->gpio = bgc->gc; - ret = gpiochip_add(&mgc->gpio); + ret = gpiochip_add(&bgc->gc); if (ret) { dev_err(dev, "%s: gpiochip_add failed\n", dev->of_node->full_name); return ret; } - return 0; + return ret; } static const struct of_device_id moxart_gpio_match[] = {