From patchwork Mon May 16 11:41:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tarun Kanti DebBarma X-Patchwork-Id: 787722 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4GBg3UE010698 for ; Mon, 16 May 2011 11:42:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753610Ab1EPLl4 (ORCPT ); Mon, 16 May 2011 07:41:56 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:45254 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753458Ab1EPLlx (ORCPT ); Mon, 16 May 2011 07:41:53 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id p4GBfnMw016282 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 16 May 2011 06:41:51 -0500 Received: from dbde70.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id p4GBfj6W006834; Mon, 16 May 2011 17:11:45 +0530 (IST) Received: from dbdp31.itg.ti.com (172.24.170.98) by DBDE70.ent.ti.com (172.24.170.148) with Microsoft SMTP Server id 8.3.106.1; Mon, 16 May 2011 17:11:45 +0530 Received: from localhost.localdomain ([172.24.191.168]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id p4GBfgOP021559; Mon, 16 May 2011 17:11:45 +0530 (IST) From: Tarun Kanti DebBarma To: CC: Tarun Kanti DebBarma , Charulatha V , Santosh Shilimkar , Kevin Hilman , Tony Lindgren Subject: [RFC PATCH 07/10] OMAP: GPIO: cleanup suspend and resume functions Date: Mon, 16 May 2011 17:11:41 +0530 Message-ID: <1305546104-1511-8-git-send-email-tarun.kanti@ti.com> X-Mailer: git-send-email 1.6.0.4 In-Reply-To: <1305546104-1511-1-git-send-email-tarun.kanti@ti.com> References: <1305546104-1511-1-git-send-email-tarun.kanti@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 16 May 2011 11:42:04 +0000 (UTC) Since wake_status, wake_clear, wake_set is common for all banks on a given OMAP version it is enough to get their values once during probe(). Also, register offsets are already initialzed according to OMAP versions during device registration. We no longer need these explicit checks. Signed-off-by: Tarun Kanti DebBarma Cc: Charulatha V Cc: Santosh Shilimkar Cc: Kevin Hilman Cc: Tony Lindgren --- arch/arm/mach-omap1/gpio16xx.c | 3 + arch/arm/mach-omap2/gpio.c | 6 +++ arch/arm/plat-omap/gpio.c | 78 +++++++------------------------ arch/arm/plat-omap/include/plat/gpio.h | 3 + 4 files changed, 30 insertions(+), 60 deletions(-) diff --git a/arch/arm/mach-omap1/gpio16xx.c b/arch/arm/mach-omap1/gpio16xx.c index d886b88..bc4cc8f 100644 --- a/arch/arm/mach-omap1/gpio16xx.c +++ b/arch/arm/mach-omap1/gpio16xx.c @@ -46,6 +46,9 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = { .irqenable = OMAP_MPUIO_GPIO_MASKIT, .irqenable_inv = true, .ctrl = USHRT_MAX, + .wkupstatus = OMAP1610_GPIO_WAKEUPENABLE, + .wkupclear = OMAP1610_GPIO_CLEAR_WAKEUPENA, + .wkupset = OMAP1610_GPIO_SET_WAKEUPENA, }; static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = { diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c index 0782e06..7e79999 100644 --- a/arch/arm/mach-omap2/gpio.c +++ b/arch/arm/mach-omap2/gpio.c @@ -111,6 +111,9 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) pdata->regs->debounce = OMAP24XX_GPIO_DEBOUNCE_VAL; pdata->regs->debounce_en = OMAP24XX_GPIO_DEBOUNCE_EN; pdata->regs->ctrl = OMAP24XX_GPIO_CTRL; + pdata->regs->wkupstatus = OMAP24XX_GPIO_WAKE_EN; + pdata->regs->wkupclear = OMAP24XX_GPIO_CLEARWKUENA; + pdata->regs->wkupset = OMAP24XX_GPIO_SETWKUENA; break; case 3: pdata->bank_type = METHOD_GPIO_44XX; @@ -128,6 +131,9 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) pdata->regs->debounce = OMAP4_GPIO_DEBOUNCINGTIME; pdata->regs->debounce_en = OMAP4_GPIO_DEBOUNCENABLE; pdata->regs->ctrl = OMAP4_GPIO_CTRL; + pdata->regs->wkupstatus = OMAP4_GPIO_IRQWAKEN0; + pdata->regs->wkupclear = OMAP4_GPIO_IRQWAKEN0; + pdata->regs->wkupset = OMAP4_GPIO_IRQWAKEN0; break; default: WARN(1, "Invalid gpio bank_type\n"); diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c index 0ebeaaa..b04688d 100644 --- a/arch/arm/plat-omap/gpio.c +++ b/arch/arm/plat-omap/gpio.c @@ -62,6 +62,9 @@ struct gpio_bank { int stride; u32 width; u16 id; + void __iomem *wake_status; + void __iomem *wake_clear; + void __iomem *wake_set; void (*set_dataout)(struct gpio_bank *bank, int gpio, int enable); @@ -1195,6 +1198,15 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev) goto err_free; } + /* + * Storing these addresses avoids redundant computation of these + * values every time in suspend/resume functions and for all the + * gpio banks. + */ + bank->wake_status = bank->base + bank->regs->wkupstatus; + bank->wake_clear = bank->base + bank->regs->wkupclear; + bank->wake_set = bank->base + bank->regs->wkupset; + pm_runtime_enable(bank->dev); pm_runtime_get_sync(bank->dev); @@ -1214,7 +1226,7 @@ err_exit: } #if defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP2PLUS) -static int omap_gpio_suspend(struct sys_device *dev, pm_message_t mesg) +static int omap_gpio_suspend(struct sys_device *dev, pm_message_t unused) { struct gpio_bank *bank; @@ -1222,41 +1234,12 @@ static int omap_gpio_suspend(struct sys_device *dev, pm_message_t mesg) return 0; list_for_each_entry(bank, &omap_gpio_list, node) { - void __iomem *wake_status; - void __iomem *wake_clear; - void __iomem *wake_set; unsigned long flags; - switch (bank->method) { -#ifdef CONFIG_ARCH_OMAP16XX - case METHOD_GPIO_1610: - wake_status = bank->base + OMAP1610_GPIO_WAKEUPENABLE; - wake_clear = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA; - wake_set = bank->base + OMAP1610_GPIO_SET_WAKEUPENA; - break; -#endif -#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) - case METHOD_GPIO_24XX: - wake_status = bank->base + OMAP24XX_GPIO_WAKE_EN; - wake_clear = bank->base + OMAP24XX_GPIO_CLEARWKUENA; - wake_set = bank->base + OMAP24XX_GPIO_SETWKUENA; - break; -#endif -#ifdef CONFIG_ARCH_OMAP4 - case METHOD_GPIO_44XX: - wake_status = bank->base + OMAP4_GPIO_IRQWAKEN0; - wake_clear = bank->base + OMAP4_GPIO_IRQWAKEN0; - wake_set = bank->base + OMAP4_GPIO_IRQWAKEN0; - break; -#endif - default: - continue; - } - spin_lock_irqsave(&bank->lock, flags); - bank->saved_wakeup = __raw_readl(wake_status); - __raw_writel(0xffffffff, wake_clear); - __raw_writel(bank->suspend_wakeup, wake_set); + bank->saved_wakeup = __raw_readl(bank->wake_status); + __raw_writel(0xffffffff, bank->wake_clear); + __raw_writel(bank->suspend_wakeup, bank->wake_set); spin_unlock_irqrestore(&bank->lock, flags); } @@ -1271,36 +1254,11 @@ static int omap_gpio_resume(struct sys_device *dev) return 0; list_for_each_entry(bank, &omap_gpio_list, node) { - void __iomem *wake_clear; - void __iomem *wake_set; unsigned long flags; - switch (bank->method) { -#ifdef CONFIG_ARCH_OMAP16XX - case METHOD_GPIO_1610: - wake_clear = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA; - wake_set = bank->base + OMAP1610_GPIO_SET_WAKEUPENA; - break; -#endif -#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) - case METHOD_GPIO_24XX: - wake_clear = bank->base + OMAP24XX_GPIO_CLEARWKUENA; - wake_set = bank->base + OMAP24XX_GPIO_SETWKUENA; - break; -#endif -#ifdef CONFIG_ARCH_OMAP4 - case METHOD_GPIO_44XX: - wake_clear = bank->base + OMAP4_GPIO_IRQWAKEN0; - wake_set = bank->base + OMAP4_GPIO_IRQWAKEN0; - break; -#endif - default: - continue; - } - spin_lock_irqsave(&bank->lock, flags); - __raw_writel(0xffffffff, wake_clear); - __raw_writel(bank->saved_wakeup, wake_set); + __raw_writel(0xffffffff, bank->wake_clear); + __raw_writel(bank->saved_wakeup, bank->wake_set); spin_unlock_irqrestore(&bank->lock, flags); } diff --git a/arch/arm/plat-omap/include/plat/gpio.h b/arch/arm/plat-omap/include/plat/gpio.h index 64b1ee7..81ba1f0 100644 --- a/arch/arm/plat-omap/include/plat/gpio.h +++ b/arch/arm/plat-omap/include/plat/gpio.h @@ -189,6 +189,9 @@ struct omap_gpio_reg_offs { u16 debounce; u16 debounce_en; u16 ctrl; + u16 wkupstatus; + u16 wkupclear; + u16 wkupset; bool irqenable_inv; };