Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DBE04C433EF for ; Sun, 28 Nov 2021 14:52:27 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B6D3680F67; Sun, 28 Nov 2021 15:52:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=akkea.ca Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=akkea.ca header.i=@akkea.ca header.b="d1p5GxQt"; dkim=pass (1024-bit key) header.d=akkea.ca header.i=@akkea.ca header.b="d1p5GxQt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6E29480F81; Sun, 28 Nov 2021 15:52:23 +0100 (CET) Received: from node.akkea.ca (li1434-30.members.linode.com [45.33.107.30]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D969E8083E for ; Sun, 28 Nov 2021 15:52:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=akkea.ca Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=angus@akkea.ca Received: from localhost (localhost [127.0.0.1]) by node.akkea.ca (Postfix) with ESMTP id 717AE4E200C; Sun, 28 Nov 2021 14:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1638111136; bh=Nl3FKKXjxhLIrm5Yn/+zUFAVe39dNXGWi4KyfuXF0z4=; h=From:To:Cc:Subject:Date; b=d1p5GxQtLG72uAzjtzS/sIoXDecQ0mFDw/KJqWgG9jVUemgX8Uep+dK9jIvTDzblf bSrQOjN1J7lRzfSOySr4jbQoQ2zOnu+SRS5BN9yyGd+PXL+mWEjFFvs7Szn1+fN/mM LQtognc8vASq5uWN8iLKkafT+NZOE7JyD8dz6egc= Received: from node.akkea.ca ([127.0.0.1]) by localhost (mail.akkea.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sPoY8M_HUzVw; Sun, 28 Nov 2021 14:52:16 +0000 (UTC) Received: from midas.localdomain (S0106788a2041785e.gv.shawcable.net [24.108.106.191]) by node.akkea.ca (Postfix) with ESMTPSA id D85AF4E2003; Sun, 28 Nov 2021 14:52:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1638111136; bh=Nl3FKKXjxhLIrm5Yn/+zUFAVe39dNXGWi4KyfuXF0z4=; h=From:To:Cc:Subject:Date; b=d1p5GxQtLG72uAzjtzS/sIoXDecQ0mFDw/KJqWgG9jVUemgX8Uep+dK9jIvTDzblf bSrQOjN1J7lRzfSOySr4jbQoQ2zOnu+SRS5BN9yyGd+PXL+mWEjFFvs7Szn1+fN/mM LQtognc8vASq5uWN8iLKkafT+NZOE7JyD8dz6egc= From: Angus Ainslie To: u-boot@lists.denx.de Cc: Simon Glass , kernel@puri.sm, Angus Ainslie Subject: [PATCH] mxc_gpio: on imx8m read the DR instead of the PSR Date: Sun, 28 Nov 2021 06:51:43 -0800 Message-Id: <20211128145143.1433262-1-angus@akkea.ca> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 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.103.2 at phobos.denx.de X-Virus-Status: Clean On imx8m it is more correct to read the data register than the pad status register. In output mode the pad status register does not contain the value being output so we must read the DR for the value. In input mode the DR will contain the same value as the PSR when the pad mode is GPIO. If the pad mode is not GPIO and the pin is an input then 0 is always returned. Signed-off-by: Angus Ainslie --- drivers/gpio/mxc_gpio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c index 03471db9e80..0d9f6f44042 100644 --- a/drivers/gpio/mxc_gpio.c +++ b/drivers/gpio/mxc_gpio.c @@ -211,6 +211,9 @@ static void mxc_gpio_bank_set_value(struct gpio_regs *regs, int offset, static int mxc_gpio_bank_get_value(struct gpio_regs *regs, int offset) { +if (IS_ENABLED(CONFIG_IMX8M)) + return (readl(®s->gpio_dr) >> offset) & 0x01; +else return (readl(®s->gpio_psr) >> offset) & 0x01; } -- 2.25.1