From patchwork Thu Oct 25 16:34:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 1645891 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id C27A7DF2AB for ; Thu, 25 Oct 2012 16:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932945Ab2JYQeV (ORCPT ); Thu, 25 Oct 2012 12:34:21 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:45529 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759668Ab2JYQeV (ORCPT ); Thu, 25 Oct 2012 12:34:21 -0400 Received: by mail-pa0-f46.google.com with SMTP id hz1so1286361pad.19 for ; Thu, 25 Oct 2012 09:34:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=ATHvEd2xbVQfCfGahR4//FH8qjU6ZvMwwZnwXzUTbHM=; b=SyZ+0ZXZEH5hBHJfpKahNPl9UQIzwxmlyT0kIh9ob+s00dzLiQ/JkyIfGA4+58UOry VWCurDbG/gxp4e/hGChE0DlfOPMA2vincM7TK92YOPx4KFExnOg1gQJonZOS3YJ6O6dZ OjeSqnPQspmjy5QuGgyFPEKt0qR3YU0u0bsAzTuvaWJ3x6RS6WBTZP5KngaClcU+8laC qCeaufqJ9PMjbU9+vIL9KBkqTb2gx4f4joluXvWvSKxS2vCr2NQPfaYn0nyp+NwEPgVB SuElddsSEpyI4SILq8syB3nFUPQG/krIb6bp1G3rWh0BsMJiRoH8+VooGN7QbcoAPSDe i04g== Received: by 10.68.197.9 with SMTP id iq9mr60551977pbc.130.1351182860683; Thu, 25 Oct 2012 09:34:20 -0700 (PDT) Received: from localhost (c-24-19-7-36.hsd1.wa.comcast.net. [24.19.7.36]) by mx.google.com with ESMTPS id hc4sm11443443pbc.30.2012.10.25.09.34.19 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 25 Oct 2012 09:34:20 -0700 (PDT) From: Kevin Hilman To: Linus Walleij , Jon Hunter , linux-omap@vger.kernel.org Cc: Paul Walmsley , Santosh Shilimkar , linux-arm-kernel@lists.infradead.org, Igor Grinberg , Grazvydas Ignotas Subject: [PATCH v3] gpio/omap: fix off-mode bug: clear debounce clock enable mask on free/reset Date: Thu, 25 Oct 2012 09:34:18 -0700 Message-Id: <1351182858-14045-1-git-send-email-khilman@deeprootsystems.com> X-Mailer: git-send-email 1.8.0 X-Gm-Message-State: ALoCoQl2soglRmewQIMx+pbml2g09y8MXTFyrnq5KKAnPU9XVU8t4/JTEWnTQ+CRBQGx3Sk2SLRH Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Kevin Hilman When a GPIO is freed or shutdown, ensure that the proper bit in dbck_enable_mask is cleared also. Otherwise, context restore on subsequent off-mode transition will restore previous debounce values from the shadow copies (bank->context.debounce*) leading to mismatch state between driver state and hardware state. This was discovered when board code was doing gpio_request_one() gpio_set_debounce() gpio_free() which was leaving the GPIO debounce settings in a confused state. If that GPIO bank is subsequently used with off-mode enabled, bogus state would be restored, leaving GPIO debounce enabled which then prevented the CORE powerdomain from transitioning. To fix, ensure that right bit in bank->dbck_enable_mask is cleared when a GPIO is freed/shutdown so debounce state doesn't persist after free/reset. If this GPIO is the last debounce-enabled GPIO in the bank, the debounce will also be cut. Special thanks to Grazvydas Ignotas for pointing out a bug in the first version that would've disabled debounce on any runtime PM transition. And, special thanks to Jon Hunter for pointing out a bug in the second version which was mistakenly clearing all debounce bits on reset instead of individual GPIOs, as well as suggesting cutting the debounce clock after all debounce bits are cleared. Tesed on 37xx/EVM board which configures GPIO debounce for the ads7846 touchscreen in its board file using the above sequence, and so was failing off-mode tests in dynamic idle. Verified that off-mode tests are passing with this patch. Reported-by: Paul Walmsley Cc: Igor Grinberg Cc: Grazvydas Ignotas Cc: Jon Hunter Signed-off-by: Kevin Hilman --- drivers/gpio/gpio-omap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 94cbc84..ce1da19 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -539,6 +539,8 @@ static void _reset_gpio(struct gpio_bank *bank, int gpio) _set_gpio_irqenable(bank, gpio, 0); _clear_gpio_irqstatus(bank, gpio); _set_gpio_triggering(bank, GPIO_INDEX(bank, gpio), IRQ_TYPE_NONE); + bank->dbck_enable_mask &= ~(GPIO_BIT(bank, gpio)); + _gpio_dbck_disable(bank); } /* Use disable_irq_wake() and enable_irq_wake() functions from drivers */