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 5D6C4EB64DA for ; Thu, 20 Jul 2023 12:38:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 177DA867DA; Thu, 20 Jul 2023 14:38:32 +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="DwB9W06t"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7F442867DD; Thu, 20 Jul 2023 14:38:20 +0200 (CEST) Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) (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 D3010867BA for ; Thu, 20 Jul 2023 14:38:16 +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-x12f.google.com with SMTP id 2adb3069b0e04-4fb77f21c63so1140508e87.2 for ; Thu, 20 Jul 2023 05:38:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689856696; x=1690461496; 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=PJXb5dhngD6iAICS0/nFxRtdCRxNm5A2FZMwniQi01s=; b=DwB9W06tNTLqiGCa9/XDoDBDyHgUwSZFa6DTo2bNSiDS4LyfVFBQBnavV28E7fyVPo 5cK4MlCkaWxecytDSUaLPWxA/hAN8wUgbGxNO1jNIGLbnqIOsqZbK7ut5HciHPlerluw c9+whbnuWrRwg0ssaLZyujXyAgC7w5VWjPejBvhatuRlaqc6E9rozwsP9Zf6O643TEpf BPoO6eBpigmF1zDv7VIgheCCiCn/1GAhoq2D+CSenYJS1ksDy+1N9lImNdzK8deU0GQp tDxlERfx8l17ecXmv0swDKNt2fw832NnhnLvq6aAW/RSJrBNedp1if1o0qaXSELGq4sC mV6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689856696; x=1690461496; 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=PJXb5dhngD6iAICS0/nFxRtdCRxNm5A2FZMwniQi01s=; b=jlsKOFd+ichWt4A9y4lTjEwMga0LgM/09LSykcG9z72H+WYesA2TycTfBD9IaAMmHK vWZ5J+SjuXTp0APpKDGIRK5A/HR+XobR0a2SFnTLEKT89PzV7a+HEum6QiRV3ZQ6CqNM PWu2vRFfMkWVyIWURUCpBwxItBsvxlwWlslNGUikeYhBVfU9kxOEMfFo77Hc+BwPDS17 kNHPhb8D2SJp/svrGb7uyTWHU1za9pV/6VFz5poA5z2IWurakR/dzL0IMdymVkvK+rtG h5UOPOwXW3WvHycn6wJR5KfrXpGkM8z0DAgajwaTA6G5f1LaIDDd8Pl0bxqC659aKrXq R6xg== X-Gm-Message-State: ABy/qLbAlySnYod93fv8a5204O5pIXXKhkWnJR4IC29s8tpdCoKfFEEe ZJ2H/s89vreP2yDojoq5/Q8= X-Google-Smtp-Source: APBJJlFFdr+T+CD8l1GNi/gXICbvTn1uYiCha+nR2yx50vfrQl5uSomvbHj+f2WWs9Bi/pNZrOjaKQ== X-Received: by 2002:a05:6512:2210:b0:4fd:c762:722c with SMTP id h16-20020a056512221000b004fdc762722cmr2949144lfu.19.1689856696034; Thu, 20 Jul 2023 05:38:16 -0700 (PDT) Received: from xeon.. ([188.163.112.64]) by smtp.gmail.com with ESMTPSA id m25-20020ac24ad9000000b004fb9c625b4asm184401lfp.210.2023.07.20.05.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jul 2023 05:38:15 -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 4/7] test: dm: regulator: provide test of auto setup Date: Thu, 20 Jul 2023 15:37:41 +0300 Message-Id: <20230720123744.26854-5-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 Replace deprecated API test with test of uclass wide autosetup. LDO2 voltage according to dts should be 3.3v not 3.0v Signed-off-by: Svyatoslav Ryhel --- include/power/sandbox_pmic.h | 2 +- test/dm/regulator.c | 131 +++++++---------------------------- 2 files changed, 27 insertions(+), 106 deletions(-) diff --git a/include/power/sandbox_pmic.h b/include/power/sandbox_pmic.h index 1dbd15b523..50fc5881f8 100644 --- a/include/power/sandbox_pmic.h +++ b/include/power/sandbox_pmic.h @@ -137,7 +137,7 @@ enum { #define SANDBOX_LDO1_AUTOSET_EXPECTED_UA 100000 #define SANDBOX_LDO1_AUTOSET_EXPECTED_ENABLE true -#define SANDBOX_LDO2_AUTOSET_EXPECTED_UV 3000000 +#define SANDBOX_LDO2_AUTOSET_EXPECTED_UV 3300000 #define SANDBOX_LDO2_AUTOSET_EXPECTED_UA -ENOSYS #define SANDBOX_LDO2_AUTOSET_EXPECTED_ENABLE false diff --git a/test/dm/regulator.c b/test/dm/regulator.c index 9b503e4c59..eb96ddcdac 100644 --- a/test/dm/regulator.c +++ b/test/dm/regulator.c @@ -182,12 +182,11 @@ static int dm_test_power_regulator_set_enable_if_allowed(struct unit_test_state *uts) { const char *platname; - struct udevice *dev, *dev_autoset; + struct udevice *dev; bool val_set = false; /* Get BUCK1 - always on regulator */ platname = regulator_names[BUCK1][PLATNAME]; - ut_assertok(regulator_autoset_by_name(platname, &dev_autoset)); ut_assertok(regulator_get_by_platname(platname, &dev)); /* Try disabling always-on regulator */ @@ -196,7 +195,6 @@ int dm_test_power_regulator_set_enable_if_allowed(struct unit_test_state *uts) /* 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 */ @@ -293,131 +291,54 @@ static int dm_test_power_regulator_set_get_suspend_enable(struct unit_test_state } DM_TEST(dm_test_power_regulator_set_get_suspend_enable, UT_TESTF_SCAN_FDT); -/* Test regulator autoset method */ -static int dm_test_power_regulator_autoset(struct unit_test_state *uts) +/* Test regulator setup inside uclass driver */ +static int dm_test_power_regulator_set(struct unit_test_state *uts) { const char *platname; - struct udevice *dev, *dev_autoset; + struct udevice *dev; /* - * Test the BUCK1 with fdt properties - * - min-microvolt = max-microvolt = 1200000 - * - min-microamp = max-microamp = 200000 - * - always-on = set - * - boot-on = not set - * Expected output state: uV=1200000; uA=200000; output enabled + * LDO1 with fdt properties: + * - min-microvolt = max-microvolt = 1800000 + * - min-microamp = max-microamp = 100000 + * - always-on = not set + * - boot-on = set + * Expected output state: uV=1800000; uA=100000; output enabled */ - platname = regulator_names[BUCK1][PLATNAME]; - ut_assertok(regulator_autoset_by_name(platname, &dev_autoset)); /* Check, that the returned device is proper */ + platname = regulator_names[LDO1][PLATNAME]; ut_assertok(regulator_get_by_platname(platname, &dev)); - ut_asserteq_ptr(dev, dev_autoset); /* Check the setup after autoset */ ut_asserteq(regulator_get_value(dev), - SANDBOX_BUCK1_AUTOSET_EXPECTED_UV); + SANDBOX_LDO1_AUTOSET_EXPECTED_UV); ut_asserteq(regulator_get_current(dev), - SANDBOX_BUCK1_AUTOSET_EXPECTED_UA); + SANDBOX_LDO1_AUTOSET_EXPECTED_UA); ut_asserteq(regulator_get_enable(dev), - SANDBOX_BUCK1_AUTOSET_EXPECTED_ENABLE); - - return 0; -} -DM_TEST(dm_test_power_regulator_autoset, UT_TESTF_SCAN_FDT); - -/* - * Struct setting: to keep the expected output settings. - * @voltage: Voltage value [uV] - * @current: Current value [uA] - * @enable: output enable state: true/false - */ -struct setting { - int voltage; - int current; - bool enable; -}; - -/* - * platname_list: an array of regulator platform names. - * For testing regulator_list_autoset() for outputs: - * - LDO1 - * - LDO2 - */ -static const char *platname_list[] = { - SANDBOX_LDO1_PLATNAME, - SANDBOX_LDO2_PLATNAME, - NULL, -}; - -/* - * expected_setting_list: an array of regulator output setting, expected after - * call of the regulator_list_autoset() for the "platname_list" array. - * For testing results of regulator_list_autoset() for outputs: - * - LDO1 - * - LDO2 - * The settings are defined in: include/power/sandbox_pmic.h - */ -static const struct setting expected_setting_list[] = { - [0] = { /* LDO1 */ - .voltage = SANDBOX_LDO1_AUTOSET_EXPECTED_UV, - .current = SANDBOX_LDO1_AUTOSET_EXPECTED_UA, - .enable = SANDBOX_LDO1_AUTOSET_EXPECTED_ENABLE, - }, - [1] = { /* LDO2 */ - .voltage = SANDBOX_LDO2_AUTOSET_EXPECTED_UV, - .current = SANDBOX_LDO2_AUTOSET_EXPECTED_UA, - .enable = SANDBOX_LDO2_AUTOSET_EXPECTED_ENABLE, - }, -}; - -static int list_count = ARRAY_SIZE(expected_setting_list); - -/* Test regulator list autoset method */ -static int dm_test_power_regulator_autoset_list(struct unit_test_state *uts) -{ - struct udevice *dev_list[2], *dev; - int i; + SANDBOX_LDO1_AUTOSET_EXPECTED_ENABLE); /* - * Test the settings of the regulator list: - * LDO1 with fdt properties: - * - min-microvolt = max-microvolt = 1800000 - * - min-microamp = max-microamp = 100000 - * - always-on = not set - * - boot-on = set - * Expected output state: uV=1800000; uA=100000; output enabled - * * LDO2 with fdt properties: * - min-microvolt = max-microvolt = 3300000 * - always-on = not set * - boot-on = not set - * Expected output state: uV=300000(default); output disabled(default) + * Expected output state: uV=330000; output disabled * The expected settings are defined in: include/power/sandbox_pmic.h. */ - ut_assertok(regulator_list_autoset(platname_list, dev_list, false)); - for (i = 0; i < list_count; i++) { - /* Check, that the returned device is non-NULL */ - ut_assert(dev_list[i]); - - /* Check, that the returned device is proper */ - ut_assertok(regulator_get_by_platname(platname_list[i], &dev)); - ut_asserteq_ptr(dev_list[i], dev); - - /* Check, that regulator output Voltage value is as expected */ - ut_asserteq(regulator_get_value(dev_list[i]), - expected_setting_list[i].voltage); - - /* Check, that regulator output Current value is as expected */ - ut_asserteq(regulator_get_current(dev_list[i]), - expected_setting_list[i].current); + /* Check, that the returned device is proper */ + platname = regulator_names[LDO2][PLATNAME]; + ut_assertok(regulator_get_by_platname(platname, &dev)); - /* Check, that regulator output Enable state is as expected */ - ut_asserteq(regulator_get_enable(dev_list[i]), - expected_setting_list[i].enable); - } + /* Check the setup after autoset */ + ut_asserteq(regulator_get_value(dev), + SANDBOX_LDO2_AUTOSET_EXPECTED_UV); + ut_asserteq(regulator_get_current(dev), + SANDBOX_LDO2_AUTOSET_EXPECTED_UA); + ut_asserteq(regulator_get_enable(dev), + SANDBOX_LDO2_AUTOSET_EXPECTED_ENABLE); return 0; } -DM_TEST(dm_test_power_regulator_autoset_list, UT_TESTF_SCAN_FDT); +DM_TEST(dm_test_power_regulator_set, UT_TESTF_SCAN_FDT); -- 2.39.2