From patchwork Sat Apr 27 08:15:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramon Fried X-Patchwork-Id: 1091932 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="oxSmIpae"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44rqc55yQrz9s5c for ; Sat, 27 Apr 2019 22:14:45 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 84650C21E50; Sat, 27 Apr 2019 12:13:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 91606C21E26; Sat, 27 Apr 2019 12:10:25 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 310D9C21C3F; Sat, 27 Apr 2019 08:15:43 +0000 (UTC) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by lists.denx.de (Postfix) with ESMTPS id CB6B4C21C29 for ; Sat, 27 Apr 2019 08:15:42 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id p21so4961202wmc.0 for ; Sat, 27 Apr 2019 01:15:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gVyGPxCJfrZK0LYMTbv9q7OsdfBwILBl4RIDLsLZK00=; b=oxSmIpaegj6XxFFfF7YWzFdm+LlyEQ0NSSrFcUkj21/OL6Wsw/+SrKey2G8keDcm+0 kGWQ2Plux35vdOyRi8TO7vlIPqzxQMmPFrH7KSWtV2w65Dm1mIbr0SukmE8GvOBgaVUF 3iNuuo/PdVDGCIUtSQk24YJ5RRp9oEUCFrkBmzTlndwitZlwI5zSXfsQL1PVdAe6V9Ok P0ZcormmJs3SVFJ7A5fUzswgG4WuLi0B1thZv+s2/jYer8iByf+2vKe22ca+PE8Nxu7R 2wP9MEyUwwCpKenww1oWdy8rak1bGe/JQEVd1qAbkx9+Jmnd60IAclIOiL9GXORD4t1V NDgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gVyGPxCJfrZK0LYMTbv9q7OsdfBwILBl4RIDLsLZK00=; b=EXYkKBjL3dN67Jzsm+H5uLR3f+JffhaXLnxJ/Gsb7/Idg48ctznkdg7llcAtq+umq6 23zti9ayEB/updV9quYr+LYQHwCRV3/JoUEDfgCDxiNBIGsREGcbxpgn6/sUDr8g4+7d c166Txekc6LsoDmeyFnRxgmWpXmCK+Dvbi4Tz44zGERRWTLb/F+QggLQdMbjrnys7RzT Ywbhys6JNyk5t4g8KnRVb2htdDHjdwEPwHC+YxW8CYK9bUBxlj17B87x9vB+SrG0/bhu sAAIoWMRi8NhnJ3WmO6wgvQMDwyx5Hr4TxkhxnZX5vgiWeRD/BvAIqJXiZ35RmrQTqa4 0aag== X-Gm-Message-State: APjAAAXez7dBS4YRkSHl5INUXkaUF61mY1EP7P40EeBUj2NNd0Ate+5y NOFU5c+Gv/Lnwa5TTvErmCI= X-Google-Smtp-Source: APXvYqx6BqwriD2t7DKL7KjM9+JhbXnOfKwv38RIkQHUeAOOa5f6iVzFWyNm1Za0LvByKycxsztMog== X-Received: by 2002:a1c:a103:: with SMTP id k3mr11101022wme.8.1556352942387; Sat, 27 Apr 2019 01:15:42 -0700 (PDT) Received: from localhost.localdomain ([141.226.31.91]) by smtp.gmail.com with ESMTPSA id u17sm19724163wmj.1.2019.04.27.01.15.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Apr 2019 01:15:41 -0700 (PDT) From: Ramon Fried To: sjg@chromium.org Date: Sat, 27 Apr 2019 11:15:24 +0300 Message-Id: <20190427081524.5759-5-ramon.fried@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190427081524.5759-1-ramon.fried@gmail.com> References: <20190427081524.5759-1-ramon.fried@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 27 Apr 2019 12:10:20 +0000 Cc: Ramon Fried , u-boot@lists.denx.de Subject: [U-Boot] [PATCH v3 4/4] test: pci_ep: add basic pci_ep tests X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Add basic PCI endpoint sandbox testing. Signed-off-by: Ramon Fried Reviewed-by: Simon Glass --- Changes in v3: - Added more testing of sandbox driver arch/sandbox/include/asm/test.h | 8 +++++ test/dm/Makefile | 1 + test/dm/pci_ep.c | 64 +++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 test/dm/pci_ep.c diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h index fc52f47f82..cfb30cb376 100644 --- a/arch/sandbox/include/asm/test.h +++ b/arch/sandbox/include/asm/test.h @@ -185,4 +185,12 @@ int sandbox_get_beep_frequency(struct udevice *dev); */ int sandbox_get_pch_spi_protect(struct udevice *dev); +/** + * sandbox_get_pci_ep_irq_count() - Get the PCI EP IRQ count + * + * @dev: Device to check + * @return irq count + */ +int sandbox_get_pci_ep_irq_count(struct udevice *dev); + #endif diff --git a/test/dm/Makefile b/test/dm/Makefile index 49857c5092..fe36f8df47 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -30,6 +30,7 @@ obj-y += ofnode.o obj-$(CONFIG_OSD) += osd.o obj-$(CONFIG_DM_VIDEO) += panel.o obj-$(CONFIG_DM_PCI) += pci.o +obj-$(CONFIG_PCI_ENDPOINT) += pci_ep.o obj-$(CONFIG_PCH) += pch.o obj-$(CONFIG_PHY) += phy.o obj-$(CONFIG_POWER_DOMAIN) += power-domain.o diff --git a/test/dm/pci_ep.c b/test/dm/pci_ep.c new file mode 100644 index 0000000000..101f861751 --- /dev/null +++ b/test/dm/pci_ep.c @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2019 Ramon Fried + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* Test that sandbox PCI EP works correctly */ +static int dm_test_pci_ep_base(struct unit_test_state *uts) +{ + struct udevice *bus; + struct pci_bar tmp_bar; + struct pci_ep_header tmp_header; + int i; + + struct pci_ep_header ep_header = { + .vendorid = 0x1234, + .deviceid = 0x2020, + .revid = 1, + .interrupt_pin = PCI_INTERRUPT_INTA, + }; + + struct pci_bar bar = { + .phys_addr = 0x80000000, + .size = 0x100000, + .barno = BAR_0, + .flags = PCI_BASE_ADDRESS_MEM_TYPE_64 | + PCI_BASE_ADDRESS_MEM_PREFETCH, + }; + + ut_assertok(uclass_get_device(UCLASS_PCI_EP, 0, &bus)); + ut_assertnonnull(bus); + + ut_assertok(pci_ep_write_header(bus, 0, &ep_header)); + ut_assertok(pci_ep_read_header(bus, 0, &tmp_header)); + ut_asserteq_mem(&tmp_header, &ep_header, sizeof(ep_header)); + + ut_assertok(pci_ep_set_msi(bus, 0, 4)); + ut_asserteq(pci_ep_get_msi(bus, 0), 4); + + ut_assertok(pci_ep_set_msix(bus, 0, 360)); + ut_asserteq(pci_ep_get_msix(bus, 0), 360); + + ut_assertok(pci_ep_set_bar(bus, 0, &bar)); + + ut_assertok(pci_ep_read_bar(bus, 0, &tmp_bar, BAR_0)); + ut_asserteq_mem(&tmp_bar, &bar, sizeof(bar)); + + for (i = 0; i < 10; i++) + ut_assertok(pci_ep_raise_irq(bus, 0, 1, PCI_EP_IRQ_LEGACY)); + + ut_asserteq(sandbox_get_pci_ep_irq_count(bus), 10); + return 0; +} + +DM_TEST(dm_test_pci_ep_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); +