[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 8/9] hw/sd: ssi-sd: Use macros for the dummy value and tokens in t
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 8/9] hw/sd: ssi-sd: Use macros for the dummy value and tokens in the transfer |
Date: |
Sun, 24 Jan 2021 21:11:05 +0100 |
From: Bin Meng <bin.meng@windriver.com>
At present the codes use hardcoded numbers (0xff/0xfe) for the dummy
value and block start token. Replace them with macros.
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210123104016.17485-12-bmeng.cn@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/sd/ssi-sd.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
index 12dffb6f55e..be1bb101645 100644
--- a/hw/sd/ssi-sd.c
+++ b/hw/sd/ssi-sd.c
@@ -78,6 +78,12 @@ OBJECT_DECLARE_SIMPLE_TYPE(ssi_sd_state, SSI_SD)
#define SSI_SDR_ADDRESS_ERROR 0x2000
#define SSI_SDR_PARAMETER_ERROR 0x4000
+/* single block read/write, multiple block read */
+#define SSI_TOKEN_SINGLE 0xfe
+
+/* dummy value - don't care */
+#define SSI_DUMMY 0xff
+
static uint32_t ssi_sd_transfer(SSIPeripheral *dev, uint32_t val)
{
ssi_sd_state *s = SSI_SD(dev);
@@ -91,14 +97,14 @@ static uint32_t ssi_sd_transfer(SSIPeripheral *dev,
uint32_t val)
switch (s->mode) {
case SSI_SD_CMD:
- if (val == 0xff) {
+ if (val == SSI_DUMMY) {
DPRINTF("NULL command\n");
- return 0xff;
+ return SSI_DUMMY;
}
s->cmd = val & 0x3f;
s->mode = SSI_SD_CMDARG;
s->arglen = 0;
- return 0xff;
+ return SSI_DUMMY;
case SSI_SD_CMDARG:
if (s->arglen == 4) {
SDRequest request;
@@ -173,15 +179,15 @@ static uint32_t ssi_sd_transfer(SSIPeripheral *dev,
uint32_t val)
} else {
s->cmdarg[s->arglen++] = val;
}
- return 0xff;
+ return SSI_DUMMY;
case SSI_SD_PREP_RESP:
DPRINTF("Prepare card response (Ncr)\n");
s->mode = SSI_SD_RESPONSE;
- return 0xff;
+ return SSI_DUMMY;
case SSI_SD_RESPONSE:
if (s->stopping) {
s->stopping = 0;
- return 0xff;
+ return SSI_DUMMY;
}
if (s->response_pos < s->arglen) {
DPRINTF("Response 0x%02x\n", s->response[s->response_pos]);
@@ -194,16 +200,16 @@ static uint32_t ssi_sd_transfer(SSIPeripheral *dev,
uint32_t val)
DPRINTF("End of command\n");
s->mode = SSI_SD_CMD;
}
- return 0xff;
+ return SSI_DUMMY;
case SSI_SD_PREP_DATA:
DPRINTF("Prepare data block (Nac)\n");
s->mode = SSI_SD_DATA_START;
- return 0xff;
+ return SSI_DUMMY;
case SSI_SD_DATA_START:
DPRINTF("Start read block\n");
s->mode = SSI_SD_DATA_READ;
s->response_pos = 0;
- return 0xfe;
+ return SSI_TOKEN_SINGLE;
case SSI_SD_DATA_READ:
val = sdbus_read_byte(&s->sdbus);
s->crc16 = crc_ccitt_false(s->crc16, (uint8_t *)&val, 1);
@@ -224,7 +230,7 @@ static uint32_t ssi_sd_transfer(SSIPeripheral *dev,
uint32_t val)
return val;
}
/* Should never happen. */
- return 0xff;
+ return SSI_DUMMY;
}
static int ssi_sd_post_load(void *opaque, int version_id)
--
2.26.2
- [PULL 0/9] SD/MMC patches for 2021-01-24, Philippe Mathieu-Daudé, 2021/01/24
- [PULL 1/9] hw/sd: ssi-sd: Fix incorrect card response sequence, Philippe Mathieu-Daudé, 2021/01/24
- [PULL 2/9] hw/sd: sd: Support CMD59 for SPI mode, Philippe Mathieu-Daudé, 2021/01/24
- [PULL 3/9] hw/sd: sd: Drop sd_crc16(), Philippe Mathieu-Daudé, 2021/01/24
- [PULL 4/9] util: Add CRC16 (CCITT) calculation routines, Philippe Mathieu-Daudé, 2021/01/24
- [PULL 5/9] hw/sd: ssi-sd: Suffix a data block with CRC16, Philippe Mathieu-Daudé, 2021/01/24
- [PULL 6/9] hw/sd: ssi-sd: Add a state representing Nac, Philippe Mathieu-Daudé, 2021/01/24
- [PULL 7/9] hw/sd: ssi-sd: Fix the wrong command index for STOP_TRANSMISSION, Philippe Mathieu-Daudé, 2021/01/24
- [PULL 8/9] hw/sd: ssi-sd: Use macros for the dummy value and tokens in the transfer,
Philippe Mathieu-Daudé <=
- [PULL 9/9] hw/sd: sd.h: Cosmetic change of using spaces, Philippe Mathieu-Daudé, 2021/01/24
- Re: [PULL 0/9] SD/MMC patches for 2021-01-24, Peter Maydell, 2021/01/25