From patchwork Wed Oct 29 13:56:43 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: 39780 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 9AC2924046 for ; Wed, 29 Oct 2014 13:57:32 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id h11sf1969633wiw.3 for ; Wed, 29 Oct 2014 06:57:31 -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=AgPbQd3Y43VHN2gMgCDOZDc3u+1ZCMHdwz8+PWJFiIs=; b=coNwIzCmmcCccnmAzjNTrK9y+yRsPoyksAvn890KQsEUyyQjfQLZ3Z2TlJZ2jJ/u2w TqKfP/heYkO8ElMACh1tfTBv2ySla6lg/ik4aQXBQHs9ONQboG1wOqfJCJLhSuJtKh9M SFo/CK6pAdzBwU2dmtghLq9AT0vjuZOwRPBMopNMSvdz5FhZ2q19gAERT9xvvLPM8mgC EAwe5iaC1uicwAFqRghyD2Qp0qd3rv1exyuv4q2i/CIE2PdZqeMcskmJnWwCmCmjnsom TqCZv42m17LTbp7W0j/eeryFTZISQrwoAsaIflix+0Lm0S5+4+mKvf/xh80d3SuUYhZF gdXQ== X-Gm-Message-State: ALoCoQmlvUj07NeJzDn4tfipMp2CJCQDyvNg0i/ZKlwi9+IYZBC4z2MCU4H3/R3nrIc6z813cPD+ X-Received: by 10.112.140.132 with SMTP id rg4mr480737lbb.12.1414591051768; Wed, 29 Oct 2014 06:57:31 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.40 with SMTP id 8ls26616lar.61.gmail; Wed, 29 Oct 2014 06:57:31 -0700 (PDT) X-Received: by 10.152.116.68 with SMTP id ju4mr11548862lab.13.1414591051562; Wed, 29 Oct 2014 06:57:31 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id ap3si7372567lbc.33.2014.10.29.06.57.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Oct 2014 06:57:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id f15so2711548lbj.41 for ; Wed, 29 Oct 2014 06:57:31 -0700 (PDT) X-Received: by 10.112.14.69 with SMTP id n5mr11585771lbc.34.1414591051434; Wed, 29 Oct 2014 06:57:31 -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 c5csp661649lbz; Wed, 29 Oct 2014 06:57:30 -0700 (PDT) X-Received: by 10.67.4.167 with SMTP id cf7mr10722695pad.52.1414591049826; Wed, 29 Oct 2014 06:57:29 -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.29 for ; Wed, 29 Oct 2014 06:57:29 -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 S932909AbaJ2N52 (ORCPT ); Wed, 29 Oct 2014 09:57:28 -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 S932834AbaJ2N52 (ORCPT ); Wed, 29 Oct 2014 09:57:28 -0400 X-IronPort-AV: E=Sophos;i="5.04,810,1406617200"; d="scan'208";a="49625209" 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:24:02 -0700 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) 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:27 -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 06:57:27 -0700 Received: from linaro.ban.broadcom.com (unknown [10.131.60.135]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id A719740FE5; Wed, 29 Oct 2014 06:57:08 -0700 (PDT) From: To: Linus Walleij , Alexandre Courbot CC: Kamlakant Patel , , Lennert Buytenhek , "Dan Williams" , Mikael Pettersson Subject: [PATCH 3/5] gpio: iop: convert to use basic mmio gpio library Date: Wed, 29 Oct 2014 19:26:43 +0530 Message-ID: <1414591005-30961-4-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.217.182 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 IOP GPIO driver to use basic_mmio_gpio generic library. Signed-off-by: Kamlakant Patel --- drivers/gpio/Kconfig | 1 + drivers/gpio/gpio-iop.c | 96 +++++++++---------------------------------------- 2 files changed, 18 insertions(+), 79 deletions(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 875d312..8cbc3ab 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -407,6 +407,7 @@ config GPIO_ICH config GPIO_IOP tristate "Intel IOP GPIO" depends on ARM && (ARCH_IOP32X || ARCH_IOP33X) + select GPIO_GENERIC help Say yes here to support the GPIO functionality of a number of Intel IOP32X or IOP33X. diff --git a/drivers/gpio/gpio-iop.c b/drivers/gpio/gpio-iop.c index 0a5e9d3..c7bbc73 100644 --- a/drivers/gpio/gpio-iop.c +++ b/drivers/gpio/gpio-iop.c @@ -14,19 +14,12 @@ #include #include #include -#include #include #include -#include -#include +#include #define IOP3XX_N_GPIOS 8 -#define GPIO_IN 0 -#define GPIO_OUT 1 -#define GPIO_LOW 0 -#define GPIO_HIGH 1 - /* Memory base offset */ static void __iomem *base; @@ -35,86 +28,31 @@ static void __iomem *base; #define IOP3XX_GPID IOP3XX_GPIO_REG(0x0004) #define IOP3XX_GPOD IOP3XX_GPIO_REG(0x0008) -static void gpio_line_config(int line, int direction) -{ - unsigned long flags; - u32 val; - - local_irq_save(flags); - val = readl(IOP3XX_GPOE); - if (direction == GPIO_IN) { - val |= BIT(line); - } else if (direction == GPIO_OUT) { - val &= ~BIT(line); - } - writel(val, IOP3XX_GPOE); - local_irq_restore(flags); -} - -static int gpio_line_get(int line) -{ - return !!(readl(IOP3XX_GPID) & BIT(line)); -} - -static void gpio_line_set(int line, int value) -{ - unsigned long flags; - u32 val; - - local_irq_save(flags); - val = readl(IOP3XX_GPOD); - if (value == GPIO_LOW) { - val &= ~BIT(line); - } else if (value == GPIO_HIGH) { - val |= BIT(line); - } - writel(val, IOP3XX_GPOD); - local_irq_restore(flags); -} - -static int iop3xx_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) -{ - gpio_line_config(gpio, GPIO_IN); - return 0; -} - -static int iop3xx_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int level) -{ - gpio_line_set(gpio, level); - gpio_line_config(gpio, GPIO_OUT); - return 0; -} - -static int iop3xx_gpio_get_value(struct gpio_chip *chip, unsigned gpio) -{ - return gpio_line_get(gpio); -} - -static void iop3xx_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value) -{ - gpio_line_set(gpio, value); -} - -static struct gpio_chip iop3xx_chip = { - .label = "iop3xx", - .direction_input = iop3xx_gpio_direction_input, - .get = iop3xx_gpio_get_value, - .direction_output = iop3xx_gpio_direction_output, - .set = iop3xx_gpio_set_value, - .base = 0, - .ngpio = IOP3XX_N_GPIOS, -}; - static int iop3xx_gpio_probe(struct platform_device *pdev) { struct resource *res; + struct bgpio_chip *bgc; + int ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(base)) return PTR_ERR(base); + bgc = devm_kzalloc(&pdev->dev, sizeof(*bgc), GFP_KERNEL); + if (!bgc) + return -EINVAL; + + ret = bgpio_init(bgc, &pdev->dev, 4, IOP3XX_GPID, + IOP3XX_GPOD, NULL, IOP3XX_GPOE, NULL, 0); + if (ret) { + dev_err(&pdev->dev, "bgpio_init failed\n"); + return ret; + } + bgc->gc.label = "iop3xx"; + bgc->gc.base = 0; + bgc->gc.ngpio = IOP3XX_N_GPIOS; - return gpiochip_add(&iop3xx_chip); + return gpiochip_add(&bgc->gc); } static struct platform_driver iop3xx_gpio_driver = {