From patchwork Fri Jan 15 14:04:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1427058 X-Patchwork-Delegate: sjg@chromium.org 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=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=SldKn54W; dkim-atps=neutral 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 4DHNKj0PH0z9tjv for ; Sat, 16 Jan 2021 01:07:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2E37082653; Fri, 15 Jan 2021 15:05:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="SldKn54W"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B14D182694; Fri, 15 Jan 2021 15:05:41 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4C704825D9 for ; Fri, 15 Jan 2021 15:05:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2c.google.com with SMTP id n2so1125760iom.7 for ; Fri, 15 Jan 2021 06:05:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Qd+RWAbHpD6SkCJm6K7gNbUEq5sXtCMcpioeZMRc7Nk=; b=SldKn54WGxDaTIZUntv+DLj/nX77nFBuTjtVr2bixaiHmo+3++sgUudDmGj6c1OauQ yMGFtnPdZioosK4qMc6t7T52/gTfcHNYrNr7s8tRSVvv9sGypA97TBuISp9v6qURd1tE Ip1POB/qfV+KORSKbYlMJgWTc1f19/H/4vemU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Qd+RWAbHpD6SkCJm6K7gNbUEq5sXtCMcpioeZMRc7Nk=; b=Ye8wJipy+nOhdtI/sQ4pW7c3sLdXyKPfhR40eTt+GPDvgGNnN6LnkQQFFp2bbWznO+ C53eaWKIzRd3ksk9QSUkfygP32/Fwfhx91NB3vW8eBy4EMwT4sKuv7U8wUgP7TwEuhWh wzC+N5D3kbXx8JpYOKgYeMDaCe1Rv3AlOJH5I5bVLE0iCuhodkChH4yOiQpPaRi626xL skf823RMDJEWGrOcQH77dX71R9JU/JmDR93AuRDm5Xhhl+5UbNDn+8RDYc0FHjM09Vzm F5tnvHo4TZGyJL9RP1AEWa9Y5SEvY+Cmbz9HM+lLl+BA2AxaUIXp4UTB5J9efKKCWegX ZQow== X-Gm-Message-State: AOAM533hsXTF0j88FKE/1MysCwjLjhUMNXm+nTMk5N1FhgjW8za50+QX H1IBmmhWCjIFDp6x4Jk8MZPNYpgtfhgt1QT2 X-Google-Smtp-Source: ABdhPJx7w+D3AifEWuNUW+OKXdGGasx5ulBK1kYMPCLsh8hJx+tOeohizgwfblMJLvPahS7Av41RwA== X-Received: by 2002:a05:6e02:b2c:: with SMTP id e12mr5502091ilu.143.1610719533880; Fri, 15 Jan 2021 06:05:33 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id 1sm5664843ilv.37.2021.01.15.06.05.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 06:05:33 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Patrick Delaunay , Tom Rini , Simon Glass , Andy Shevchenko , Patrick Delaunay , Walter Lozano Subject: [PATCH 08/15] gpio: sandbox: Fully separate pin value from output value Date: Fri, 15 Jan 2021 07:04:53 -0700 Message-Id: <20210115140500.846307-9-sjg@chromium.org> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog In-Reply-To: <20210115140500.846307-1-sjg@chromium.org> References: <20210115140500.846307-1-sjg@chromium.org> MIME-Version: 1.0 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 At present we have the concept of a pin's external value. This is what is used when getting the value of a pin. But we still set the GPIOD_IS_OUT_ACTIVE flag when changing the value. This is not actually correct, since if the pin changes from output to input, the external value need not change. Adjust the logic for this difference. Signed-off-by: Simon Glass Reviewed-by: Patrick Delaunay --- drivers/gpio/sandbox.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c index 52e73e2300a..ebc160cb849 100644 --- a/drivers/gpio/sandbox.c +++ b/drivers/gpio/sandbox.c @@ -85,7 +85,7 @@ int sandbox_gpio_get_value(struct udevice *dev, unsigned offset) int sandbox_gpio_set_value(struct udevice *dev, unsigned offset, int value) { - set_gpio_flag(dev, offset, GPIOD_IS_OUT_ACTIVE | GPIOD_EXT_HIGH, value); + set_gpio_flag(dev, offset, GPIOD_EXT_HIGH, value); return 0; } @@ -137,10 +137,19 @@ static int sb_gpio_direction_input(struct udevice *dev, unsigned offset) static int sb_gpio_direction_output(struct udevice *dev, unsigned offset, int value) { + int ret; + debug("%s: offset:%u, value = %d\n", __func__, offset, value); - return sandbox_gpio_set_direction(dev, offset, 1) | - sandbox_gpio_set_value(dev, offset, value); + ret = sandbox_gpio_set_direction(dev, offset, 1); + if (ret) + return ret; + ret = set_gpio_flag(dev, offset, GPIOD_IS_OUT_ACTIVE | GPIOD_EXT_HIGH, + value); + if (ret) + return ret; + + return 0; } /* read GPIO IN value of port 'offset' */ @@ -154,6 +163,8 @@ static int sb_gpio_get_value(struct udevice *dev, unsigned offset) /* write GPIO OUT value to port 'offset' */ static int sb_gpio_set_value(struct udevice *dev, unsigned offset, int value) { + int ret; + debug("%s: offset:%u, value = %d\n", __func__, offset, value); if (!sandbox_gpio_get_direction(dev, offset)) { @@ -162,7 +173,12 @@ static int sb_gpio_set_value(struct udevice *dev, unsigned offset, int value) return -1; } - return sandbox_gpio_set_value(dev, offset, value); + ret = set_gpio_flag(dev, offset, GPIOD_IS_OUT_ACTIVE | GPIOD_EXT_HIGH, + value); + if (ret) + return ret; + + return 0; } static int sb_gpio_get_function(struct udevice *dev, unsigned offset)