Message ID | 1597658722-12922-2-git-send-email-bin.meng@windriver.com |
---|---|
State | New |
Headers | show |
Series | hw/sd: Add Cadence SDHCI emulation | expand |
diff --git a/hw/sd/sd.c b/hw/sd/sd.c index fad9cf1..3226404 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -806,11 +806,12 @@ static void sd_function_switch(SDState *sd, uint32_t arg) sd->data[11] = 0x43; sd->data[12] = 0x80; /* Supported group 1 functions */ sd->data[13] = 0x03; + for (i = 0; i < 6; i ++) { new_func = (arg >> (i * 4)) & 0x0f; if (mode && new_func != 0x0f) sd->function_group[i] = new_func; - sd->data[14 + (i >> 1)] = new_func << ((i * 4) & 4); + sd->data[16 - (i >> 1)] |= new_func << ((i % 2) * 4); } memset(&sd->data[17], 0, 47); stw_be_p(sd->data + 64, sd_crc16(sd->data, 64));