From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 09/11] hw/sd/omap_mmc: Split 'pseudo-reset' from 'power-on-reset'
Date: Mon, 9 Jul 2018 14:54:33 +0100 [thread overview]
Message-ID: <20180709135435.836-10-peter.maydell@linaro.org> (raw)
In-Reply-To: <20180709135435.836-1-peter.maydell@linaro.org>
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
DeviceClass::reset models a "cold power-on" reset which can
also be used to powercycle a device; but there is no "hot reset"
(a.k.a. soft-reset) method available.
The OMAP MMC Power-Up Control bit is not designed to powercycle
a card, but to disable it without powering it off (pseudo-reset):
Multimedia Card (MMC/SD/SDIO) Interface [SPRU765A]
MMC_CON[11] Power-Up Control (POW)
This bit must be set to 1 before any valid transaction to either
MMC/SD or SPI memory cards.
When 1, the card is considered powered-up and the controller core
is enabled.
When 0, the card is considered powered-down (system dependent),
and the controller core logic is in pseudo-reset state. This is,
the MMC_STAT flags and the FIFO pointers are reset, any access to
MMC_DATA[DATA] has no effect, a write into the MMC.CMD register
is ignored, and a setting of MMC_SPI[STR] to 1 is ignored.
By splitting the 'pseudo-reset' code out of the 'power-on' reset
function, this patch fixes a latent bug in omap_mmc_write(MMC_CON)i
recently exposed by ecd219f7abb.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20180706162155.8432-2-f4bug@amsat.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/sd/omap_mmc.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/hw/sd/omap_mmc.c b/hw/sd/omap_mmc.c
index 671264b6500..d0c98ca0214 100644
--- a/hw/sd/omap_mmc.c
+++ b/hw/sd/omap_mmc.c
@@ -1,6 +1,8 @@
/*
* OMAP on-chip MMC/SD host emulation.
*
+ * Datasheet: TI Multimedia Card (MMC/SD/SDIO) Interface (SPRU765A)
+ *
* Copyright (C) 2006-2007 Andrzej Zaborowski <balrog@zabor.org>
*
* This program is free software; you can redistribute it and/or
@@ -278,6 +280,12 @@ static void omap_mmc_update(void *opaque)
omap_mmc_interrupts_update(s);
}
+static void omap_mmc_pseudo_reset(struct omap_mmc_s *host)
+{
+ host->status = 0;
+ host->fifo_len = 0;
+}
+
void omap_mmc_reset(struct omap_mmc_s *host)
{
host->last_cmd = 0;
@@ -286,11 +294,9 @@ void omap_mmc_reset(struct omap_mmc_s *host)
host->dw = 0;
host->mode = 0;
host->enable = 0;
- host->status = 0;
host->mask = 0;
host->cto = 0;
host->dto = 0;
- host->fifo_len = 0;
host->blen = 0;
host->blen_counter = 0;
host->nblk = 0;
@@ -305,6 +311,8 @@ void omap_mmc_reset(struct omap_mmc_s *host)
qemu_set_irq(host->coverswitch, host->cdet_state);
host->clkdiv = 0;
+ omap_mmc_pseudo_reset(host);
+
/* Since we're still using the legacy SD API the card is not plugged
* into any bus, and we must reset it manually. When omap_mmc is
* QOMified this must move into the QOM reset function.
@@ -459,7 +467,7 @@ static void omap_mmc_write(void *opaque, hwaddr offset,
if (s->dw != 0 && s->lines < 4)
printf("4-bit SD bus enabled\n");
if (!s->enable)
- omap_mmc_reset(s);
+ omap_mmc_pseudo_reset(s);
break;
case 0x10: /* MMC_STAT */
--
2.17.1
next prev parent reply other threads:[~2018-07-09 13:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-09 13:54 [Qemu-devel] [PULL 00/11] target-arm queue Peter Maydell
2018-07-09 13:54 ` [Qemu-devel] [PULL 01/11] hw/arm/smmu-common: Fix devfn computation in smmu_iommu_mr Peter Maydell
2018-07-09 13:54 ` [Qemu-devel] [PULL 02/11] ptimer: Add TRIGGER_ONLY_ON_DECREMENT policy option Peter Maydell
2018-07-09 13:54 ` [Qemu-devel] [PULL 03/11] hw/timer/cmsdk-apb-timer: Correct ptimer policy settings Peter Maydell
2018-07-09 13:54 ` [Qemu-devel] [PULL 04/11] hw/timer/cmsdk-apb-timer: Correctly identify and set one-shot mode Peter Maydell
2018-07-09 13:54 ` [Qemu-devel] [PULL 05/11] hw/timer/cmsdk-apb-timer: run or stop timer on writes to RELOAD and VALUE Peter Maydell
2018-07-09 13:54 ` [Qemu-devel] [PULL 06/11] target/arm: Suppress Coverity warning for PRF Peter Maydell
2018-07-09 13:54 ` [Qemu-devel] [PULL 07/11] tcg: Restrict check_size_impl to multiples of the line size Peter Maydell
2018-07-09 13:54 ` [Qemu-devel] [PULL 08/11] target/arm: Fix do_predset for large VL Peter Maydell
2018-07-09 13:54 ` Peter Maydell [this message]
2018-07-09 13:54 ` [Qemu-devel] [PULL 10/11] boards.h: Remove doc comment reference to nonexistent function Peter Maydell
2018-07-09 13:54 ` [Qemu-devel] [PULL 11/11] hw/net/dp8393x: don't make prom region 'nomigrate' Peter Maydell
2018-07-09 17:29 ` [Qemu-devel] [PULL 00/11] target-arm queue Peter Maydell
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=20180709135435.836-10-peter.maydell@linaro.org \
--to=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).