From patchwork Wed Mar 18 17:21:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 451551 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C44B814008F for ; Thu, 19 Mar 2015 04:22:00 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756594AbbCRRVk (ORCPT ); Wed, 18 Mar 2015 13:21:40 -0400 Received: from mail-wg0-f45.google.com ([74.125.82.45]:36400 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756562AbbCRRVd (ORCPT ); Wed, 18 Mar 2015 13:21:33 -0400 Received: by wgra20 with SMTP id a20so41047393wgr.3 for ; Wed, 18 Mar 2015 10:21:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nguESGwSd2pA2T2sCPZBYdLkTid8TBCXFO12+WvKmxk=; b=Nw86MOmfOJJXdoxGrQic+mtGPPFz8MDw10g7fBv4b7jkTIQnWEjWOI080gBvk0uA4X FP/9YiEIV0ERfk8cxvTrrZqgO176aTlZCd9h6XuDt+VN17HKiI7md2BWagLe/UDWMCVq kvHMKxyhliDzwlCJwbqZ/DY2tD3U+ajzsKir6Oq+lvTlOTFbEZK6fEGOIYqo6KLculqT nu5ukffiI69kKF0FyXrYiZw9fQwp/nbiIvg4P0INQ1uXp83vWT7jd02vw0GP05P5P6oZ t9e6KqmtzJ65ovDHPCa+df5VXbtMjsVy7iqQSk6umKiVuV17wl0bj2Oh5Y3nhH97USZW kOMw== X-Gm-Message-State: ALoCoQn5MJWPnN4HHC/LJgA/u/IFt+bIOxLPWgEGso/3EuurOrK3T4C8k0PvCdAKFXZGAeRfRK8E X-Received: by 10.180.76.4 with SMTP id g4mr8714110wiw.43.1426699292197; Wed, 18 Mar 2015 10:21:32 -0700 (PDT) Received: from localhost.localdomain ([81.134.86.251]) by mx.google.com with ESMTPSA id v13sm4021936wij.10.2015.03.18.10.21.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Mar 2015 10:21:31 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linus.walleij@linaro.org, linux-gpio@vger.kernel.org Cc: lee.jones@linaro.org, kernel@stlinux.com Subject: [PATCH v2 5/6] pinctrl: st: Show correct pin direction -- even when in GPIO mode Date: Wed, 18 Mar 2015 17:21:18 +0000 Message-Id: <1426699279-9258-6-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1426699279-9258-1-git-send-email-lee.jones@linaro.org> References: <1426699279-9258-1-git-send-email-lee.jones@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Until now ST's pinconf_dbg_show() call-back has displayed the PIO alternate function direction, which is only relevant if a pin is operating in an alternate function mode i.e not GPIO mode. If a pin is in GPIO mode its direction is both set and status is obtained by a completely different/unrelated bunch of registers. This change ensures that the correct pin direction is shown, even if a pin is operating in GPIO mode. Reported-by: Olivier Clergeaud Acked-by: Maxime Coquelin Signed-off-by: Lee Jones --- drivers/pinctrl/pinctrl-st.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index 52a4377..1cda40e 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -206,6 +206,9 @@ #define gpio_chip_to_bank(chip) \ container_of(chip, struct st_gpio_bank, gpio_chip) +#define pc_to_bank(pc) \ + container_of(pc, struct st_gpio_bank, pc) + enum st_retime_style { st_retime_style_none, st_retime_style_packed, @@ -1053,15 +1056,18 @@ static int st_pinconf_get(struct pinctrl_dev *pctldev, static void st_pinconf_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, unsigned pin_id) { + struct st_pio_control *pc; unsigned long config; + int offset = st_gpio_pin(pin_id); mutex_unlock(&pctldev->mutex); + pc = st_get_pio_control(pctldev, pin_id); st_pinconf_get(pctldev, pin_id, &config); mutex_lock(&pctldev->mutex); seq_printf(s, "[OE:%ld,PU:%ld,OD:%ld]\n" "\t\t[retime:%ld,invclk:%ld,clknotdat:%ld," "de:%ld,rt-clk:%ld,rt-delay:%ld]", - ST_PINCONF_UNPACK_OE(config), + !st_gpio_get_direction(&pc_to_bank(pc)->gpio_chip, offset), ST_PINCONF_UNPACK_PU(config), ST_PINCONF_UNPACK_OD(config), ST_PINCONF_UNPACK_RT(config),