From patchwork Thu Aug 13 08:28:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 1344209 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=collabora.com Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BS39M1Gq6z9sPB for ; Thu, 13 Aug 2020 20:44:39 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8D07F8224C; Thu, 13 Aug 2020 12:44:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 9D7028223F; Thu, 13 Aug 2020 10:28:35 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B8E6E82235 for ; Thu, 13 Aug 2020 10:28:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sebastian.reichel@collabora.com Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 56474299907 Received: by jupiter.universe (Postfix, from userid 1000) id AD069480118; Thu, 13 Aug 2020 10:28:29 +0200 (CEST) From: Sebastian Reichel To: Sebastian Reichel , Stefano Babic , Fabio Estevam , "NXP i.MX U-Boot Team" Cc: Jaehoon Chung , Simon Glass , u-boot@lists.denx.de Subject: [PATCHv2 02/10] gpio: mxc_gpio: add support to read status of output gpios Date: Thu, 13 Aug 2020 10:28:11 +0200 Message-Id: <20200813082819.86973-3-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200813082819.86973-1-sebastian.reichel@collabora.com> References: <20200813082819.86973-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 13 Aug 2020 12:44:25 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean This is supported by the hardware when the pinmux is configured correctly. Usually it is not, so this adds explicit code for this. This fixes all GPIO regulators being shown as disabled. Signed-off-by: Sebastian Reichel --- drivers/gpio/mxc_gpio.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c index 88b920a0746b..ddf79c3bb2d0 100644 --- a/drivers/gpio/mxc_gpio.c +++ b/drivers/gpio/mxc_gpio.c @@ -209,6 +209,11 @@ static void mxc_gpio_bank_set_value(struct gpio_regs *regs, int offset, writel(l, ®s->gpio_dr); } +static int mxc_gpio_bank_get_out_value(struct gpio_regs *regs, int offset) +{ + return (readl(®s->gpio_dr) >> offset) & 1; +} + static int mxc_gpio_bank_get_value(struct gpio_regs *regs, int offset) { return (readl(®s->gpio_psr) >> offset) & 0x01; @@ -245,7 +250,10 @@ static int mxc_gpio_get_value(struct udevice *dev, unsigned offset) { struct mxc_bank_info *bank = dev_get_priv(dev); - return mxc_gpio_bank_get_value(bank->regs, offset); + if (mxc_gpio_is_output(bank->regs, offset)) + return mxc_gpio_bank_get_out_value(bank->regs, offset); + else + return mxc_gpio_bank_get_value(bank->regs, offset); } /* write GPIO OUT value to pin 'gpio' */