From patchwork Mon Sep 16 00:35:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 275087 X-Patchwork-Delegate: vipin.kumar@st.com 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 B415D2C010F for ; Mon, 16 Sep 2013 10:42:47 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2CE474A05F; Mon, 16 Sep 2013 02:42:43 +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 BR+sAWBNBRFa; Mon, 16 Sep 2013 02:42:42 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B8BAC4A062; Mon, 16 Sep 2013 02:42:37 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A40F24A062 for ; Mon, 16 Sep 2013 02:42:30 +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 JMEk68Oztntl for ; Mon, 16 Sep 2013 02:42:24 +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 mail-pb0-f43.google.com (mail-pb0-f43.google.com [209.85.160.43]) by theia.denx.de (Postfix) with ESMTPS id 4F1E34A060 for ; Mon, 16 Sep 2013 02:42:18 +0200 (CEST) Received: by mail-pb0-f43.google.com with SMTP id md4so3392958pbc.30 for ; Sun, 15 Sep 2013 17:42:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=G6FUXI80oS0t2N3WrEc3jt+hmHLe7vCCEa+IRxcy8Xs=; b=NrPlXHvxl6v/mGCU7TGQcxnbvMY6vPEhM2P2nZr44IOHD0baItBEMkxappBWBbOVCk q1yGUG/f7xGZPCkfF78+31Z8aseQOrZanAYixlJQiLgV48gOeht9E7rOgVQGHzj9EX6j RSxw64UeWFdGS+2NS2ihjnfEgi7yfPOXZU5vGndCppkF409GHfXPjn8FxWo0MvGOgktQ Mid9vVp4WfRz/S6Sb+8yJZYDqA4sDaohhg8xlqNAimqWGM56mPntJHCYdfzXOzaezcb0 waSeUafSMWcd+/9Pe/mT9/05pGERR/9Wx4maPHUR2J1twMQTuXssEVVEinj0l38hdNu3 gCWQ== X-Gm-Message-State: ALoCoQkSn/GeykPNFvUUJ0Nl8y0rezAID2AobZGv3kqJbQSGYFjuKa8v14QiHmhSVvTZU+JhSXTS X-Received: by 10.66.187.34 with SMTP id fp2mr27796022pac.12.1379291746003; Sun, 15 Sep 2013 17:35:46 -0700 (PDT) Received: from [192.168.0.102] (36-239-209-70.dynamic-ip.hinet.net. [36.239.209.70]) by mx.google.com with ESMTPSA id b4sm27046058pbc.22.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 15 Sep 2013 17:35:45 -0700 (PDT) Message-ID: <1379291741.13052.1.camel@phoenix> From: Axel Lin To: u-boot@lists.denx.de Date: Mon, 16 Sep 2013 08:35:41 +0800 X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 Cc: Vasut , Marek@theia.denx.de, Tom Rini Subject: [U-Boot] [PATCH v2] gpio: spear_gpio: Fix gpio_set_value() implementation 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 In current gpio_set_value() implementation, it always sets the gpio control bit no matter the value argument is 0 or 1. Thus the GPIOs never set to low. This patch fixes this bug. The address bus is used as a mask on read/write operations, so that independent software drivers can set their GPIO bits without affecting any other pins in a single write operation. Thus we don't need a read-modify-write to update the register. Signed-off-by: Axel Lin Acked-by: Stefan Roese Reviewed-by: Vipin Kumar Reviewed-by: Michael Trimarchi --- v2: Update commit log to explain why a read-modify-write is not necessary for clearing specific GPIO bit. Also added Michael Trimarchi's reviewed-by tag since he does review the patch and said the patch is fine. drivers/gpio/spear_gpio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/spear_gpio.c b/drivers/gpio/spear_gpio.c index 367b670..6fb4117 100644 --- a/drivers/gpio/spear_gpio.c +++ b/drivers/gpio/spear_gpio.c @@ -36,7 +36,10 @@ int gpio_set_value(unsigned gpio, int value) { struct gpio_regs *regs = (struct gpio_regs *)CONFIG_GPIO_BASE; - writel(1 << gpio, ®s->gpiodata[DATA_REG_ADDR(gpio)]); + if (value) + writel(1 << gpio, ®s->gpiodata[DATA_REG_ADDR(gpio)]); + else + writel(0, ®s->gpiodata[DATA_REG_ADDR(gpio)]); return 0; }