From patchwork Wed Jun 19 13:44:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 252580 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 39ABD2C0082 for ; Wed, 19 Jun 2013 23:44:46 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 74ADF4A026; Wed, 19 Jun 2013 15:44:44 +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 BMn4S2dkPQKV; Wed, 19 Jun 2013 15:44:44 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9913C4A028; Wed, 19 Jun 2013 15:44:42 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 95EB54A028 for ; Wed, 19 Jun 2013 15:44:35 +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 O1SkcIrznWn9 for ; Wed, 19 Jun 2013 15:44:29 +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-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by theia.denx.de (Postfix) with ESMTPS id 458B34A026 for ; Wed, 19 Jun 2013 15:44:22 +0200 (CEST) Received: by mail-pa0-f46.google.com with SMTP id fa11so5147574pad.5 for ; Wed, 19 Jun 2013 06:44:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:subject:from:to:cc:date:content-type:x-mailer :mime-version:content-transfer-encoding:x-gm-message-state; bh=q7+yvsnZ3SWFFe7xsMEDvggybepQVjaZk+KFKqBwRUM=; b=Wp/PWkEV9CZFnT+FVIx67xfhwFOqclSQil8j49Lo24AR9SGH0ChRn6QnKFDoJla3WI dcH0vxfR6DjHx2d3YkzwFccOvuMrVEEnIs+4VAy3HFe20j/QWTP/z6ztgU/C5VNL5bCg htpcBKSmWv3Qp+ZwqIy75OKihCFDe2TqwpaeXhbODXX4Khp101E4zlQEcCZeEoTdLYZp 6Os91QwLiX8dLfjiF6a8zS3hy2HWCx3lScAmGD+VJFuODEddZEaD823WBT27E95QrnBO RAmcIsS8odKxD56NNvj4ozhaud2m55ZmcuK6zGOuybfWyGGKYW3QXfBb3oMjmz1525CC Nj3w== X-Received: by 10.68.88.129 with SMTP id bg1mr2941388pbb.10.1371649459578; Wed, 19 Jun 2013 06:44:19 -0700 (PDT) Received: from [192.168.0.100] (122-121-48-143.dynamic.hinet.net. [122.121.48.143]) by mx.google.com with ESMTPSA id dg3sm23209429pbc.24.2013.06.19.06.44.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Jun 2013 06:44:18 -0700 (PDT) Message-ID: <1371649453.2126.2.camel@phoenix> From: Axel Lin To: Stefan Roese Date: Wed, 19 Jun 2013 21:44:13 +0800 X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 X-Gm-Message-State: ALoCoQl4Xki+ItSCoE0YoLmiNeDZUPzsENp32SxmiICwiIrtuh/90Lc182emzgMP9HfXjge/4LN8 Cc: Vasut , Marek@theia.denx.de, u-boot@lists.denx.de, Tom Rini Subject: [U-Boot] gpio: Question about gpio_set_value() implementation in spear_gpio.c 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 Current code looks strange because no matter the value argument is 0 or 1 it always calls writel(1 << gpio, ®s->gpiodata[DATA_REG_ADDR(gpio)]); And then gpio_get_value() always return 1. I'm wondering if it needs to be fixed, something like below change: diff --git a/drivers/gpio/spear_gpio.c b/drivers/gpio/spear_gpio.c index d3c728e..8878608 100644 --- a/drivers/gpio/spear_gpio.c +++ b/drivers/gpio/spear_gpio.c @@ -52,7 +52,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; }