All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org,
	"Marcin Krzeminski" <marcin.krzeminski@nokia.com>,
	"Cédric Le Goater" <clg@kaod.org>
Subject: [Qemu-devel] [PATCH v2 08/11] aspeed/smc: reset flash after each test
Date: Mon,  9 Jan 2017 17:24:44 +0100	[thread overview]
Message-ID: <1483979087-32663-9-git-send-email-clg@kaod.org> (raw)
In-Reply-To: <1483979087-32663-1-git-send-email-clg@kaod.org>

Let's make sure when each test is run that the flash object is in an
initial state and did not keep configuration from the previous tests.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 tests/m25p80-test.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/tests/m25p80-test.c b/tests/m25p80-test.c
index cb7ec81f1a6d..8dd550deb95e 100644
--- a/tests/m25p80-test.c
+++ b/tests/m25p80-test.c
@@ -50,6 +50,8 @@ enum {
     READ = 0x03,
     PP = 0x02,
     WREN = 0x6,
+    RESET_ENABLE = 0x66,
+    RESET_MEMORY = 0x99,
     EN_4BYTE_ADDR = 0xB7,
     ERASE_SECTOR = 0xd8,
 };
@@ -76,6 +78,14 @@ static void spi_conf(uint32_t value)
     writel(ASPEED_FMC_BASE + R_CONF, conf);
 }
 
+static void spi_conf_remove(uint32_t value)
+{
+    uint32_t conf = readl(ASPEED_FMC_BASE + R_CONF);
+
+    conf &= ~value;
+    writel(ASPEED_FMC_BASE + R_CONF, conf);
+}
+
 static void spi_ctrl_start_user(void)
 {
     uint32_t ctrl = readl(ASPEED_FMC_BASE + R_CTRL0);
@@ -95,6 +105,18 @@ static void spi_ctrl_stop_user(void)
     writel(ASPEED_FMC_BASE + R_CTRL0, ctrl);
 }
 
+static void flash_reset(void)
+{
+    spi_conf(CONF_ENABLE_W0);
+
+    spi_ctrl_start_user();
+    writeb(ASPEED_FLASH_BASE, RESET_ENABLE);
+    writeb(ASPEED_FLASH_BASE, RESET_MEMORY);
+    spi_ctrl_stop_user();
+
+    spi_conf_remove(CONF_ENABLE_W0);
+}
+
 static void test_read_jedec(void)
 {
     uint32_t jedec = 0x0;
@@ -108,6 +130,8 @@ static void test_read_jedec(void)
     jedec |= readb(ASPEED_FLASH_BASE);
     spi_ctrl_stop_user();
 
+    flash_reset();
+
     g_assert_cmphex(jedec, ==, FLASH_JEDEC);
 }
 
@@ -155,6 +179,8 @@ static void test_erase_sector(void)
     for (i = 0; i < PAGE_SIZE / 4; i++) {
         g_assert_cmphex(page[i], ==, 0xffffffff);
     }
+
+    flash_reset();
 }
 
 static void test_erase_all(void)
@@ -182,6 +208,8 @@ static void test_erase_all(void)
     for (i = 0; i < PAGE_SIZE / 4; i++) {
         g_assert_cmphex(page[i], ==, 0xffffffff);
     }
+
+    flash_reset();
 }
 
 static void test_write_page(void)
@@ -195,6 +223,7 @@ static void test_write_page(void)
 
     spi_ctrl_start_user();
     writeb(ASPEED_FLASH_BASE, EN_4BYTE_ADDR);
+    writeb(ASPEED_FLASH_BASE, WREN);
     writeb(ASPEED_FLASH_BASE, PP);
     writel(ASPEED_FLASH_BASE, make_be32(my_page_addr));
 
@@ -215,6 +244,8 @@ static void test_write_page(void)
     for (i = 0; i < PAGE_SIZE / 4; i++) {
         g_assert_cmphex(page[i], ==, 0xffffffff);
     }
+
+    flash_reset();
 }
 
 static char tmp_path[] = "/tmp/qtest.m25p80.XXXXXX";
-- 
2.7.4

  parent reply	other threads:[~2017-01-09 16:26 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-09 16:24 [Qemu-devel] [PATCH v2 00/11] Aspeed SMC controller fixes and improvements Cédric Le Goater
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 01/11] aspeed/smc: remove call to reset in realize function Cédric Le Goater
2017-01-11 18:10   ` mar.krzeminski
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 02/11] aspeed/smc: remove call to aspeed_smc_update_cs() in reset function Cédric Le Goater
2017-01-16 17:23   ` mar.krzeminski
2017-01-17  8:05     ` Cédric Le Goater
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 03/11] aspeed/smc: rework the prototype of the AspeedSMCFlash helper routines Cédric Le Goater
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 04/11] aspeed/smc: autostrap CE0/1 configuration Cédric Le Goater
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 05/11] aspeed/smc: unfold the AspeedSMCController array Cédric Le Goater
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 06/11] aspeed/smc: adjust the size of the register region Cédric Le Goater
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 07/11] aspeed/smc: handle SPI flash Command mode Cédric Le Goater
2017-01-19 19:26   ` Peter Maydell
2017-01-19 20:35     ` Cédric Le Goater
2017-01-20 10:13       ` Peter Maydell
2017-01-20 10:17         ` Cédric Le Goater
2017-01-20 11:22           ` Cédric Le Goater
2017-01-09 16:24 ` Cédric Le Goater [this message]
2017-01-16 17:37   ` [Qemu-devel] [PATCH v2 08/11] aspeed/smc: reset flash after each test mar.krzeminski
2017-01-16 18:10     ` Cédric Le Goater
2017-01-16 18:19       ` mar.krzeminski
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 09/11] aspeed/smc: extend tests for Command mode Cédric Le Goater
2017-01-16 17:51   ` mar.krzeminski
2017-01-17  8:34     ` Cédric Le Goater
2017-01-17 17:34       ` mar.krzeminski
2017-01-18 14:56         ` Cédric Le Goater
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 10/11] aspeed: use first FMC flash as a boot ROM Cédric Le Goater
2017-01-30 12:55   ` Peter Maydell
2017-01-30 13:38     ` Cédric Le Goater
2017-01-09 16:24 ` [Qemu-devel] [PATCH v2 11/11] aspeed/smc: handle dummy bytes when doing fast reads in command mode Cédric Le Goater
2017-01-11 18:20   ` mar.krzeminski
2017-01-11 18:55     ` Cédric Le Goater
2017-01-14 18:56       ` mar.krzeminski
2017-01-16  8:18         ` Cédric Le Goater
2017-01-16 18:58           ` mar.krzeminski
2017-01-17  8:37             ` Cédric Le Goater
2017-01-17 17:30               ` mar.krzeminski
2017-01-16 17:00 ` [Qemu-devel] [PATCH v2 00/11] Aspeed SMC controller fixes and improvements Peter Maydell
2017-01-16 17:08   ` Cédric Le Goater

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1483979087-32663-9-git-send-email-clg@kaod.org \
    --to=clg@kaod.org \
    --cc=crosthwaite.peter@gmail.com \
    --cc=marcin.krzeminski@nokia.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.