From patchwork Sun Jan 6 11:12:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Grinberg X-Patchwork-Id: 1937561 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 879A5DF2A2 for ; Sun, 6 Jan 2013 11:16:37 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TroA7-0003sF-0i; Sun, 06 Jan 2013 11:13:07 +0000 Received: from softlayer.compulab.co.il ([50.23.254.55] helo=compulab.co.il) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TroA2-0003ri-V3 for linux-arm-kernel@lists.infradead.org; Sun, 06 Jan 2013 11:13:03 +0000 Received: from [62.90.235.247] (port=53295 helo=zimbra-mta.compulab.co.il) by softlayer.compulab.co.il with esmtp (Exim 4.80) (envelope-from ) id 1Tro9y-0004J6-Kw; Sun, 06 Jan 2013 13:12:59 +0200 Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id F0DF8644195; Sun, 6 Jan 2013 13:12:57 +0200 (IST) X-Virus-Scanned: amavisd-new at compulab.co.il Received: from zimbra-mta.compulab.co.il ([127.0.0.1]) by localhost (zimbra-mta.compulab.co.il [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K+oH9+lYASdA; Sun, 6 Jan 2013 13:12:56 +0200 (IST) Received: from grinberg-linux (grinberg-pc.compulab.local [10.1.1.13]) by zimbra-mta.compulab.co.il (Postfix) with SMTP id D9A15644198; Sun, 6 Jan 2013 13:12:55 +0200 (IST) Received: by grinberg-linux (sSMTP sendmail emulation); Sun, 06 Jan 2013 13:12:52 +0200 From: Igor Grinberg To: Haojian Zhuang Subject: [PATCH] ARM: PXA27x: fix workaround for AC97 reset Date: Sun, 6 Jan 2013 13:12:41 +0200 Message-Id: <1357470761-14363-1-git-send-email-grinberg@compulab.co.il> X-Mailer: git-send-email 1.7.3.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - softlayer.compulab.co.il X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - compulab.co.il X-Get-Message-Sender-Via: softlayer.compulab.co.il: acl_c_relayhosts_text_entry: grinberg@compulab.co.il|compulab.co.il X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130106_061303_142540_518DBBDB X-CRM114-Status: GOOD ( 15.67 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -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: Eric Miao , stable@vger.kernel.org, Robert Jarzmik , Igor Grinberg , 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: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Fix the workaround to a hardware bug in the AC97 controller of PXA27x. A bug in the controller's warm reset functionality requires that the MFP used by the controller as the AC97_RESET_n line be temporarily reconfigured as a GPIO (AF0) and manually held high for the duration of the warm reset cycle. The workaround was broken long ago by commit fb1bf8cd ([ARM] pxa: introduce processor specific pxa27x_assert_ac97reset()). The commit above changed the original workaround code in a way that changed the MFP to AF0 (GPIO), but forgot to drive the GPIO high output. This way, the GPIO state was left input (and undriven) and only worked for boards with external pullup on the line. Fix the above breakage by actually configurring the GPIO for output high in case of reset assert and returning it to default state (AF2 and GPDR - input) in case of reset deassert. Reported-by: Mike Dunn Signed-off-by: Igor Grinberg Cc: Robert Jarzmik Cc: Eric Miao Cc: stable@vger.kernel.org --- Mike, this should work and without the GPIO not requested warning. Can you test this, please? arch/arm/mach-pxa/devices.c | 13 ++++++++++++- arch/arm/mach-pxa/pxa27x.c | 5 +++++ 2 files changed, 17 insertions(+), 1 deletions(-) diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c index daa86d3..eaa7282 100644 --- a/arch/arm/mach-pxa/devices.c +++ b/arch/arm/mach-pxa/devices.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -488,7 +489,17 @@ struct platform_device pxa_device_ac97 = { void __init pxa_set_ac97_info(pxa2xx_audio_ops_t *ops) { - pxa_register_device(&pxa_device_ac97, ops); + int err = 0; + + if (ops && gpio_is_valid(ops->reset_gpio)) { + err = gpio_request_one(ops->reset_gpio, GPIOF_IN, "ac97 rst"); + if (err) + pr_err("%s: Failed requesting GPIO%d (ac97 rst): %d", + __func__, ops->reset_gpio, err); + } + + if (!err) + pxa_register_device(&pxa_device_ac97, ops); } #ifdef CONFIG_PXA25x diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c index 8047ee0..bb7e7c3 100644 --- a/arch/arm/mach-pxa/pxa27x.c +++ b/arch/arm/mach-pxa/pxa27x.c @@ -62,6 +62,11 @@ void pxa27x_assert_ac97reset(int reset_gpio, int on) if (reset_gpio == 95) pxa2xx_mfp_config(on ? &ac97_reset_config[2] : &ac97_reset_config[3], 1); + + if (on) + gpio_direction_output(reset_gpio, 1); + else /* to be on the safe side, return the GPDR to input */ + gpio_direction_input(reset_gpio); } EXPORT_SYMBOL_GPL(pxa27x_assert_ac97reset);