From patchwork Thu Mar 5 19:25:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 446870 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 9FC351400A0 for ; Fri, 6 Mar 2015 06:28:25 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1804BA7451; Thu, 5 Mar 2015 20:27:38 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oRYl1H9DC2Ew; Thu, 5 Mar 2015 20:27:38 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CD20FAB81E; Thu, 5 Mar 2015 20:26:41 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9E4F0A741B for ; Thu, 5 Mar 2015 20:26:08 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pDD0TWpd6OQa for ; Thu, 5 Mar 2015 20:26:08 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pd0-f202.google.com (mail-pd0-f202.google.com [209.85.192.202]) by theia.denx.de (Postfix) with ESMTPS id 34D2BA7423 for ; Thu, 5 Mar 2015 20:26:05 +0100 (CET) Received: by pdbfl12 with SMTP id fl12so10410240pdb.0 for ; Thu, 05 Mar 2015 11:26:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/Pf9dJ69F1vkDxf6TNLD8M3rzaOVcRMT7jH3a7hZkCA=; b=C90atKyx3sxeHEcIKSKR1HV6CM4Ytg1KYrwRE5KIEqo0RxF5trgpH3qgnaII419CjA 1b1Ia7KNdR/0bHmSI5h1YkClx5lopHYt3FsFCjKVFwOVqRP4DXMBsh1VH7wxVepPtNGG Yq+sNWiCYCfZLqh+Ly49CpsAc//JydIIio0aPye9N3mPmrzrte1dx+WCcj1Eb2osFdQS wdaCSW/E2SzkOWdeeL9P7wcOxZwLG7ZiuzOnWQOrwRZb6TKIa6yAs69v3ylFWyjJtvKr 1l2BiqawvR0xuqQjdQYJqeYPWMZG7WrLntvoStRzKOotEfrB/gBEnauIXBQBbiKXzWt7 biLQ== X-Gm-Message-State: ALoCoQnZQxJ2QRxU1E4MGGfHT2uux/6HEuS4y7lvRF0TgT7Ie0l3SF2Hq0HZXbL4vsj8w1rpDMsw X-Received: by 10.67.29.201 with SMTP id jy9mr3907137pad.9.1425583564323; Thu, 05 Mar 2015 11:26:04 -0800 (PST) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id 3si554497yhe.0.2015.03.05.11.26.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Mar 2015 11:26:04 -0800 (PST) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id mXPXkNSd.3; Thu, 05 Mar 2015 11:26:04 -0800 Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id ABCED221027; Thu, 5 Mar 2015 12:26:03 -0700 (MST) From: Simon Glass To: U-Boot Mailing List Date: Thu, 5 Mar 2015 12:25:34 -0700 Message-Id: <1425583534-2238-23-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1425583534-2238-1-git-send-email-sjg@chromium.org> References: <1425583534-2238-1-git-send-email-sjg@chromium.org> Cc: Tom Rini , Masahiro Yamada Subject: [U-Boot] [PATCH v2 22/22] dm: pci: Add driver model tests for PCI X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add some basic tests to check that things work as expected with sandbox. Signed-off-by: Simon Glass --- Changes in v2: None test/dm/Makefile | 1 + test/dm/pci.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/dm/test.dts | 17 ++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 test/dm/pci.c diff --git a/test/dm/Makefile b/test/dm/Makefile index 612aa95..8281779 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -21,4 +21,5 @@ obj-$(CONFIG_DM_GPIO) += gpio.o obj-$(CONFIG_DM_SPI) += spi.o obj-$(CONFIG_DM_SPI_FLASH) += sf.o obj-$(CONFIG_DM_I2C) += i2c.o +obj-$(CONFIG_DM_PCI) += pci.o endif diff --git a/test/dm/pci.c b/test/dm/pci.c new file mode 100644 index 0000000..6c63fa4 --- /dev/null +++ b/test/dm/pci.c @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2015 Google, Inc + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include + +/* Test that sandbox PCI works correctly */ +static int dm_test_pci_base(struct dm_test_state *dms) +{ + struct udevice *bus; + + ut_assertok(uclass_get_device(UCLASS_PCI, 0, &bus)); + + return 0; +} +DM_TEST(dm_test_pci_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test that we can use the swapcase device correctly */ +static int dm_test_pci_swapcase(struct dm_test_state *dms) +{ + pci_dev_t pci_dev = PCI_BDF(0, 0x1f, 0); + struct pci_controller *hose; + struct udevice *bus, *swap; + ulong io_addr, mem_addr; + char *ptr; + + /* Check that asking for the device automatically fires up PCI */ + ut_assertok(uclass_get_device(UCLASS_PCI_EMUL, 0, &swap)); + + ut_assertok(uclass_get_device(UCLASS_PCI, 0, &bus)); + hose = dev_get_uclass_priv(bus); + + /* First test I/O */ + io_addr = pci_read_bar32(hose, pci_dev, 0); + outb(2, io_addr); + ut_asserteq(2, inb(io_addr)); + + /* + * Now test memory mapping - note we must unmap and remap to cause + * the swapcase emulation to see our data and response. + */ + mem_addr = pci_read_bar32(hose, pci_dev, 1); + ptr = map_sysmem(mem_addr, 20); + strcpy(ptr, "This is a TesT"); + unmap_sysmem(ptr); + + ptr = map_sysmem(mem_addr, 20); + ut_asserteq_str("tHIS IS A tESt", ptr); + unmap_sysmem(ptr); + + return 0; +} +DM_TEST(dm_test_pci_swapcase, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); diff --git a/test/dm/test.dts b/test/dm/test.dts index 84024a4..96775e1 100644 --- a/test/dm/test.dts +++ b/test/dm/test.dts @@ -10,6 +10,7 @@ console = &uart0; i2c0 = "/i2c@0"; spi0 = "/spi@0"; + pci0 = &pci; testfdt6 = "/e-test"; testbus3 = "/some-bus"; testfdt0 = "/some-bus/c-test@0"; @@ -135,6 +136,22 @@ }; }; + pci: pci-controller { + compatible = "sandbox,pci"; + device_type = "pci"; + #address-cells = <3>; + #size-cells = <2>; + ranges = <0x02000000 0 0x10000000 0x10000000 0 0x2000 + 0x01000000 0 0x20000000 0x20000000 0 0x2000>; + pci@1f,0 { + compatible = "pci-generic"; + reg = <0xf800 0 0 0 0>; + emul@1f,0 { + compatible = "sandbox,swap-case"; + }; + }; + }; + spi@0 { #address-cells = <1>; #size-cells = <0>;