From nobody Sun Nov 24 05:41:44 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1726687489; cv=none; d=zohomail.com; s=zohoarc; b=mwFf4MPAoZII0pWutErPY1Z0hOYQHOkgBbPjICXPkXj0Wukv/JXJU6i2SaQGoB8yeNx24pfFlHCwIOSbkfVCZaTzHiD/k2jj8bvwuhA2bGJFS85R3ZUIVTfUPr6GAr5xy2n8iMCzOryrBaqcEBsS7DbjsJlZaq8kkXp7uxSel28= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726687489; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HmWuRxg44yVQ0HmHhf9/Qn51jwseOfLAmYdAlCa+aBg=; b=bdXtIuqaclErCdH4MLeTRV+E1QIud/A4q5yn/Q3STPuiBrV8Cq1Vq7f/B4HROBnOe9Nmi/QobwxC9RzbECEprix3/GGDFzqBsa32afgK9RAiaXSyioG85oTT7BVKE5yHf3ZJfMLSAzCdQS7tI0Km0WCKgiSIw64t5JZSCYha6YQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726687489056866.629492814123; Wed, 18 Sep 2024 12:24:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sr0H0-0005ej-FK; Wed, 18 Sep 2024 15:23:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3ryjrZgUKCuofMhUbSaaSXQ.OaYcQYg-PQhQXZaZSZg.adS@flex--tavip.bounces.google.com>) id 1sr0Gy-0005XD-9P for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:32 -0400 Received: from mail-pj1-x1049.google.com ([2607:f8b0:4864:20::1049]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3ryjrZgUKCuofMhUbSaaSXQ.OaYcQYg-PQhQXZaZSZg.adS@flex--tavip.bounces.google.com>) id 1sr0Gw-0007OY-KT for qemu-devel@nongnu.org; Wed, 18 Sep 2024 15:23:32 -0400 Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-2d8759255d4so200065a91.3 for ; Wed, 18 Sep 2024 12:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726687409; x=1727292209; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=HmWuRxg44yVQ0HmHhf9/Qn51jwseOfLAmYdAlCa+aBg=; b=b04drPva2CUU7OQDCreihGEaMgqW4Jm/PGYoCO25zJLd5K/09sIgo8UpgyDbFja5jr seJ0JVwo1FsVCyBpyLFtIziyBo20vF4yEb/bE5HL5Gd7Zae7H6ocRa/19UzBi0/0r2bE DoUGcxQNJzOskz7jJsKkchjK3OC7EbNhujU/Wd4KNM7TpU/j7FlZ9ydMlOvhXn5ZwOYg P6ie7XxADsXe9joed+HfUlQs+vAC8U2Yb0Wo+O1ntAFCreSIH4Fzi5TlKRxsXdT3HkQ8 /1J0JkjR4zwHcI0GqHtO2RwRSIstIH2Kp7c+JHp2Oo0UER41l0Hx8igcUvBi5Q83vTPo tv8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726687409; x=1727292209; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HmWuRxg44yVQ0HmHhf9/Qn51jwseOfLAmYdAlCa+aBg=; b=runJSs0vFOwWaavRCsk62I7/m1lcBVrT9yuN1eODMRWtAVvjO9fqAWuB2O0fU7dk8n Klz0RmjlwyZyAewTqUvNIculktEP5r/PI+Nd3y4YGu0sfwGm9KEJONyq1L4h/rrvO825 0BlHdvuInp2ZSVyRilGK/H7QIhPqOkPzhuPjaBlH3npwnXAGl/WxEE4XRpLOBkObhDta Ga6HRbRvNMeukSekPCd4O4ufZWTcNz7s5dagnwU/oyZ9c4dSH3ODtmg6ypOO/nJqLgz7 na0wsL6n7OlbBiR+ljpO8abkSTdIz5DXYLpLso2HK1XHxNvaPpelpmqZALMDtXhWkWKE RDlg== X-Gm-Message-State: AOJu0YwuFoJ4JaXMk8LYCDOlx/DZ4+ehFPKJnkZd7I/vUKVCAxSCo2mo 0LbuNbUOlzHBAFxsqdmxnJJjEpb5fmeXRjtfKE0IMLgxSlTytIepVSRjRf/sSkLA/e1jVfdvyPw LQ5upNhCiYKfryEVV7g4iWInjWxQAxZDHqGFlIdO+r2jtxjzSsl0vXCiOjQLL6Wgi/35wsbBByY 1yO7NT2exS6D8sAbttz2r+bFwSQQ== X-Google-Smtp-Source: AGHT+IFCuELIg7JeqLtjD4NokVRS2wPk3+ZOc7k9/OwlvjKyjaUuRs3Q7rCruWU+rk1pc5GJRyXY4UUg/g== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a17:90a:ebc9:b0:2d8:8e8a:2b06 with SMTP id 98e67ed59e1d1-2dbb9ebabf8mr66302a91.4.1726687407717; Wed, 18 Sep 2024 12:23:27 -0700 (PDT) Date: Wed, 18 Sep 2024 12:22:45 -0700 In-Reply-To: <20240918192254.3136903-1-tavip@google.com> Mime-Version: 1.0 References: <20240918192254.3136903-1-tavip@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918192254.3136903-18-tavip@google.com> Subject: [PATCH 17/25] tests/qtest: add flexcomm tests From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1049; envelope-from=3ryjrZgUKCuofMhUbSaaSXQ.OaYcQYg-PQhQXZaZSZg.adS@flex--tavip.bounces.google.com; helo=mail-pj1-x1049.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1726687490986116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add flexcomm function selection unit tests. Signed-off-by: Octavian Purdila --- tests/qtest/flexcomm-test.c | 82 +++++++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 1 + 2 files changed, 83 insertions(+) create mode 100644 tests/qtest/flexcomm-test.c diff --git a/tests/qtest/flexcomm-test.c b/tests/qtest/flexcomm-test.c new file mode 100644 index 0000000000..ffbee8bfb8 --- /dev/null +++ b/tests/qtest/flexcomm-test.c @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2024 Google LLC + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "qemu/main-loop.h" +#include "exec/memory.h" +#include "hw/irq.h" +#include "hw/qdev-properties.h" + +#include "hw/misc/flexcomm.h" +#include "hw/arm/svd/flexcomm.h" +#include "hw/arm/svd/rt500.h" +#include "reg-utils.h" + +#define FLEXCOMM_BASE RT500_FLEXCOMM0_BASE + +static void select_test(gconstpointer data) +{ + static const unsigned persel[] =3D { + FLEXCOMM_PERSEL_USART, + FLEXCOMM_PERSEL_SPI, + FLEXCOMM_PERSEL_I2C, + }; + + g_assert(REG32_READ_FIELD(FLEXCOMM, PSELID, PERSEL) =3D=3D 0); + + /* no register access until a function is selected */ + readl_fail(FLEXCOMM_BASE); + writel_fail(FLEXCOMM_BASE, 0); + + for (int i =3D 0; i < ARRAY_SIZE(persel); i++) { + + REG32_WRITE(FLEXCOMM, PSELID, persel[i]); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM, PSELID, PERSEL), =3D= =3D, + persel[i]); + + /* test that we can access function registers */ + writel(FLEXCOMM_BASE, 0xabcd); + readl(FLEXCOMM_BASE); + } + + /* try to select something invalid */ + REG32_WRITE(FLEXCOMM, PSELID, 7); + /* check for no function selected */ + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM, PSELID, PERSEL), =3D=3D, 0= ); + + /* now select and lock USART */ + REG32_WRITE(FLEXCOMM, PSELID, + FIELD_DP32(FLEXCOMM_PERSEL_USART, FLEXCOMM_PSELID, LOCK, 1= )); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM, PSELID, PERSEL), =3D=3D, + FLEXCOMM_PERSEL_USART); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM, PSELID, LOCK), =3D=3D, 1); + + /* try to change the selection to spi */ + REG32_WRITE(FLEXCOMM, PSELID, FLEXCOMM_PERSEL_SPI); + /* it should still be locked USART */ + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM, PSELID, PERSEL), =3D=3D, + FLEXCOMM_PERSEL_USART); + g_assert_cmpuint(REG32_READ_FIELD(FLEXCOMM, PSELID, LOCK), =3D=3D, 1); +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + + qtest_add_data_func("/flexcomm/select", NULL, select_test); + qtest_start("-M rt595-evk"); + ret =3D g_test_run(); + qtest_end(); + + return ret; +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index fc852f3d8b..cb35778ce6 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -231,6 +231,7 @@ qtests_arm =3D \ (config_all_devices.has_key('CONFIG_FSI_APB2OPB_ASPEED') ? ['aspeed_fsi-= test'] : []) + \ (config_all_devices.has_key('CONFIG_STM32L4X5_SOC') and config_all_devices.has_key('CONFIG_DM163')? ['dm163-test'] : []) + \ + (config_all_devices.has_key('CONFIG_FLEXCOMM')? ['flexcomm-test'] : []) = + \ ['arm-cpu-features', 'boot-serial-test'] =20 --=20 2.46.0.662.g92d0881bb0-goog