From patchwork Thu Jan 21 03:11: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: 1429597 X-Patchwork-Delegate: patrice.chotard@st.com 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) 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=lbD1B6gl; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4DLnYL14n3z9sVX for ; Thu, 21 Jan 2021 14:14:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E6BB882A7E; Thu, 21 Jan 2021 04:13:05 +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="lbD1B6gl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BBA3782A5B; Thu, 21 Jan 2021 04:12: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-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) (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 D0F9A82A00 for ; Thu, 21 Jan 2021 04:12: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-pj1-x102d.google.com with SMTP id my11so4120501pjb.1 for ; Wed, 20 Jan 2021 19:12: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=kqhqi9g62GYjODbJQaHuVbKvJKhujhvx26QQEDMRi1U=; b=lbD1B6glEydc/7uuE46H1JPGgMrzscZpR1TT2Uyp4HwRqtVLcKnSXTE0BEXVNbOZrL EfDpmlRUrYCktqe4HW77WPRPQdWLk6AuAHsKK5cq0uScPz7JWh8IhPi2qkjLyxHQhtTD FNVsNIxyeZ+OVqsNNZ30ZYLCD6STfAOE6VoqE= 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=kqhqi9g62GYjODbJQaHuVbKvJKhujhvx26QQEDMRi1U=; b=PhtrOdZBouk/ELVw0m1edfaFjsB2TFv20OBM8zopcTVVh1MzXkC3fcyIXrN6Sfmq3F YlZjyyyt5WNsiqh438u/0Y463Ew+bgzexiyFqjwiUvSPcxQK2e72tw6aw7xXGo9la5zS mahZYPcGrkgn66S3to85pFnA4Ia0orgrNgrFq/Z7zKKjUvXR3va+8MyeZIwoo2y0hScO 0+FAeyxaiEHoH58FvoDGHyTKmKa4/uMUcdXzjeaxFGeZY785BysaMW3QakbLYiVJWoNM YOZ/PYV5GlES7+uloYA4zNo1Wny7PqLIS3+LEWKeNGASjNVRZoA3gns8Q3h5Qvgslrhu gFJw== X-Gm-Message-State: AOAM533csGFM1jo9e4Zf1dTwX3WK0FltFJ5RX//ggLWW7ZZO1gPxKpe+ UNSpUnIDSfcOs1amo1Mq1vFNlMlrS4uIEiQl X-Google-Smtp-Source: ABdhPJx/EMxt41ggVKUhCQ+Hp4kskcJteRZMhqTCyaRwBERD0wcvtFyASj0rd9UrIXlL7bMEZpSR8A== X-Received: by 2002:a17:90a:aa91:: with SMTP id l17mr9551752pjq.177.1611198754205; Wed, 20 Jan 2021 19:12:34 -0800 (PST) Received: from sjg1.home ([2600:6c4c:507f:f8e5:0:ec6e:a61e:6ad]) by smtp.gmail.com with ESMTPSA id b2sm3619305pff.79.2021.01.20.19.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 19:12:33 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Patrick Delaunay , Tom Rini , Simon Glass Subject: [PATCH v2 09/15] gpio: sandbox: Make sandbox_gpio_set_flags() set all flags Date: Wed, 20 Jan 2021 20:11:53 -0700 Message-Id: <20210121031159.559841-10-sjg@chromium.org> X-Mailer: git-send-email 2.30.0.296.g2bfb1c46d8-goog In-Reply-To: <20210121031159.559841-1-sjg@chromium.org> References: <20210121031159.559841-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 Allow this function to see all flags, including the internal sandbox ones. This allows the tests to fully control the behaviour of the driver. To make this work, move the setting of GPIOD_EXT_HIGH -to where the flags are updated via driver model, rather than the sandbox 'back door'. Signed-off-by: Simon Glass --- (no changes since v1) drivers/gpio/sandbox.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c index ae9ebd141d9..b446d0dcc81 100644 --- a/drivers/gpio/sandbox.c +++ b/drivers/gpio/sandbox.c @@ -114,9 +114,7 @@ int sandbox_gpio_set_flags(struct udevice *dev, uint offset, ulong flags) { struct gpio_state *state = get_gpio_state(dev, offset); - if (flags & GPIOD_IS_OUT_ACTIVE) - flags |= GPIOD_EXT_HIGH; - state->flags = (state->flags & GPIOD_SANDBOX_MASK) | flags; + state->flags = flags; return 0; } @@ -217,14 +215,23 @@ static int sb_gpio_set_flags(struct udevice *dev, unsigned int offset, ulong flags) { debug("%s: offset:%u, flags = %lx\n", __func__, offset, flags); + struct gpio_state *state = get_gpio_state(dev, offset); + + if (flags & GPIOD_IS_OUT) { + if (flags & GPIOD_IS_OUT_ACTIVE) + flags |= GPIOD_EXT_HIGH; + else + flags &= ~GPIOD_EXT_HIGH; + } + state->flags = flags; - return sandbox_gpio_set_flags(dev, offset, flags); + return 0; } static int sb_gpio_get_flags(struct udevice *dev, uint offset, ulong *flagsp) { debug("%s: offset:%u\n", __func__, offset); - *flagsp = *get_gpio_flags(dev, offset); + *flagsp = *get_gpio_flags(dev, offset) & ~GPIOD_SANDBOX_MASK; return 0; }