From patchwork Sun Jun 16 23:41:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 2729921 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 969E59F39E for ; Sun, 16 Jun 2013 23:41:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B58C1201AD for ; Sun, 16 Jun 2013 23:41:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DF3092019D for ; Sun, 16 Jun 2013 23:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755568Ab3FPXlz (ORCPT ); Sun, 16 Jun 2013 19:41:55 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:39193 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755550Ab3FPXly (ORCPT ); Sun, 16 Jun 2013 19:41:54 -0400 Received: by mail-pa0-f49.google.com with SMTP id ld11so2279077pab.36 for ; Sun, 16 Jun 2013 16:41:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:date:message-id:subject; bh=Sf8uY6OBHVSz2ruhsJdsorPM/vMO/tdVpMaVAx4YW0k=; b=A73HHQnHa3z78LqVbhIpSPMujzfLsnDsgNLLiBaTfkwAygSuZODmtiJSiSzvearnTK SoICgWtd7KnbL3La8DdKJmzxNL/6IGfCh50J3FXjZUf5mAcbrrG7mTHzBR9WTDap0Cg0 zQYekuxtGV9l5mgtrm7SHOxEdk3BDcPo3wu5PmP1Sukp2zTotZ2ILWvrqshknEXJeTyp b9vdnlj+kykMPREyZ7YyCXhPbY2ZFsRLxREYIu8Dm3lVkcIXsMdxF2bwfXHLfbORcsgr YCYKRy6KXEZeSFPYjzKtS+lf75UoFQe+bInY6PMX4HHgbL0XG9pgDTZz6n/ngZ1mwepv D4Qw== X-Received: by 10.66.25.45 with SMTP id z13mr10882740paf.151.1371426114333; Sun, 16 Jun 2013 16:41:54 -0700 (PDT) Received: from [127.0.0.1] (ac230065.ppp.asahi-net.or.jp. [183.77.230.65]) by mx.google.com with ESMTPSA id wi6sm11383703pbc.22.2013.06.16.16.41.51 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 16 Jun 2013 16:41:53 -0700 (PDT) From: Magnus Damm To: linux-gpio@vger.kernel.org Cc: kuninori.morimoto.gx@renesas.com, linux-sh@vger.kernel.org, linus.walleij@linaro.org, horms@verge.net.au, laurent.pinchart@ideasonboard.com, grant.likely@linaro.org, Magnus Damm Date: Mon, 17 Jun 2013 08:41:52 +0900 Message-Id: <20130616234152.23721.85467.sendpatchset@w520> Subject: [PATCH] gpio-rcar: Use OUTDT when reading GPIOs configured as output Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 From: Magnus Damm Testing on r8a7790 shows that INDT does not indicate the correct pin state when reading a GPIO configured as output, so update the gpio_rcar_get() function to handle this case. Signed-off-by: Magnus Damm Acked-by: Laurent Pinchart --- drivers/gpio/gpio-rcar.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 0001/drivers/gpio/gpio-rcar.c +++ work/drivers/gpio/gpio-rcar.c 2013-06-12 09:23:53.000000000 +0900 @@ -230,7 +230,14 @@ static int gpio_rcar_direction_input(str static int gpio_rcar_get(struct gpio_chip *chip, unsigned offset) { - return (int)(gpio_rcar_read(gpio_to_priv(chip), INDT) & BIT(offset)); + u32 bit = BIT(offset); + + /* testing on r8a7790 shows that INDT does not show correct pin state + * when configured as output, so use OUTDT in case of output pins */ + if (gpio_rcar_read(gpio_to_priv(chip), INOUTSEL) & bit) + return (int)(gpio_rcar_read(gpio_to_priv(chip), OUTDT) & bit); + else + return (int)(gpio_rcar_read(gpio_to_priv(chip), INDT) & bit); } static void gpio_rcar_set(struct gpio_chip *chip, unsigned offset, int value)