From patchwork Thu Feb 18 10:33:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 384383 Delivered-To: patch@linaro.org Received: by 2002:a02:c80e:0:0:0:0:0 with SMTP id p14csp3558981jao; Thu, 18 Feb 2021 02:33:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIDrSlS3bkZwAEUVYrlN1n4xFKHYvW9foidhtsaai/tKQY622RQNGW/9XZ9QaJfmmBwAYG X-Received: by 2002:a17:906:b357:: with SMTP id cd23mr3329975ejb.307.1613644436614; Thu, 18 Feb 2021 02:33:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613644436; cv=none; d=google.com; s=arc-20160816; b=XEMoHCN3Q0j0LVTNiLQ3NC1R1oNaHUKxSWUkYmFI7Yg9pbM/aTILXauXGVC4digGLl cBxH9YnPS57cZXWQUKn6AYywUVYOBi7IuoSVrzrGLmqiyF3Fr+tPHN3NiooSPRWDX7SH PS0TASBqHnpsDsO6jFkS9mvLI0HkHW9Z3WjP73QIlyMddHCCwsVEzID6lbEtx1d30TEM +/Guk5sQF8IbdepmCDObmfYRfl2oIrYLLson5Z/e+FXhKiIHhTGhINYOH50JxNBYaYCa noV2nVTXxCYIRL1pr2mMGRmZm5KerQJsYxtUxGSUKyyOozTwu6smY4kSGt0SpFQbb2Bc aYIQ== 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=tuQsUpq5/OlVBER2QAMSd+0JI4Kda1qrTRbP1LAD5vQ=; b=Mt/L31JDz2l/SAUEjVMxUvstBsECfAT79u1t066WTItLvGqvEoYq93WDq19IIObbNF HCcHHCF61y7g/MTnDzXxuC17H/sSxyuK4WEvXxPogrR7KcJjLMmaRZEXhEE2YH1uw2oh HcaEbiJeh80LW/UQCwDY380l6wClzQNHEPuZbLO0wnUSDGPrgWsH4//SQ4DsyAS0wFF5 6NPZvXgejyUdxqZPyUBtLBellHYR1kgyR2ZR083c4jxtUo5/G6ge6shc7lRerFaGIzaI 84K1xvvNtWaBGpGSfGzMdPI++1jkwNKNML/5DghDe5dQVUa3MHf0k0QMsN5wGkenpe5F osew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=mywYpeqa; 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 i3si319206ejy.226.2021.02.18.02.33.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Feb 2021 02:33:56 -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=mywYpeqa; 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 88B4C82385; Thu, 18 Feb 2021 11:33:49 +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="mywYpeqa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 18A098268D; Thu, 18 Feb 2021 11:33:47 +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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F3EDC801D8 for ; Thu, 18 Feb 2021 11:33:41 +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 eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20210218103330euoutp018943e1ef878adb2d1449e805c2b3f78d~k0QrTG10J1511615116euoutp01y for ; Thu, 18 Feb 2021 10:33:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20210218103330euoutp018943e1ef878adb2d1449e805c2b3f78d~k0QrTG10J1511615116euoutp01y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1613644410; bh=tuQsUpq5/OlVBER2QAMSd+0JI4Kda1qrTRbP1LAD5vQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mywYpeqarpl0L0RqBWVnjeET529vt9y9jxLDxiQOTKnGlnNbbVzjcCZ1iRfJsGR5P e2kibOcs2uu3Fmp/BXXWlTEQXlWfzfTOszsBQ1MSZ054Ay35k7XULYPHuvMXqe9ysX OZxOo9zGw4xEN1qeoaVNMDqOjDMfExQweSoMFYqY= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20210218103330eucas1p220e36251e227664d358c554f31e3dd1d~k0Qq3Qki91548715487eucas1p2E; Thu, 18 Feb 2021 10:33:30 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id F5.F7.44805.A724E206; Thu, 18 Feb 2021 10:33:30 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20210218103329eucas1p1d03a2bddc8712a3993ec52f95c9a3c5d~k0QqUmslH2705627056eucas1p1E; Thu, 18 Feb 2021 10:33:29 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210218103329eusmtrp2a7222ebfb8c476615e72e8eba4c70714~k0QqT2baY2025120251eusmtrp2u; Thu, 18 Feb 2021 10:33:29 +0000 (GMT) X-AuditID: cbfec7f4-b37ff7000000af05-16-602e427a899a Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 58.73.21957.9724E206; Thu, 18 Feb 2021 10:33:29 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210218103329eusmtip2ea01c55f98301d497e143d624aa5a4e4~k0Qp27J813210932109eusmtip2w; Thu, 18 Feb 2021 10:33:29 +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 v7 5/5] test: add a simple test for the adc-keys button driver Date: Thu, 18 Feb 2021 11:33:18 +0100 Message-Id: <20210218103318.18915-6-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210218103318.18915-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmleLIzCtJLcpLzFFi42LZduznOd0qJ70EgyuvRCw2zljPanHjVxur xfN3l5ks1h65y25xqC/aouOwssW3LdsYLSZN+MVm8XZvJ7vF4akfGB24PN7faGX3mN1wkcVj 3qwTLB4fPsZ5zO/8zuRx9s4ORo++LasYPTYuO8AcwBHFZZOSmpNZllqkb5fAlbHqymbGgrlq FZ1vz7A3MLYqdDFyckgImEice3CVrYuRi0NIYAWjxJaORmYI5wujRPOVViYI5zOjxPKz84Ey HGAty1o1IeLLGSU+L9zODtdx+fgaFpC5bAKGEl1vu9hAbBEBI4lLTTtYQIqYBe4wSXRNbgAr EhYIkNjQ8JwRxGYRUJV4P2E6K4jNK2Ar0THlAzPEgfISqzccALM5BewknpydDzZIQuAIh8TD 7+/ZIIpcJH7090DZwhKvjm9hh7BlJP7vnM8E0dDMKPHw3Fp2CKcH6NamGYwQVdYSd879YgN5 jllAU2L9Ln2IsKPE6Zmv2SF+5pO48VYQJMwMZE7aNh0aFLwSHW1CENVqErOOr4Nbe/DCJagS D4ne2b6QAJrIKLFu5yvGCYzysxB2LWBkXMUonlpanJueWmyUl1quV5yYW1yal66XnJ+7iRGY Xk7/O/5lB+PyVx/1DjEycTAeYpTgYFYS4WX/rJUgxJuSWFmVWpQfX1Sak1p8iFGag0VJnDdp y5p4IYH0xJLU7NTUgtQimCwTB6dUA9OKStc1+/pSCtW/fztjEda1d+nCKT/25CswbpP9LHNm 6Zt5+1coT/K6Y5p992e6r9hqAWUugbdS2s9nn7v96Na/zY/tal5N+1869VnELpeIWPW7rNFv 4k0kGv/sO/uOO2aewnwjtmIx3abH0w94R6VmM+Q/LGwu77/6acLW6BNTfFxdP0Tzx77IC7c8 7aO34E2OW3+33LrkKbz1gt+sXXdNOGzuZrz6tNuM+xnNv+/W50wyXD7t0eUJr/rY5R8ESxrt kbgwW5M1pZT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85nzx7cL3ymfIqLWv33c1W8tXzY/rmlObMEOAsWvVc7O9zYZtZ/+5s0dE+6XibV4mlOCPR UIu5qDgRAPl+mc7/AgAA X-CMS-MailID: 20210218103329eucas1p1d03a2bddc8712a3993ec52f95c9a3c5d X-Msg-Generator: CA X-RootMTR: 20210218103329eucas1p1d03a2bddc8712a3993ec52f95c9a3c5d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20210218103329eucas1p1d03a2bddc8712a3993ec52f95c9a3c5d References: <20210218103318.18915-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 Reviewed-by: Simon Glass --- arch/sandbox/dts/test.dts | 28 +++++++++++++++++++++- configs/sandbox_defconfig | 1 + test/dm/button.c | 50 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 76 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index e95f4631bf..202e091841 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -69,6 +70,30 @@ }; }; + buttons2 { + compatible = "adc-keys"; + io-channels = <&adc 3>; + keyup-threshold-microvolt = <3000000>; + + button-up { + label = "button3"; + linux,code = ; + press-threshold-microvolt = <1500000>; + }; + + button-down { + label = "button4"; + linux,code = ; + press-threshold-microvolt = <1000000>; + }; + + button-enter { + label = "button5"; + linux,code = ; + press-threshold-microvolt = <500000>; + }; + }; + cros_ec: cros-ec { reg = <0 0>; compatible = "google,cros-ec-sandbox"; @@ -587,8 +612,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);