From patchwork Thu Feb 11 08:47:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 380892 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp1885241jah; Thu, 11 Feb 2021 00:49:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJzoDin+2FPHgMx8i4wX8Tks90aOWYawe80i6X68WHps0u/ZbCa6pOSkvGloWJBV989oS+NU X-Received: by 2002:a17:906:3c0f:: with SMTP id h15mr6615270ejg.295.1613033343958; Thu, 11 Feb 2021 00:49:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613033343; cv=none; d=google.com; s=arc-20160816; b=kp7ZRPRBTLNyBjp4nPPYLjDQbZmGQ9MYqQSERB5IKB1QamEvq2U+vfoQOoZMmr+U4u 5jjMmygChgqE6SVmUC7z8I7lkWk+nSIAYc4dt0XBJSXtug1+78HgWZRsJfg6tyqXds1O mGWlzMzSbkVsOLM4GWy3+VQ3hbOyPycHrGXYXz0mQScvw9Nfajvk/yIE7e3U8ERjd8da EgMSstxvnr3YzJ7jabDJ8rMmWU8SSziI/JNx/3wE696giuZiQLLcd2WjWJxjQT+y+2Wo GNLzq2pBsxQcLUh1IjHLEM55uNj249Uq2ea09yDh42+ajigvg1ZNjLtlFBCnLVbfD/N0 0yoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=oDnB7YE84RYcuHJnMgbwYk+6MOvdpACHdTK/rReaxjM=; b=Cnv4wWHCdMSqeiB3v+1vhvxUhJfUWBe7OJPdSKxcDquOxnOyYPBqAqWrpEUdmqM4b8 u5bSFs2xBsnnuaWoIIaKQ9ysIFKTXiZXc4zrsl2LG9pdJM4Ww+NlhxuXBG17Av8IS3BO +DFCnlQ2gDLe/uuZL0miVNYzUPP4B46Areb//DVXhQTAKSB6RiUdW+MtsdMnoMS5ER7g GkSlDHfuF+GJRim0OXbcuiYxo6VAKIEF/r6lkHyMB26y266p33eer5+1C94BxaYDM813 YQXVf79+mptaiwCmVqVAQTGVK+BrEz/4JPYF9znqXErH0kpjWY8sWtFSkOUBP60er2sZ QONA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=cWfr4rER; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id r21si3753759ejo.123.2021.02.11.00.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 00:49:03 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=cWfr4rER; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4126C826B2; Thu, 11 Feb 2021 09:48:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com 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=samsung.com header.i=@samsung.com header.b="cWfr4rER"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 13C0082604; Thu, 11 Feb 2021 09:48:17 +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=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B042882663 for ; Thu, 11 Feb 2021 09:48:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=m.szyprowski@samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20210211084808euoutp02f6b224b59b976da1646f47cd0276f2ae~ipTrE64Ui2343823438euoutp02b for ; Thu, 11 Feb 2021 08:48:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20210211084808euoutp02f6b224b59b976da1646f47cd0276f2ae~ipTrE64Ui2343823438euoutp02b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1613033288; bh=oDnB7YE84RYcuHJnMgbwYk+6MOvdpACHdTK/rReaxjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cWfr4rERt/kQA2uHm2zp7GGKrIE7pKwabzetJCywl3IeLEUGPYpEYgMyeRm5+KIPH O9PACKvEOan+0ukgmXWXarGYZjoKwa2rn3KVpMYN++5j0+BUNeI4Qp7pBiHBqXSeXc T0zz3JJ/QBP426XVnzENfUQO3ndK3CLKxkjo2veE= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20210211084807eucas1p29870879d922d67ae9528c4927d42546a~ipTqmz5o31146611466eucas1p2i; Thu, 11 Feb 2021 08:48:07 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 50.A4.45488.74FE4206; Thu, 11 Feb 2021 08:48:07 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20210211084807eucas1p2e9e5d1fe99d98130649d97ebcd82d854~ipTp9lcVw1131511315eucas1p2h; Thu, 11 Feb 2021 08:48:07 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210211084807eusmtrp11acdf5ebe8e0412606ec2205d9e11c97~ipTp8vy7H3224132241eusmtrp1f; Thu, 11 Feb 2021 08:48:07 +0000 (GMT) X-AuditID: cbfec7f5-c5fff7000000b1b0-8e-6024ef470726 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id DF.56.16282.74FE4206; Thu, 11 Feb 2021 08:48:07 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210211084806eusmtip1bd482e205bee4c15de719f0e7c3c9a50~ipTpd2-zw2079920799eusmtip1d; Thu, 11 Feb 2021 08:48:06 +0000 (GMT) From: Marek Szyprowski To: u-boot@lists.denx.de, u-boot-amlogic@groups.io Cc: Marek Szyprowski , Neil Armstrong , Lukasz Majewski , Philippe Reynes , Simon Glass , Heinrich Schuchardt , Jaehoon Chung , Bartlomiej Zolnierkiewicz Subject: [PATCH v6 5/5] test: add a simple test for the adc-keys button driver Date: Thu, 11 Feb 2021 09:47:57 +0100 Message-Id: <20210211084757.22759-6-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210211084757.22759-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmleLIzCtJLcpLzFFi42LZduznOV339yoJBreuG1psnLGe1eLGrzZW i+fvLjNZrD1yl93iUF+0RcdhZYtvW7YxWkya8IvN4u3eTnaLw1M/MDpweby/0cruMbvhIovH vFknWDw+fIzzmN/5ncnj7J0djB59W1YxemxcdoA5gCOKyyYlNSezLLVI3y6BK+NV41XWgi3K FZd/VDYwXpHtYuTkkBAwkXh67DdzFyMXh5DACkaJu8vXs0E4XxglXp/vYIRwPjNKdE9dyQLT 0v3lLitEYjmjxJSTs9nhWi6t2cMMUsUmYCjR9baLDcQWETCSuNS0gwWkiFngDpNE1+QGsFHC AgES7/4/YwSxWQRUJc6dPAwW5xWwlThz9DoTxDp5idUbDoAN5RSwk9i35w7YagmBAxwSC183 Qt3kIvH8xSV2CFtY4tXxLVC2jMTpyT0sEA3NjBIPz61lh3B6GCUuN81ghKiylrhz7hfQrRxA 92lKrN+lD2JKCDhKnPufD2HySdx4KwhSzAxkTto2nRkizCvR0SYEMUNNYtbxdXBbD164xAxh e0i82rIBGkATGSW+flvLOIFRfhbCrgWMjKsYxVNLi3PTU4uN81LL9YoTc4tL89L1kvNzNzEC 08vpf8e/7mBc8eqj3iFGJg7GQ4wSHMxKIrz8rSoJQrwpiZVVqUX58UWlOanFhxilOViUxHl3 bV0TLySQnliSmp2aWpBaBJNl4uCUamBafsF4++K35aUhUR8qrq53XRA47+uFj1eLdt01/8// 6HBqR8isyWcy7tobPwg/5TnrYevzOdwGQid+zhDIv/AnfVHu77dOv+5MMDTe0D9n1poVjxW3 JC8Unt8SZ//6kOmsCsuLt5OXd8aVuzTwivhNU/BL+zD1SOef87/7vD++nbtyv/Hrva++b1nq 7pKkV3zh3ouY/smzZwo2FT/ovtUyN+b80/pPW3L4ZzXNf+a+U5Vn3c2X96fPSynUNDql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Xc 7jmLnPZZt+5+9gLfaccadNpeXax0ZJjEyLtI8fKP67K7ZhfOePbJlXX7j1QlluKMREMt5qLi RAB3+5ax/gIAAA== X-CMS-MailID: 20210211084807eucas1p2e9e5d1fe99d98130649d97ebcd82d854 X-Msg-Generator: CA X-RootMTR: 20210211084807eucas1p2e9e5d1fe99d98130649d97ebcd82d854 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20210211084807eucas1p2e9e5d1fe99d98130649d97ebcd82d854 References: <20210211084757.22759-1-m.szyprowski@samsung.com> 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 Add adc-keys device to the sandbox/test.dts and connect it to the channel #3 of the sandbox_adc driver. The default values sampled by sandbox_adc driver determines that button3 and button4 are released and button5 is pressed. Signed-off-by: Marek Szyprowski --- arch/sandbox/dts/test.dts | 24 ++++++++++++++++++- configs/sandbox_defconfig | 1 + test/dm/button.c | 50 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 72 insertions(+), 3 deletions(-) -- 2.17.1 Reviewed-by: Simon Glass diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index e95f4631bf..a32b019ae7 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -69,6 +69,27 @@ }; }; + buttons2 { + compatible = "adc-keys"; + io-channels = <&adc 3>; + keyup-threshold-microvolt = <3000000>; + + button-up { + label = "button3"; + press-threshold-microvolt = <1500000>; + }; + + button-down { + label = "button4"; + press-threshold-microvolt = <1000000>; + }; + + button-enter { + label = "button5"; + press-threshold-microvolt = <500000>; + }; + }; + cros_ec: cros-ec { reg = <0 0>; compatible = "google,cros-ec-sandbox"; @@ -587,8 +608,9 @@ i2c-eeprom = <&bootcount_i2c>; }; - adc@0 { + adc: adc@0 { compatible = "sandbox,adc"; + #io-channel-cells = <1>; vdd-supply = <&buck2>; vss-microvolts = <0>; }; diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 0c7674efc9..3731bf05ff 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -122,6 +122,7 @@ CONFIG_DM_BOOTCOUNT=y CONFIG_DM_BOOTCOUNT_RTC=y CONFIG_DM_BOOTCOUNT_I2C_EEPROM=y CONFIG_BUTTON=y +CONFIG_BUTTON_ADC=y CONFIG_BUTTON_GPIO=y CONFIG_CLK=y CONFIG_CLK_COMPOSITE_CCF=y diff --git a/test/dm/button.c b/test/dm/button.c index ecaa47cf5f..f8a7fab61d 100644 --- a/test/dm/button.c +++ b/test/dm/button.c @@ -7,7 +7,10 @@ #include #include +#include #include +#include +#include #include #include #include @@ -17,11 +20,20 @@ static int dm_test_button_base(struct unit_test_state *uts) { struct udevice *dev; - /* Get the top-level device */ + /* Get the top-level gpio buttons device */ ut_assertok(uclass_get_device(UCLASS_BUTTON, 0, &dev)); + /* Get the 2 gpio buttons */ ut_assertok(uclass_get_device(UCLASS_BUTTON, 1, &dev)); ut_assertok(uclass_get_device(UCLASS_BUTTON, 2, &dev)); - ut_asserteq(-ENODEV, uclass_get_device(UCLASS_BUTTON, 3, &dev)); + + /* Get the top-level adc buttons device */ + ut_assertok(uclass_get_device(UCLASS_BUTTON, 3, &dev)); + /* Get the 3 adc buttons */ + ut_assertok(uclass_get_device(UCLASS_BUTTON, 4, &dev)); + ut_assertok(uclass_get_device(UCLASS_BUTTON, 5, &dev)); + ut_assertok(uclass_get_device(UCLASS_BUTTON, 6, &dev)); + + ut_asserteq(-ENODEV, uclass_get_device(UCLASS_BUTTON, 7, &dev)); return 0; } @@ -72,3 +84,37 @@ static int dm_test_button_label(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_button_label, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); + +/* Test adc-keys driver */ +static int dm_test_button_keys_adc(struct unit_test_state *uts) +{ + struct udevice *supply; + struct udevice *dev; + int uV; + + ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc@0", &dev)); + + ut_assertok(regulator_get_by_devname(SANDBOX_BUCK2_DEVNAME, &supply)); + ut_assertok(regulator_set_value(supply, SANDBOX_BUCK2_SET_UV)); + ut_asserteq(SANDBOX_BUCK2_SET_UV, regulator_get_value(supply)); + /* Update ADC plat and get new Vdd value */ + ut_assertok(adc_vdd_value(dev, &uV)); + ut_asserteq(SANDBOX_BUCK2_SET_UV, uV); + + /* + * sandbox-adc returns constant value on channel 3, is used by adc-keys: + * SANDBOX_ADC_CHANNEL3_DATA * SANDBOX_BUCK2_SET_UV / SANDBOX_ADC_DATA_MASK = + * 0x3000 * 3300000 / 0xffff = 618759uV + * This means that button3 and button4 are released and button5 + * is pressed. + */ + ut_assertok(button_get_by_label("button3", &dev)); + ut_asserteq(BUTTON_OFF, button_get_state(dev)); + ut_assertok(button_get_by_label("button4", &dev)); + ut_asserteq(BUTTON_OFF, button_get_state(dev)); + ut_assertok(button_get_by_label("button5", &dev)); + ut_asserteq(BUTTON_ON, button_get_state(dev)); + + return 0; +} +DM_TEST(dm_test_button_keys_adc, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);