From: Vincent Palatin <vpalatin@chromium.org>
This patch adds support for eMMC cards, change SET_RELATIVE_ADDR
command to assign relative address as requested by user.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
[spb: Split original patch series]
Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
---
hw/sd/sd.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 74b9162..42ee49c 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -108,6 +108,7 @@ struct SDState {
uint8_t spec_version;
BlockBackend *blk;
bool spi;
+ bool emmc;
/* Runtime changeables */
@@ -431,9 +432,13 @@ static void sd_set_csd(SDState *sd, uint64_t size)
sd->csd[15] = (sd_crc7(sd->csd, 15) << 1) | 1;
}
-static void sd_set_rca(SDState *sd)
+static void sd_set_rca(SDState *sd, uint16_t value)
{
- sd->rca += 0x4567;
+ if (sd->emmc) {
+ sd->rca = value;
+ } else {
+ sd->rca += 0x4567;
+ }
}
FIELD(CSR, AKE_SEQ_ERROR, 3, 1)
@@ -979,8 +984,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
case sd_identification_state:
case sd_standby_state:
sd->state = sd_standby_state;
- sd_set_rca(sd);
- return sd_r6;
+ sd_set_rca(sd, req.arg >> 16);
+ return sd->emmc ? sd_r1 : sd_r6;
default:
break;
@@ -2176,6 +2181,7 @@ static Property sd_properties[] = {
* board to ensure that ssi transfers only occur when the chip select
* is asserted. */
DEFINE_PROP_BOOL("spi", SDState, spi, false),
+ DEFINE_PROP_BOOL("emmc", SDState, emmc, false),
DEFINE_PROP_END_OF_LIST()
};
--
2.7.4