From patchwork Mon Jul 15 13:58:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 259045 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 2221E2C00A0 for ; Mon, 15 Jul 2013 23:58:59 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0A8514A02E; Mon, 15 Jul 2013 15:58:57 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id V35jtph46CVh; Mon, 15 Jul 2013 15:58:56 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 588154A026; Mon, 15 Jul 2013 15:58:55 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 64C894A026 for ; Mon, 15 Jul 2013 15:58:53 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EG1tSntjrS7W for ; Mon, 15 Jul 2013 15:58:48 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp6-v.fe.bosch.de (smtp6-v.fe.bosch.de [139.15.237.11]) by theia.denx.de (Postfix) with ESMTPS id 34CD14A025 for ; Mon, 15 Jul 2013 15:58:42 +0200 (CEST) Received: from vsmta14.fe.internet.bosch.com (unknown [10.4.98.54]) by imta23.fe.bosch.de (Postfix) with ESMTP id B879E1580015 for ; Mon, 15 Jul 2013 15:58:41 +0200 (CEST) Received: from localhost (vsgw3.fe.internet.bosch.com [10.4.98.16]) by vsmta14.fe.internet.bosch.com (Postfix) with SMTP id 8ADECA40585 for ; Mon, 15 Jul 2013 15:58:41 +0200 (CEST) Received: from SI-HUB1001.de.bosch.com (10.4.103.108) by si-hub04.de.bosch.com (10.3.153.46) with Microsoft SMTP Server (TLS) id 8.3.298.1; Mon, 15 Jul 2013 15:58:29 +0200 Received: from hi-z5661.hi.de.bosch.com (10.34.217.143) by SI-HUB1001.de.bosch.com (10.4.103.108) with Microsoft SMTP Server id 14.3.146.0; Mon, 15 Jul 2013 15:58:28 +0200 Received: from hi-z5661.hi.de.bosch.com (localhost [127.0.0.1]) by hi-z5661.hi.de.bosch.com (Postfix) with ESMTP id BC432411C5; Mon, 15 Jul 2013 15:58:28 +0200 (CEST) From: Dirk Behme To: , Stefano Babic Date: Mon, 15 Jul 2013 15:58:27 +0200 Message-ID: <1373896707-4204-1-git-send-email-dirk.behme@de.bosch.com> X-Mailer: git-send-email 1.8.2 MIME-Version: 1.0 Cc: Dirk Behme Subject: [U-Boot] [PATCH] mxc_gpio: Correct the GPIO handling in gpio_direction_output() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Setting the direction and an output value should be done by First, set the desired output value. Then, switch to output. If this is done in the inverse order, like at the moment, there can be a glitch on the GPIO line while switching first the old output value and aftwards the new one. Fix this by inverting the order of the direction/set_value calls. Signed-off-by: Dirk Behme Acked-by: Stefano Babic --- drivers/gpio/mxc_gpio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c index a388064..1d820d4 100644 --- a/drivers/gpio/mxc_gpio.c +++ b/drivers/gpio/mxc_gpio.c @@ -143,10 +143,10 @@ int gpio_direction_input(unsigned gpio) int gpio_direction_output(unsigned gpio, int value) { - int ret = mxc_gpio_direction(gpio, MXC_GPIO_DIRECTION_OUT); + int ret = gpio_set_value(gpio, value); if (ret < 0) return ret; - return gpio_set_value(gpio, value); + return mxc_gpio_direction(gpio, MXC_GPIO_DIRECTION_OUT); }