From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A854CC433E0 for ; Sun, 24 Jan 2021 13:11:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1497322D3E for ; Sun, 24 Jan 2021 13:11:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1497322D3E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=lmichel.fr Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l3fB4-0008VH-Bu for qemu-devel@archiver.kernel.org; Sun, 24 Jan 2021 08:11:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l3f9m-0007oW-6h; Sun, 24 Jan 2021 08:10:18 -0500 Received: from pharaoh.lmichel.fr ([149.202.28.74]:55530) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l3f9g-0006Bn-WA; Sun, 24 Jan 2021 08:10:17 -0500 Received: from localhost (sekoia-pc.home.lmichel.fr [192.168.61.100]) by pharaoh.lmichel.fr (Postfix) with ESMTPSA id 0A361C602E6; Sun, 24 Jan 2021 14:10:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lmichel.fr; s=pharaoh; t=1611493808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=SJyJcEvUt69BxmSu6MT1J+V50x+xt2q+A8wKVTuROlw=; b=YD1EKqg/PUdPpjOHlQJOUWZ30hLgP8nBU1AW6sXPOyK0XNoulVcmsbcj0UKfqW22Vif+/C xwaRypccpQmLfN5eAsSVlebJ/t6rpemMmQnRYGQ54SdR8X6ZbWFQBxDNzAI2GUNgUTy0Al gBeDYuK7+8VNBrb9GTcHdZ3hlh5TFg/UDpqsltml7M34I+DI7d6NNJP3GEzcCGpGEdgObc TfG1Rt9PEzVQ3f9zRbjG1XYHr5n+9/VVFJezvf2onl0E70M8gsEkQZkWnRWeGEu9fbSXzj G5bchaOlXyiykSzH7+86p9jhiwrh6HZub+SN+UN8C5c4UbDj4+wUy7Q25j+78w== Date: Sun, 24 Jan 2021 14:10:30 +0100 From: Luc Michel To: Peter Maydell Subject: Re: [PATCH 04/25] tests: Add a simple test of the CMSDK APB watchdog Message-ID: <20210124131030.dxvcid4i6j7kmt4r@sekoia-pc.home.lmichel.fr> References: <20210121190622.22000-1-peter.maydell@linaro.org> <20210121190622.22000-5-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210121190622.22000-5-peter.maydell@linaro.org> Received-SPF: pass client-ip=149.202.28.74; envelope-from=luc@lmichel.fr; helo=pharaoh.lmichel.fr X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , qemu-arm@nongnu.org, qemu-devel@nongnu.org, Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 19:06 Thu 21 Jan , Peter Maydell wrote: > Add a simple test of the CMSDK watchdog, since we're about to do some > refactoring of how it is clocked. > > Signed-off-by: Peter Maydell Reviewed-by: Luc Michel > --- > tests/qtest/cmsdk-apb-watchdog-test.c | 80 +++++++++++++++++++++++++++ > MAINTAINERS | 1 + > tests/qtest/meson.build | 1 + > 3 files changed, 82 insertions(+) > create mode 100644 tests/qtest/cmsdk-apb-watchdog-test.c > > diff --git a/tests/qtest/cmsdk-apb-watchdog-test.c b/tests/qtest/cmsdk-apb-watchdog-test.c > new file mode 100644 > index 00000000000..c6add1fee85 > --- /dev/null > +++ b/tests/qtest/cmsdk-apb-watchdog-test.c > @@ -0,0 +1,80 @@ > +/* > + * QTest testcase for the CMSDK APB watchdog device > + * > + * Copyright (c) 2021 Linaro Limited > + * > + * This program is free software; you can redistribute it and/or modify it > + * under the terms of the GNU General Public License as published by the > + * Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, but WITHOUT > + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or > + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License > + * for more details. > + */ > + > +#include "qemu/osdep.h" > +#include "libqtest-single.h" > + > +/* > + * lm3s811evb watchdog; at board startup this runs at 200MHz / 16 == 12.5MHz, > + * which is 80ns per tick. > + */ > +#define WDOG_BASE 0x40000000 > + > +#define WDOGLOAD 0 > +#define WDOGVALUE 4 > +#define WDOGCONTROL 8 > +#define WDOGINTCLR 0xc > +#define WDOGRIS 0x10 > +#define WDOGMIS 0x14 > +#define WDOGLOCK 0xc00 > + > +static void test_watchdog(void) > +{ > + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); > + > + writel(WDOG_BASE + WDOGCONTROL, 1); > + writel(WDOG_BASE + WDOGLOAD, 1000); > + > + /* Step to just past the 500th tick */ > + clock_step(500 * 80 + 1); > + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); > + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500); > + > + /* Just past the 1000th tick: timer should have fired */ > + clock_step(500 * 80); > + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1); > + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 0); > + > + /* VALUE reloads at following tick */ > + clock_step(80); > + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000); > + > + /* Writing any value to WDOGINTCLR clears the interrupt and reloads */ > + clock_step(500 * 80); > + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500); > + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1); > + writel(WDOG_BASE + WDOGINTCLR, 0); > + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000); > + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); > +} > + > +int main(int argc, char **argv) > +{ > + QTestState *s; > + int r; > + > + g_test_init(&argc, &argv, NULL); > + > + s = qtest_start("-machine lm3s811evb"); > + > + qtest_add_func("/cmsdk-apb-watchdog/watchdog", test_watchdog); > + > + r = g_test_run(); > + > + qtest_end(); > + > + return r; > +} > diff --git a/MAINTAINERS b/MAINTAINERS > index 010405b0884..58956497888 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -588,6 +588,7 @@ F: hw/char/cmsdk-apb-uart.c > F: include/hw/char/cmsdk-apb-uart.h > F: hw/watchdog/cmsdk-apb-watchdog.c > F: include/hw/watchdog/cmsdk-apb-watchdog.h > +F: tests/qtest/cmsdk-apb-watchdog-test.c > F: hw/misc/tz-ppc.c > F: include/hw/misc/tz-ppc.h > F: hw/misc/tz-mpc.c > diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build > index 74addd74868..9e2ebc47041 100644 > --- a/tests/qtest/meson.build > +++ b/tests/qtest/meson.build > @@ -142,6 +142,7 @@ qtests_npcm7xx = \ > 'npcm7xx_watchdog_timer-test'] > qtests_arm = \ > (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \ > + (config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \ > (config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \ > (config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \ > ['arm-cpu-features', > -- > 2.20.1 > --