From patchwork Mon Apr 27 19:26:47 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russ Dill X-Patchwork-Id: 20230 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3RJQsmO019867 for ; Mon, 27 Apr 2009 19:26:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753476AbZD0T0w (ORCPT ); Mon, 27 Apr 2009 15:26:52 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756294AbZD0T0w (ORCPT ); Mon, 27 Apr 2009 15:26:52 -0400 Received: from rv-out-0506.google.com ([209.85.198.230]:25164 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753476AbZD0T0w (ORCPT ); Mon, 27 Apr 2009 15:26:52 -0400 Received: by rv-out-0506.google.com with SMTP id f9so80369rvb.1 for ; Mon, 27 Apr 2009 12:26:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=T+9bmvpbKw3rRhzfzQvsstNFIYJvDCg/YR+8oqtRGMU=; b=u4/642LNO38LkKGx7uzEn2Kb22gJSX2hCsDl4hQ1eg6crmz5CKbmlbP2rrO+PPDhsl 26uq//vW/iGi78oquBu5/72mf9V+c1S5XV6jxU5hG6/Uk8lGoopJgfbkaplmT4gFOXhK efLLbyVPLslbiF22easJHvVfLw5XSY0FslgUQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=tvcqCRj1XVYSkEUkpmpg+jTYw2qwChBEwPklHeq/XDuEe9Xf9Eyul+QH2pyExELwO1 GJdnRWwlcb+3k6hMP7TlyltBK7lJ8aJdgjNX1kBferRjVyMH0pbGVvaJtSWAC0drnzQe +0L1LTo6HxxyCnrxR3Rh3imr80Z2tStdp6rd8= Received: by 10.141.50.11 with SMTP id c11mr1802990rvk.139.1240860411192; Mon, 27 Apr 2009 12:26:51 -0700 (PDT) Received: from localhost (ip70-176-249-242.ph.ph.cox.net [70.176.249.242]) by mx.google.com with ESMTPS id f21sm9075105rvb.25.2009.04.27.12.26.49 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 27 Apr 2009 12:26:50 -0700 (PDT) From: Russ Dill To: linux-omap@vger.kernel.org Cc: Russ Dill Subject: [PATCH] Allow OMAP3 GPIO wakeup from power off. Date: Mon, 27 Apr 2009 12:26:47 -0700 Message-Id: <1240860407-14883-1-git-send-email-Russ.Dill@gmail.com> X-Mailer: git-send-email 1.6.0.4 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org This patch configures the wakeup padconf registers to reflect the sysfs power/wakeup settings. This allows a GPIO to wake the processor from off mode. Signed-off-by: Russ Dill --- arch/arm/plat-omap/gpio.c | 58 ++++++++++++++++++++++++++++++-------------- 1 files changed, 39 insertions(+), 19 deletions(-) diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c index 64852db..3b2054b 100644 --- a/arch/arm/plat-omap/gpio.c +++ b/arch/arm/plat-omap/gpio.c @@ -277,7 +277,14 @@ static const struct gpio_pad_range gpio_pads_config[] = { { 170, 182, 0x1c6 }, { 0, 0, 0x1e0 }, { 186, 186, 0x1e2 }, + { 187, 187, 0x238 }, + { 32, 32, 0x23a }, { 12, 29, 0x5d8 }, + { 1, 1, 0xa06 }, + { 30, 30, 0xa08 }, + { 2, 10, 0xa0a }, + { 11, 11, 0xa24 }, + { 31, 31, 0xa26 }, }; /* GPIO -> PAD config mapping for OMAP3 */ @@ -289,7 +296,8 @@ struct gpio_pad { #define OMAP34XX_GPIO_AMT (32 * OMAP34XX_NR_GPIOS) -struct gpio_pad *gpio_pads; +static struct gpio_pad *gpio_pads; +static u16 gpio_pad_map[OMAP34XX_GPIO_AMT]; #endif static struct gpio_bank *gpio_bank; @@ -1353,32 +1361,21 @@ static int __init omap3_gpio_pads_init(void) { int i, j, min, max, gpio_amt; u16 offset; - u16 *gpio_pad_map; gpio_amt = 0; - gpio_pad_map = kzalloc(sizeof(u16) * OMAP34XX_GPIO_AMT, GFP_KERNEL); - if (gpio_pad_map == NULL) { - printk(KERN_ERR "FATAL: Failed to allocate gpio_pad_map\n"); - return -ENOMEM; - } - for (i = 0; i < ARRAY_SIZE(gpio_pads_config); i++) { min = gpio_pads_config[i].min; max = gpio_pads_config[i].max; offset = gpio_pads_config[i].offset; for (j = min; j <= max; j++) { - /* - * Check if pad has been configured as GPIO. - * First module (gpio 0...31) is ignored as it is - * in wakeup domain and does not need special - * handling during off mode. - */ - if (j > 31 && (omap_ctrl_readw(offset) & + /* Check if pad has been configured as GPIO. */ + if ((omap_ctrl_readw(offset) & OMAP34XX_MUX_MODE7) == OMAP34XX_MUX_MODE4) { gpio_pad_map[j] = offset; - gpio_amt++; + if (j > 31) + gpio_amt++; } offset += 2; } @@ -1388,20 +1385,23 @@ static int __init omap3_gpio_pads_init(void) if (gpio_pads == NULL) { printk(KERN_ERR "FATAL: Failed to allocate gpio_pads\n"); - kfree(gpio_pad_map); return -ENOMEM; } gpio_amt = 0; for (i = 0; i < OMAP34XX_GPIO_AMT; i++) { - if (gpio_pad_map[i] != 0) { + /* + * First module (gpio 0...31) is ignored as it is + * in wakeup domain and does not need special + * handling during off mode. + */ + if (gpio_pad_map[i] && i > 31) { gpio_pads[gpio_amt].gpio = i; gpio_pads[gpio_amt].offset = gpio_pad_map[i]; gpio_amt++; } } gpio_pads[gpio_amt].gpio = -1; - kfree(gpio_pad_map); return 0; } late_initcall(omap3_gpio_pads_init); @@ -1676,6 +1676,26 @@ static int omap_gpio_suspend(struct sys_device *dev, pm_message_t mesg) __raw_writel(0xffffffff, wake_clear); __raw_writel(bank->suspend_wakeup, wake_set); spin_unlock_irqrestore(&bank->lock, flags); + +#ifdef CONFIG_ARCH_OMAP34XX + if (bank->method == METHOD_GPIO_24XX) { + int j; + for (j = 0; j < 32; j++) { + int offset = gpio_pad_map[j + i * 32]; + u16 v; + + if (!offset) + continue; + + v = omap_ctrl_readw(offset); + if (bank->suspend_wakeup & (1 << j)) + v |= OMAP3_PADCONF_WAKEUPENABLE0; + else + v &= ~OMAP3_PADCONF_WAKEUPENABLE0; + omap_ctrl_writew(v, offset); + } + } +#endif } return 0;