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 B7D20EB64DC for ; Thu, 20 Jul 2023 12:38:38 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DBB0C867E2; Thu, 20 Jul 2023 14:38:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="h8cU2kSr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AFE8D867B0; Thu, 20 Jul 2023 14:38:16 +0200 (CEST) Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) (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 E1E42867BA for ; Thu, 20 Jul 2023 14:38:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=clamor95@gmail.com Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4f95bf5c493so1168313e87.3 for ; Thu, 20 Jul 2023 05:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689856693; x=1690461493; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/LDBM0kru62+bHvDqgBH9EsVX+/DThiGzcorwaxeAdU=; b=h8cU2kSrW0mp5Ny7Ze96NgirnY5e/UIntBJ/U7BBdjSxCQsIeauz+Oex4rxMxAmcEP Al1BeeFD26RRZz/cR+50epGrZSfHfcU3tQ0BRtQUpuwxGS8dtnHd/nfA2hL4Nx0iXG9S RqXQhneU8n8CSy8teHD2xBJsOazEHuQ2b73tWfqNG+G6XbUyP9KowLXHIZV4K0OInNPg Z/KHHKqSkKWQTWZOgGUkqWZf/Z62hv44pKnvFyP0VWfTk7lamYFYukLmA2soInt4piEO hMthp5r1kEdW6JW+KFTeRe9MPSZ4Awq1hfwm2SQoNC7OyGqHZ+Jg0m+eW2rj5F8UqMIe RBVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689856693; x=1690461493; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/LDBM0kru62+bHvDqgBH9EsVX+/DThiGzcorwaxeAdU=; b=gVCDy8WXyiSrdwlBGUpYto93hoLyXM9ijyTEPZW1F8LyAgS1iiEl6jJ2mfVK8MFJyC MyWnETEpKRIyyMRceYVrSdjzFF5zsYvTq9p1Ddqr7yuQLoeQZxLX8VK/vZdzRYYZAz52 4K+QoOo1TlkUzGA3H2pQ5z8ekCVpG2iiY6qfnZQceL7vCiubxg5uVco4KuWts3WYiNs+ xN2PVo7XoqnK0uFVnnYHlcBF8DXCsMHkdB99hin0iTAALHCBLj5x76y0lSkqifttu8hV 1Y7A0Xg0M+wqA8WxKeHdGOxYgS5lSJztewsyJr6XbX1YTRgc/UwThiOAGGjMt4XNBV3u hYOw== X-Gm-Message-State: ABy/qLY5chDYu10EpJTQissbGnQ5O9iQ3Qhk3YfggK/dqbqSpKStp7h6 otoNrV/hKJ4Eg/PL1iNzVpo= X-Google-Smtp-Source: APBJJlFHnxku0eaSmomhnpZJrtAGAOXQMjzthI1kTV3Xz2b2XAdebR4SjbtuXBiFkILdYTExY5pMMw== X-Received: by 2002:a19:6d06:0:b0:4fd:d1df:9bda with SMTP id i6-20020a196d06000000b004fdd1df9bdamr1652729lfc.42.1689856692960; Thu, 20 Jul 2023 05:38:12 -0700 (PDT) Received: from xeon.. ([188.163.112.64]) by smtp.gmail.com with ESMTPSA id m25-20020ac24ad9000000b004fb9c625b4asm184401lfp.210.2023.07.20.05.38.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jul 2023 05:38:12 -0700 (PDT) From: Svyatoslav Ryhel To: Simon Glass , Philipp Tomsich , Kever Yang , Neil Armstrong , Marek Vasut , Patrick Delaunay , Patrice Chotard , Jagan Teki , Matteo Lisi , Jaehoon Chung , Anatolij Gustschin , Jonas Karlman , Quentin Schulz , Svyatoslav Ryhel , Eugen Hristev Cc: u-boot@lists.denx.de, u-boot-amlogic@groups.io, u-boot@dh-electronics.com, uboot-stm32@st-md-mailman.stormreply.com Subject: [PATCH v2 2/7] test: dm: regulator: test counter in set_enable_if_allowed test Date: Thu, 20 Jul 2023 15:37:39 +0300 Message-Id: <20230720123744.26854-3-clamor95@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230720123744.26854-1-clamor95@gmail.com> References: <20230720123744.26854-1-clamor95@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean Emulate use of the regulator by a few consumers with balanced on/off calls. Signed-off-by: Svyatoslav Ryhel --- test/dm/regulator.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/dm/regulator.c b/test/dm/regulator.c index 86f4862d9d..9b503e4c59 100644 --- a/test/dm/regulator.c +++ b/test/dm/regulator.c @@ -194,6 +194,25 @@ int dm_test_power_regulator_set_enable_if_allowed(struct unit_test_state *uts) ut_assertok(regulator_set_enable_if_allowed(dev, val_set)); ut_asserteq(regulator_get_enable(dev), !val_set); + /* Set the Enable of LDO1 - default is disabled */ + platname = regulator_names[LDO1][PLATNAME]; + ut_assertok(regulator_autoset_by_name(platname, &dev_autoset)); + ut_assertok(regulator_get_by_platname(platname, &dev)); + + /* Get the Enable state of LDO1 and compare it with the requested one */ + ut_assertok(regulator_set_enable_if_allowed(dev, true)); + ut_asserteq(regulator_get_enable(dev), true); + + /* Emulate second consumer */ + ut_assertok(regulator_set_enable_if_allowed(dev, true)); + ut_asserteq(regulator_get_enable(dev), true); + + /* Emulate one of counsumers disable call */ + ut_assertok(regulator_set_enable_if_allowed(dev, false)); + + /* Regulator should still be on since counter indicates one consumer active */ + ut_asserteq(regulator_get_enable(dev), true); + return 0; } DM_TEST(dm_test_power_regulator_set_enable_if_allowed, UT_TESTF_SCAN_FDT); -- 2.39.2