From patchwork Mon Dec 1 12:09:36 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: 41767 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 671AD24001 for ; Mon, 1 Dec 2014 12:09:09 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id f15sf6535949lbj.7 for ; Mon, 01 Dec 2014 04:09:08 -0800 (PST) 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:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=ktwCCubO8R65RFD2Vj4QLe7xCfN1kF41aWphB9EhYmI=; b=YyBedIbwrpbu+XbwtzaRiyZhHdc6kzM3r/zkg+isDgkwx/Hg1wz/aQxa7E+XINPf/J ZJdRmkgeKydKUzmhyzEkXEvf96YQ4vDlMU7FHP4klHtG3EbSR4nipKzvFHmc5OGF/JCw Vp1AGmoWQa7VIq8gGyC89IDxaHvGU2a40sO2ZIaC26upqTZmi+vlaId8vsl+kBJknEdr RbZSJJ6bLolxyv/SW2v8Eppu2wT5PXE8odSQgixtcLcxkelS+jv8jHhx9ePhF8AeNbK4 zELdeM8CZhLrrLgIY/Rnsc5ATwDQ97Dr9EHrapo+quuUjC6ZlY7AxSHn/nvH/yfqP7ZS QK6Q== X-Gm-Message-State: ALoCoQmDtu1WS+I3L85DQS/aWzDPHrCIEErwc2596odS9LktynqDRvkmVfO3R5bhUibxTUXhFFBL X-Received: by 10.194.104.227 with SMTP id gh3mr288900wjb.7.1417435748346; Mon, 01 Dec 2014 04:09:08 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.7 with SMTP id 7ls1020744laq.88.gmail; Mon, 01 Dec 2014 04:09:08 -0800 (PST) X-Received: by 10.112.235.196 with SMTP id uo4mr55630594lbc.66.1417435748119; Mon, 01 Dec 2014 04:09:08 -0800 (PST) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id pt7si17428913lbb.120.2014.12.01.04.09.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Dec 2014 04:09:08 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id s18so8525668lam.21 for ; Mon, 01 Dec 2014 04:09:08 -0800 (PST) X-Received: by 10.152.43.12 with SMTP id s12mr3681736lal.67.1417435748025; Mon, 01 Dec 2014 04:09:08 -0800 (PST) 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.184.201 with SMTP id ew9csp272723lbc; Mon, 1 Dec 2014 04:09:06 -0800 (PST) X-Received: by 10.70.136.202 with SMTP id qc10mr99187328pdb.152.1417435745740; Mon, 01 Dec 2014 04:09:05 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9si630660pds.219.2014.12.01.04.09.05 for ; Mon, 01 Dec 2014 04:09:05 -0800 (PST) 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 S1753270AbaLAMJE (ORCPT ); Mon, 1 Dec 2014 07:09:04 -0500 Received: from mail-gw3-out.broadcom.com ([216.31.210.64]:14590 "EHLO mail-gw3-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753051AbaLAMJE (ORCPT ); Mon, 1 Dec 2014 07:09:04 -0500 X-IronPort-AV: E=Sophos;i="5.07,493,1413270000"; d="scan'208";a="51782604" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw3-out.broadcom.com with ESMTP; 01 Dec 2014 04:18:02 -0800 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; Mon, 1 Dec 2014 04:09:04 -0800 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; Mon, 1 Dec 2014 04:09:04 -0800 Received: from linaro.ban.broadcom.com (unknown [10.131.60.135]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id B364A40FE6; Mon, 1 Dec 2014 04:08:29 -0800 (PST) From: To: Linus Walleij , Alexandre Courbot CC: Kamlakant Patel , , Lennert Buytenhek , "Dan Williams" , Mikael Pettersson Subject: [PATCH v1 3/5] gpio: iop: convert to use basic mmio gpio library Date: Mon, 1 Dec 2014 17:39:36 +0530 Message-ID: <1417435778-21879-4-git-send-email-kamlakant.patel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1417435778-21879-1-git-send-email-kamlakant.patel@linaro.org> References: <1417435778-21879-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.48 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..d70cf37 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, NULL, IOP3XX_GPOE, 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 = {