From patchwork Wed Dec 5 10:01:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Lo X-Patchwork-Id: 1840701 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 932133FCF2 for ; Wed, 5 Dec 2012 10:06:22 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TgBpB-00078H-O1; Wed, 05 Dec 2012 10:03:30 +0000 Received: from hqemgate04.nvidia.com ([216.228.121.35]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TgBoA-0006nR-RL for linux-arm-kernel@lists.infradead.org; Wed, 05 Dec 2012 10:02:28 +0000 Received: from hqnvupgp06.nvidia.com (Not Verified[216.228.121.13]) by hqemgate04.nvidia.com id ; Wed, 05 Dec 2012 02:02:03 -0800 Received: from hqemhub02.nvidia.com ([172.17.108.22]) by hqnvupgp06.nvidia.com (PGP Universal service); Wed, 05 Dec 2012 02:01:50 -0800 X-PGP-Universal: processed; by hqnvupgp06.nvidia.com on Wed, 05 Dec 2012 02:01:50 -0800 Received: from localhost.localdomain (172.20.144.16) by hqemhub02.nvidia.com (172.20.150.31) with Microsoft SMTP Server (TLS) id 8.3.279.1; Wed, 5 Dec 2012 02:02:25 -0800 From: Joseph Lo To: Stephen Warren Subject: [PATCH V2 6/6] ARM: tegra20: cpuidle: apply coupled cpuidle for powered-down mode Date: Wed, 5 Dec 2012 18:01:54 +0800 Message-ID: <1354701715-24150-8-git-send-email-josephl@nvidia.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1354701715-24150-1-git-send-email-josephl@nvidia.com> References: <1354701715-24150-1-git-send-email-josephl@nvidia.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121205_050227_168123_D7508073 X-CRM114-Status: GOOD ( 13.24 ) X-Spam-Score: -7.6 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [216.228.121.35 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org return ret; diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c index 63cb643..32ecdb6 100644 --- a/drivers/gpio/gpio-tegra.c +++ b/drivers/gpio/gpio-tegra.c @@ -71,6 +71,7 @@ struct tegra_gpio_bank { u32 oe[4]; u32 int_enb[4]; u32 int_lvl[4]; + u32 wake_enb[4]; #endif }; @@ -332,6 +333,9 @@ static int tegra_gpio_suspend(struct device *dev) bank->oe[p] = tegra_gpio_readl(GPIO_OE(gpio)); bank->int_enb[p] = tegra_gpio_readl(GPIO_INT_ENB(gpio)); bank->int_lvl[p] = tegra_gpio_readl(GPIO_INT_LVL(gpio)); + + /* Enable gpio irq for wake up source */ + tegra_gpio_writel(bank->wake_enb[p], GPIO_INT_ENB(gpio)); } } local_irq_restore(flags); @@ -341,6 +345,36 @@ static int tegra_gpio_suspend(struct device *dev) static int tegra_gpio_wake_enable(struct irq_data *d, unsigned int enable) { struct tegra_gpio_bank *bank = irq_data_get_irq_chip_data(d); + u8 port, bit, mask; + int gpio = d->hwirq; + + if (gpio < 0) + return -EIO; + + port = GPIO_PORT(gpio); + bit = GPIO_BIT(gpio); + mask = BIT(bit); + + if (enable) + bank->wake_enb[port] |= mask; + else + bank->wake_enb[port] &= ~mask; + + return 0; +} + +static int tegra_gpio_irq_set_wake(struct irq_data *d, unsigned int enable) +{ + struct tegra_gpio_bank *bank = irq_data_get_irq_chip_data(d); + int ret; + + ret = tegra_gpio_wake_enable(d, enable); + if (ret) { + pr_err("Failed gpio wake %s for irq=%d error=%d\n", + (enable ? "enable" : "disable"), d->irq, ret); + return ret; + } +printk(KERN_EMERG "gpio back->irq: %d hwirq: %d irq: %d\n", bank->irq, d->hwirq, d->irq); return irq_set_irq_wake(bank->irq, enable); } #endif @@ -352,7 +386,7 @@ static struct irq_chip tegra_gpio_irq_chip = { .irq_unmask = tegra_gpio_irq_unmask, .irq_set_type = tegra_gpio_irq_set_type, #ifdef CONFIG_PM_SLEEP - .irq_set_wake = tegra_gpio_wake_enable, + .irq_set_wake = tegra_gpio_irq_set_wake, #endif }; diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 79435de..0a14ec0 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -398,7 +398,7 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id) BUG_ON(irq != bdata->irq); spin_lock_irqsave(&bdata->lock, flags); - +printk(KERN_EMERG "key pressed irq %d\n", bdata->irq); if (!bdata->key_pressed) { if (bdata->button->wakeup) pm_wakeup_event(bdata->input->dev.parent, 0); @@ -809,8 +809,10 @@ static int gpio_keys_suspend(struct device *dev) if (device_may_wakeup(dev)) { for (i = 0; i < ddata->pdata->nbuttons; i++) { struct gpio_button_data *bdata = &ddata->data[i]; - if (bdata->button->wakeup) + if (bdata->button->wakeup) { +printk(KERN_EMERG "gpio-key wake irq:%d\n", bdata->irq); enable_irq_wake(bdata->irq); + } } } else { mutex_lock(&input->mutex);