544156efcf
sdhci: fix incorrect use of Error *
...
Detected by Coverity (CID 1386072, 1386073, 1386076, 1386077). local_err
was unused, and this made the static analyzer unhappy.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com >
Message-id: 20180320151355.25854-1-pbonzini@redhat.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org >
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-03-23 18:26:45 +00:00
7eceff5b5a
hw: Do not include "sysemu/block-backend.h" if it is not necessary
...
After reviewing a patch from Philippe that removes block-backend.h
from hw/lm32/milkymist.c, I noticed that this header is included
unnecessarily in a lot of other files, too. Remove those unneeded
includes to speed up the compilation process a little bit.
Signed-off-by: Thomas Huth <thuth@redhat.com >
Message-Id: <1518684912-31637-1-git-send-email-thuth@redhat.com >
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com >
2018-03-12 16:12:46 +01:00
08022a916c
sdhci: Fix a typo in comment
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Peter Maydell <peter.maydell@linaro.org >
Message-id: 20180309153654.13518-8-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-03-09 17:09:45 +00:00
0c3fb03f7e
sdcard: Add the Tuning Command (CMD19)
...
From the "Physical Layer Simplified Specification Version 3.01":
A known data block ("Tuning block") can be used to tune sampling
point for tuning required hosts. [...]
This procedure gives the system optimal timing for each specific
host and card combination and compensates for static delays in
the timing budget including process, voltage and different PCB
loads and skews. [...]
Data block, carried by DAT[3:0], contains a pattern for tuning
sampling position to receive data on the CMD and DAT[3:0] line.
[based on a patch from Alistair Francis <alistair.francis@xilinx.com >
from qemu/xilinx tag xilinx-v2015.2]
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180309153654.13518-5-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-03-09 17:09:44 +00:00
75a96f5e1c
sdcard: Display which protocol is used when tracing (SD or SPI)
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Peter Maydell <peter.maydell@linaro.org >
Message-id: 20180309153654.13518-4-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-03-09 17:09:44 +00:00
2ed61fb57b
sdcard: Display command name when tracing CMD/ACMD
...
The SDBus will reuse these functions, so we put them in a new source file.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Message-id: 20180309153654.13518-3-f4bug@amsat.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org >
[PMM: slight wordsmithing of comments, added note that string
returned does not need to be freed]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-03-09 17:09:44 +00:00
586634b9a8
sdcard: Do not trace CMD55, except when we already expect an ACMD
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Acked-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180309153654.13518-2-f4bug@amsat.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org >
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-03-09 17:09:44 +00:00
4e5cc67565
sdcard: simplify SD_SEND_OP_COND (ACMD41)
...
replace switch(single case) -> if()
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215221325.7611-17-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:54 +00:00
ad0ade5547
sdcard: simplify SEND_IF_COND (CMD8)
...
replace switch(single case) -> if()
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215221325.7611-16-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:54 +00:00
3116280040
sdcard: warn if host uses an incorrect address for APP CMD (CMD55)
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215221325.7611-15-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:54 +00:00
d691148655
sdcard: check the card is in correct state for APP CMD (CMD55)
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215221325.7611-14-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:54 +00:00
946897ce18
sdcard: handles more commands in SPI mode
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215221325.7611-13-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:53 +00:00
a21208646d
sdcard: use a more descriptive label 'unimplemented_spi_cmd'
...
Suggested-by: Alistair Francis <alistair.francis@xilinx.com >
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215221325.7611-12-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:53 +00:00
688491c71a
sdcard: handle the Security Specification commands
...
returning sd_illegal, since they are not implemented.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215221325.7611-11-f4bug@amsat.org
[PMM: tweak multiline comment format]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:53 +00:00
49fb7381b2
sdcard: handle CMD54 (SDIO)
...
Linux uses it to poll the bus before polling for a card.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215221325.7611-10-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:53 +00:00
da26e3f360
sdcard: use the registerfields API for the CARD_STATUS register masks
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Acked-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215221325.7611-9-f4bug@amsat.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org >
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:53 +00:00
3d42fb52b2
sdcard: use the correct masked OCR in the R3 reply
...
use the registerfields API to access the OCR register
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215221325.7611-8-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:53 +00:00
67bfddd62b
sdcard: simplify using the ldst API
...
the code is easier to review/refactor.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215221325.7611-7-f4bug@amsat.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org >
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:53 +00:00
0aad4fdfd4
sdcard: remove commands from unsupported old MMC specification
...
This device does not model MMCA Specification previous to v4.2
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215221325.7611-6-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:53 +00:00
9b7ec55c5c
sdcard: clean the SCR register and add few comments
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215221325.7611-5-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:53 +00:00
d7ecb86752
sdcard: fix the 'maximum data transfer rate' to 25MHz
...
To comply with Spec v1.10 (and 2.00, 3.01):
. TRAN_SPEED
for current SD Memory Cards that field must be always 0_0110_010b (032h) which is
equal to 25MHz - the mandatory maximum operating frequency of SD Memory Card.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215221325.7611-4-f4bug@amsat.org
[PMM: fixed comment indent]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:53 +00:00
e8feec808e
sdcard: update the CSD CRC register regardless the CSD structure version
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215221325.7611-3-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:53 +00:00
9273ea6123
sdcard: Don't always set the high capacity bit
...
Don't set the high capacity bit by default as it will be set if required
in the sd_set_csd() function.
[based on a patch from Alistair Francis <alistair.francis@xilinx.com >
and Peter Ogden <ogden@xilinx.com > from qemu/xilinx tag xilinx-v2015.4]
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215221325.7611-2-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:52 +00:00
6f296421f8
sdcard: use the registerfields API to access the OCR register
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215220540.6556-12-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:52 +00:00
7af83490fe
sdcard: use G_BYTE from cutils
...
code is now easier to read.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215220540.6556-11-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:52 +00:00
f250015be6
sdcard: define SDMMC_CMD_MAX instead of using the magic '64'
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215220540.6556-8-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:52 +00:00
814b2adc16
sdcard: add more trace events
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Acked-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215220540.6556-6-f4bug@amsat.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org >
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:52 +00:00
5cd5e2e7e3
sdcard: replace fprintf() by qemu_hexdump()
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215220540.6556-5-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:52 +00:00
5592193231
sdcard: add a trace event for command responses
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Message-id: 20180215220540.6556-4-f4bug@amsat.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org >
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:52 +00:00
1b640aa929
sdcard: replace DPRINTF() by trace events
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215220540.6556-3-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:52 +00:00
d49b1ce0a3
sdcard: reorder SDState struct members
...
place card registers first, this will ease further code movements.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180215220540.6556-2-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:52 +00:00
c3abd91309
hw/sd/ssi-sd: use the SDBus API, connect the SDCard to the bus
...
On reset the bus will reset the card,
we can now drop the device_reset() call.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-id: 20180216022933.10945-5-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:52 +00:00
3d0369ba49
hw/sd/milkymist-memcard: expose a SDBus and connect the SDCard to it
...
using the sdbus_*() API.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Acked-by: Michael Walle <michael@walle.cc >
Message-id: 20180216022933.10945-4-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:52 +00:00
85fd6e5db1
hw/sd/milkymist-memcard: split realize() out of SysBusDevice init()
...
Create the SDCard in the realize() function.
Suggested-by: Michael Walle <michael@walle.cc >
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Acked-by: Michael Walle <michael@walle.cc >
Message-id: 20180216022933.10945-3-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:51 +00:00
d9f98aab67
hw/sd/milkymist-memcard: use qemu_log_mask()
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Acked-by: Michael Walle <michael@walle.cc >
Message-id: 20180216022933.10945-2-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org >
2018-02-22 15:12:51 +00:00
1e23b63f02
sdhci: add Spec v4.2 register definitions
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Message-Id: <20180208164818.7961-31-f4bug@amsat.org >
2018-02-13 16:15:09 +01:00
da34692234
sdhci: implement CMD/DAT[] fields in the Present State register
...
[based on a patch from Alistair Francis <alistair.francis@xilinx.com >
from qemu/xilinx tag xilinx-v2015.2]
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-Id: <20180208164818.7961-23-f4bug@amsat.org >
2018-02-13 16:15:08 +01:00
0034ebe6ee
sdhci: implement UHS-I voltage switch
...
[based on a patch from Alistair Francis <alistair.francis@xilinx.com >
from qemu/xilinx tag xilinx-v2015.2]
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-Id: <20180208164818.7961-22-f4bug@amsat.org >
2018-02-13 16:15:08 +01:00
238cd93567
sdbus: add trace events
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-Id: <20180208164818.7961-21-f4bug@amsat.org >
2018-02-13 16:15:08 +01:00
ea55a221bf
sdhci: implement the Host Control 2 register (tuning sequence)
...
[based on a patch from Alistair Francis <alistair.francis@xilinx.com >
from qemu/xilinx tag xilinx-v2015.2]
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-Id: <20180208164818.7961-20-f4bug@amsat.org >
2018-02-13 16:15:08 +01:00
06c5120b09
sdhci: rename the hostctl1 register
...
As per the Spec v3.00
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-Id: <20180208164818.7961-19-f4bug@amsat.org >
2018-02-13 16:15:08 +01:00
4d67852d9c
sdhci: add support for v3 capabilities
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-Id: <20180208164818.7961-18-f4bug@amsat.org >
2018-02-13 16:15:08 +01:00
0540fba949
sdhci: check Spec v2 capabilities (DMA and 64-bit bus)
...
Incorrect value will throw an error.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-Id: <20180208164818.7961-14-f4bug@amsat.org >
2018-02-13 16:15:08 +01:00
04654b5a8c
sdhci: Fix 64-bit ADMA2
...
The 64-bit ADMA address is not converted to the cpu endianes correctly.
This patch fixes the issue and uses a valid mask for the attribute data.
Signed-off-by: Sai Pavan Boddu <saipava@xilinx.com >
[AF: Re-write commit message]
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-Id: <20180208164818.7961-13-f4bug@amsat.org >
2018-02-13 16:15:08 +01:00
bf8ec38e17
sdhci: replace DMA magic value by BLOCK_SIZE_MASK
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-Id: <20180208164818.7961-12-f4bug@amsat.org >
2018-02-13 16:15:07 +01:00
6ff37c3dfa
sdhci: check the Spec v1 capabilities correctness
...
Incorrect value will throw an error.
Note than Spec v2 is supported by default.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-Id: <20180208164818.7961-11-f4bug@amsat.org >
2018-02-13 16:15:07 +01:00
09b738ff65
sdhci: simplify sdhci_get_fifolen()
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-Id: <20180208164818.7961-10-f4bug@amsat.org >
2018-02-13 16:15:07 +01:00
aa164fbff3
sdhci: use a numeric value for the default CAPAB register
...
using many #defines is not portable when scaling to different HCI.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-Id: <20180208164818.7961-9-f4bug@amsat.org >
2018-02-13 16:15:07 +01:00
aceb5b064c
sdhci: add a 'spec_version property' (default to v2)
...
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-Id: <20180208164818.7961-8-f4bug@amsat.org >
2018-02-13 16:15:07 +01:00
ab958e3864
sdhci: use error_propagate(local_err) in realize()
...
avoid the "errp && *errp" pattern (not recommended in "qapi/error.h" comments).
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org >
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com >
Message-Id: <20180208164818.7961-2-f4bug@amsat.org >
2018-02-13 11:44:13 +01:00