From patchwork Tue Jul 15 00:56:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 369808 X-Patchwork-Delegate: jagannadh.teki@gmail.com 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 7532E140171 for ; Tue, 15 Jul 2014 11:01:28 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 80552A75BB; Tue, 15 Jul 2014 03:00:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 a3P-EaDCjOJe; Tue, 15 Jul 2014 03:00:58 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 16B10A75E3; Tue, 15 Jul 2014 02:58:45 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B806CA757F for ; Tue, 15 Jul 2014 02:58:34 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 sJqt-bc7KKC7 for ; Tue, 15 Jul 2014 02:58:33 +0200 (CEST) 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-pa0-f73.google.com (mail-pa0-f73.google.com [209.85.220.73]) by theia.denx.de (Postfix) with ESMTPS id 66D55A7583 for ; Tue, 15 Jul 2014 02:58:09 +0200 (CEST) Received: by mail-pa0-f73.google.com with SMTP id kx10so894115pab.0 for ; Mon, 14 Jul 2014 17:58:08 -0700 (PDT) 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=DzQQhnPpS8Jta/NOcaSzwAVtmMmWVrHR9xyL9/5YGzQ=; b=E8R7WvLqVYNrC4hCxIMnSBs3QFuAQ9JKEvyIg821YrHc6yiiJtSZXpCcvHig3Nn/o1 DXb67JusPR0TdIVzmbM1UXYT0sri2trA8+Qrsrdgl/KFmLHeRtnCxOKCzjIBnlpCRnDq s3DdDNbFx5NEBCIKLn8wCH51NBWlZt6vSvtx1ucorKOJDvhZ8HLhVHHQo3en9PCTXedE fogydTuJi5XCE8TFn6OVqujYin5fqZ+ge2VjtyPRi9DaKWunve8ZHwyTZdIRcSdU3eUm UqEJZsKqmyqz0yaF5xX2srfOVBuW0fvbIlC1ZttcbaTL2L26szwJlJYrFjJ+RXVieLrh g7Hg== X-Gm-Message-State: ALoCoQmS5URL7i7KkwTbttPNbGHcNBD2XAvPgl8jasLyb+Le2ULLih7L0gGxmIXw+h6uCNy/0iv8 X-Received: by 10.70.24.163 with SMTP id v3mr3265404pdf.8.1405385888422; Mon, 14 Jul 2014 17:58:08 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id v44si749689yhv.0.2014.07.14.17.58.08 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Jul 2014 17:58:08 -0700 (PDT) Received: from kaki.bld.corp.google.com (kaki.bld.corp.google.com [172.29.216.32]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 4322F31C1FE; Mon, 14 Jul 2014 17:58:08 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 12D64220B38; Mon, 14 Jul 2014 18:58:08 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 14 Jul 2014 18:56:28 -0600 Message-Id: <1405385792-4469-22-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.0.0.526.g5318336 In-Reply-To: <1405385792-4469-1-git-send-email-sjg@chromium.org> References: <1405385792-4469-1-git-send-email-sjg@chromium.org> Cc: Jagannadha Sutradharudu Teki Subject: [U-Boot] [PATCH 21/25] dm: spi: Add tests X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de These tests use SPI flash (and the sandbox emulation) to operate. Signed-off-by: Simon Glass --- test/dm/Makefile | 1 + test/dm/spi.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 test/dm/spi.c diff --git a/test/dm/Makefile b/test/dm/Makefile index 5c2415e..d1b9c9a 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -18,4 +18,5 @@ obj-$(CONFIG_DM_TEST) += core.o obj-$(CONFIG_DM_TEST) += ut.o ifneq ($(CONFIG_SANDBOX),) obj-$(CONFIG_DM_GPIO) += gpio.o +obj-$(CONFIG_DM_SPI) += spi.o endif diff --git a/test/dm/spi.c b/test/dm/spi.c new file mode 100644 index 0000000..45aabeb --- /dev/null +++ b/test/dm/spi.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2013 Google, Inc + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Test that sandbox SPI works correctly */ +static int dm_test_spi(struct dm_test_state *dms) +{ + struct spi_slave *slave; + struct udevice *dev; + const int busnum = 0, cs = 0, mode = 0; + const char dout[5] = {0x9f}; + unsigned char din[5]; + + ut_assertok(spi_get_bus_and_cs(busnum, cs, 1000000, mode, NULL, 0, + &dev, &slave)); + ut_assertok(spi_claim_bus(slave)); + ut_assertok(spi_xfer(slave, 40, dout, din, + SPI_XFER_BEGIN | SPI_XFER_END)); + ut_asserteq(0xff, din[0]); + ut_asserteq(0x20, din[1]); + ut_asserteq(0x20, din[2]); + ut_asserteq(0x15, din[3]); + spi_release_bus(slave); + + /* + * Since we are about to destroy all devices, we must tell sandbox + * to forget the emulation device + */ +#ifdef CONFIG_DM_SPI_FLASH + sandbox_sf_unbind_emul(state_get_current(), busnum, cs); +#endif + + return 0; +} +DM_TEST(dm_test_spi, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);