From patchwork Fri Jul 11 15:34:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Harvey X-Patchwork-Id: 4535471 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C9C54BEEAA for ; Fri, 11 Jul 2014 15:37:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EDB3820260 for ; Fri, 11 Jul 2014 15:37:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7981420204 for ; Fri, 11 Jul 2014 15:37:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X5cqS-0005rc-RZ; Fri, 11 Jul 2014 15:34:44 +0000 Received: from mail-oa0-f43.google.com ([209.85.219.43]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X5cqP-0005ak-KN for linux-arm-kernel@lists.infradead.org; Fri, 11 Jul 2014 15:34:42 +0000 Received: by mail-oa0-f43.google.com with SMTP id i7so394047oag.2 for ; Fri, 11 Jul 2014 08:34:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc :content-type; bh=0gL4HZlCOCxkbGtA7KDaOSepsjZVWIweGT9p946jjR8=; b=VNe5Pzcz3h70STqC+Z775LLh8cWtat5kIB3RuKJDE6BEJZGR97UMF19t0Szec+y+po 5aior2wJG3srPOF/2GnYN9godORVNSKuAL//rh6+GBuz5FeOrjUoPQkQSsBeWX5mF11V kyX4E7jxru2TvgQ2Wmhh67ad0uivjr+5k80ENwN/6d0WVGcgk+0PV+YSXpdOdNzN4O82 dNpegGiwLv3bQ3xlD2SeFUnyXVrtKDOp9CIpxAqwH5huRRFBX8E4lm2Aun+hWLJsRr2O KEAATnW6GKItS4r6ycL3kOLNyN4HGCQiznfcM+rav4gHU6OKd7vvs5wIfL4XlyRdEUXz v3EQ== X-Gm-Message-State: ALoCoQmRHG/o0PZHQzFiVFiN+X5KbxNoOpySqxyx0P9EQ6+ktRVGK4J3T85B9uTLHBYeHulHpK6e MIME-Version: 1.0 X-Received: by 10.182.72.167 with SMTP id e7mr64514668obv.28.1405092859818; Fri, 11 Jul 2014 08:34:19 -0700 (PDT) Received: by 10.202.105.2 with HTTP; Fri, 11 Jul 2014 08:34:19 -0700 (PDT) Date: Fri, 11 Jul 2014 08:34:19 -0700 Message-ID: Subject: gpio-mxc gpio get always returns 0 for outputs for IMX6 From: Tim Harvey To: Shawn Guo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140711_083441_733690_611F8412 X-CRM114-Status: GOOD ( 14.56 ) X-Spam-Score: -1.4 (-) Cc: "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Shawn, I've noticed that for IMX6 the gpio-mxc gpio driver always returns 0 for gpio's configured as outputs regardless of if they are outputing high or low. Digging into gpio-mxc.c I see that the basic memory-mapped generic gpio controller is used, but its configured to use GPIO_PSR to obtain the gpio value. For the IMX6 (I can't speak for the other MXC/IMX users of this driver) the reference manual indicates that GPIO_PSR is appropriate only if the GPIO is an input and that GPIO_DR will read the proper state if its configured as an output or an input. Even before the driver was converted to use the basic memory-mapped generic gpio controller this was the case (GPIO_PSR used for get). Is there a reason for this, or is it simply a bug that has been around since the driver's original creation as I suspect? The following patch resolves the issue and causes gpio get to always return the proper setting when configured for an input or output: If this looks right to you for all IMX users let me know and I'll post a properly formatted patch with commit message. Regards, Tim diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c index 7176743..25b97db 100644 --- a/drivers/gpio/gpio-mxc.c +++ b/drivers/gpio/gpio-mxc.c @@ -458,8 +458,8 @@ static int mxc_gpio_probe(struct platform_device *pdev) } err = bgpio_init(&port->bgc, &pdev->dev, 4, - port->base + GPIO_PSR, - port->base + GPIO_DR, NULL, + port->base + GPIO_DR, + NULL, NULL, port->base + GPIO_GDIR, NULL, 0); if (err) goto out_iounmap;